14 ms·
Recently I was curious why so much big cloud software is written in Java. Cassandra, Kafka, and Neo4j are some examples. I don't have a lot of experience in the
by jmts 8y ago
Recently I was curious why so much big cloud software is written in Java. Cassandra, Kafka, and Neo4j are some examples. I don't have a lot of experience in the area myself (embedded software engineer) so I put it down the JVM providing straightforward platform independence and a consistent API, and the (assumed) simplicity deploying .jar files. This anecdote suggests it may be a less deliberate choice and that Java is just the de facto language. Does anyone have deeper insight on this this trend that they might be able to share?
My apologies for this post being a little tangential.
- wmf 8y agoBefore Go and Rust came out, the mainstream statically-typed languages were C, C++, and Java. Java was also one of the few "modern" languages that can idiomatically use multiple cores. So yes, Java was pretty de facto.
- mrath 8y agoEven now Java is pretty much defacto in many places. Go does not scale well and it is a dumb language, not that that is bad. But just that it does not feel like a improvement to switch to Go. Rust is still new and I think it will not get mass adoption like Java because of higher learning curve.
- dan-robertson 8y agoI’m slightly unconvinced by the learning curve thing about rust. C++ has a high learning curve too but it is used very widely. I don’t really think rust has a higher learning curve than C++. The main differences are the borrow checking (instead of having to learn and unreliable manually check memory usage everywhere), the type system having more ML-style polymorphism instead of crazy templates, and instead of inheritance with tables being implied by class, vtables are independent things (ie traits) and work largely like implementing multiple interfaces in c++ but without the inheritance and with implied instances from some rules. The rest of the differences are just having different standard libraries/tool chains. I don’t think that, for a novice knowing neither, rust is somehow much harder than c++
- chipperyman573 8y agoC and C++ are also both taught in almost every university (at least in America but I assume in other places as well). You can't really say the same for rust.
- steveklabnik 8y agoThere have been university classes on Rust, but nowhere near C++ or Java, it’s true.
- dan-robertson 8y agoC is nearly 50 years old. C++ is 35 years old. Rust is 8 years old. Rust 1.0 is 4 years old. I think it is reasonable to guess that this is the reason rust is not taught so much at universities. Especially at universities which choose things based on what they think industry wants or what the professors know as this will lag behind actual trends in industry too. I think this argument only really applies to rust’s learning curve if one assumes that each year universities asses the programming language world for the best teaching languages and pick out those which can be used for the courses and are easiest to use. They obviously do not do this and you can tell because they picked c++ (which is actually at least three languages to learn with the preprocessor macros and the functional programming language that is hidden in the template system)
- mrath 8y agoI love Rust and all my personal side projects are in Rust nowadays. But rust is definitely not close to the learning curve of golang and Java. In comparison with C++ I am not too sure.
- jefftk 8y ago> Go does not scale well What do you mean? I've seen huge services built in Go handling an enormous amount of traffic. (Disclosure: I work at Google, primarily in C++ and JS)
- mrath 8y agoI was not intending to say that there can't be huge code bases with go, but java, C# with the tooling, eco system, less verbose and a much better static type system scale much better. There is still some areas where golang doing great, like CLIs and infrastructure tools. I definitely understand its simile design but I would very unlikely going to use golang where I can use Java.
- cutler 8y agoJava/C# less verbose than Go? In which alternate reality?
- apta 8y agoMy current employer uses golang for the majority of their code base. Absolutely agree that Java would have been more concise. There’s almost nothing in golang that lends itself to writing shorter code. Error checking is verbose and dumb. Need to define interfaces just for the sake of mocking, even if they have a single implementor. No map/filter/takeWhile/etc. meaning a single or 2 line in Java ends up taking 5-10 lines and more, with helper functions littered throughout the code base, making code harder to follow and ending up with more code. Even a simple example like final var a = foo() ? bar() : baz(); Is several lines in golang, which doesn’t even have an analogy to ‘final’ var a int if foo() { a = bar() } else { a = baz() }
- mrath 8y agoI never thought that there will be a modern programming language that is more verbose than Java. But there you go, golang proved me wrong. and Java is getting less verbose with each release. The major pieces of verbosity in Java is auto-generated by IDE anyway.
- Matthias247 8y ago> Go does not scale well Are there any articles to back this up? I'm aware that the scheduler and networking integration are certainly opinionated. Nevertheless it seems to work very well for most applications that I have seen so far.
- mrath 8y agoI mean code base does not scale well, not performance. Performance of golang is top notch.
- Matthias247 8y agoHave you e.g. checked the Kubernetes codebase? It's pretty much huge. I would agree that at least the past iterations of Go dependency management might not have been ideal (but neither was it e.g. for C/C++), but that that apparently hasn't prevent people from building huge projects with it.
- apta 8y agoYou can have large code bases in assembly and C and python. Just because you can it doesn’t mean you should. Golang does not have any useful features for defining and navigating large code based. The way imports are handled is dumb and verbose. Seriously you can’t import a specific struct or function? Also other things like you have to import “strings” to use features like split and substring, instead of them being defined on the string struct itself, which makes code awkward. No string interpolation which is quite ridiculous. The list goes on.
- apta 8y agoWasn’t it Kubernetes that was notorious for having large amounts of code being auto generated and checked in because hey, no generics.
- 127 8y agoI don't really buy Rust learning curve. The good IDE integration and package management makes it all a breeze. VScode with RLS is great. I went from zero to fully shipped software inside a week, with meager C++ knowledge beforehand. Only trouble was understanding lifetimes and getting the borrow mechanics solidified in my spine. The entire set of language constructs is actually very small, there's just a couple of new unfamiliar concepts. Biggest downside compared to C++ is absolutely library support. Sorely missing many powerful C++ libraries.
- abernard1 8y agoPerformance. The JVM is an extremely fast platform given its feature set. It also has a coherent and powerful concurrency specification that is stable. While it is possible to have very low latency systems in Java, it requires a bit more work, and people tend to gravitate to C++ if the 3x penalty from C is too high. But aside from the latency, if you can deal with full GCs, Java is a data throughput monster. The default GC is actually very good in most cases, and the JVM GCs allow significant performance tuning, which is a discipline in its own right. It will be interesting if the low latency Z Garbage Collector introduced in JDK11 eventually removes one of the last complaints on Java performance.
- dwaite 8y agoJava has issues both with latency and memory usage due to the garbage collector and general age of the language (missing modern features like value types). Performance is.. complex. The lack of value types causes a lot more indirection, the hotspot compiler patches away some of it, the copy collector will compress connected objects together so that they will fit 'automagically' into CPU cache. Unoptimized Java code may often run faster than unoptimized C/C++ code, but Java gives you only vague, global flags for attempting to tune memory behavior and code generation. For monolithic Java applications, you can have a lot of different memory patterns internally (short term objects for the web stack, medium-term objects for transactional state, plus long-term objects representing accumulated state) which can really muck with the garbage collector's assumptions around generations. For server applications, this can cause things like heavy load causing request/response short-term state to be promoted to the mature generation. You start having to break up monolithic applications for performance reasons. But, that still is being a victim of your success - and you would be better off by default creating the first version of your application in a language that allows your developers to iterate quickly.
- hodgesrm 8y agoJava has a huge base of engineers familiar with it, great libraries, scales well, and has stable development tools. If it were not for some of the FUD around Oracle ownership I think at least some of the concerns about it would disappear. It's interesting to me that people don't seem to throw shade on C++ as much even though it's even older and in many ways harder to use effectively than Java.
- Gibbon1 8y ago> people don't seem to throw shade on C++ I hear my friends make dismayed noises about C++ any time they are forced to work on it. When I look at Java or C# code snippets I mostly feel like I understand what's going on. C++ makes me go wat?! far too often. Personal opinion I think Java would have a better rep if they'd optimized the GC for latency instead of speed. C# on the other hand would have a vastly better rep if it wasn't a Microsoft product.
- apta 8y agoThere are Java GCs that are optimized for latency. Check out project Shenandoah and ZGC for examples.
- Gibbon1 8y agoTo be a big fairer I had friends that worked at Azul Systems. One of them said that earlier versions of 0x86 processors didn't support the required atomic operations to implement guaranteed low latency GC. Also despite the marketing hype the main application for Java was server side. I wouldn't be surprised if GC latency issues weren't a problem in that space.
- mrath 8y agoJava is a very decent language even in comparison with other modern languages. And the amount of tooling, libraries are not matched by any other. It is easier to hire good Java developers. C# is the only other languages I can think which is as much capable as Java. I was hoping for golang but IMO it is not great for anything other than small command line apps.
- Macha 8y agoFaster than Python/Ruby. Safer than C/C++. Sun was seen as nicer than MS. No remaining languages had as many replacement developers once you ruled the previous ones out. Then add in two decades of entrenched software and network effects.
- RivieraKid 8y agoWhat's the alternative? I have experience with a lot of programming languages and recently decided to use Java on the server side of a side project. Java is fast, has amazing IDE support, large library ecosystem and it's a solid language. And yes, I stand behind the last claim, I don't understand why Java gets so much hate. Swift is the best-designed general purpose language I've used and it's not hugely better than Java. BTW, part of the decision to use Java was that I'm very familiar with it and wanted to get started fast, but now I'm having second thoughts. I guess Kotlin would be a good choice? And maybe Swift but not sure about library ecosystem on the server.
- m463 8y ago> I don't understand why Java gets so much hate. I remember when java first came out, I thought it would take over the world if they would "finish it". To me, this meant letting it run like other scripting languages: #!/usr/bin/java and let it do useful things everywhere in the os, but with wonderful OO. But instead of becoming a systems language, it sort of became a "nice cobol" that was mostly adopted to do business logic. I suspect the limitations imposed on it were to ensure portability and security, but it sort of polarized the people who would or would not adopt it. It was approachable to people who didn't think pointers were necessary (or some who couldn't do pointers), and repulsive to people who didn't want these constraints. I think over the 20 or so years that followed, the idea of what java is used for has stuck. I also think perl took up the slack on the systems side, with python. I wonder if java had been more of a systems language from the start, would it have been unsucessful? Or would it have displaced perl/python?
- RivieraKid 8y agoYeah I agree that it should be easy to run it like a scripting language... I just found out it's possible since Java 11, you can now run "java MyProgram.java" Now that I think about it, I can understand why people would dislike Java, the standard library kind of sucks, it lacked lambda functions before Java 8... and in general there seems to be lack of focus on usability and elegance, which also spreads to the ecosystem. Modern Java is not that bad though. But - Java offers a surprisingly unique package - it's fast, it has GC, static typing, good library and IDE availability, supports both OOP and functional programming (kind of). There's really only 1 competitor unless I'm missing something - C#. There's also Kotlin if that counts. Swift doesn't have GC and not sure if it's mature enough outside of the Apple ecosystem. Dart is slower.
- sidlls 8y agoEngineers with Java experience and enterprise development are more plentiful (less expensive) than with many other languages and ecosystems.
- slaymaker1907 8y agoJava, by nature of its moving GCs, can often do better with long running applications than languages like C and C++ which can much more easily suffer from internal memory fragmentation. You can work around it by using tricks like memory pools, using a sophisticated malloc implementation, etc., but that all is much higher effort than with Java. Additionally, a lot of the systems you mentioned can often benefit from the sophistacted dynamic classloader the JVM provides. For something like Spark (mentioning this one because I am familiar with it), it is a requirement to load and run user specified code dynamically. You can do this in C, but the JVM makes this much easier.
- sehugg 8y agoYes, it's really more about the GCs than the JIT. The yak-shaving involved in a performant C++ app is an order of magnitude higher. Plus, you get nice stack traces. Libraries like Netty make for extremely high-throughput apps.