4 ms·
One of the reasons I went with Scala instead of Clojure is that you don't "just have to make a jump". You can write one class, in code that clearly corresponds
by lmm 12y ago
One of the reasons I went with Scala instead of Clojure is that you don't "just have to make a jump". You can write one class, in code that clearly corresponds 1:1 to what you'd write in Java, and the interop is smooth enough that other classes don't notice that this class is in Scala. Later on you (hopefully) are writing a very different style of code, more declarative and immutable and putting much more of the business logic into the type system. But it doesn't have to be a big-bang switchover; you can be productive from day 1, hour 1 even.
- sz4kerto 12y agoAnd what did you gain? What I found is writing Scala that is not striving for ~100% immutability and functional style does not bring much benefit. It is just a different syntax, that is nicer than Java on one hand, but also big and not straightforward on the other (in the C++ sense, so 'Scala' does not have a conventional coding style, it ranges from Java to Scalaz). Also, making core 'half-functional' does not bring any benefits in terms of composability, concurrency, reasonability (about the code). That's why I am pro Clojure.
- lmm 12y ago> And what did you gain? All the functional goodness of easier to reason about code. A much more concise way to express common patterns, and a type system powerful enough to abstract away things that you have to repeat in Java. More dynamism than is possible to use safely in a dynamically-typed language, because I can write code that simply "does the right thing" in a principled, safe way that the reader can confirm by checking the types, whereas in something like Python it would be impossible for a reader to see whether that code was buggy. > It is just a different syntax, that is nicer than Java on one hand, but also big and not straightforward on the other Actually the syntax is often more straightforward than Java's. E.g. {} just means a block in a sense that's handled consistently everywhere in Scala, whereas in Java {} are required on a try/catch or a method but optional on an if/else. > making core 'half-functional' does not bring any benefits in terms of composability, concurrency, reasonability (about the code). Of course it does, or at least if it doesn't then the whole functional programming effort is a mistake. Any "pure" core is a) relative to some notion of equivalence that might or might not correspond to the things that are important to your particular problem and b) doesn't do anything without an impure interpreter. See e.g. http://conal.net/blog/posts/the-c-language-is-purely-functional http://conal.net/blog/posts/the-c-language-is-purely-functio...
- htor 12y agoI think you missed the overall point of the author, which was that in order make a significant improvement at all, you need to make a radical shift in the modelling of the system. One of the problems mentioned was the inherent complexity of using a type system for modelling data. Scala is very type oriented and so as a result you will end up with a lot of types for everything there as well. Yes it's certainly easier to make a transition into Scala, but I don't think using Scala will solve the actual problem, even if it does have FP capabilities and encourage immutability.
- AnimalMuppet 12y agoAs I read the article, though, it's not just types. The fundamental problem was that nobody there had a good idea how to architect a Java application that large. So they threw out the Java, and replaced it with Clojure, which they had even less experience architecting. Sure, Clojure may have resulted in 100,000 lines instead of a million, but that's still a large enough system that architecture matters. Did they create another large mess? It seems reasonably likely that they did. Java's types aren't broken enough to force you into a terrible architecture. Trying to use them badly (that is, in the way that everybody seems to think that you're supposed to use them for enterprise apps) seems to be the actual culprit.
- PetrGlad 12y agoI would argue that Clojure-Java interop is better than Scala-Java. E.g. Clojure's collections are Iterable, can be used in Java without conversion. 'reify' and protocols are other good things in this area. Keeping old programming style sure allows to lessen frustration compared to diving right into working with immutable collections but the difference won't be that big if you are learning anyway.