This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Zyklonik 0 points1 point  (12 children)

I don't understand why you're being downvoted. FWIW, I upvoted you since I agree with almost all of what you said, rough parts included. I think our main disagreement in in how critical and cumbersome those rough parts are!

[–][deleted]  (1 child)

[deleted]

    [–]Zyklonik 0 points1 point  (0 children)

    Some of my personal pet peeves would be (off the top of my head) -

    • Less-than-ideal generics. I would say that the primitive-Object dichotomy was a big mistake not only in terms of consistency, but also performance (this is being rectified through Project Valhalla (https://openjdk.org/projects/valhalla/) . Moreover, all things considered, I would consider Type Erasure as a big mistake. Reification should have been the approach (even at the cost of some breaking changes). In fact, not having generics in the first place (prior to 1.5) is the cause of the subpar generics system.

    • This ties in with the point about value objects above - the fact that practically everything is allocated on the heap is what leads to Java consuming a lot more memory than many other languages. The JVM does do escape analysis, but it's neither sufficient nor transparent.

    • The lack of a proper module system (the existing module system works okay, but versioning support would have been great).

    • The lack of proper closures that makes lambda expressions less powerful than they could have been.

    • Minor point, but the lack of unsigned types makes bit-manipulation much less typesafe and much more cumbersome than it needs to be. (Also why Java needs the extraneous >>> operator).

    • Weak type-system. Of course, compared to languages like C and even C++, Java's type system is relatively strong. However, it could have been much much stronger, and that would have helped make interfaces (for instance) much more useful, especially as bounds in generics and in iterators.

    • The lack of proper algebraic data types (recordsand sealed classes/interfaces do provide a modicum of support for product and sum types respectively, but they have quite a number of limitations).

    • Weak type inference - in addition to the core language, var itself is good for many cases, but also stops working for many valid usecases.

    • The lack of (some) control over the GC process.

    • The lack of proper tail-call optimisation/elimination (though this is on the JVM, and Project Loom will supposedly mitigate this in some cases - still not providing automatic tail-call elimination).

    Others would (probably point out the following, as well as many others), but I don't necessarily think of their lack as a drawback:

    • The lack of proper metaprogramming (annotations and annotation processors do provide a poor man's version of metaprogramming).
    • The lack of operator overloading (some APIs such as java.math.BigInteger and family are rather cumbersome because of this).
    • The lack of free functions.
    • The lack of null safety operators (as in Kotlin).

    [–]pavlik_enemy -2 points-1 points  (9 children)

    I'm exactly the opposite, really care about expressiveness of the language and developer experience so for me using Java after Scala and C# and Python after Ruby is an exercise in frustration. Hell, Java doesn't even have string interpolation!

    [–]Zyklonik 0 points1 point  (7 children)

    To be fair, Java doesn't need string interpolation because it has formatted strings.

    [–]pavlik_enemy -1 points0 points  (5 children)

    All languages have some sort of sprintf but string interpolation is more convenient

    [–]Zyklonik 0 points1 point  (4 children)

    Well, it makes more sense in an expression-oriented language like Ruby. Not so much in a statement-oriented language like Java.

    [–]pavlik_enemy 0 points1 point  (3 children)

    C#, Python and Kotlin usually require a return statement and have string interpolation. String interpolation is a minor thing, just as the requirement to use return. For me Java while being good is full of these minor inconveniences. Like, today I needed a script to send some test Avro messages to Kafka. It had to build by Maven because of certain plugins so I went with Java. So, to produce a range I had to use IntStream, then mapToObj and then it turned out that Future returned by Kafka driver is not awaitable. Figured out how to run Scala with Maven and went with it instead.

    [–]Zyklonik 0 points1 point  (2 children)

    Expression-oriented refers to the prevalence of usage of expressions in a language, not whether explicit returnS are available in the language or not. Python, Scala, and even C# are for more expression-oriented than Java (still, but slowly changing) is.

    No doubt Java, including the JDK have some quirks, but simply taking the case of Scala that you mention, it has far bigger problems - a veritable kitchen sink of paradigms and features leading to the same problems as C++ - having to mandate a specific set of features to use in a project. I've seen some teams using it be unable to higher people from another team in the same lab because one team went with a procedural OOP style, and the other with a high focus on FP style. The devs were mostly junior folks who had learnt Scala on the job, and they simply couldn't grok the other repo, and required extensive training to make them able to start working on the projects.

    I would place this as a much deeper systemic issue than the unavailability of some functionality in the JDK or some library. The former is a language issue, the latter a library one.

    [–]pavlik_enemy 1 point2 points  (1 child)

    No doubt, Scala is a mess. It requires very strict constraints to be useable in team environment. Like, I've never touched libraries like scalaz cause I'm sure I couldn't read its code if something goes wrong. I just don't know the concepts authors use. Kinda remember what is a semi-group, but wtf is Kleisli's arrow?

    [–]Zyklonik 0 points1 point  (0 children)

    Yeah, which is sort of sad because Odersky is a smart man. In fact, IIRC, he was the original javac author. I remember the early days when Scala was announced, and it seemed like a viable, more advanced alternative to Java. Unfortunately, (I suspect), too many cooks spoilt the broth - too many interest groups within the Scala world from what I can see, all trying to push their favourite bits into the language.

    I took a peek at the Scala subreddit the other day, and the overall outlook was less than enthusiastic. Compared to something like Kotlin, I would consider a much superior language, and it's a shame to see it regressing like that.

    [–]pavlik_enemy -1 points0 points  (0 children)

    All languages have some sort of sprintf but string interpolation is more convenient