by medeas_crypt · 10y ago · 0 comments
Edit: I can understand shipping logic from the server to client, for validation perhaps. But... meh.
* 40% UI (visualising states, handling user input, feedback, etc),
* 55% moving data around (read an XML file, translate it, push it into db over there)
* 5% algorithmic work (given input of x million records, figure y out)
The UI stuff I already did in Javascript, however it turns out that one single threaded process can shuffle a lot of data around (resource efficiently), if I adopt an async programming style. I know NodeJS is not the only language that does async stuff nicely, but it's rather convenient to have the same language everywhere (though I recognise Javascript is not the most elegant).Perl, Java, Spring, Ruby on Rails each offered significant benefits over what existed before. What does JavaScript on the server side do better than other solutions? There's the event loop and non-blocking behaviour but is that enough for most applications to justify using JavaScript on the server side?
1) It makes no difference at all if is the server is implemented using a different language than the client.
2) You shouldn't share any logic/code between the server and the client, even if they are using the same language.
Current big project at work has a back end that is not in JS, but we still have a way to run the same validation code on both sides, which is run in an embedded JS interpreter on the server.
I'm not sure I would want to write a complete back end in JS or not (even if I'm not in love with Java, lately), but reusing this part makes a lot of sense.
---
We currently serialize (sync block) validation requests on the server through Nashorn, rather than having multiple instances (per thread or a pool). But, it's not like the requests wouldn't be serialized through Node, though. The rest of the request processing happens on independant threads normally. Not overly fond of threads, but I don't think I could get my team to by into Erlang or Elixir :-)
For that matter, my primary partner on this project is a big Scala fan, and we couldn't even get the rest of the group to go for that :-(
Makes a difference: Same people can maintain it without too much friction.
> 2) You shouldn't share any logic/code between the server and the client, even if they are using the same language.
Why not? It's nice, for example, to export your validation logic to a separate library and consume it from both sides.
Javascript is not going to be faster than Go or Rust, which are increasingly taking over as web backends. (I'm writing stuff in Rust's Iron framework lately.) Or Java, for that matter.
I can serve more requests from these languages than "concurrent" Javascript.
IDK of any Python, Ruby, or PHP runtime that has Node's paradigm of single threaded + concurrent I/O.