It seems that perfection is attained not when there is nothing more to add but when there is nothing more to take away — Antoin de Saint-Exupery
There is a lot that can be inferred/taken by the above statement. Errors only occur in programs if they are not perfect in every way. Antoin also gives us the insight that anything can be made perfect by taking things away from it not adding things to it.
Douglas Crockford in his book JS the Good parts says if a feature is sometimes useful and some times dangerous. and you have a better option always use the better option.
WE ARE NOT PAID TO WRITE PROGRAMS THAT USE ALL THE FEATURES OF THE LANGUAGE. INSTEAD, WE ARE PAID TO WRITE PROGRAMS THAT ARE ERROR-FREE AND WORK WELL.
My thoughts/take-aways on the above idea
Always Always Always(I know I am stressing this out too much but it’s a fact), Remember to know how, why, and when to use the specific concept of the language.
here is a very simple example, we all use >, < operators in JS right for instance consider the following example
Number(true);//1 Number(false);//0 1 < 2;//true 2 < 3;//true 1 < 2 < 3;//true ( 1 < 2 ) < 3 ( true ) < 3//Auto Coercion by js 1 < 3//true But (Wait for it) 3 > 2 > 1 ( 3 > 2 ) > 1 (true) > 1 1 > 1 //false
what!!! but we know that thats not true, this is one of the corner cases in js with auto conversion from boolean to number :’( .
My point being that if we knew about this corner case this could easily be prevented.
By this, I don't mean that we should go to extremes and follow
Type Rigidity or Static Types or Type Soundness.
People say that JS’s dynamic typing is its biggest weakness. I feel that its one of its greatest strengths. I mean, I couldn't imagine js without its dynamic typing. We would have been deprived of so many paradigms if we didn't have dynamic typing.
So what I mean to say is people. Nothing in a language is magic, everything happens to cause its either meant to be that way or because of historical reasons(in order to not break the older functionality ). Please ppl, remember to understand why questioning the same at every point(there is no stupid question remember). Always understand why before applying.
ERRORS occur usually (not including the corner cases :) because we do not understand the language and because of our own stupidity, Not the other way round
The Better Parts. Douglas Crockford.
Do not agree with me, Change my view ❤