

Ask HN: Is it worth to study languages on the JVM without knowing Java? - oscardelben

I've recently began looking at languages built on the JVM like Clojure and Scala.<p>I come from a Ruby background mostly, but I deeply appreciate languages like scheme, and even Erlang.<p>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.<p>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.
======
davidw
My guess is that it's something similar to knowing Ruby, Python, Tcl, etc...
without knowing C. You can certainly get by and even be very productive, but
if you want to do deep hacking, or library integration, you're going to need
some Java at some point. Over time, it will probably be less necessary.

~~~
cabalamat
> library integration

Presumably the whole point of using a language that runs on the JVM is that
you can use libraries written in Java.

~~~
xtho
In an ideal world, you should be able to use libraries written in any jvm-
based language. It seems to me this isn't easily possible today with most jvm-
based languages but maybe I'm wrong.

~~~
bad_user
Yes, but Java is the middle-man providing the FFI, and implementing bindings
to whatever library written in whatever language on top of the JVM is a lot
easier. And it will get a lot more easier with the upcoming invokedynamic
support (since right now the reflection mechanisms for calling methods are
very slow).

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/>

~~~
xtho
In an ideal world the would be no need for Java being the middle-man.

That project was founded in 2007. The last release is from 2008. Has anybody
ever adopted it?

~~~
bad_user
> _In an ideal world the would be no need for Java being the middle-man._

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 ;)

~~~
xtho
I wouldn't say "not possible". Interoperability between java and groovy is
quite good. It's to some degree true for clojure and scala -- two languages I
haven't used myself yet. There are example snippets around in the Internet
that demonstrate that a combination of groovy/scala/clojure/jruby is possible.
So the situation isn't that bad.

------
bensummers
Having gone from Ruby to JRuby, I think it's worth learning enough Java so you
can truly benefit from the JVM platform. You may not write much Java, but
you'll want to use all the wonderful libraries available to you.

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. (!)

------
keefe
<http://mitpress.mit.edu/sicp/> You should check this book out and contemplate
the generalities of programming languages. Java is the most popular example of
a whole class of programming languages - object oriented, automatic garbage
collection, no lambda functions :[, single inheritance, runs in a VM etc. etc.
If you know C++ really well then moving to Java is easy and if you know Java
really well then moving to C# is easy etc. There's no reason to hate on Java
just because it's not sexy anymore. Also, there are a hell of a lot of
libraries already written in Java and a hell of a lot of jobs for Java
programmers out there.

~~~
oscardelben
I've already studied that book, thanks

------
Falaina
The JVM is a platform, much like x86/linux or PPC/mac. It's always
advantageous to have a better understanding of the platform your code will be
working on, but it's not strictly required to be an effective programmer.

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.

------
shantanu_k06
JVM languages bootstrapped themselves from Java and for integration sooner-or-
later you _will_ run into situations where you must understand the underlying
concepts. For example, writing web apps requires you to understand Servlets
which is Java based. I come from Java background, have coded in Clojure and I
speak from experience - you should learn Java if you are going to be on the
JVM.

------
ivenkys
It depends on the level of proficiency you want to gain in Clojure and Scala.

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.

------
maryrosecook
Approach it like you're probably approaching learning the actual language you
are interested in (Scala/Clojure): you learn a bit, write some code, find a
gap in your knowledge, learn what you need to know to fill that gap, write
more code etc. i.e. bootstrap

------
jsankey
You can get by without having to learn much directly about Java - just by
picking bits and pieces up as you need them. But the value in learning the
underlying platform, and indeed a key reason why these languages target the
platform, is the wealth of libraries available.

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.

------
lele
I would not recommend studying Java (the language) in depth, since basic
knowledge is enough to interact with libraries. However, because of the Law of
Leaking Abstractions
([http://www.joelonsoftware.com/articles/LeakyAbstractions.htm...](http://www.joelonsoftware.com/articles/LeakyAbstractions.html)),
you better know Java (the platform and its tools) inside-out.

------
wlievens
What do you mean by "knowing java"? Learning the language syntax will take you
a couple hours at most (if you already know e.g. python or ruby).

~~~
oscardelben
I mean being familiar with the api, and thinking in java when something is not
possible to do with the language.

~~~
cjg
The JDK is where a lot of the power of running on the Java platform comes
from. It is an enormous library and you will never know it all thoroughly. It
will, however, definitely be worth your while learning the parts most relevant
to you.

------
joubert
I knew nothing of the Java API's but am able to use Clojure quite
successfully. There are oodles of Java API documents and discussions online. I
also use several Apache projects from Clojure, and haven't had too much
trouble getting to know how to interface with them.

------
hvs
What you need to know of Java in order to use the libraries with Clojure and
Scala can be picked up as necessary while you are learning those languages.
Depending on your field and interest, though, it can't hurt to know Java
anyway.

