4 ms·
OK but these things are not enough. I'm a long time Java dev and all these were known in c.l.j.p. and IRC since a very long time. I was doing precisely that,
by martinced 14y ago
OK but these things are not enough. I'm a long time Java dev and all these were known in c.l.j.p. and IRC since a very long time. I was doing precisely that, even using the "functional Java" libs when they came out and doing even more radical things...
And I can tell you that even when doing that switching to Clojure is pure joy.
Because even when doing what TFA talks about, this still doesn't solve lots of very nasty Java issues, like the totally outdated approach to concurrency.
What Java programmers can learn from Clojure is that it's possible to create a language targetting the JVM which cannot deadlock and which can offer a dramatic reduction in the size of the source code.
Sadly you simply cannot apply these to "Java the language": Java is utterly verbose and there's no way to have a "sane" way to deal with concurrency in Java (yes, I've got my Java "Concurrency In Practice" copy since it came out).
The other major thing to learn about Clojure + Datomic is that there's a world out there made of something else than the special kind of hell that Java/C# + ORM ([N]Hibernate) + XML + SQL is. (and before you start whining like cry-babies, Datomic can be backed by SQL DBs)
Programmers who haven't done it so yet should really go watch videos by Rich Hickey, here are three particularly good ones:
"Simple made easy"
"The value of values"
and "The Database as a value"
http://www.infoq.com/presentations/Datomic-Database-Value http://www.infoq.com/presentations/Datomic-Database-Value
Now sure some will criticize Clojure as being a Lisp-1 and not having real reader macros, others will rightly point out that Clojure's documentation sucks big times and that stacktraces are still a serious issue.
But at least Clojure is showing that there's a saner way than this Java madness.
You have to realize that Clojure is Rich Hickey's fourth attempt or so at a Lisp dialect and that he had lots of very painful experience working on Java Real-World [TM] maddening codebases.
- jbooth 14y agoWhat do you mean by the totally outdated approach to concurrency? I'm also a longtime Java dev who's embraced these values for a long time, and I generally thought of using ExecutorServices and Callables as a very functional approach to concurrent programming. If you're referring to manually starting threads and using synchronized monitors to ensure thread-safety, then I agree, but java.util.concurrent really doesn't encourage that approach.
- pivo 14y agoNot the author, but I'd say he's referring to two Clojure features that make programming with concurrency so nice, specifically STM (Software Transactional Memory) and immutability by default. STM is much better (IMO) approach to concurrency than locking, but it's really only viable (as far as I know) in a language like Clojure where values are immutable by default. The great thing about STM is that it's easily composable, while locking isn't.
- seanmcdirmid 14y agoIt can be done at the page level in an OS if you want. It's not efficient, but then it hasn't been shown to be that efficient in a controlled functional language yet either. Locking still wins on clock cycles, unfortunately.