My latest anti-java rant

I’m not really part of the “older” generation of programmers, but when I was a teenager I experienced the personal computer boom first-hand. I remember the days of 4.7 Mhz computers doing incredibly wonderful things on 8-bit and 16-bit architectures with crappy video chipsets and very low memory. I majored in college in Computer Science and programmed a bunch of C code on DOS and Amiga computers. I used to download 3k demos written in assembly code over my 2400 baud modem.
I grew up with crappy technology; slow networking and crappy computers with very low resources … but the programs were good! Editors were fast and very capable. Games were plentiful and action-packed. Email flowed. The web was young, no javascript, no flash, but it worked and we jumped around on the net from site to site and made our own web pages and linked them together.
Today, a single machine has many gigabytes of ram, terabytes of hard drive space and 8 cores of 3.0 GHz processing power. If people still programmed like they did 20 years ago, you could run an entire company on a single computer and the machine would be mostly idle. But how come people don’t run whole projects on single machines? How come we still need hundreds of these computers to host a website that’s just a glorified search engine for a few million products?
The problem is the programming languages and laziness. Personally, I blame java. Java is a language that has tons of functionality built-in. Java has security, error and trap handling, tons of libraries, easy code reuse, etc … You may say, hay, wait a minute, those are all great things! What’s wrong with java? My main gripe is that java is bloated. It’s not as slow as it used to be, but it’s still pretty un-optimized. It doesn’t run “close to the metal” like C and assembly does. It virtualizes almost all data representation internally so whenever you access your data, there’s an wrapper that you have to go through. All of this gives you certain advantages if you’re a programmer. You can program on any platform and deploy on another platform. You can write an app quickly and don’t have to worry about security or some of the things that a C or assembly programmer may have to worry about. You pay a price in performance and resource consumption for these extras. C and assembly programmers look at languages like java and see a language that is bloated and full of things that are not necessary. Any C or assembly programmer looks at a bloated java program and says to themselves, “I could rewrite that in C and it' would be 1000 times faster”. C programmers look at java programmers and think they’re lazy. Why use a bloated language like java that gives you free exception handling when I can just check for return codes and handle them myself and get much better performance? Why use a language like java where you don’t need to allocate and free memory when I can just allocate and free my own memory then I don’t have to deal with the overhead of a garbage collector that takes CPU cycles. If I’m not lazy about my programming practices I can use a language like C or assembly and my program will run mega-fast and use only as much memory as is needed!!!
I’ve started to notice recently that other languages (ruby, erlang, …) are exhibiting similar traits to java. These languages are used to do rapid prototyping (and are great for that) but when you move your code into production, the language isn’t very efficient and doesn’t scale well, so programmers tell their sysadmin to just throw more hardware at the problem. As a sysadmin, this screams to me “I’m a lazy programmer and use an inefficient language to write my code in. I’m not willing to write it in a more efficient language, so I need you to work hard and build and maintain hundreds of computers so my app will scale”. I go about my work and deploy the machines, but in the back of my head I’m telling myself, I could re-write that code in C and it’d be awesome and it would run on a single machine and wouldn’t need much of an infrastructure at all. I could buy a second machine as a backup and just have it sit there in case something happened to the first machine. The whole platform would run on two machines and could ROCK!!!
I think that the newer generation of programmers might not know that their code is bloated and that it’s even possible to write in a different language that would offer better performance. Maybe they just don’t even consider writing it in a language other than java. It’s the defacto-standard nowadays in the startup and web-app world. But should it be? All operating systems are written in C and optimized down to assembly when necessary. Why? The operating system should take as little resources and be as quick as possible. It shouldn’t crash and it should be stable and reliable. Why aren’t operating systems written in Java? Exactly!
Write your damn web apps in C! Save money! Keep your sysadmins from having to maintain whole datacenters full of hardware just to run something simple that should be able to run on a single machine! Companies used to run fine and process tons of data 20 years ago before the invention of java and when we had crappy computers! Don’t be lazy! Invest some time and effort in your code and save us all some money and headaches.
- Steve's blog
- Login or register to post comments
- 5164 reads

Comments
Respectfully, performance is
Respectfully, performance is an inherently good thing. But there are some thing worth sacrificing a little performance for. (I'm not defending Java, but I am a Ruby fan boy.) In languages like Ruby, you spend 90% of your time thinking up cool ideas, and thinking of the wisest, most intelligent, and most elegant ways of implementing them. Then you spend 10% of your time doing the actual implementation and bug-fixing. But in C, you spend 10% of your time thinking up an idea, and then 90% on implementation.
In languages like Ruby, you can implement the most complicated data structure you've ever thought of in 5 lines. In C, you spend hours trying to get the simplest data structure ideas across to your compiler.
Some of us are glad to give up C and 'low-level' programming, not because we are lazy, but because we are frustrated. Thanks to languages like Ruby, programming is finally becoming an creative art, not a chore.
Also, Ruby (and a lot of other languages) lets you use C for back-end functionality, which lets you get hard-core performance gains in those few cases where it is really important.
I've always been anti Java
I've always been anti Java since at least 2001 when they tried to make me take a java class in school for computer information systems. I dislike the language it slows down the browser and there is nothing javascript jquery or ajax can't do which all run a lot faster. The web hosting i use finally got rid of it.
First, full disclosure - I
First, full disclosure - I write mostly in java and php at my day job.
However, I am inclined to agree with you.
We run lots of servers for our webapps. Most of the apps see pretty low traffic (<10K hist per day). But we have lots of apps. So the traffic piles up and all our "little" apps end up bogging down our servers.
There are some quick ways to boost performance (caching, connection pooling, etc...) but that will only get you so far. You can work around the issue all you like but to truly solve the root problem you need to go low-level. Think about it: why are people so crazy about nginx? It aint because nginx makes web dev so much easier.
People love high-level languages because they are more productive. We get that C is going to be more efficient and faster, but currently it is not worth the time needed to properly write a webapp in C.
I think most devs prefer a more academic / purist approach but we just aren't afforded the time. Also, as high-level languages get faster there is even more pressure on devs to just do it quick and dirty. It is a sad thing indeed.
Personally, the ability to
Personally, the ability to drop down into C is part of the reason I feel Python is such a good language. That said I've never actually had to do it. The reason is because the bottleneck is rarely the language, but the IO.
The IO is usually related to one of two things, 1) the database(s) and/or 2) the network. In my own situations, the databases are always written in C or C++, with the network sometimes being a remote service that is out of my own control in terms of resources.
As I said before, I think having C as an optimization option is helpful, but in practice I've found it is not the language that is the bottleneck in terms of performance.
Points for knocking on java,
Points for knocking on java, though I think you're doing it for the wrong reasons. You may not consider yourself part of the older generation, but your "write it in C, damnit!" attitude is. I have a couple of points:
1) As far as languages go, java's not that slow at all (bloated, yes. But not that slow). If you have java apps that require that much more computing power than your own C equivalents (Do you? Have you written them and tested your assumptions? Otherwise, how would you know?), Then I suspect your main problem is programmer incompetence. It's a widespread issue. Replacing an entire data center with just a single machine is simply ridiculous, and if that's possible than java isn't the only thing wrong with your code.
2) Programmer time is expensive. Very expensive. (see http://www.codinghorror.com/blog/2008/12/hardware-is-cheap-programmers-a... ). languages that increase productivity can save you a lot of money at the cost of relatively little (if you do it right) performance. More importantly:
3) for 99% of code, performance is mostly irrelevant. Even a 100% savings on java code that runs in 1ms only saves you a millisecond. Or, in case of I/O bound code, Amdahl's law bounds your savings to a few percent. In many cases, Loops are worth micro-optimizing, but other than that your savings will usually be very small anyway.
By all means, write the most performance-critical parts of your application in C/assembly, _after_ you've determined that this would save you enough time/money to be worth it. But the other 99% of your code can be python/ruby/whatever (java, if you must), which saves you hundreds of thousands of dollars in development time at very little cost. The performance simply doesn't matter.
Sure, java isn't always the right language choice, far from it. But C/Assembly is only rarely actually necessary (how many programmers are really writing the code that needs to, for example, serve millions of page requests a day?). This post lacks nuance. But then again, rants tend to do that.
Incidentally, I am also one
Incidentally, I am also one of the kids of the personal computer boom. Used to program a *lot* in assembly back in the day, first 6502, then 680x0 on the Amiga. Mostly demos, some small games, etc. These days I'm a professional software developer (Mostly Java, JavaScript, some python).
Back in those days, I might have agreed with you, but I would have been just as wrong in the big picture ;)
First of all, the apps today are nothing like the applications were back then. They just do a lot more stuff, have to integrate a lot more technologies. People expect a mouse driven interface these day, they want a WIMP interface etc. The programs work with much more data etc.
Don't get me wrong, it would be really interesting to see what modern software you could written with terminal clients, we are just never going to find out, because no one wants such software anymore, so no one is going to pay for it.
Our clients want modern applications with all bells and whistles and they want it cheap, which means developed in as few hours as possible.
One new server costs as much as 2 or 3 days of development for a single person.
The difference between Java and C is also not a 1000 times, but rather something like 1.6 ( http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=all ). Malloc and free take CPU cycles, too.
It's difficult to compare one
It's difficult to compare one java app to another app written in C mainly because people don't code the same exact app in two languages except for the occasional benchmark tests or 'hello world'.
What I see in the workplace is, "I need to write this app in java that serves-up jpgs from a key/value database. I'll need 6x 3GHz quad-core, dual-CPU machines with 8GB of memory each". Are you f-ing kidding me? This is basically Apache on top of a file system. Don't tell me that you need that kind of hardware to run the equivalent of existing technologies that are available in C that can run on a single machine.
Applications with mouse-driven interfaces, integrating with different technologies, and what you mentioned above are all very do-able with C. Look at your common desktop app. 95% of them are all written in C or C++, not java.
One new server costs $1500 nowadays, but there is a cost for maintenance, datacenter space, A/C and power for that machine too. Trust me, it adds up fast. It's not uncommon for a single java web app to take up *racks* of machines (not just one extra), so we're now talking about tens of thousands of dollars up-front (that's a programmer's salary for 4-6 months) and thousands of dollars of monthly costs (add one programmer's monthly salary - so one FTE reoccurring.
There are C libraries to do security, web parsing, regex's, error parsing, etc ... It's not difficult to write a feature-rich app in C and it's not slow to develop either. Just don't be lazy. Convince yourself that you'll live if you have to use malloc() and free() and might have to bring up a debugger once in a while and you'll be surprised at the result, I guarantee!
This is a great post! You
This is a great post! You need to submit it to HN and watch the backlash :)
I got tons of comments, but
I got tons of comments, but mostly dissing my hate of java. I'm guessing that they're all java people defending their language choice. It's possible that not many C or C++ programmers read HN. :)
I responded to most of them in-line on the HN page. I still am strongly convinced that my point of view has a ton of merit and the responders were just defending their language choice whether it is valid or not in the context of my original article.
Done:
Done: http://news.ycombinator.com/item?id=1207494