Follow

I ask because I suspect there are some solid answers.

To all the JVM users out there, other than momentum/ecosystem, what is the primary elevator pitch for doing JVM-based webdev in 2022? What does the JVM give us compared to Node, PHP, or Python?

@worldsendless It's much faster than any of these options, though how much depends on what you're doing, with PHP and JS often coming close.

It has so much more good code written for it than anything else. Python comes close, but it's the slowest and has the least support for multi-threaded computing (due to the GIL).

For webdev specifically, the JVM doesn't have the very best web frameworks. The currently popular ones are Spring MVC and Play. These are both serviceable frameworks.

@worldsendless Where the JVM really shines in webdev is when you have a lot of JVM-related backend code already (or if you want to use JVM-related technologies).

Then you can just natively use your JVM code and the webdev code is just a thin layer on top of your JVM ecosystem.

Note that you'll still realistically need JS along with the JVM, but it can be relatively simple front-end code (and/or leveraging JS frameworks), with the JVM language(s) doing the heavy lifting.

@urusan Excellent point, sharing with the other non-webdev business logic things. Come to think of it, I have used some of that (ie Mallet for text processing).

About the speed vs Python, though -- isn't that mostly a myth? Very rarely is python itself doing anything heavy. It just wraps the C code, right?

@worldsendless It depends on what you're doing.

The main issues with wrapping C (in general) are:
1. You have to write whatever it is in C, not your high level language.
2. It doesn't compose well, and methods to force this increase the overhead.

So in areas like scientific computing, where you can profitably convert a wide range of problems to vector or matrix math, you mostly are running C. In areas where this isn't possible, you're mostly running Python.

@urusan Pardon my ignorance, but isn't this just what popular libs like Numpy, Pandas, and PyTorch are doing?

@worldsendless Yes, but it's only relevant for matrix calculations or problems you can reframe in a matrix form.

So it's great for deep learning and scientific computing, but not so much for web development.

@worldsendless While I'm no expert at how Python webdev frameworks work, both Flask and Django seem to be nearly pure Python:
github.com/django/django
github.com/pallets/flask

So it's probably going to be pretty much all Python or JS code running.

There might also be web servers like nginx involved, so those parts would be highly optimized.

What about Web2Py? I am not a coder, but I wish I was - I find it fascinating.

@FourOh-LLC I don't know that one, but it's probably pretty cool if it is like some of the tools I use in Clojure

@FourOh-LLC @worldsendless It looks interesting, but it doesn't seem to be designed for serious work. It's more of an educational tool.

That said, if you're doing it for fun or a small scale site, it looks just fine.

It looks like it'll still continue to be maintained for the time being, which is the most important attribute that a webdev framework needs, since the web is constantly changing. Unless you're using a static site generator, you need continuing updates.

@urusan Good points. I've dealt with apps in both flask and Django, and they have some definite benefits. I don't know their performance characteristics, though. That was something that inspired the questions: what pros does the JVM bring in uniquely?

@worldsendless By the way, another important detail to bring up: the reason Python and Ruby were so popular for webdev initially were that their slow performance doesn't really matter that much.

The reason is that most webdev is heavily I/O bound, so you're not actually waiting on Python most of the time. You're waiting on the network or memory/disk most of the time.

That said, this inefficiency adds up over large scales. Also, if you have backed stuff and want it in Python it could be slow.

@worldsendless One last key pro of Java (which is not strictly unique) is the type system.

Python, PHP, and JS all do not require types to be used, and until recently they didn't have type systems.

Python's was added in 3.5 and is still evolving: docs.python.org/3/library/typi

Javascript doesn't have a formal type system but there's tools to add them via JSDoc as well as Typescript.

I don't know about PHP.

Type checking is crucial for any large scale program, but it's not a big deal at small scale

@urusan being a Clojure programmer, I have a different perspective on type systems. But I recognize some utility (and much great tooling) to that end, too (assuming you are using Java on your JVM)

@worldsendless Even if you're using Clojure without types for your own stuff, you're still benefiting from types in library code.

By the way, my more general position on the matter is that optional typing (such as that in Julia or Python) are the ideal middle ground, and this approach will become the mainstream in the coming decades.

Java's typing strictness slows down early development, but the value of types grows with scale and codebase stability.

@worldsendless While I have used Clojure before, I didn't really get into what's going on in type systems.

Reading about dependent type systems as mentioned on Clojure's Wikipedia page sent me down a very interesting rabbit hole.

It reminds me a lot of validation, except it's baked into a type system rather than having to write additional code to do the validation.

There's also some interesting trends in Julia that are going in a similar direction, which makes sense as Julia is a secret Lisp.

@urusan Thank for the take. I actually don't see types too much in the libraries I use, either (I read much of the code, and create my own libraries keeping with some of the community idioms). A great discussion of the types stuff (not strictly Clojure) is on this thread: clojureverse.org/t/dynamic-typ

But I concede that they are proven useful at scale. As far as this topic, though, the question is about the JVM and what it offers, which is entirely different from Java

@worldsendless I don't necessarily mean the use of types externally are what benefits you, but rather that the quality of the libraries written in Java/Kotlin/Scala will be better than they would be otherwise thanks to types.

This only applies to libraries of substantial complexity of course.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.