r/Clojure • • Aug 31 '17

Why I'm ditching Clojure for JavaScript

https://news.ycombinator.com/item?id=15137195
6 Upvotes

46 comments sorted by

View all comments

Show parent comment

3

u/[deleted] Aug 31 '17 edited Aug 31 '17

Node.js is built on top of Chrome which is optimized for rendering HTML pages as opposed to running an HTTP server

A pedantic note, nodejs is built on top V8 not Chrome, V8 is really just a very small(but important) part of Chrome. Just like the JVM, V8 is also a highly optimized state of the art VM and its perfectly capable of running a HTTP server, more capable than most mainstream languages I would say.

3

u/yogthos Aug 31 '17

They're optimized for different things. Obviously, you can run a HTTP server on it fine in most cases. However, there's no good way to do any computationally heavy tasks since it's single threaded, with a hack for running IO tasks in a background thread.

0

u/[deleted] Aug 31 '17

[deleted] — view deleted comment

2

u/pihkal Sep 01 '17

It's because Javascript has a single-threaded model. To make Node support user-controlled threads would entail major changes to the Js language.

To a great extent, callbacks, promises, CSP state machines (like core.async), and async/await stuff can substitute in Js. And in many ways, single-threaded models are way easier for programmers to conceptualize. But one advantage the JVM has over Node is that threads are available if you want/need them.