News for hackers. Stuff that matters.
Re:The Modern Java Platform – 2021 Edition by mberning on Wednesday March 17, 2021 @12:19AM (#26486488)
My biggest gripe with java is developer productivity. It has gotten better but is still far behind interpreted languages like Python and Ruby. Class hot loading and things like that have made it better, but if you change a method signature or interface you have to stop your process, recompile, redeploy, and restart. For big codebases it’s brutal compared to the aforementioned languages and their attendant frameworks.
Re:The Modern Java Platform – 2021 Edition by tiew9Vii on Wednesday March 17, 2021 @12:45AM (#26486643)
That's interesting.

I'm not the biggest Java fan, I can tolerate it. Recently working on a Python project I find I'm massively unproductive compared to something like Java or more specifically Scala as using Spark.

Not having strong types and limited type hinting. I have no idea what things are, is it a int, string, object etc, clicking through in an IDE to see code/docs isn't as great as it's hard for an IDE to inspect the code compared to strongly typed language.

Not having a compiler means I have to have unit tests doing what a compiler would do or finding out I have syntax errors or other errors at runtime. This massively throws of my development flow as can't lean on the compiler to find trivial errors. Rather than doing compile I have to hope I have a test case with high coverage to instrument the code to get a syntax error or I have to start / deploy it to get the error.

There's a great deal of issues with dependency management. Venv, Docker etc help with this but it's a bunch of extra stuff on top I now need to worry about and sometimes still hit errors.

The only time I find I'm relatively productive in Python is writing a short 100-200 line script to do one off tasks / sysadmin / devops type scripts.

The fact if I change an interface, rename a method I need to recompile I find a huge advantage as everything breaks and I worth through the errors one by one and once complete and no more errors I have confidence the refactor is complete and the compiler has verified it.

Re:The Modern Java Platform – 2021 Edition by kaliszad on Wednesday March 17, 2021 @01:04AM (#26486772)
Types almost never save the day and they don't add much to the understanding. The code should be structured and documented in such a way that you are able to understand it, reason about it and swap implementations of stuff in the places where such flexibility is handy. E.g. in Clojure, I can trivially test my functions in the context of the application using the REPL. I don't have to reload anything, I do it right in the namespace I am modifying. I can also just look at the data there. Also Clojure is way more consistent and you can probably learn all the functions in clojure.core and some of the typical libraries by heart. These functions then work basically on anything you will do and are almost 100% transferable to ClojureScript.

For sysadmin-like tasks, for most stuff you can use Babashka, which is a limited Clojure + some frequently used libraries implementation with very fast startup thanks to GraalVM. For the rest, Python/ Perl etc. will probably still have a bit better standing because of all the libraries e.g. working with SNMP.

Re:The Modern Java Platform – 2021 Edition by tiew9Vii on Wednesday March 17, 2021 @07:19AM (#26489464)
> Types almost never save the day and they don't add much to the understanding.

There’s a saying in strongly typed languages “make illegal states unrepresentable”.

Java doesn’t let you get all the way there but it’s better than nothing.

When you look at strongly typed languages with a good type system, often when you compile it just works.

Besides hello world, I’ve never written program beyond a few lines that has just worked in a dynamic language.

...I do like clojure and the repl workflow and how everything is data. Haven’t done much besides play with it but have a friend who writes clojure professionally on a large codebase and their feedback is most of the errors they now see wouldn’t exist with a type system.

Re:The Modern Java Platform – 2021 Edition by kaliszad on Friday March 19, 2021 @12:46PM (#26515510)
Can you be more specific about your friends codebase? How large, what industry/ problem space?

Of course, you can write bad/ unmaintainable code in any language. I have seen such code in Clojure(Script) as well. But some languages really encourage bad code where other languages already feel like you are doing something wrong when you write bad code. (e.g. Using many atoms in Clojure, doing boolean transformations etc. just from the top of my head.)

Strongly typed languages in my experience don't help anything, make programming harder for everybody and the benefit is (for most software) questionable. Compilers should handle most types for us and only give us a hint something could be better, if we were more specific e.g. with a type hint. Humans should think about the problems not about deep implementation details (like integer vs float vs double), when not strictly needed.

Re:The Modern Java Platform – 2021 Edition by fulafel on Wednesday March 17, 2021 @12:08PM (#26493103)
Schema systems (like spec and malli in the Clojure world) work well for checking states in data and are more powerful and ergonomic for that than type systems in mainstream languages.
Re:The Modern Java Platform – 2021 Edition by Aperocky on Wednesday March 17, 2021 @01:21AM (#26486870)
That's strongly dependent on how big the code base is.

I'm a huge python fan, and I don't like/use IDEs on my personal projects. But eventually I still gravitated towards typescript because it had typing and the compiler + unit tests giving me a huge boost in ability to extend my project beyond a certain size.

I think the threshold is around 50-100 files, but smaller code bases also benefits from the typing structure.

Re:The Modern Java Platform – 2021 Edition by kaliszad on Friday March 19, 2021 @12:38PM (#26515400)
At OrgPad, we are well over 100, maybe even 200 namespaces in Clojure and ClojureScript and I don't think we have any trouble keeping up. Most of the problems we have are frankly not in any capacity connected to Clojure or ClojureScript but rather half-baked, inconsistent technologies and their implementations like CSS, browser interoperability/ APIs mostly. The server-side (Clojure) is rather boring currently, so can't say much about that - most of the stuff seems to be just ok. There seems to be a lack of libraries for transforming image/ video formats in Java for the newer formats like WebP, AV1. Probably most people drop to imagemagick/ ffmpeg? That is kind of a problem, but not really pressing. We have lost much more time to CSS and bad browser APIs.
Re:The Modern Java Platform – 2021 Edition by auganov on Wednesday March 17, 2021 @09:50AM (#26491201)
> I have no idea what things are, is it a int, string, object etc,

What if it's some kind of a String? Only a String starting with "_". You may define UnderscoreString. But now it's not obvious what this is. You have to go look it up either way. A compiler may stop you from passing a regular String. If you're very lucky it may even stop you from casting an obviously wrong literal. But beyond that you're probably out of luck unless it's a crazy language. Once everything is a custom type how is remembering all the types different from remembering what each function does?

I'm not sure how unit tests help here much either. Why would you come up with an example that breaks your code in a unit test but couldn't think of it beforehand? Unit tests are used just as much in environments with a helpful compiler. They mostly help stop new breakage affecting stuff that used to work.

I wouldn't write off checking at runtime. You can actually define exactly what it is and it's easier. You can do as little or as much of it as you want. It's not compile time but depending on your software you may be able to get fast feedback. This level of checking would not be compile time either way. If you really want to be sure you'll be doing this in your typed language too. You're only worse off if you'd really benefit from the simple stuff.

If wrong data hitting a function can cause multi-million dollar loses would a single person think the compiler is good enough? What if it can cause major data loss? Big embarrassment? Pretty clear to me one will only trust the compiler with bugs that don't matter in the first place.

Re:The Modern Java Platform – 2021 Edition by guggle on Wednesday March 17, 2021 @04:20AM (#26487899)
> Not having a compiler means I have to have unit tests doing what a compiler would do or finding out I have syntax errors or other errors at runtime.

Nope, it's not the only way. In practice you'd have type hints all over your code and a linter to perform static analysis. Of course this can be integrated in you IDE, so it's easy to do.

> Not having strong types and limited type hinting. I have no idea what things are, is it a int, string, object etc, clicking through in an IDE to see code/docs isn't as great as it's hard for an IDE to inspect the code compared to strongly typed language.

Again, with type hints you'll find your IDE does a pretty good job. Heck, Pycharm even gets it right without type hints sometimes.

Not that I don't see the value in compilers, but the case is not as clear cut as you expose, far from it.

> There's a great deal of issues with dependency management. Venv, Docker etc help with this but it's a bunch of extra stuff on top I now need to worry about and sometimes still hit errors.

Not sure what Docker has to do with Python here... I don't use it and we're doing fine. Venv is something you have to learn, sure, but that's what it takes to become productive on any platform, be it Python, Java, Go, Whatever: learn the good practices associated with it.

And while the dependency management is not stellar with Python, that's really not something to love from Java either.

Re:The Modern Java Platform – 2021 Edition by tiew9Vii on Wednesday March 17, 2021 @07:10AM (#26489393)
Type hints are optional.

Type hints are very different to a strongly typed language with a good type system. Haskel as an extreme feels like algebra, you have a type a, you need a type c, you have a function a to b, and a function b to c, you just compose them together and from your a you have a b. Tools like hoogle can tell you the function to use for the given args to get to the final type you want.

Ignoring Haskel even Typescript can let you express things hard to express in Python with ADT’s etc.

Docker has nothing to do with Python but if you want to produce an artifact you can just run anywhere it solves the dependency issue in that the decencies are in the image and you don’t need to run pip install on a deployment server.

Re:The Modern Java Platform – 2021 Edition by oblio on Wednesday March 17, 2021 @05:11AM (#26488353)
The thing is, type hints are optional. The vast majority of existing projects don't use them. Third party dependencies don't use them.

Python is a toddler in terms of typing system support. Probably a 2 year old.

Re:The Modern Java Platform – 2021 Edition by guggle on Wednesday March 17, 2021 @05:21AM (#26488448)
Indeed. But way to go... third party dependencies wont support Python < 3.6 forever. And it's still very useful for the application code alone.
Re:The Modern Java Platform – 2021 Edition by kaliszad on Wednesday March 17, 2021 @12:51AM (#26486691)
You could use Clojure of course and drop to Java for the few performance-supercritical functions if needed (most likely not for like 95%+ of codebases). The productivity and performance may be even better than Python or Ruby. Another positive is, quite a bit of the code can be taken 1:1 and used in ClojureScript if you do back-end and front-end at the same time. (Of course you can program in ClojureScript targeting not the browser but Node.JS e.g. using shadow-cljs which makes working with npm easy.) Also, I haven't spent much time on StackOverflow when programming in Clojure/ ClojureScript because the language is very clear and consistent and usually the documentation and maybe one or two examples there is enough. Or I just play with the function in the REPL for a bit, maybe do a quick (time (dotimes [_ 1e3] (some-function-under-bench))) and dirty benchmark for the more involved stuff.

Clojure is a superpower especially for large codebases because you can maintain your state and ship your adjustments from the editor to the REPL in development which is almost instantaneous. This works for production code also, if you need a very, very quick hot-fix or want to look at live data in the live database without copying possibly confidential data around. Of course, you have to be careful. With great power... and all that.

Re:The Modern Java Platform – 2021 Edition by hello_moto on Wednesday March 17, 2021 @12:23AM (#26486513)
In big codebases, people don't change Interface (that's a contract btw) that often. They would do the proper "migration" by offering path to the new contract/api.

If you have huge codebase in Python or Ruby, you'll rip your hair more often because it's riskier to make changes (dynamic language) according to your use-case :).

Re:The Modern Java Platform – 2021 Edition by mberning on Wednesday March 17, 2021 @12:26AM (#26486528)
Sure, according to some OO professor. In real life these things change all the time. And it’s not just methods and interfaces that force a recompile, those are just examples.

As for dynamic language projects, they should include a test suite to mitigate such issues, but often do not.

Re:The Modern Java Platform – 2021 Edition by NOGDP on Wednesday March 17, 2021 @12:59AM (#26486739)
A big chunk of the issues you're writing that test suite for, and constantly rerunning, are solved, out of the box, by having a decent type system. The type system also gives you superior code completion (with proper IDE support), which already outweighs any potential reload time costs in Java vs Python/Ruby, for me personally.
Re:The Modern Java Platform – 2021 Edition by NOGDP on Wednesday March 17, 2021 @12:52AM (#26486700)
If your development productivity is entirely reliant on how quickly you can reload your changes, then you're doing something wrong. Though I guess you'd have to write mounds of unit tests and constantly rerun them to prevent common issues that Java's type system solves for free.
Re:The Modern Java Platform – 2021 Edition by kaliszad on Wednesday March 17, 2021 @01:17AM (#26486846)
Actually, Java, its syntax, the explicit types and how its often taught only obscure the solutions that could be much more obvious. Since I have seen Clojure, I was swearing why nobody has shown it to us right in the beginning when I was in the university. Back then, Clojure was already an established, stable language and that has been a decade. I could just skip the C, Java and other classes and would be a much better real-world problem solver/ engineer much earlier. If I needed the specifics e.g. for embedded or legacy applications, I could always look-up/ learn the details for C/ Java etc. but that is not needed for more than 95% of the tasks a software engineer would encounter in the real world.
Re:The Modern Java Platform – 2021 Edition by NOGDP on Wednesday March 17, 2021 @10:40AM (#26491900)
You're not saying anything specific about what's wrong with Java. Java is not perfect, but you haven't actually given a single good reason. The type system alone is a huge benefit over languages such as Python/Ruby. Lisp has existed and been taught for a long time, and I like Lisp languages such as Clojure, but the allusion to Clojure being some kind of magic bullet is also pretty baseless.
Re:The Modern Java Platform – 2021 Edition by kaliszad on Friday March 19, 2021 @12:27PM (#26515269)
Well, I did say at least 2 specific things (syntax, explicit types). But maybe approach this a bit differently and talk about what is great in Clojure that is not good in Java: - persistent datastructures that can easily be made transient in specific performance critical cases - consistent syntax - the language itself is a datastructure so manipulating of code is very easy and you have a serialization format (again EDN) basically for free - the REPL - most of the code transfers 1:1 to ClojureScript, that is not the case for Java and JavaScript which are completely different languages and have very different strengths - dynamic types, but out of the box type hinting is available for some corner cases where it improves performance/ makes interoperability a bit clearer and e.g. using clojure.spec you can with some effort make something approaching depend type systems/ very strong tests incl. generative testing - Clojure/ ClojureScript interoperability with the Java/ JavaScript ecosystem - developer productivity - actually performance especially compared to Python/ Perl/ Ruby, very carefully written Java would win microbenchmarks but in Clojure you can probably improve the overall performance of a large codebase because in the same time as you would need with Java you can do many, many iterations more and therefore explore the optimal solution - you can become very proficient in Clojure in about 6 - 12 months where with Java you probably need maybe 3-5x that time to tackle the same problem space

Yes, some of those things are not so specific to Java. If you only care about performance in micro-benchmarks Java would probably win but probably 95% of the problems in the real world are way more complex. Also, good luck writing correct multi-threaded code in Java vs Clojure. Clojure is uniquely positioned for multi-threaded workloads thanks to persistent datastructures, atoms, agents etc.

Re:The Modern Java Platform – 2021 Edition by tracer4201 on Wednesday March 17, 2021 @02:07AM (#26487170)
I don’t think op was stating developer productivity completely relies on reloading changes, but developer experience does matter. Many folks end up working with legacy code bases that don’t have clean code, weren’t designed with testability in mind, among other issues. Reloading changes, writing to a logger, etc. end up being common techniques. Depending on the complexity and how much your org is willing to invest in such a system, you can be in a tough spot.
Re:The Modern Java Platform – 2021 Edition by lenkite on Wednesday March 17, 2021 @12:32AM (#26486568)
Well..there are always commercial tools like JRebel (https://www.jrebel.com/products/jrebel) that one can leverage for live reload
Re:The Modern Java Platform – 2021 Edition by victor106 on Wednesday March 17, 2021 @09:56AM (#26491276)
Jrebel is really really good but it’s just way too expensive. Maybe worth it for some folks though.

http://hotswapagent.org/ Is an open source alternative and covers about 90% of what jrebel does

Re:The Modern Java Platform – 2021 Edition by jakear on Wednesday March 17, 2021 @12:28AM (#26486539)
If you change an interface in Python you need to manually verify that everything is correctly using that new interface. That’s much more of a devprod hit.
Re:The Modern Java Platform – 2021 Edition by suyash on Wednesday March 17, 2021 @01:13AM (#26486824)
With interpreted languages you pay the price in terms of productivity (best practices, design patterns), performance (at scale) in long run which is way more than what you gain in short term is my opinion.
Re:The Modern Java Platform – 2021 Edition by reactor on Wednesday March 17, 2021 @05:27AM (#26488511)
May be you should try Quarkus, its hot reloading is slick. Even with a large code base, I could just do change->save->refresh cycle (about a second).