At Sulu we have decided to use Flow for static type checking, and I am still convinced that it was the correct decision back then. However, today TypeScript seems to be the much more popular choice. This claim can also be supported by earlier blog posts and presentations being more about what to choose, whereby more recent ones are about how to switch. So I think it is time to reconsider that decision, therefore I am going to compare these type checkers in this blog post.
#@ What is static type checking?
Static type checking has the goal of finding errors before you even run your code. This will catch quite a bunch of errors for you, and helps a lot to deliver higher quality code. Let’s have a look at a short example:
"5" is stored in a variable, and the value of that variable is not completely clear, because it is determined in a 100 lines of code. In that case it would be quite easy to mess this up in some way, without immediately realizing it. A static type checker would tell you about the error at the moment you introduce it, and you are much more likely to know what’s wrong than when finding out about this error at runtime a year later.
Now there are different ways on how to apply static type checking. Many compiled languages do this during their compilation step, which means that the program does not compile at all if you get any type errors in your project. This is a valid approach, and you will also know about the error very soon. But you are losing the opportunity to quickly test doing something in a slightly different way, because you might have to adjust a huge amount of types before you can even compile the program.
The advantage of the latter approach is that you can adjust the code in a way that types will fail, but you can ignore that for the moment, if you are just trying to quickly test something. In a compiled language you would have to fix all the type errors first. Now you can say that the program won’t run anyway as expected (although that is not completely true, because you might use it in a way that the type errors don’t matter), but at least it can run until a certain point, where you might be able to already do a
console.log to check on something. That’s something I really enjoy.
On a sidenote, there are also languages like PHP, which have improved their type system over the last years significantly, but it still feels a bit weird. PHP comes with the possibility to annotate your code with types in many different places, but it does not allow to check these errors before runtime. So you can e.g. define in a function that the parameter must be a string, but if you are calling the function with a wrong type, you will not realize that before this code is being executed, in which case you will get a runtime error. In my opinion this is the worst of both worlds, because you can’t tell about the errors before actually running the code, and it doesn’t allow you to quickly test something with different types. To be fair, there are tools like PHPStan and Psalm that work in a similar fashion than TypeScript and Flow, but PHP will still not allow to execute your code with wrong types.
Looking for an attractive & user-friendly web developer? HourlyDeveloper.io, a leading web, and mobile app development company, offers web developers for hire through flexible engagement models. You can **[Hire Web...
With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...
You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...
Build your eCommerce project by hiring our expert eCommerce Website developers. Our Dedicated Web Designers develop powerful & robust website in a short span of time.
This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.