mxriverlynn / ama

Ask me anything!
2 stars 0 forks source link

Would you use a type checker (e.g. TypeScript) for a medium size node.js application? #21

Closed BorisKozo closed 8 years ago

BorisKozo commented 8 years ago

We are starting a development of a medium sized Node.js application (by "medium sized" I mean the total LOC count of all the modules we are going to write and not a single module).

The application will have a client (mainly in React) so we would probably want to use the same thing for both the client and the server part.

We are considering to use TypeScript or Flow as the language of choice. My concern is that we are adding a build step to a node.js application for something I am not sure is really needed. I have about 4 years of experience with JavaScript coming from C# and I feel comfortable without type checking (actually I think it gets in the way). The other members of the team are coming from either C# or Java and have a little less experience with JavaScript but still over a year.

mxriverlynn commented 8 years ago

i would not use any form of type checking, personally.

TypeScript may have some advantages over plain JavaScript, but I don't see type checking as an advantage. it breaks a lot of the power of flexibility and object composition that you get with JavaScript. I don't want my code limited to the attributes that a type defines. i more often compose objects at runtime, than not.

static typing is not a failsafe, in spite of what the static typing fans say. the compiler is not a test of any kind, and does not guarantee anything other than the code was compiled to whatever the target is (JS in this case).

if you want safety, write tests - unit, functional, integration, whatever you want to call them. they are your safety net, not static types.

if your teams wants that because it makes them comfortable, go for it. i'm all for comfort and familiarity - we all need that at times. just don't let them delude themselves by thinking it gives them something that isn't there. :)

...

lastly, i would suggest Node v6 w/ all the ES6 goodness it has, as a viable alternative to TypeScript - at least for the server side.

i'm not a fan of trying to keep the front-end and back-end looking exactly the same. use the best tool for the job, which means your front-end will look different than the back.