Yumi's Blog / The Power of Statically Typing

The Power of Statically Typing

There are a few languages I’ve been working on and learning recently because I want to, TypeScript and Rust (occasionally Swift). Why am I talking about these languages? Well, these are languages where I can type my variables and functions, making my coding life so much easier as well as my code safer.

What is typing?

If you’ve ever had an opportunity to code, you may have heard terms such as string, int, and array. These are the types you can assign to variables. Thus, typing is the act of assigning types to variables.

Why type?

The power of typing variables comes in a few ways.

First, you can use autocomplete features in IDEs. Whenever you forget the exact spelling of that one long property of a class, you can just type a few characters you remember, and your IDE will suggest you with a few that relate to the characters you entered. This reduces the time you have to look back and search for specific variables. When your projects get more complex and it’s hard to manage all the attributes and properties, typing will become your best friend. You will thank yourself, who typed those variables three days ago.

Another merit of typing is that you can, most of the time, guarantee that you are not assigning a different type to a specified variable (like assigning a string to a number). This will reduce runtime errors and catch errors at compile time, meaning that your end users will not experience wasteful typing issues that may occur in non-typed languages.

For correctness

Dynamically typed languages like JavaScript and Python are amazing, in the sense that programmers, especially beginners, don’t have to think too much about types. However, it comes at the cost of runtime errors, which are errors that the users will experience. Being “correct” and making sure that types are correct, makes many runtime errors to disappear like magic.

Conclusion

In conclusion, statically types languages makes life much easier and makes the codebase much more secure, error-free, and easier to navigate through. If I could go back 10 years, I would tell myself to learn and code with TypeScript, instead of JavaScript. It just makes everything much better.