Ask HN: Is it worth to study languages on the JVM without knowing Java?
I've recently began looking at languages built on the JVM like Clojure and Scala.
I come from a Ruby background mostly, but I deeply appreciate languages like scheme, and even Erlang.
The thing is that both Clojure and Scala assumes that you know Java to get the most out of it. For example in the Scala book from the pragprog, the author says that if you are not experienced with Java, you should complement your study with several Java books.
The fact is that I don't think it's worth for me to learn Java, so I wonder if learning any of these JVM languages is worth it.
26 comments
[ 3.8 ms ] story [ 72.7 ms ] threadPresumably the whole point of using a language that runs on the JVM is that you can use libraries written in Java.
Attila Szegedi is also working on a MOP for dynamic languages, which, if integrated by language designers, will make it possible to instantiate classes and call methods from modules written in other languages (much like the DLR, but with a different architecture) ... see here ... http://dynalang.sourceforge.net/
That project was founded in 2007. The last release is from 2008. Has anybody ever adopted it?
Not possible, ideal world or not.
Programming languages have different type-systems. First of all you can't have the VM optimize for all of them, so the priority is always the primary language (Java for the JVM, or C# for .NET).
The second problem is that those type-systems have behaviors defined either at compile-time, or at runtime.
For instance, in Haskell a method is resolved / specialized on the use-site (based on the arguments provided) at compile-time, since by design, all types are known. If you call that same method from Java, you can't use the same interface ... you'll probably call a proxy, that based on the types provided (at runtime this time) it would find the right method and call it (with a call-site cache to optimize future calls).
Another example ... Common Lisp has multi-dispatching. It makes sense for Lisp, but not so much for Ruby. And Java has single-dispatching too. Simulating multi-dispatching on top of the JVM is not easy (it will be easier with invokedynamic and MethodHandles) ... and even if some kind of multi-dispatching was implemented, which one? Asymmetric or symmetric?
The only way to communicate with a language efficiently is trough the standardization of a MOP. But that's also hard to define because of the same reasons ... the author of IronScheme for example was considering dropping support for the DLR because it wasn't a good match.
Progress is going slowly since every
That project was founded in 2007. The last release is from 2008. Has anybody ever adopted it?
If you'll look at the repository, there are regular commits. I'm following the "JVM languages" google group, and the author is communicating regularly with people like John Rose (JVM / invokedynamic) and Charles Oliver Nutter (JRuby) among others, getting feedback, providing feedback, and Charles even attempted an integration of JRuby at some point. I don't really know the state of that.
In the case of such a project you have to please everyone, being a complicated matter from both a political and technical point of view.
If you are truly interested in such things, you can always scratch your own itch ;)
There are times when a Java method demands a specific Java type and JRuby does not automatically convert correctly, but mostly the use of Java libs from JRuby is pretty trivial, and the only time I've had to write Java to wrap anything was when I wanted a nicer API for some 3rd-party crypto libs and adding a few methods to the Java source was easier for me.
At the moment, the ten most popular languages are (according to http://www.tiobe.com/index.php/content/paperinfo/tpci/index.... and whatever metric they use):
1) Java
2) C
3) PHP
4) C++
5) (Visual) Basic
6) C#
7) Python
8) Perl
9) JavaScript
10) Ruby
Given that Java is #1 on that list, I'd find it hard to call some time spent learning it wasted, you're just going to run across it too much, at conferences, in papers, in code that you inherit, in libraries you have to interact with or debug, etc.
Besides, if you know C or C++ it won't take very long to learn the syntax, and the libraries are worth learning because you'll use them in any JVM language anyways. If you don't know C/C++...well, um, add another one to your list, every programmer should have at least a basic understanding of some flavor of C for the same reasons they should know some Java.
If you do start with Java, make sure you actually use Java tools for the job, though, at least once you have the basics down; if you're coding Java in a text editor, even a good one, you're making things far more difficult than they need to be, because it's a language where tools are absolutely crucial if you don't want to drive yourself crazy. Whether it's Eclipse, Netbeans, or IntelliJ, you haven't really learned Java if you haven't learned how to use one of them well.
http://www.langpop.com
I agree though, that a cursory knowledge of Java is probably helpful in this day and age.
What you will properly need to learn to use is the class hierarchy, Swing programming (if you want GUIs, you should take a look at MIGLayout) and the classpath (which you will have to deal with, regretfully).
The question is really if it is worth writing your own libraries from scratch as opposed to learning and using the vast amount of (usually commercially-friendly licensed open source) code that is already out there. Most of the time this is a pretty simple choice.
At this point in time,to make the most of either language and to develop a "real" application you should know Java and not just Java but the tool, library and the infrastructure support of the Java ecosystem that comes with it.
Having said that, if you just want to "learn" the language i.e. the Type System, really grok STM , the API's and how to do something in it - then there can be no better substitute than to start building the libraries,tools etc. that do not exist in Clojure and Scala. Pick up something that you currently can't do in Scala without dropping into Java and build it. Of course this is not an easy undertaking but you will learn lots.
With that aside, I think it's certainly worthwhile to take the time and get a basic understanding of Java, as well as survey what is available in terms of libraries (both standard and 3rd party libraries). Some of the biggest appeal of these languages comes from the fact that they're able to leverage all this existing Java code.
I do, however, know C++ well so Java isn't much of a problem. But it's not a difficult language, especially as it's designed to stop people making mistakes. (!)