DEV Community

How a Type System Improves your JavaScript Code

Ian Wilson on February 24, 2019

Vanilla JavaScript is untyped by nature, some will call it “smart” because it is able to figure out what is a number or a string. This makes it ea...
Collapse
 
lexlohr profile image
Alex Lohr

I still like writing plain old Javascript like we did in the good old days, but when I work with 50 people in 3 timezones on a large project, I currently prefer typescript (the tooling is really a differentiator).

Collapse
 
dirkncl profile image
Dirk Levinus Nicolaas
  • Original JavaScript with traditional programming is very exciting. Moreover, just using Notepad ++ is more festive for us just as a casual hobby.
  • With TypeScript, React or Flow it is possible that we cannot execute directly with our browser but must be compiled first. And the end result is an enlarged file.
  • Likewise with various libraries like jquery, underscore and others we don't understand the original syntax of javascript itself.
  • The library as a tool is really needed like Codemirror, Mathjax, Katex.
  • Maybe for developers who are tied to tasks that require high productivity, certainly Typescript, Flow, React, jquery, undersore can help increase productivity.
  • But if we are only as experimentalists or as hobbies, we recommend experimenting with Original Javascript with traditional programming.
  • Three reference mainstays that we can use are: MDN, W3Shool and Stackoverlow.
  • This is my opinion, and your thoughts and yours must be different from mine.
Collapse
 
theaccordance profile image
Joe Mainwaring • Edited

My appreciation for TypeScript grew out of maintaining the same two JavaScript projects over a 5 year period. Writing POJS is fine, but if your project doesn't have a finite scope, or you have multiple contributors, the additional structure provided by types pays huge Dividends in the long term.

Collapse
 
tomerbendavid profile image
Tomer Ben David • Edited

While a type system won't improve my personal code it would drastically improve team productivity and code maintenance burdon when someone else needs to maintain my code. Basically from hell to heaven, tooling, early error check. Code can be good either way, maintenance definitely not.

Collapse
 
jacksonelfers profile image
Jackson Elfers

We have this habit of beating around the JavaScript bush using transpilers to hide its non-classical behavior. I have trouble justifying the extra build step just to arrive back at good ol' js.

Collapse
 
iwilsonq profile image
Ian Wilson

Yep, I definitely wouldn't recommend it for every single project, especially not when working through an experiment or proof-of-concept. Static analysis can be a bit tiring but it gets stronger as the codebase increases significantly.

Collapse
 
jacksonelfers profile image
Jackson Elfers

I could definitely see where JavaScript could become unwieldy in larger projects. For people who've learned class based languages, typescript offers a great abstraction from js oddities.

Collapse
 
juancarlospaco profile image
Juan Carlos

Try Nim lang, better types and compiles to JavaScript.