3 ms·
>Also you shouldn't lock yourself into classifications. Instead, just check the input and throw an error if it doesn't fit. I really don't see the gain here -
by mschulze 11y ago
>Also you shouldn't lock yourself into classifications. Instead, just check the input and throw an error if it doesn't fit.
I really don't see the gain here - instead of delegating the typechecks to a tool, the compiler you clutter your code with them. You still have to think about the types, functions/methods (public ones) start with at one, two or more ifs and you even have a hit on runtime perfomance.
- z3t4 11y agoBy helping out the compiler you can get better performance. But I like to think that current JavaScript engines or future ones are quite smart and can optimize beyond that. Lets say you are writing software for a cargo company ... The code has well defined classes. The company now wants to expend by including buss goods. But in the code, the terminals and containers will only accept trucks ... It would be better if the terminal code checked if the good fitted etc. Thinking about Buss vs Truck is much better then thinking about Array vs Object, but you shouldn't let classifications limit the solutions either.