11 ms·
This is tangential and possibly too open ended to be productive but worth a shot anyway. Why is Java so popular? I know of a major Silicon Valley company that's
by kaycebasques 5y ago
This is tangential and possibly too open ended to be productive but worth a shot anyway. Why is Java so popular? I know of a major Silicon Valley company that's migrating their backend to it. Why Java over other languages? Or maybe there's not really other viable options?
I'm speaking as someone who spent the last 6 years focused on frontend web technology.
- badhombres 5y agoIt's a stable and well proven technology that still has a lot of developer activity. Businesses are trying to make money, not explore technology, so a lot of them don't want to bother risking deliverables on something they may not have experience with. IMO
- jraph 5y agoI'll try: Java is a proven, boring and "easy" language without much surprise, with a big standard library and ecosystem.
- ape4 5y agoJava is great, but here's a surprise: if (str1 == str2) { // oops }
- dpratt 5y agoThat’s not an oops. You’re comparing pointers.
- jraph 5y agoStill, coming from other languages, it is all too easy to write this and this silently fails without any warning. This is consistent with the rest of the language, but I'd bet one rarely wants referential equality when comparing strings. People commenting "yeah but that's because you are a newbie / you are comparing references and you should know better" miss the point I think. I can easily see myself making this mistake while fully understanding what's going on.
- jrsj 5y agoMost editors will warn you about this now as soon as you type it
- pritambarhate 5y agoLinters catch this: https://rules.sonarsource.com/java/RSPEC-4973 https://rules.sonarsource.com/java/RSPEC-4973 Basically the tooling around Java is very evolved and Java static type system helps the IDEs a lot. One of the main reason enterprises prefer Java. Also majority of the tools and IDEs is free for commercial use.
- __float 5y agoIt's easy to make this mistake, still: https://github.com/openjdk/jdk/blob/722d639fad2e4fc6eb2aabd427e2719501899cfe/src/java.base/share/classes/sun/net/www/http/HttpClient.java#L310 https://github.com/openjdk/jdk/blob/722d639fad2e4fc6eb2aabd4...
- nsxwolf 5y agoI learned this 25 years ago when I got started with the language. It tripped me up once, I learned about how references work in Java, and that was that. We are expected to learn about our tools.
- jraph 5y ago> We are expected to learn about our tools. I hope making mistakes is ok though? I learnt C years before Java, it's also the first language I properly learnt. And a little bit of C++ too, so I've known the concepts of pointers and references way before learning Java. In C, you also either do pointer equality or explicit value equality (with strcmp) for string equality tests. I never had any issue understanding how things work in Java. It's not about learning anything. It's about doing mistakes. And I won't take "you should know better" as a counter argument to a mention of some rough edge in an API or a programming language. It's like Javascript: you might know the differences between == and === in Javascript full well, but still happen to write == by mistake because you just wrote some C/Java/Python code just before. I'll probably not forget about .equals(...) in Java most of the time but the fact that == would be silently accepted and not do what is wanted is still a bit concerning (and .equals(...) is ugly, too). A linter will do indeed and that's a fair point. I'd argue that linters are there to work around rough edges of programming languages, but that's fair enough too, every programming language has its gotchas and I'll accept considering a programming language + its linter(s) instead of a programming language alone. However, that's still not ideal because you might have to work on non linted code and deal with these gotchas without any safety net. I hadn't thought about number comparisons (mentioned in other comments) but that's even worse indeed. It's no wonder Kotlin and Groovy both chose value comparison for ==.
- dtech 5y agoReference equality being the default instead of something you very explicitly have to ask for is a flaw.
- jraph 5y agoYeah, I hate that about Java.
- junon 5y agoIf you actually understand Java, you'll understand why this is wrong. Only newbies have confusion about this, most of which dissipates when you actually learn the language you're working with. Tired of this 20+ year old "flaw" being used as cannon fodder.
- dtech 5y agoJust because something is a well known-flaw doesn't make it a glaring flaw. There's a reason newer JVM languages like Kotlin use == as an alias for equals instead of reference equality.
- marginalia_nu 5y agoWhat if you are interested in reference equality?
- __float 5y agoIn practice, how often are you interested in it? C# has `Object.referenceEquals()` because you _may_ want this sometimes. But to have reference equality be the default for something like `==` is a design flaw. Not one that can be fixed now, of course, but it will continue to cause bugs for years to come. Sometimes, it happens in core Java libraries themselves: https://bugs.openjdk.java.net/browse/JDK-8274779 https://bugs.openjdk.java.net/browse/JDK-8274779 https://github.com/openjdk/jdk/blob/722d639fad2e4fc6eb2aabd427e2719501899cfe/src/java.base/share/classes/sun/net/www/http/HttpClient.java#L310 https://github.com/openjdk/jdk/blob/722d639fad2e4fc6eb2aabd4...
- marginalia_nu 5y agoDunno, I do a fair bit of low level java work, happens every once in a while. Curiously, I don't do a lot of value-comparisons. Based on grepping in the repo for my search engine, I appear to do one every 1000 lines of code. May just be how I write code though. Some people seem to do that a lot more.
- 5y ago
- UncleMeat 5y agoIt is true that C# improved this. Separating primitives and references in Java was definitely an error and it cannot be fixed at this point. The good news is that a linter trivially detects this bug.
- msgilligan 5y agoActually Project Valhalla is going to fix (well at least improve) this: https://openjdk.java.net/projects/valhalla/ https://openjdk.java.net/projects/valhalla/
- nkzd 5y agoReally? You are only "confused" by this if you are very new to programming in general.
- Cthulhu_ 5y agoOnly if you skip all the tutorials and don't use an editor that warns you about it. Which is another selling point for Java; it has the best editor support and quality assurance tools out there. It took years for e.g. Javascript to catch up and it's still a far cry from a proper typed language with tooling. I mean by that same logic, Javascript will confuse you as well because `{} != {}`, or C++ because of pointer mechanisms and custom operators.
- Banana699 5y agoIt's really says a lot that you have to compare with JS or Cpp so that Java comes out on top. Those are 2 extremely flawed languages that are the butts of cliché jokes well-known across every programming circle, their history alone has "HACK" written all over it.
- MBCook 5y agoFor what it’s worth any decent IDE will warn you about that. But as a Java developer you know it’s wrong, Strings are objects and that’s not how you compare objects. The tricky one is numbers. Integer == int // fine int == int // fine numVarOne == numVarTwo // Uh-oh In that third example you better make sure they aren’t both boxed objects or BigDecimals. I’ve almost never seen the string one for some reason. It’s always boxed numbers. Again, a good IDE is worth a ton.
- vips7L 5y agoInteger == Integer actually works... sometimes, as long as you're within the Integer cache. It gets people all the time though.
- MBCook 5y agoYep. I’ve been bitten by that myself. It’s sneaky because it may pass all your unit tests because you’re using small numbers. Then it gets to prod with record number 2718 and kablooie.
- marginalia_nu 5y agoEh, I'll take that over <https://dorey.github.io/JavaScript-Equality-Table/ https://dorey.github.io/JavaScript-Equality-Table/> any day. Boolean.getBoolean, however, now that is a proper Java land mine.
- azth 5y agoIn addition to what the other posters replied, the IDE will warn you about this.
- darkhorn 5y agoAnother surprise is it that it has issues on Turkish localized Windows operating systems.
- kaba0 5y agoWhat do you mean? Can you give a source where I can read more on that?
- darkhorn 5y agohttp://haacked.com/archive/2012/07/05/turkish-i-problem-and-why-you-should-care.aspx/ http://haacked.com/archive/2012/07/05/turkish-i-problem-and-... http://www.i18nguy.com/unicode/turkish-i18n.html http://www.i18nguy.com/unicode/turkish-i18n.html https://community.jaspersoft.com/questions/1065746/jasperreports-server-640-installation-issue-turkish-windows https://community.jaspersoft.com/questions/1065746/jasperrep... https://userapps.support.sap.com/sap/support/knowledge/en/1493845 https://userapps.support.sap.com/sap/support/knowledge/en/14... https://github.com/java-native/jssc/issues/80 https://github.com/java-native/jssc/issues/80 https://issues.apache.org/jira/plugins/servlet/mobile#issue/VELOCITY-908 https://issues.apache.org/jira/plugins/servlet/mobile#issue/...
- kaba0 5y agoWell, I think it’s just the usual gotcha of programmers assuming things about languages that are not true. Though I’m not sure why wasn’t two new i’s added instead of modifying the latin i? It is a different letter after all in this case.
- cies 5y agoTooling is quite good with IntelliJ and Gradle, Kotlin is neat. It's pretty fast, allows for high level'ish programming and is verrrry widely used (many like to claim this helps for finding devs, seen by many others as the super scarcest thing producing software, but i beg to differ).
- vorpalhex 5y agoWith Java comes the whole JVM which is equal parts blessing and curse. You no longer need to know a bunch of OS details, but you pay in overhead. From a business standpoint, there are lots and lots of Java programmers out there. Of course that doesn't reflect anything about the average skill of those programmers..
- kaba0 5y agoFor a typical business app, I really don’t think there is all that much overhead. Java is very fast, virtual calls are basically free due to the JIT, and these apps usually don’t need that much cache coherency for issuing an SQL query for a request. It’s not decoding video.
- vorpalhex 5y agoIf you think 512mb of base memory usage is "nothing" and you're ok with slow program start times, that's probably fine. If you're like me and you sort of get sad when your program uses more than 64mb when idle because it feels wasteful, then yeah that overhead is pretty gnarly. "But we have servers with hundreds of gigs of ram!" you might respond - and sure, we do, but having resources doesn't mean you have to use them. It is better to write small fast efficient programs than extravagant enterprise stuff.
- kaba0 5y agoWhat about the fact that Java is the most energy efficient managed language? Not constantly crunching through memory to choose which memory should be freed is efficiency, not laziness/bloat. Sure, there are use cases where it is not a reasonable tradeoff, but for CRUD business apps, it is perfectly fine. Especially given that not all cores can be used uniformly.
- igouy 5y agoMaybe `vorpalhex` was interested in any "most energy efficient" language, not just a "managed language".
- cityofdelusion 5y agoIt’s stable, mature, fast, and it is very easy and cheap to hire for, both domestic and offshore.
- sidlls 5y agoIt's trivial to find dirt-cheap java programmers domestically and in overseas sweatshops.
- jmyeet 5y agoBecause Java is stable and mature, has well-understood performance, is statically-typed, has a proven track record when it comes to backwards compatibility, is reasonably fast and has lots of library and tooling support. Additionally lots of people know it. Some complain about verbosity. It's really a non-issue particularly in a modern IDE and not worth making a language decision over. Not everything has to be new and sexy.
- dfee 5y agoDefinitely an issue in 8. My hack is to call everything an `int`, write the statement, and go back and let IntelliJ handle the proper name, adding the import, etc. I understand though, that in more recent versions of Java this is taken care of for you.
- l5ymep 5y agoJava developers are cheap and easy to find. There are libraries for everything that you would need - AWS SDK, Redis, etc. Performance is tolerable and can be improved with things like Micronaut and native ahead of time compilation (GraalVM).
- sz4kerto 5y agoThey're not cheap :) or -- I'm not sure what you mean by cheap, but good Java coders are generally amongst the best paid ones.
- paulmd 5y agoit's really bimodal imo, there's a tier of sweatshop contractor job that pays $50-70k (or did before salaries got nuts the last few years) and then senior jobs pay $140k ish average now. Senior getting paid more isn't new but it seems like maybe a 2x ratio is higher than elsewhere.
- isbvhodnvemrwvn 5y agoGood <insert any language> coders are generally amongst the best paid ones, but let's be honest an average Java developer is lost if they can't find an annotation to solve their problem. It was the "default mid-tier university language" for a while, and it really shows in quality of people who apply.
- manuelabeledo 5y ago> Java developers are cheap and easy to find. I wish.
- wiseowise 5y agoNobody said they’re good quality though.
- kaba0 5y agoNative AOT doesn’t improve performance, but start up time and memory overhead.
- junon 5y agoThe language is simple. Reasonable performance, lots of opportunities to tune that performance without changing code. Great error handling. Works across all platforms in most cases. The tooling has a long standing reputation for being incredible, given what Eclipse and Jetbrains have done for the community. It integrates nicely with native code, and is easy enough to interface with (compared to e.g. Node.js and python, which have hellish bindings). Strictly typed, which has a lot of benefits. Lots of long-standing libraries that have been battle tested and still work even today. Great ability to mock, inject, and invert dependencies. No language is perfect of course, the point isn't to start a war. I don't personally use Java for my own projects anymore but I can see why it's very attractive.
- dfee 5y agoGreat error handling? What does that mean? Checked exceptions seem cool at first, but are really just nonsense… as your only real way of dealing with this is: 1. Catch, log and rethrow, or 2. Wrap as a runtime exception (so you don’t have to change every method signature up to main()) Sure, there’s option 3: catch and handle… but this is used 1/50 times, and the ergonomics of (2) overwhelm the utility of this. BTW, vavr is nice. Just, “run it all” and optimize for the golden path. If there’s an error account for it locally.
- junon 5y agoWas referring more to structured stack traces. You're able to shoot yourself in the foot in any language's error handling system - quite trivially at that.
- dfee 5y agoBut the problem is that checked exceptions create the same “what color is your function” problem for errors.
- simion314 5y ago>But the problem is that checked exceptions create the same “what color is your function” problem for errors. Compared to "SEGFAULT at 0x000000 in some xxx.dll" having to handle exception and having readable stack traces is a productivity win.
- jakebasile 5y agoThe JVM is great. It's easy(-ish) to deploy and there is a library for anything you can possibly think of, probably more than one, on Maven. It handles large throughput and big memory usage very well and is extremely tunable. Using the JVM doesn't mean you're limited to Java anymore, and hasn't for a long time. I have built software for the JVM for the past 6+ years nearly exclusively in Clojure with only a few moments where I needed to dip down into Java proper.
- packetlost 5y agoCan confirm. Been learning Clojure lately (after using Python for a long time) and it's great. That being said, the JVM is a bit chunky in terms of disk usage and when you get into really high performance things, tuning heap space and whatnot is a pain (I'm looking at you ElasticSearch), but it really is a fantastic piece of engineering.
- dfee 5y agoI think it has a relative speed performance over languages that are interpreted (runtime). It also has an ecosystem of tooling to monitor and profile built both into the JDKs and by teams across Silicon Valley (eg first class bazel support). I’m in one of these companies now, and while I’m certainly productive using Java, it’s also got huge downside in the community which these companies don’t really care about. Never have I seen so much cargo cult practice. The ecosystem isn’t great, with hard to google docs and everything pointing you to a poorly written baeldung article. Java gets no one excited. And, it gets no one fired.
- fifticon 5y agoActually, i like it for basic desktop apps, because it just works, and i stay clear of the last 12 years of front-end dumpster fires, where nothing that is over 18 months old, can build, compile or get support anymore. In my day job, I inherit "fun" tasks as 'get this thing someone glued together with webpack4 and frontend-du-jour to work with webpack5 in 2022. Java thank you, any day of the week.
- dfee 5y agoThere are a lot of problems in the JS and Swift communities, as there are for Java. I think you’ve got to meet your customer where they are, and if you can ship Java desktop apps, and they’re happy… keep going. But you’re not shipping apps to their iPhones using Java. It’s either JS or Swift. And, on Android it’s JS or Kotlin. So the common target is JS.
- ohgodplsno 5y agoOr Kotlin Multiplatform, which generates .frameworks/cocoapods/spm files that you can use, and all you have to do is write your UI layer in Swift.
- native_samples 5y agoYou can ship to iOS with Java actually. That's the business model of Gluon: https://gluonhq.com/ https://gluonhq.com/ It's a combination of JavaFX, a custom controls library that implements Material Design and GraalVM native image. Whether you want a non-native UI toolkit on iOS is a separate matter, but it can be done technically. In fact, you can ship JavaFX apps to the web too. It doesn't compile to megabytes of JS either - instead, the JavaFX app runs on the server and the UI is projected to divs and SVG elements on the fly. The browser provides native scrolling and text selection. If you have low latency to the server (e.g. same continent) it can work remarkably well. Check out https://www.jpro.one/ https://www.jpro.one/ - the entire website is a JavaFX app.
- tauntz 5y agoIt's rather easy to use, stable, has a really decent standard library, the tooling is excellent, it's performant, etc. There are 3rd party libraries and integrations for _everything_ and it's comparatively easy to find skilled developers with years of experience.
- runevault 5y agoLanguage with a fast runtime minus startup (although maybe they've fixed the startup since I last looked) that is incredibly tunable to fit your specific needs for good performance profile, while not needing to manage raw memory the way c or c++ would. Personally I prefer c#, but a lot of places already were using Java in significant ways before c# became good (IMO 2.0ish) and saw no reason to change.
- kaba0 5y agoJava’s startup only slows down when a ton of classes have to be loaded, e.g. that’s why Clojure’s repl takes quite some time as you are loading two standard libs. For a simple hello world it is below 0.1s.
- pkolaczk 5y agoBut noone cares about hello world. You're not building hello-worlds in real life. Slow startup time is a problem in automated testing of big codebases - when you aim to test the whole codebase, but each test alone does not stress any code path hard enough for the hotspot compiler to kick in. So basically most of your Java code in testing runs in interpreted mode, which is like 20x-100x slower than properly compiled and optimized C/C++/Rust.
- kaba0 5y agoThat’s just not how it works. If no code path gets run enough times, then frankly, it simply doesn’t matter, they could have been written in bash and still be “fast enough”. Like, I can’t fathom a program that doesn’t have loops where the actually important part happens. You simply can’t write enough “linear” code to make a modern CPU sweat even just a little. And if you do have said loop, than it will be JIT compiled.
- pkolaczk 5y agoBut it's not just interpreting linear code. It is also classloading which involves a non-trivial amount of work before any code in a class can even run. Also I never said the testing code doesn't have any loops. There often are loops but they need to run for a really long time until hotspot kicks in. So if you lose a few tens of millisecond here and there in a single test, you will get minutes or hours in total in a codebase that has hundreds of thousands tests. And it gets terribly worse if many of your tests are end-to-end tests that e.g. launch new JVMs.
- matwood 5y agoGreat tooling. Good performance. The JVM is very tunable. Huge ecosystem of libraries. Language wise modern Java is fine, but if not, there are other languages on the JVM that interop.
- giaour 5y agoJava values backwards compatibility very highly, so if something runs today, it's likely to keep running without modification on future JVMs. (Though the 8->9 transition was pretty rough for some.) Compiled Java artifacts are usually portable across OSes and CPU architectures, so your build pipeline can be pretty simple even if your infrastructure is not. JVM performance is generally fine, and the language prevents you from introducing whole classes of memory safety bugs. You can still shoot yourself in the foot with native (JNI) extensions, but the decent performance of the JVM makes developers use JNI far less frequently than, say, Python or Ruby devs reach for compiled libraries. JVM byte code decompilation is fairly trivial, so tools for the security scanning of artifacts are cheaper and more fully featured than similar tools for scanning machine code.
- ok123456 5y ago> Java values backwards compatibility very highly, so if something runs today, it's likely to keep running without modification on future JVMs. Then why do I have to have multiple JVMs installed, which I need to go through via trial-and-error, if I'm given some random java application?
- NoSorryCannot 5y agoI don't know, why do you? There are occasionally breaking changes but most old jars out there will run fine in the latest runtime, so the answer to your question is going to depend on how squirrely your use case is.
- stevoski 5y ago> Then why do I have to have multiple JVMs installed, which I need to go through via trial-and-error, if I'm given some random java application? You don't. Almost any Java program written ever will run on Java 18.
- ok123456 5y agoJavaFX isn't guaranteed to be in a JVM. You run into "deprecated" APIs that were removed. JVM options change, and that breaks how things are deployed. If the JVM were a stable target a site like http://whichjdk.com/ http://whichjdk.com/ wouldn't be necessary. This is just how things are. It's Java fanfiction to say this isn't the case, and necessitates having multiple JVMs installed.
- letmeiiin 5y agoBecause Java is engineered. You can imagine the amount of work going into it. You have multiple companies have whole teams working just on different garbage collection algorithms. No other dev stack has this kind of focus. The JVM is a small wonder. And Java is evolving quite nicely too.
- renewiltord 5y agoUsing backend technology: - Java has great ecosystem support - JVM is very performant - Java has well understood quirks - Reasonably mature build system - Good deploy story I wouldn’t use Java for a web server but I like it very much for many other things. I think Scala + Play does a good job for JVM web frameworks but I’d use a Typescript thing (or just Rails) There are downsides to Java. Bit and byte manipulation are annoying, for instance. But I’m still happy with it.
- lkrubner 5y agoFor me the choice is really about the JVM, rather than going with Microsoft and .NET. I work mostly in Clojure, which runs on the JVM. But I have the whole universe of Java libraries available to me. Whatever flavor of language you are into, you will find something that runs on the JVM. The competition includes languages like Rust, Go, Haskell or Erlang. Most of these lack the languages that you'll find on the JVM, so it really is a question of what you are trying to do. Go is certainly interesting in some places, especially if you want a binary that is entirely self sufficient. Each of these languages is interesting, though of course one has to wonder about hiring, whereas finding developers who've worked on the JVM is easy enough.
- jwesleyharding 5y ago1) network effects, around runtime and core library especially. IMO, for enterprise, runtime is especially sticky. 2) of the JVM languages, Java will (always?) be the easiest to hire for
- rr808 5y agoIts popular because it was popular. C#/Go/Rust/Scala/Kotlin have some advantages over Java but aren't worth switching because Java works fine. Java has been around a long time and lots of people know it.
- paskozdilar 5y agoIMHO, Marketing. Java had so many marketing crazes that it's crazy. I still remember the "Java mobile game" fad from a dozen of years ago - Java this, Java that, Java for phone, Java for toaster... At some point, the public mind starts to associate "programming" with Java. Since there were (and probably always will be, unless we evolve into utopia) hordes of job-desperate people who would do anything to feed themselves and their families, a lot of them hear about Java, start programming in Java and develop their whole world around Java. Java helps them with this by providing this huge, Java-centric ecosystem which gives you everything you ever need to do whatever you want to do. Of course, there is also the fact that Java is a managed environment and makes it a lot harder for programmers to write broken code, which makes large-scale programming possible even if all you have is a horde of mediocre programmers. But then again, that property is not unique to Java.
- zero_shift 5y agoI see this post is getting some downvotes; I'm not sure I agree with all of it myself. But I would ask those, who reject the premise here outright, to think back really hard to how things were in the 1990s. The Java brand was everywhere. It was a truly massive endeavour and one of the first languages to really go "viral" as the Solution For Everything. People laugh at the cute "Java runs on four billion devices!" tagline but back in 1995 if you weren't doing Java, you were a last-century coder. It was so pervasive Brendan Eich even renamed his strange scheme-smalltalk mashup "JavaScript".
- paskozdilar 5y agoPeople don't like to see their favorite languages bashed. It's completely understandable. I suppose there are many Java enthusiasts on here.
- kaba0 5y agoI mean, Java is not a liked language by any metrics, so I guess fans (myself included) are more than used to bashing. That’s why I don’t think that marketing helped the language become as great as it is. Sure, it had a part, but if something would have been substantially better it could have taken over a long time since java is not hypes at all anymore.
- grishka 5y agoJava is easy to understand and it's hard to shoot yourself in the foot with (no raw memory access, unless you use JNI/JNA). Garbage collector makes memory management a non-issue. Exceptions make error handling easy. OOP is a simple concept and many real-world programming tasks can be laid out as a nice class hierarchy. Java's changes are few (as opposed to some other languages), feel logical (to me at least), and solve real problems. Most of "syntactic sugar" features don't make the code using them less readable. Java also supposedly runs on everything. And, you could as well write Android apps in it.
- paulmd 5y agoTo echo others: relatively good performance, incredible tooling/deployment infra (really best-in-class), intercompatibility with tons of other languages built on top of the JVM such that it can be functional/do actors/whatever your other weird approach is, relatively high productivity due to a large library base (not just the standard library but also a huge amount of stuff written to support android apps), and ease of hiring/replacement. But to throw another onto the pile, Java being statically compiled makes it a lot easier to comprehend a larger codebase that you didn't necessarily write yourself. The history of dynamically-typed languages is basically getting to a certain critical size and realizing there's some merit to a well-defined, compiler-checkable code interface and then retconning it in - this happened with Facebook (Hack-lang), with Typescript/CoffeeScript (Google), and I think there's one for Python now too. So yeah, basically people like Java because it's fast and versatile, because it's got a Pythonesque amount of stuff already written for it, and because it's got features that are oriented towards bigger teams with more turnover/etc that make it practical for business reasons.
- pianoben 5y ago> with Typescript/CoffeeScript (Google) cough Microsoft did Typescript, actually https://en.wikipedia.org/wiki/TypeScript#History https://en.wikipedia.org/wiki/TypeScript#History
- azth 5y ago> relatively good performance, That's kind of downplaying it right? Outside of "native" languages like C, C++, Rust, fortran, Java blows everything else out of the water.
- kevincox 5y ago"If you exclude the well performing languages java performs excellently." But that is what I think OP means. It isn't top tier performance, but it is in the second tier which I wouldn't argue for qualifying for "relatively good". FWIW I find that languages tend to fall into a couple rough performance groups: - Native at about x1 performance: C, C++, Rust, Fortran - Compiled GC at about 2x performance: Java, Go, Haskell, Lisp - Dynamic at 20-50x native performance: Python, Ruby... JS is a weird one that varies a lot depending on your workload and can sometimes look similar to compiled GC performance.
- vips7L 5y agoTooling, performance, observability, and maintainability.
- oaiey 5y agoThis is an interesting question. Not because of Java (that is answered) but because of the alternatives. Kotlin/Scala/C#/F# are the same stack types, C/C++/Rust are lower level, leaving it realistically (job market) to Python, JavaScript and Go. Python and JavaScript are quickly sorted out as non static typed and Go is still not in the league of Java or .NET despite all it's amaziness. So it boils down to: do the people like static typing or not.
- stonemetal12 5y agoWhat else would you use? Java is the shark that ate everyone else's lunch. At this point all you have as alternatives in the category of "easy to use for backend type stuff" is C#, and go. Both of which have their pros and cons but on the whole aren't bad choices. I guess like bellbottoms, Java is making a fashionable comeback.
- tetsusaiga 5y agoThis is my default answer. What else would you use? C# is the only realistic alternative in my opinion, and I could respect that choice. I work in Go currently and although I see the positives, I'd be less inclined to unleash a bunch of mid-level devs using Go to create a huge codebase. If I could have my way, personally, I'd go for one of the other fun JVM langs out there... but that's just me having fun.
- Ternari 5y ago> I'd be less inclined to unleash a bunch of mid-level devs using Go to create a huge codebase Why?
- jillesvangurp 5y agoKotlin is actually the natural upgrade from Java if you want something that feels more modern than Java. Very easy to switch to from Java: a conversion tool is actually built into intellij. For most traditional Java frameworks (like Spring or Quarkus), Kotlin has long been a first class citizen (support, documentation, custom Kotlin extension functions, etc.) and probably the easier language to use when you are starting out with those frameworks. And of course on Android, it has long replaced Java as the default language. On the server server-side, Spring has done so much work on integrating with Kotlin in the last five years that you are probably not doing yourself any favors if you choose not to use that. Kotlin DSL support is just a killer feature here. Spring has really embraced that and they've added nice Kotlin DSLs for pretty much everything that matters. No more builders. No more endless function chaining. No more annotation magic (or at least a lot less of it).
- 5y ago
- WYepQ4dNnG 5y agoJVM echo system / tools / libraries / performance is awesome. Frameworks like Spring/Spring Boot have made JVM the default choice for many big tech. It is a no brainer and it works. No one will ever get fired for choosing Spring Boot for a new project :)
- marginalia_nu 5y agoI can tell you why I choose Java for my projects: * It's very fault tolerant. In almost every case C++ would mushroom cloud, Java can walk it off. It's easy to write code that cleans itself up on error. try-with-resources is great. * Modern JVM JIT and GC are pretty damn good, and the tooling is great. * It's very boring and stable. I see this as the killer feature. Cool is a conserved quantity. It's extremely hard to write cool software in a cool language, as that attracts cool developers too busy getting cool jobs to maintain their cool framework you depended on. There's a lot of mature high quality libraries available. APIs are stable, stuff very seldom breaks. You can often use code that's 10-15 years old just fine. This has changed a bit lately, but it's still extremely reliable. There are drawbacks as well, primarily memory mapping files is difficult, some of the aforementioned libraries are a bit bloated as well and overall the language sort of encourages large complicated solutions to simple problems.
- stjohnswarts 5y agoFirst comer advantage. Initial Java was a robust, yet simple, sane build tools, relatively safe, typed language when most everything else was c or c++ and not as "safe" (modern c++ is actually very safe language if you stick to its guidelines however). Over time Java has become almost as complicated as Modern C++ but people picked it up over time mostly. It's still used because it's still a robust general purpose language, tons of libraries, huge corps don't like to rewrite things, and there are lots of Java programmers out there. Don't let the webstack blind you, there is a whole other world out there of backend, embedded, finance, and legacy stuff that hackernews audience is just a small part of.
- deleted 5y ago[deleted]
- munificent 5y agoI think it's a combination of four things: 1. GC is an enormous productivity improvement for applications whose performance characteristics can afford it. Seriously, I can't think of a single programming language feature/concept/technology that makes a bigger difference in developer velocity than memory safety and GC. 2. Static types are also a large productivity improvement for developers comfortable using them and the kinds of projects that benefit from them (large, multi-dev, multi-year). 3. Imperative and object-oriented. Java is imperative in the small, which is familiar to most developers and seems to strike a balance of letting developers write correct code with good performance. Java is OOP in the large and for many classes of applications, that's been a wildly successful way of organizing code and lowering the cognitive overhead. 4. Path dependence. The past largely determines the present. We don't reset all of our technology choices and start from scratch at the beginning of each fiscal quarter, so the languages that were widely used tend to stay the languages widely used. Java was the first heavily engineering and marketed language that featured GC, static types, and OOP, so it got big and continues to stay big. I also think it's a pretty decent language. The things people don't criticize about Java are mostly complaints about a certain style of programming in the 90s and less the language itself.
- paulmd 5y ago> I also think it's a pretty decent language. The things people don't criticize about Java are mostly complaints about a certain style of programming in the 90s and less the language itself. (assuming that's a typo there, the things people don't like/the things people criticize?) I disagree on that point, I think the language itself was a problem. Java 6 and prior were very very verbose and very very slow. I think that really changed with JDK 7/8, but the java we know today isn't the java of the 90s. Even then, to some extent that problem hasn't gone away, it's just been papered over with frameworks and library code. Like honestly even as a java dev, I couldn't tell you off the top of my head the exact code to open a file, read each of the lines, and then close everything, or the right way to open a JNP connection to RabbitMQ or something. Anything touching files or sockets is still an absolute nightmare of boilerplate code, inputstreams, filestreams, printwriters, try/catch, and mother. fucking. IOException. thrown everywhere. But you don't care, because you just call Apache commons-io or Spring RestTemplate. And that has contributed to some criticism of its own. Spring tends to turn into architecture-astronaut crap, like everyone's favorite AbstractSingletonProxyFactoryBean. > Java was the first heavily engineering and marketed language that featured GC, static types, and OOP, so it got big and continues to stay big. The other quiet boost that people don't talk about is Android. Tons of libraries get written with the intent of being used in some android app somewhere, but you can use that equally much on desktop/server. It really really helps the rapid-prototyping aspect of Java that ~half the smartphones in the world are running Android.
- manigandham 5y agoJava (and .NET) have vast ecosystems with lots of developer experience, a massive standard library, a big selection of 3rd-party packages, vendors and services, solid backwards compatibility and deployment stability, and tons of research/development constantly making everything better. Contrary to the Silicon Valley popular opinion, these languages are incredibly productive and run much of the world, with code running in all of the Fortune 500 companies down to small businesses and even your phones.
- gmokki 5y agoOne thing that is not mentioned is security. There are java libraries for almost everything. And when something is implemented in Java it is much harder to exploit. Python and node are both great but mostly just wrap C libraries, so If openssl or your database driver has a bug your fancy interpreted/sandboxed language does not help. Java has existed a long time and developers have had time to reimplement many popular protocols and libraries. This can sometimes cause few % points of performance, but you get stability and the excellent monitoring&debugging. For example, if I need to accept images from the internet I would use Java since there are pure java image libraries that cannot be exploited with unexpected data. At most it fails and everything is cleaned up.
- Banana699 5y agoIt's popular for the same reason C++ and JS are popular, hype trains and lock-in. There's no good reason to use it in a new project, people saying "Performance" and "Tooling" need to take a good long fresh look at the language landscape, we're not in 2005. A trivially easy replacement would be Kotlin, it compiles to the same VM (and additionally webassembly), it is designed and implemented by one of the leading IDE vendors, it can trivially call and be called from Java, it has tons of zero-cost syntactic sugar that covers the inhumane verbosity that Java buries you under till your eyes bleed and your hands scream. A well-designed language, what should have been all along.
- darkhorn 5y agoJava is popular because of marketing. https://www.theregister.com/2003/06/09/sun_preps_500m_java_brand/ https://www.theregister.com/2003/06/09/sun_preps_500m_java_b...