1. 程式人生 > >Ported a Web Back end from Java to Node/Typescript: 40% less code,

Ported a Web Back end from Java to Node/Typescript: 40% less code,

Ported our Cloud Backend Web Service from Java to Node/Typescript: 40% less code, ...

We just finished porting one of our Cloud Web Backend (video collaboration platform for Machine Learning) from Java 8/Jetty to NodeJS / TypeScript.

1) 40% less code. Size does matter, simple scales better.

2) Cleaner code design: Functional first, OO as needed, no more Class-For-Everything induced contortionism.

3) Cleaner module public API: intent driven function with related types, class often as a module implementation details (when needed).

4) Better typing: TypeScript modern structural typing model reduce typing friction while maximizing expressiveness.

5) npm libraries (the good ones) tend to be better maintained and much simpler to use than their Java/Maven counter/part (Google SDK, Image with opencv, ...)

6) Much fewer files: No more 1-1 between module and file. Same module file can export all needed for a service, functions, const, and types, and can even re-export external module structure.

7) Same advanced "enterprise/CRUD/..." feature set, "AOP" like with decorators for RBAC and perf instrumentation, full DAO and Service layer fully reimplemented (with much less Class).

8) Maximum code reuse between server, micro-services (also in TS), and client (also in TS).

9) Ironically, orchestrating advanced concurrency in nodejs is better achieved than in Java standard programming, as async is ubiquitous, async/await/promise is simply powerful.

10) Did some domain-specific benchmarking, and while Java is about 2x faster on a single concurrency mode, node.js was 2x once turning concurrency to 100.

Can probably make Java scale with quite a bit of work, but even if Java vs NodeJS perf is a wash, the value above are too important to ignore.

After 20 years of Java, we are starting all our new #BigApp enterprise/cloud projects with nodejs/typescript now. The only caveat now is to fight clich├ęs.