7 ms·
As a personal project, I've built a simple search driven website using Scala + Lucene. The article doesn't make a fair comparison of Scala vs. Java complexity.
by osipov 17y ago
As a personal project, I've built a simple search driven website using Scala + Lucene. The article doesn't make a fair comparison of Scala vs. Java complexity. The examples in the article are focused on Scala strengths, e.g. for-comprehensions, closures, Range classes, etc. It is true that these features are superior to Java equivalents. However, Scala is still too awkward in implementation of annotations, generics and type inference in general. For example, Scala 2.7.5 annotation problems make integration with Java Persistence API (JPA) an adhoc hack. Scala 2.8 still has serious bugs open on annotations. Generic type are fundamentally complex and while Java attempts to abstract some of the complexity related to co/contra-variant types, Scala requires a deep understanding of nuances in practical application of generics. ML type inferencer in Scala is great when it works (in simple situations) but it is a headache to figure out _why_ it causes problems in the cases when type inference doesn't work as intended. Unfortunately when the type inference doesn't work as expected one is forced to hard code type casting which defeats the whole purpose of a type inferencer.
- plinkplonk 17y ago"ML type inferencer in Scala is great when it works (in simple situations) but it is a headache to figure out _why_ it causes problems in the cases when type inference doesn't work as intended." I've heard this many times. I think learning some formal type theory might help. It worked for me, helping me get my head around Haskell and make sense of type error messages.
- barrkel 17y agoUnfortunately, many many essays have been written attempting to describe e.g. monads, which are actually a really simple concept, just very abstract. The evident difficulty the general programming public has had getting to grips with even this topic would make me pessimistic as to the efficacy of your advice.
- plinkplonk 17y agoThat is why I said formal type theory (which is very different from describing monads in the essays for the "general programming public"). Working through Pierce's book "Types And Programming Languages" (aka TAPL) is more what I had in mind. It is very clearly written and not that difficult(I have no formal Computer Science education and had no trouble with the book). Monads aren't really very difficult when learned from the Type Theory perspective (vs from weird essays comparing them to elephants, space stations and so on). I was specifically addressing this bit. " but it is a headache to figure out _why_ it causes problems in the cases when type inference doesn't work as intended" In my experience, knowing basic type theory helps this "figuring out" process. 'would make me pessimistic as to the efficacy of your advice.' Fair Enough! I just posted what worked for me. YMMV :-)
- osipov 17y ago"learning some formal type theory might help" -- understanding formal type theory is not a prereq for understanding Java. If you are you suggesting that knowledge of formal type theory is needed to be an effective Scala programmer, then as I pointed out, Scala is more complex than Java.
- plinkplonk 17y ago@osipov " then as I pointed out, Scala is more complex than Java." I didn't comment (either way) on this. I was just trying to say learning type theory worked well for me when I was learning languages with powerful type systems (Haskell in my case), especially in understanding type errors. It may or may not work for you. It is just an experience report/suggestion. I don't care if Scala is more complex than Java or not. Apologies if you thought I was making a claim to that effect.
- osipov 17y agoNo apologies needed, I thought your comment about learning formal type theory and your book recommendation were valuable. My comment was based on the premise of this thread (per the title) and the premise of the article.
- joe_the_user 17y agoAn interesting thing about this article is it makes me think about just how natural the english-fragments within mainstream (c-like) languages are. Loosely speaking, a c-like English would be: "For each tree in the grove, paint on the stem" But what would a Scala-like sentence be??? "trees in the grove - paint circles on their stems"???
- rincewind 17y agoThat might show that idioms from C got into your english, not the other way round: "For every cookie in the jar; I ate that cookie" vs. "I ate all the cookies from the cookie jar" vs. "The cookie jar is empty" (the last one assumes that the cookie jar was type-safe and contained nothing but cookies)
- jongraehl 17y agoI do recall hearing about some mismatch between Scala and Java generics (both ultimately use type erasure, due to JVM limitation). Scala generics on their own are fine. 2.8 is supposed to improve both, I think. The type inference is local (and unification based), and not Hindley-Milner (ML). I'm pretty sure Scala's type inference is more complicated (and less awesome as a result).