7 ms·
one reason why JS is so popular is because there are no standard lib. There would be no nodejs etc.
by z3t4 10y ago
one reason why JS is so popular is because there are no standard lib. There would be no nodejs etc.
- cocktailpeanuts 10y agonode.js was built from scratch, in C, to resemble javascript syntax intentionally.
- ryanolsonx 10y agoNo, it was not. It uses Chrome's JavaScript Engine, V8. From nodejs.org: > Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
- bobbytherobot 10y agoWhat? The engine is written in C, but all JavaScript engines are written in another language (C being the most popular) because it is an interpreted language. The engine isn't written from scratch because it is the V8 engine from Google. Of course the system binding and package system is written specifically for Node.
- paulddraper 10y agoC++, actually.
- jnbiche 10y agonode.js doesn't just resemble JavaScript, it is JavaScript. Like ES5 standard JavaScript, and (very soon) ES6 standard JS as well. It uses the V8 JS engine. The only non-standard features of Node.js has been the module system (CommonJS), but even that will be ECMA standard as of next version. (also, Node.js was built in C++ and JS)
- dcherman 10y agoThe module standard that is present in ES6 is a very different beast than CommonJS
- jnbiche 10y agoAgreed. I use ES6 modules regularly (via Babel compiled to CommonJS, and also Rollup). Unlike CommonJS, ES6 modules have the advantage (and disadvantage) of being statically resolved, which permits tree-shaking (but denies dynamic resolution of imports like CommonJS). The "that" in my sentence refers to "module system", not "CommonJS", but I agree my sentence was unclear.
- jnbiche 10y agoMore specifically: in the next major Node.js release (v7.0.0), ES6 modules will be implemented. That's what I was trying to say.
- kpil 10y agoIt's popular because it's in the browser. Everything else is just Stockholm-syndrome. Nodejs strikes me as an unfortunate consequence of having js in the browser and a drive for reducing the complexity by having the same language on the server.
- z3t4 10y agoExample of use outside browsers: Windows and OS X scripting, classic ASP, Pebble watch, MongoDB database, Adobe Photoshop PDF et al, LibreOffice, Unity game engine, Qt, GNOME Shell, Ubuntu Touch, Chromebooks. ref: https://en.wikipedia.org/wiki/JavaScript https://en.wikipedia.org/wiki/JavaScript I used JavaScript as a web developer for 15 years, but did not like it. It wasn't until I started with NodeJS three years ago I learned JavaScript in depth. It's when you grok closures, events/async/concurrency, prototype, objects, and commonJS modules it starts to get fun. There where a lot of headache going from serial programming to parallel programming like the pyramid of doom, Christmas tree from hell etc, until I learned to manage it. When CPU's get more cores instead of getting much faster, concurrency is the way to go, and it fits JavaScript well. You should have raised an eyebrow or two reading this, as JavaScript is "single threaded". That just makes things more simple though, if you know how to write event based code, like handling clicks on a web page, you already know how to write distributed systems and can scale beyond a single CPU or server.
- kpil 10y agoI argue that the reason it's used outside browsers is primarily that a generation of programmers learned it first - IN a browser. As a language, it has more warts and less features than many other languages, but it also is unimposing and does not get in your way. It could have been much better though.
- z3t4 10y agoMicrosoft tried to make vbScript an alternative to JavaScript. vbScript is a good language, but JavaScript is better. For example, how to make a custom object in vbScript: Class foo Private barval Public Property Get bar() bar = barval End Property Public Property Let bar(b) barval = b End Property Private Sub Class_Initialize( ) barval = 1 End Sub End Class To make an object in JavaScript: foo = {bar: 1}; Before NodeJS existed, most people, including myself thought that JavaScript is a stupid language only used in browsers. I was also aware of NodeJS for at least two years before I finally tried it. I thought it was stupid why the hell would you want to code JavaScript outside the browser I thought. After maybe one year of learning, walking through the swamps, I finally saw the light. The most revolutionary I think is the module system in NodeJS, it's what makes writing huge programs in JavaScript manageable. Because of this many JavaScript programs now a days comes with thousands LOC tested and hardened in production, while the actual code you write and maintain yourself is only like one hundred LOC. I think the NodeJS module system is maybe hundred years ahead of its time, it's right in front of us, but few people seem to notice. And in the direction we are heading now it will soon be forgotten (ES6 import). People use NodeJS modules like imports and couples the code instead of decouple. Sure it works fine for a while, but sooner or later the project will grind to an halt because of code complexity.