3 ms·
Article points to http://wtfjs.com/ http://wtfjs.com/ to show "glaring flaws" of JS. JavaScript is not perfect, but almost all what is presented on sites simila
by hawski 11y ago
Article points to http://wtfjs.com/ http://wtfjs.com/ to show "glaring flaws" of JS. JavaScript is not perfect,
but almost all what is presented on sites similar to wtfjs.com are non-issues to me. It may be stupid
or surprising that API behaves in some ways, but as long as it behaves exactly as in documentation it is not much of a problem. I always check available documentation even for basic APIs in every language that I use. i.e. I was amazed that even senior developers at my previous job did not know that strncpy is practically useless. It was just `man strncpy` away.
In a way static typing can save you just like reading of documentation, but in a more organized manner. That said you should still eat your ve^W^W^W read documentation.
What helps in case of dynamic languages is REPL. It is even better than documentation sometimes. You can easly check every line with your reasoning. For C or C++ I always have some simple file for testing basic constructs to check my assumptions. One could argue that that is the role of unit tests, but one does not prevent the other. Unit tests are same thing, but in more organized manner.
- gnuvince 11y agoTwo things: a) Maxime works on a compiler for JS, so even if something is documented to death, it usually makes analyses less precise and/or more complex. b) Many statically-typed languages have a REPL (OCaml, Haskell, Scala); this is not an issue with the typing discipline, but with the tools available to the developers.
- dllthomas 11y agoWith type inference, a REPL can even tell you things about code that can't run yet! Prelude> :t mapM undefined [5,6,7] mapM undefined [5,6,7] :: Monad m => m [b] This can get even more informative with Typed Holes: Prelude> mapM _whatFunc [5,6,7] <interactive>:14:6: Found hole ‘_whatFunc’ with type: Integer -> m b Where: ‘m’ is a rigid type variable bound by the inferred type of it :: m [b] at <interactive>:14:1 ‘b’ is a rigid type variable bound by the inferred type of it :: m [b] at <interactive>:14:1 Relevant bindings include it :: m [b] (bound at <interactive>:14:1) In the first argument of ‘mapM’, namely ‘_whatFunc’ In the expression: mapM _whatFunc [5, 6, 7] In an equation for ‘it’: it = mapM _whatFunc [5, 6, 7]