5 ms·
Do I need to have a somewhat decent knowledge of Java to plunge into Clojure right away?
by forlorn 5y ago
Do I need to have a somewhat decent knowledge of Java to plunge into Clojure right away?
- Fellshard 5y agoMostly for understanding any stack traces you might see while running the code, I'd say. Other than that, you can use the bulk of the core language without needing a deep level of Java knowledge. Those bits of Java you may touch can be used as 'incantations' until you learn more.
- eyelidlessness 5y agoMostly only for interop, which unfortunately includes the language itself. Normal usage you shouldn’t have to care. But if you get internal stack traces you’re gonna be learning about the various Map implementations etc, all of which are defined in Java. Significantly easier to trace than machine code though!
- NightMKoder 5y agoJava the language? Very likely not. As proof - a majority of Clojure runs in JavaScript without any code changes (via ClojureScript). That said exceptions tend to look like Java classes, so you’ll definitely see Java bits. Java the JVM? You _probably_ don’t need to know it to get started, but you’ll have to get familiar with JVM deployment, dependency management, packaging, JVM memory settings, etc if you want to run something outside your dev machine. Getting to 90% here is pretty easy, but the last 10% (to me at least) tends to feel a lot more difficult that other languages. As a small pro-tip: use jstack. I wish every language came with a jstack. It just dumps the stack traces of all threads of a program by pid.
- eyelidlessness 5y agoMy experience with ClojureScript is you absolutely have to know the host environment because you will encounter type errors and the maintainers have negative interest in making them clear to users (as in flatly refused offers to contribute changes to make those errors easier to understand).
- futharkshill 5y agoThere is nothing worse than library or language maintainers who do not understand that "pure" error messages are absolute hell. If 99.99 % of the time a user should simply write x instead of y, the message should absolutely state that if possible.
- eyelidlessness 5y agoAmusingly to me, this is what drove me to TypeScript. “Don’t do that” be damned, I’ll get my useful errors from the compiler.
- elias94 5y agoI mostly worked with Javascript and Python, never touched Java. Depends what you do. But generally no, Java knowledge is not required.
- d_t_w 5y agoNot right away no, but it will help to have an understanding of Java/JVM for Clojure and Browser/Javascript for Clojurescript if you are intending on building real systems.
- roenxi 5y agoNon-trivial I/O requires knowledge of the host. Trivial I/O is things handled by the slurp or println functions. The obvious way of doing GUIs is swing (Java), 3D means JOGL (Java), file manipulation through clojure.java.io expects a grasp of Java's Reader/Writer abstractions and associated structures. It doesn't require Java as such - I can't really program in Java and Clojure is great. A lack of Java fundamentals is still a handicap and probably around my #3 annoyance as a Clojure user. It makes dependency management (#2 annoyance) harder because the already complicated Java dependency management systems gets a thick layer of Clojure confusion ladled on top. The stacktraces obviously take the spot for #1 annoyance, which is a consequence of the Java but knowing Java won't help navigate them. Can't recommend Clojure enough though. Very fun language.
- thom 5y agoYou’re leaving a lot of value on the table if you don’t make use of Java libraries (even the standard ones). Many open source projects are thin layers over Java bindings, and it’s a huge free buffet lunch if you can do that yourself. But as long as you know the interop syntax you can pick that stuff up as and when you need to. Many people get by googling some JVM command line parameters when they hit a problem (running out of heap space, bringing in additional modules etc) and there are still plenty of people who work in pure Clojure and claim never to have to think about Java or the JVM, even the Maven bits.
- dgb23 5y agoThere are some things that you eventually want to learn. One of them is the underlying data types. For example if you use Clojure on the JVM you are dealing with Java strings, if you use a JavaScript runtime with ClojureScript, then you get JavaScript strings. The tutorial showcased here runs on ClojureScript for example. So: (reverse "abc") Becomes: ("c" "b" "a") In ClojureScript. But in Clojure it becomes: (\c \b \a) Since Java has a character type but JavaScript doesn't. It's little things like this that. The benefit here is superb interop, but in turn you aren't as isolated from the host language as you would be in another language.
- raspasov 5y agoNo Java knowledge required.