Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is all Groovy code valid with Groovy++?

After seeing this link, I want to try Groovy++, but I have a worry;

Is all of Groovy's syntax valid in Groovy++?

For example I can do this in Groovy:

def list = [1,2]

Is the above code valid in Groovy++?

like image 725
testing31 Avatar asked Sep 06 '11 09:09

testing31


People also ask

Does Java code work on Groovy?

Groovy scripts can use any Java classes. They can be compiled to Java bytecode (in . class files) that can be invoked from normal Java classes. The Groovy compiler, groovyc, compiles both Groovy scripts and Java source files, however some Java syntax (such as nested classes) is not supported yet.

Why Groovy is not popular?

This was mainly due to a feature of the JVM that was blocking dynamic languages. From Java7 a new feature called invokeDynamic greatly improves dynamic code execution; the compiled groovy classes usually share the same execution time of Java (kind of). However, Groovy is still seen as the “slow” JVM language.

Which IDE is good for Groovy?

IntelliJ IDEA supports the latest stable version of Groovy and Groovy 4 syntax.


2 Answers

The aim (I believe) is to get it to to support as much Groovy code as is possible.

I believe there are currently a few areas that are not working including:

  1. Multiple assignment - doesn't compile
  2. The spread-dot operator can cause problems in some situations
  3. .with {} doesn't work

But you can always work around these issues, or don't mark the class that needs them as @Typed

like image 112
tim_yates Avatar answered Sep 23 '22 15:09

tim_yates


There's a list of differences with code samples at http://groovy.dzone.com/articles/groovycomparetogroovy-part-1

Some of the differences:

  • stricter compile-time checks
  • no on-the-fly type modifications with ExpandoMetaClass
  • closures can't change variables outside closure code
  • no direct access to private methods
like image 43
Vorg van Geir Avatar answered Sep 25 '22 15:09

Vorg van Geir