Does it make sense to choose JavaScript instead of Java for server-side programming and why? For an experienced Java engineer. What is so special about JavaScript?
-
There is an opinion, that JavaScript, being initially created for the client-side, gradually became a popular choice for server-side too, because front-end developers decided to use the same language for coding on back-end, since it didn't require learning new languages. If it is right, does it make sense to choose JavaScript, if a person is proficient in Java?
-
Answer:
No, there is no technical advantage in choosing JavaScript over the JVM. Quite the reverse. The "one less language to learn" argument is very weak. Any competent developer will learn 6, 10 or more languages in their career. They do this because they are seeking better tools for the job, depending on the objective. On the server, JavaScript is not a technically better tool than the existing tools. It is also not a particularly helpful language for complex backend implementations. Indeed, it has drawbacks for front-end coding too, which helps explain this profusion: http://altjs.org/
Toby Thain at Quora Visit the source
Other answers
If you are an experienced Java programer and you feel confortable with Java I would say to you to use Java for your Back-End. Learn NodeJS on the side, it may be useful for some realtime application (you can use Play for that in Java). On the other hand I could not recommend more for a Client-side programer to learn NodeJS. It is powerful and familiar.
Mariz Melo
JavaScript is a horrid language.Writing in JavaScript is like scratching your nose by wrapping your right hand behind your head, over your left ear, to reach your nose.A better and more definitive browser language needs to be defined.Iâve written elsewhere, so Iâm repeating - JavaScript is a terror, is a terrorist. JavaScript is Daesh - a terrorising parasite that is in nobodyâs interest to get rid of.When corporations, organisation, and whatnots have invested so much into their respective JavaScript frameworks, where the results of such heavily invested/infested efforts become barriers against competitors - why would you want to invest any resources and effort to get rid of JavaScript, and to lose all these protective competitive advantage?People, engineers, programmers are trying to get rid of JavaScript and be replaced by something more sensible (like python maybe, or groovy) but are hindered by the said Daesh-preservation political phenomena.Anyone who is trying to propagate the use of JavaScript when most people are trying to get rid of it from its existing lairs, they are outa their screws. These people are trying to scale Mt Everest, and then deliberately illogically increase their burden by carrying a bag of rocks with them, to prove their macho mettle.Server-side JavaScript is âso popularâ. âSo popularâ is a subjective, Kim-Jong-Il-esque hyperbole.
Cynthia Avishegnath
So someone invented NodeJS and now suddenly JS is better than Java for backend? Really? How many years ago did the first Java web server come around? Do you really think NodeJS is all of a sudden better than Tomcat, Jetty and the rest? NodeJS is asynchronous, and benchmarked against old-school implementations of web servers in Java, itâs obviously better. Run it against async Glassfish, for loveâs sake.Oh, and JavaScript is a shambles of a language.
Vladimir Iliev
This answer is very simple.There are few main reasons to choose Server-Side JavaScript over anything else: It is lighter compared to Java (which is humongous with its standard library), therefore it could scale better in much more ways, than by just adding extra resources. This makes it easier for embedding, so a lot of tools use embedded javascript (lets not focus on Node.js only). It is easier to be used, without a lot of the security restrictions and isolation applied by Java (which as we see are not really working well) It has an easier entrance level for programming, so it is easier to find or teach programmers to use it. It is not structured language (as Java) so the amount of code lines necessary to achieve a certain goal are much less. Modern front end applications uses a lot of JavaScript (HTML5). It is easier to do the backend in JavaScript then, because: you can share the same programming resources, you can exchange data natively, you write lot less code and a lot of the code is shared, which simplifies the maintenance So this makes the programming community excited, because we could probably achieve more, by writing less code. Therefore the development in the JavaScript world is very active, and it produces a lot of advantages and disadvantages - Advantage - the modern JavaScript VMs are extremely light and fast, and they are optimized constantly. JavaScript for many tasks is faster than Java, but it is also generally lighter. That means that a thread (JS does not have threads in its standard library, but many implementations exists, like the Workers in HTML5) and instance is much lighter compared to Java. This is partially achieved by the fact that JavaScript does not have a heavy standard library (actually, one could say - no standard library at all) Disadvantage - no standard library (excluding HTML5 which acts a bit like a standard library), so every environment is different. Somewhere you may have threads, somewhere you are supposed to use functional programming, somewhere event based programming with call backs, etc. So the variety is higher, for good and bad. For many traditional programmers, this is bad, as it is hard so sell your knowledge in the programming language :) Imagine if you do a modern project with advanced UI interface.You could chose to design it traditionally using MySQL as storage, Java for backend business logic, JavaScript for UI. But to maintain and support it, you will need resources with knowledge in SQL, Java (+ a lot of libraries) and HTML+JavaScript.If you decide to go for all JavaScript you can choose to use MongoDB for backend (it has a JavaScript interface and stores JSon natively), JavaScript (like Node.JS) for backend business logic and JavaScript for front end. Much more focused approach. Of course, you may need different styles of programming for every element, but the advantages are many. Including that, if you have a smart design, you can make the middleware (Node.js) extremely light, up to almost no code there (to be used many for authentication and authorization).We could talk a lot about advantages or disadvantages of one or another programming style, one or another framework, one or another language, one or another tools.But the main reasons why most of the projects choosing to use JavaScript end-to-end are already mentioned. Lighter, less code and easier for maintenance.
Delian Delchev
What are the disadvantages of using JavaScript on the server side? What are the advantages of using one language for your whole app? Answer these questions and you'll get your answer.
Alexandro Chen
Java is neither a full OOP language (I don't mean lack of multiple inheritance. Rather I'm speaking of lack of extending instantiated objects, nor having non-objects called "primitives") nor is it strongly typed (it is statically typed - very very different.) Java makes composability difficult and hiding even more difficult. I'm sure most "security experts" will disagree about this, but ask yourself this - can you enforce beyond all doubt that a library you are using hasn't exposed "static" fields that can't be exploited?JavaScript wins for me personally just purely on the containment. I can absolutely certainly ensure that any arbitrary piece of crap that is given to me by others can be wrapped inside a closure no matter how badly it chooses to behave. I can prevent it from seeing other libraries too.Basically objects are about containment and encapsulation. In a server, more so.Javascript will easily load 10 versions of the same library for different non interacting components. Java can't do that - you'll face namespace conflicts. Which you'll fight with custom class loaders. Besides having first class functions is just so sweet.Add in the new ecmascript 6 stuff like pattern matching and object deconstruction, and I'm sold.
Archis Gore
Javascript on the server at the moment means Node.JS ( and Dart as someone else answered in this question ). Why choose Javascript / NodeJS? Here's an answer from a previous question:
Bresson Nemesis
You have advantages: Faster serialization. Also, common libraries can be created for models and validation.But there are disadvantages: Maintaining large codebases takes a greater level of discipline. Patterns and refactoring take more deliberate effort. It is a lot easier to stray away from design patterns because there just isn't a great way to enforce them in javascript.That being said, for smaller, experienced teams js on the server is viable.
Thomas Johnston
Right now, the only somewhat mature solutions around for JS are Node and Dart; Node being the most popular one. Though it is new, the community is expanding very rapidly. Node has some very nice advantages. If you want something that will scale insanely, you should definitely go for Node. It isn't suitable for pages with a very long life-cycle though. Another major advantage would be that some of the codebase will be common on the server as well as the client.
Ameya Karve
Related Q & A:
- Does it ever make sense to use RAM Disk to force RAM allocation for tempdb with SQL Server 2008?Best solution by Database Administrators
- What risks do I have to consider when encrypting server side as opposed to client-side?Best solution by Information Security
- What is the best way to make UI for an Isometric game in Java?Best solution by Game Development
- How to pass a javascript object back to the server?Best solution by developer.mozilla.org
- What's so special about being a Yahoo contributor?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.