Node.js and MongoDB Turning JavaScript Into a Full-Stack Language
Nerval's Lobster writes "For all its warts and headaches, JavaScript has emerged as the lingua franca of the modern Web, arguably second in adoption only to HTML itself, which obviously is just a markup standard rather than a full-fledged programming language. It's effectively impossible to launch a sophisticated Web project without making extensive use of JavaScript and AJAX dynamic loading. That's precisely why recent projects that move JavaScript beyond its usual boring domain of defining in-browser interactivity are so interesting — because it's already dominant, and growing even more so. Writer and software developer Vijith Assar argues that Node.js and MongoDB are turning JavaScript into a full-stack language. 'In the grand scheme, Node and Mongo are still quite new; for the most part, ace JavaScript developers who can write brilliant code on both sides of the request transaction have yet to emerge,' he suggests. 'But if and when they do, the things they build could be jaw-dropping.'"
In the grand scheme, Node and Mongo are still quite new; for the most part, ace JavaScript developers who can write brilliant code on both sides of the request transaction have yet to emerge, but if and when they do, the things they build could be jaw-dropping.
Can any real developer explain why having a javascript backend would be any different to any other backend in such a way where something jaw-dropping could only be the result of the javascript backend?
No, it's fanboy hyperbole.
So instead of having one portion of my stack vulnerable to hundreds of exploits, now I can have the ENTIRE stack vulnerable to hundreds of exploits. Sign me up!
sudo make me a sandwich
I wouldn't necessarily pick Javascript on its merits as a language, but for a language as dynamic as it is, it has very good optimizing compilers, probably research state-of-the-art for this kind of language (Google's V8 engine is largely built by ex-Smalltalk researchers). That gives it some advantages over, say, Python.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
Javascript isn't really a very good programming language (its lack of strong typing and lack of pointers are two things that often frustrate experienced coders). The only reason it's so popular is that it is a universal standard for client-side scripting in the browser. If you want to run code on the user's web browser, you have to use Javascript.
On servers, that doesn't apply. There are much better languages, no matter which platform you prefer. And MongoDB isn't particularly impressive, either; it's basically a database for people too stupid to understand SQL.
ace JavaScript developers who can write brilliant code
There are so many things wrong with that statement, my brain hurts trying to figure out where to begin
So many good JVM based languages (Scala, Closure, JRuby).
I wonder if anyone ever thought of letting a JVM run in a browser and use those for the full stack as a replacement for javascript.
(Edit: yes, I've heard of java applets before)
Oh, God no!
JavaScript has turned the web into a thick client medium.
I tried recently to use NoScript and I ended up having to turn it off for every damn website that I visit in order to just use it. I couldn't even log into my credit union or broker without it!
JavaScript has turned the web into bloatware. And all it does is make pages more cluttered, harder to use, longer to load, pages frequently lock up my browser, takes up bandwidth, etc .... JavaScript is a tool for crap. It is for advertising. It's funny, not wasn't I able to login to my credit union with NoScript, but all the ads/promotions/(shit I don't care about) didn't work.
I think I'll start a new metric or new law - the AC law:
A website's quality is inversely proportional to the amount of JavaScript.
Case in point: Google. No scripts there but immensely valuable.
Worthless Social media websites: loaded with the crap.
The real thing that's turning javascript into the lingua franca of the web are really three things:
It's an inside-out stack.
It takes a man to suffer ignorance and smile
Be yourself no matter what they say
You're very clever, young man, very clever... but it's turkeys all the way down.
Dark Reflection
I couldn't even log into my credit union or broker without it!
Financial web applications probably use JavaScript to store a cookie that verifies that this browser has previously been used to access this account. This makes the browser the second factor in a two-factor authentication system.
And all it does is make pages more cluttered
Not always. JavaScript lets a web page hide a particular element until the user expresses interest in viewing it by clicking it.
harder to use
With JavaScript, a user can (for instance) click to expand help for a particular field of a form without having to navigate away from the form.
longer to load
Without JavaScript, the only way to expand or collapse an element in a document, such as an element in a tree or an aside that has been hidden, is to follow a link or submit a form that results in sending the whole page back. This whole page takes long to load.
takes up bandwidth
Updating only what has changed on a page takes up less bandwidth than having to send the whole page all over again.
Google. No scripts there but immensely valuable.
If Google Search doesn't use JavaScript, how do the Suggest (drop-down completion box below text input) and Instant (replacement when the user pauses typing) features of Google Search work? Besides, Google also produces Gmail, Google Docs, and YouTube, which use plenty of JavaScript.
Basically, they're saying JavaScript could be used at the OS level, the database level, and the presentation level.
Dark Reflection
Sharing a single code base between client and server is a huge benefit for any application. Nobody likes to write things twice.
Pretty good is actually pretty bad.
Sometimes "a much better development team" is a larger and therefore costlier development team.
Besides, sometimes I want the code on the client and the server to do the same thing, and the easiest way to do that is to run the same code. (See Don't repeat yourself and Once and only once.) Say I want to validate input on the client for speed and offline capability and then revalidate it on the server for security. With a common language, I can reuse the same validation functions on the client and server. Without a common language, what's the standard practice to formally verify the equivalence of the client-side and server-side input validation code?
and recovering from an exception in node-js is next to impossible. You really have little choice but to reboot the instance.
If you post it, they will read.
This seems to happen every time someone confuses a language with an environment and/or implementation and/or API.
Ca. 1998-2000, I was writing these things in JavaScript:
*Web browser DOM stuff aka "Dynamic HTML"
*Server-side ASP and NS-SSJS (Remember Netscape? They used to do servers, too...)
*System apps using ScriptEase/JS on *nix and COM/ActiveWhatever/JS on Windows
*Interaction in PDFs and SVG docs
*Extensions for Macromedia (now Adobe) DreamWeaver
*Extensions for Mozilla
We didn't have Ajax or Canvas in those days. We also didn't have smartphones or Justin Bieber.
But we still used JavaScript in lots of places, we still made phone calls, and we still changed the channel or hit the Mute button when MTV started playing crap.
Il n'y a pas de Planet B.
Wake me up when this is over.
none
completely hide the separation between client and server
Won't work. The separation between remote and local is fundamental because you've got a whole world of additional failure modes when you go remote. You can code client and server in different languages or the same language (hey, it's been tried before with C++ and Java and C# and VB and many others) but the real issue is that you just can't hide the fact that more things can go wrong. The network can go away. Someone can try to hack things (for profit or for lulz). Traffic levels can suddenly spike massively in ways you didn't anticipate. Lots of ways to fail. Pretending that there's no client/server separation just makes the fail much harder.
I advise writing the client and server in different languages because that helps you be sure that you've not made the interface between them language-specific (and so hard to reuse). It's not a strong recommendation — if you want to do both sides in the same language it will work — but keeping the separation clean is definitely a good idea.
"Little does he know, but there is no 'I' in 'Idiot'!"
In the web development world a stack is the combination of webserver, database and programming language, so you have the well known LAMP stack (Linux, Apache, MySQL and PHP) and the Java stack (Tomcat [for example], Oracle [for example] and Java) and the Microsoft stack (Windows, IIS, SQL Server and C#). Now you also have the JavaScript stack (Node.js [with build in webserver] and MongoDB).
Me
>>But if you're going to pick a single language to be used by everyone for all purposes, then why pick something kludgy like JavaScript?
>Because it is the only language that is universally supported in browsers. Would be nice were that not the case, but it is the fact that we have to live with.
"Because it is the only language for which there are claims of universal support in browsers."
FTFY
JavaScript is a shit language: Fuck off.
Wow, good argument. BTW, my office mate was at Netscape when Javascript was created. The author of Javascript has since apologized for creating Javascript. In his defense, it was only ever intended to run one line bits of logic inside of a web page. Ideas like functions actually had to be added later as the idea of using Javascript for a general purpose language came after the language was designed, not before. See how this leads to problems?
Javascript isn't and shouldn't be used as a general purpose language, EVER! It has uses but very few in general and they probably all have to do with browsers and DOMs.
JavaScript is not strongly-typed: Since when did strongly-typed languages become "better"?
Um, since math has existed? Compilers double as automated code error checkers. Or maybe you like checking your code's syntax by hand?
JavaScript is insecure: You're doing it wrong.
Javascript forces clients to execute general logic. This is a security issue no matter what. I'm sure you have some solution to this issue, but I assure you that there are ways around your solution (and anyone else's solution).
Node.js is single-threaded: OK, were you planning on serving clients with a single server instance/process?
Javascript is single threaded, this is OK for writing web apps, sometimes. But not always and its a huge hole in a general purpose language.
A single language client- and server-side offers little to no benefits: Yeah, you're right. Why would I want to a single test suite for my client- and server-side code? Why would I want to (securely) share model definitions between the client- and server-side? Why would I want to optimise one code-base instead of two? Why would I want to debug one language instead of two?
You finally make a good point. +1 for you.
MongoDB is for people who can't/won't learn SQL/the relational model: I'll admit that SQL is not my area of expertise, but my naive understanding is this: in SQL databases, you normalise your data by default until you hit performance issues. In NoSQL databases, you denormalise it by default. The decision on which one to use should depend entirely on the data you want to store.
Take it from me, you know NOTHING about data persistence no matter how much you think you do. Relational Algebra is the basic math governing manipulating, querying and storing data as tuples. It governs MongoDB (and other NoSQL tools) too, just that the authors of those systems basically lopped off all the hard parts of the relational algebra and implemented just the easy bits. And they did those parts quite poorly when compared to traditional RDBMSes.
NoSQL was an attempt to re-invent a very complex wheel that 1) already worked, and 2) the often didn't let you do things that were bad ideas (even if you didn't realize they were bad ideas at the time). SQL isn't perfect, but more people know it than HTML and Javascript combined. And the systems that implement SQL have reputations (and a history) of not losing data (well, as long as the hardware works) and allowing very large datasets to be queried. And before someone says something dumb like "Web Scale", Sharded DBs store and query some very large datasets. Only when you have datasets the size of google's do you have to implement your own. And they made BigTable so fast by not implementing things that DBs need but they didn't (like data consistency and joins). It might be nice for a RDBMS to allow you to choose to not use table locks or do other things to make these trade-offs. But RDBMSes evolved in a world where throwing hardware at problems was always a valid strategy and it probably still is and will be into the foreseeabl
"Those that start by burning books, will end by burning men."
No, let's keep advancing JavaScript.
Let's compare
* find web site promoting some application
* go to download link
* find it's not available for Mac/Linux/your phone/Windows XP
* or it is, but you need to download a different Qt/GTK/SDL/DotNet/JDK runtime
* but that's not available for your machine, or it's 32-bit not 64-bit
* now download, save, run installer, wait for virus checker
* now finally run the bloody thing
* (Windows-only) wonder why there's another task running, it's the %^$#! Check for updates service
* A week later. Yay, there's an update. Repeat all these steps.
vs.
* find web site promoting some application
* click link
* you're running today's build. It just works.
You have to be a clueless, blind, future-fearing Luddite, yet simultaneously have the skills to master the download-find-install-run-maintain loop to find the former preferable. The 0.1% of the world population who fit that niche all hang out on Slashdot and vote up "bloated browser" comments.
=S
Mongo's console is a javascript interpreter. The folks at 10gen seem to have been the first (only?) modern NoSQL development group to have the blindingly obvious realization that javascript would be the ideal interpreter language for their database. The rest has been history....