Types For Frontend Developers
It's hard to bring up static types in JavaScript without starting a debate. The benefits of using static types are real, and so are the tradeoffs. As with so many things in software, the key to figuring out if the benefits outweigh the costs for you and your team. At Reflexion Health, we recently looked at introducing static types; I'd like to share some of the lessons we learned, and shed some light on how static types can help your team.
Frontend Tools (maybe Future JS?)
Tools
How do you know what a function does, what are valid inputs, what values will it return? How do you make sure that a function that's supposed to work on string
doesn't get called with an object
and take down your app at runtime? How do you communicate to the other developers on your team all of the assumptions in your code; all of the stuff you've got in your head about how that function you just wrote is supposed to work?
This is where types shine.
Introducing types can help you clearly communicate your intentions to other developers on your team. But this can go much further that simply enforces that a function takes a string
, for example. Modern type systems allow you to be much more expressive that was capable in the past.
At the same time, there are tradeoffs that come when you introduce types to your code. Types are meant to constrain; that's the point. But the constraints that help you write more expressive code can hinder your team if you don't consider them upfront. How do you handle and ad-hoc task or prototyping new ideas if you've got all this extra stuff to type? You're compiling your code now, so you know about errors earlier, but compiling isn't that quick and the error messages can be cryptic. Lastly, JavaScript has a rich ecosystem of libraries & tools that were not writing with static types; how do you take advantage everything that already exists?
My team recently went through all of this and we've learned a lot. We're seeing a lot benefit, but it's not all rainbows and kittens. I'll share with you why we feel it's worth it.
- Why our team decided to investigate static typing
- What options we considered, and why we chose what we did
- How we handle interop with existing libraries & tools
- Some examples of where having types can pay off
Developers, intermediate
Intermediate
Attendees will learn how static types can help write more expressive & correct software and how to address tradeoffs when considering statically typed languages. With any luck, we'll also dispell some misconceptions about static types.
Attendees should have a good understanding of JavaScript, and some opinion on static types.
Conceptual
Thanks @getify! That is great feedback!