Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: When should a web application use Java?
14 points by ejstronge on May 10, 2014 | hide | past | favorite | 21 comments
After seeing the Modern Java series I've grown curious: when is Java and its related framworks the best choice for a side project/small group endeavour?

Django/RoR or Flask/Sinatra have their niches - what are good reasons for a solo developer or small team to look outside Python, Ruby or PHP? Also, for those who are using Java, where do you host your application/service?




> Also, for those who are using Java, where do you host your application/service?

Heroku, EC2 (or Elastic Beanstalk) and Google AppEngine are all pretty good choices if you ask me. For side projects I usually just throw them up on Heroku, but I'll use EC2 for more sophisticated deployments.

> Django/RoR or Flask/Sinatra have their niches - what are good reasons for a solo developer or small team to look outside Python, Ruby or PHP?

I'm struggling to come up with an answer to this topic. To be honest, I think you'll be fine with whatever tool you choose and I think you should just use whatever is most comfortable for you. That said, some scenarios where it might make sense to use Java (or another JVM language) over Django/RoR include:

(1) This doesn't matter for most applications (and isn't necessarily true for all applications), but if you are expecting a lot of load you will likely get more throughput out of the JVM (see how the Java platforms compare to Ruby and Python ones in this benchmark: http://www.techempower.com/benchmarks/) and you will probably be able to handle more traffic with fewer machines (Twitter reportedly needs about ten times fewer machines to run its site after rewriting a bunch of Ruby services in Scala).

(2) You may need to use a particular JVM library (there's a lot of really good ones).

(3) Some spaces of the open-source ecosystem are largely written with JVM languages (especially in the data space: Hadoop, Mahout, Spark, etc). If your team is heavily dependent on one of those spaces you may choose the JVM for your web applications simply to focus your teams knowledge and tooling on one platform.


> (2) You may need to use a particular JVM library (there's a lot of really good ones).

I would love to hear some examples? It always appears to me that you could use JVM on the backend and have robust services that communicate with the front end layer (flask/tornado/whatever). However, I would be open to hearing something new.

> (3) Some spaces of the open-source ecosystem are largely written with JVM languages (especially in the data space: Hadoop, Mahout, Spark, etc). If your team is heavily dependent on one of those spaces you may choose the JVM for your applications simply to focus your teams knowledge on one platform.

From the data perspective, in all the places I have been, the data has been sliced up, processed, put through models and is available either as services or SQL databases. After that, there has never been a strong enough rationale not to use something else for the web server. I mean, from my understanding, you will end up having to write JS for the browser side of things. So you are no longer tooling on one platform any more, are you?


> (1) if you are expecting a lot of load you will likely get more throughput out of the JVM

This is true but not really a reason to move away from Ruby. We've found a really good medium between doing Rails on MRI and writing Rack services with JRuby and Torqubox when we need a lot of throughput.

>(2) You may need to use a particular JVM library (there's a lot of really good ones).

Honestly, this is more of a reason to stay on the Ruby/Rails side instead of the JVM side. In Rails there are libraries that can help you with anything dealing with web applications. I've been in the Java ecosystems: Play Framework, Spring, and Java EE(JSF), and I have never seen anything like the Rails ecosystem. It allows you to iterate much faster on a project. The JVM never really attracted me(on the web side) with it's libraries. We do however use JFreeChart which we use as a fallback to javascript charts, because it outputs an image really fast. For that Rack and JRuby are enough though.


I don't think, it is good idea to think about language and framework first than domain.

If it is prototype or just proof of concept then it is better to use good framework that helps to build quick prototype. May be Django or RoR is best choice if you already know it. But if you have some problem with exiting system like improve system performance or scalability issue then you could think about something else.

In the end, to me need to understand problem first then framework or language but not vice versa.


They're good for when you need heavy lifting and processing on the backend. It's great as an API, with a javascript front end.

The JVM ecosystem has amazing parallelism, and when tuned right has amazing speed and scales well. The distributed systems stack from hadoop et. al also has produced tooling for handling at scale operations for building services.

This is why facebook builds databases with it (presto) or twitter uses it for all of their services (mesos/scala).

The uberjar has also allowed for go like deployment schemes with everything in one package so it can play well with external services or using something like dropwizard.

Those mentioning RoR and the like as a middle man...if you're starting fresh, I'll pose the opposite question, if you aren't experienced in a particular language why have a middle man? It's great to keep your services modular, and if you already have an existing stack, yes rewrites are expensive.

Tooling wise, there's a lot of great support for hosting as well. Openshift, cloud foundry, and the usual suspects come to mind for java hosting.

That being said, use what you know.


> when is Java and its related framworks the best choice for a side project/small group endeavour?

If you want to use the project to learn a new language/framework, go ahead, but if you already know Java and you just want to get the project done, use it.

And while typing doesn't matter so much for many applications, static typing can save your ass as well as provide a guide for integrating with libraries. My experience with Django was good, but I found myself diving down into the source of both the core and of other "apps" in order to get the interactions right. With a java application, you almost never have to do this.

Generally, though, you should use the language/framework you know, as long as it isn't PHP.


Instead of spending your time bashing PHP, why not encourage people to write "PHP the right way"?

http://www.phptherightway.com/


I think the question should be what is it that you're trying to develop? Then we can answer why or why not a particular language or technology would be good or bad.


Java is much faster than any Python/Ruby/PHP stack and this is a reason alone. Javascript is similar or better but some people consider it unfit for large scale backend because of the language peculiarities with OO.


Ironic, considering the OO 'peculiarities' of Java...


Email me in a few weeks -- it looks as though I may be looking at different Java web frameworks for my employers. We recently did a project with Spring Boot and had a mixed experience.


PHP is a joke, you can't seriously ask that question in 2014 "why not PHP?". There are 100000s websites about why it is a bad choice beside performance and security, you can easily look that up.

Why not Ruby/Python though?

I think about these languages as developing something quick, a prototype, demo sort of things and internal tools for limited number of users (<100 000). The performance is good enough for this range, and Sinatra/Django gives you great tooling around building a small web application (regardless if it is a UI or just an API). The memory management of these languages (especially the libraries) are not great, so sooner or later you gonna hit a barrier (just like several companies did, Opscode, Twitter etc.) That is the time when you need to think about something else, or the TCO will consume your revenue and it is simply not profitable to run your service.

I am kind of surprised that you see Java at the top and nothing else. My experience is that Java, Erlang (and more recently probably Go) sits at the top, when you are talking about programming languages for implementing a web application.

But why?

Java as a language does not really matter much, same goes to Erlang and Go as well. The more important part is the VM and the libraries you need to use for building a webapp. JVM has outstanding single node performance, with libraries like Jetty (last time I measured it was doing 7500 req/s with ~30ms p99 latency on my MBP out of the box) that gives you a great toolkit to implement a web application with amazing performance. Almost the same with Erlang, I think it still needs more community and better libraries, especially for more UI heavy apps, but on the other hand, the p100 latency is equal to p99 and p50 because of the per "process" (Erlang process, not operating system one) garbage collection. There is no global VM lock.

So, to answer your question, when Java? When you need good single node performance, you are expecting 1M+ users and you need to scale up your application with reasonable TCO. If you are more adventurous you can play with Erlang (build the next WhatsApp) or Go (and get the great support from the community and nice libraries from Google).

Personally I am using Compojure a lot with Jetty, and learning React (actually the Clojure port of it called Om). This gives me a sweet spot in terms of maturity, quick prototyping, lots of immutability and access to the most comprehensive library collection of the planet (LDAP, JDBC, you name it). I usually host my own stuff on AWS and company stuff is hosted in our DCs.


[deleted]


node.js is probably the most fun.. if i "had to" write some crappy "web app", it'll most likely be in php. because it's fast, easy, whatever. if i want to have fun doing it, i'll make it in node.js.

what i won't do is tell you about all the crappy java toolkits i use on the weekends and tell you about how awesome comicon or whatever was this past year.


you are a joke


As a web newb, can you explain why the things in this comment are wrong and downvoted?


Don't worry about it, I got used to occasional trolling on HN. Basically if you are not talking about the newest hottest community approved thing or you have a slightly different opinion than the HN standard you get down voted. Making which programming language is the best for web applications sound like "node.js is the silver bullet of web apps, it also cures cancer and aids at the same time" is laughable. I enlisted several technical details why Java (besides Erlang and Go) is the best for scalable web applications while the other guy was just "java sucks node.js rocks". If I get down voted, it tells more about the people reading this site than anything else.


My advice is to treat downvotes as editorial feedback in regard to the quality of your writing.

Yes, down votes can express disagreement. More often they represent a misunderstanding - rewriting a post can fix this - or they represent a conflict with community guidelines/standards - rewriting can also fix this. Sometimes the best edits are deletions.

It's the tone, particularly the opening line that is likely to cause downvoting of your post. It's demeaning and PHP trolling and unsubstantiated, and therefore, poorly written for HN. The technical discussion which follows, though fine, can't fix it.

Good luck.


Thanks for the feedback. I still think that if you go the a cooking website and you suggest to people to eat mud you can't expect a serious discussion about the nutrition values in mud as meal. This is called common sense. You don't dry your kid in a microwave, you don't eat dirt, and in certain circles you don't use PHP. This is my opinion and I am not going to change it just because HN editorial stuff does not like it. Hope that help. :)


You use programming languages for the features they provide and the requirements they can accomplish. This is why I called you a joke. Most people can build anything in any language but requirements are what should dictate it.


[deleted]


Well last time I have checked this question was not a single dimensional, trivial, internet troll friendly, stupid problem. Your statement is either trolling (likely) or you have zero experience in the field this question is about.


Unless you're talking node.js, in which case you should disregard my last statement.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: