3 ms·
Still, JVM languages are wonderful and meet this criteria. Groovy --- print "Hello World" Clojure --- (print "Hello World")
by wellpast 10y ago
Still, JVM languages are wonderful and meet this criteria.
Groovy
---
print "Hello World"
Clojure
---
(print "Hello World")
- vorg 10y agoApache Groovy meets the one-line criteria but fails the simple syntax rules criteria. In your example, you have to explain that Groovy's println syntax above only works for certain types of arguments. If you want to print a string then println "Hello World" is being translated internally to `System.out.println("Hello World")` and therefore works. But if you want to print a list then println [1, 2, 3] doesn't work because it's being translated to `println.getAt([1,2,3])`. You need to put parentheses around it, writing println([1, 2, 3]) to achieve the same effect. Your choice of example obscures this dirty little secret about Apache Groovy. There's many other confusing rules like this in the language, e.g. `myVariable.class` returns the class of myVariable, whereas `myVariable.clazz` returns a property called clazz. The Java example in the blog post works for all types of arguments, even if it is 5 lines long. I agree with you that Clojure meets both the one-line and simple syntax rules, though.