How powerful is Java?
#42 Members - Reputation: 282
Posted 08 November 2012 - 10:10 AM
Any anything clojure does Groovy does better ;)....
http://groovy.codehaus.org/
And you have tried Clojure?
#43 Members - Reputation: 285
Posted 08 November 2012 - 11:56 AM
Also, as you can see below, Groovy is less typing (Trivial example I know).
Groovy (70 Characters):
[source lang="groovy"]for (i in 1..100) { println "${i%3?'':'Fizz'}${i%5?'':'Buzz'}" ?: i }[/source]
Clojure (116 Characters):
(map #(cond (zero? (mod % 15)) "FizzBuzz" (zero? (mod % 3)) "Fizz" (zero? (mod % 5)) "Buzz" :else %) (range 1 101))
#44 Members - Reputation: 282
Posted 08 November 2012 - 01:18 PM
91 characters.
I haven't used Groovy, but I can't imagine that it could be better than Clojure.
[source lang="java"]JButton okButton = new JButton("Ok");okButton.setBounds(30, 35, 80, 25);okButton.addActionListener(this);panel.add(okButton);[/source]
becomes
[source lang="java"](.add panel (doto (JButton. "Ok") (.setBounds 30 35 80 25) (.addActionListener this)))[/source]
And even though Clojure is code not the shortest when it comes to small examples, the homoiconicity and simplicity of the syntax is very useful, and macros can get rid of a lot of code in longer programs.
Edited by tufflax, 08 November 2012 - 03:46 PM.
#45 Crossbones+ - Reputation: 1094
Posted 08 November 2012 - 01:46 PM
Comparing apples to oranges. The Groovy one-liner is so clever it's no longer readable (nested ternary operators? please) and I'd complain about it in a code review, whereas both your and tufflax' Clojure implementations are clean code minus whitespace.Also, as you can see below, Groovy is less typing (Trivial example I know).
Groovy (70 Characters):
[source lang="groovy"]for (i in 1..100) { println "${i%3?'':'Fizz'}${i%5?'':'Buzz'}" ?: i }[/source]
Clojure (116 Characters):(map #(cond (zero? (mod % 15)) "FizzBuzz" (zero? (mod % 3)) "Fizz" (zero? (mod % 5)) "Buzz" :else %) (range 1 101))
#46 Members - Reputation: 285
Posted 08 November 2012 - 05:52 PM
One thing I do like about Groovy is the ability to encode statements in the quotes using ${}. The in the above example isn't really a great demonstration of where it would be useful and I wouldn't be using nested ternary operators myself either, I'd complain about it too in a code review.
#47 Staff - Reputation: 9020
Posted 08 November 2012 - 06:24 PM
Try IntelliJ -- I haven't used it for quite some time, but last time I tried it was very good, and the other products from the same company are excellent.Debugging is atrocious and the tools for it are from the archaic at best and intentionally tortuous at worst. (compared to something like VS2010/2012).
- Jason Astle-Adams.
From my blog: 20 ways to advertise your game | What next? Intermediate to advanced C++
How to make games WITHOUT programming | 4 reasons you aren't a successful indie developer
#48 Crossbones+ - Reputation: 3870
Posted 08 November 2012 - 06:40 PM
It's like that guy who implemented a basic ray tracer in 99 lines of ultra-compressed - and, quite frankly, unreadable without adding line breaks - C code. I just don't see the point. Every time I stumble across it, I die a little inside. I too can compress my code with 7z and end up with sub-1KB source code, big deal. Is it useful? No. Is it helpful to others? No. Does it warrant bragging rights? To people who want to understand the code, certainly not.
Edited by Bacterius, 08 November 2012 - 06:40 PM.
#49 Crossbones+ - Reputation: 3419
Posted 08 November 2012 - 06:42 PM
I'm sorry but that Groovy isn't that clever (ie. terse) and it's very readable. And actually it's easier to read the Groovy than the Clojure. As far as Scheme-like languages go, I've used Racket, as a learning tool. And I think it's great.Comparing apples to oranges. The Groovy one-liner is so clever it's no longer readable (nested ternary operators? please) and I'd complain about it in a code review, whereas both your and tufflax' Clojure implementations are clean code minus whitespace.
Also, as you can see below, Groovy is less typing (Trivial example I know).
Groovy (70 Characters):
[source lang="groovy"]for (i in 1..100) { println "${i%3?'':'Fizz'}${i%5?'':'Buzz'}" ?: i }[/source]
Clojure (116 Characters):(map #(cond (zero? (mod % 15)) "FizzBuzz" (zero? (mod % 3)) "Fizz" (zero? (mod % 5)) "Buzz" :else %) (range 1 101))
But to get back on topic, Java as a language or a platform can address all the needs a developer or business may have.
Beginner in Game Development? Read here.
Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley
If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts ![]()






