TypeScript before JavaScript?

Ben Lovy - Oct 31 '18 - - Dev Community

Shiny objects

Am I shooting myself in the foot by learning TypeScript without properly learning JavaScript first?

When I started taking programming seriously I thought I wasn't interested in web development so I focused on getting productive with C and Rust and dabbling in Haskell - but rather quickly discovered that things are different now then they were in 2004 when I first tackled a website. The web is a whole new platform and it's ridiculous to avoid it outright. You cannot beat the portability it offers.

This kicked off a largely fruitless chain of hipster tech. I built little prototypes in ClojureScript's Reagent, Re-Frame, and Om. I built a few Elm toys. I tried PureScript's Halogen and Pux. I tried bucklescript-tea and ReasonReact. I built an app in yew, an experimental framework for Rust targeting WebAssembly, which, while cool tech, was definitely a weird use of time figuring out how to hook everything up for someone who'd never done it in JavaScript before - learning yew taught me about React before I'd ever looked at any React code. I even spent a ridiculous about of time messing around with GHCJS to write my frontend code in Haskell - my poor old 2011 ThinkPad deserves a medal for that week.

The writing was on the wall, though. If I'm going to take this industry seriously and eventually switch careers, I cannot avoid learning JavaScript. Being able to read snippets is all well and good but I've gotta learn how it really works, and I'm not even honestly sure why I've been avoiding it in the first place.

However, I'm still having trouble giving up my types. My favorite of the above menagerie was Re-Frame except for the lack of types. Clojure is a joy to write but a pain to debug - I still spent the vast majority of my development time tracking down stupid errors at runtime that I'm used to having caught for me, or sifting through opaque Java stacktraces with very little relevant info. Part of me thinks this is a lack of experience with dynamic languages - almost everything I've used has been typed and compiled, with the sole exception of Clojure. Which suggests I should invest more time in learning how not to do that.

Enter TypeScript - at face value it's everything I want. It uses ES6 constructs, so I can learn about those, and has a pretty advanced type system to boot. It's object-oriented in a way that's more similar to the big industry-standard OOP systems - something I don't have a lot of exposure to or practice with. All of the JavaScript bundlers and testing libraries and what have you still apply. The way I see it, learning TypeScript well is kinda like learning both for the price of one. All I'd need to do to adapt to a JS codebase is rip my types out.

Is this disingenuous? I'd love to hear what people who already know and use these technologies think. Comfort-zone-wise I'm completely content to continue using TypeScript on my personal projects, and it seems more and more that it's being adopted by larger companies and frameworks. If that's holding me back, though, I should start learning JS proper now!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player