3 ms·
Please don't assume that the problems that are specific to Javascript also happens with other dynamically typed languages.
by flavio81 9y ago
Please don't assume that the problems that are specific to Javascript also happens with other dynamically typed languages.
- spraak 9y agoBut why don't they? Aren't the problems nearly the same? And if not, how?
- carlmr 9y agoThey do, JavaScript is just the worst offender. Python has the dynamic typing problems, but is better because it has a somewhat strong type system. It will tell you when it's wrong, but often too late (oh this function only gets called wrong once every 100h on my server, thank you for telling me now that it went wrong). And sometimes different types can duck into the same function (e.g. string and list are both iterable). So yeah, Python suffers from the same issues when you want to scale your code, but it's A LOT less bad than JavaScript.
- flavio81 9y ago>But why don't they? Aren't the problems nearly the same? And if not, how? Concrete example: Common Lisp is very strongly typed. So it almost never automatically converts from type to another, except when it makes total sense (i.e. the square root of -1 will return a complex number). So, if there is a type mismatch, it will be caught (at runtime) raising an exception. Now, you would think "yeah but my statically typed language will check this BEFORE the code runs". Yes, but in Lisp, the exception doesn't terminate the execution, it enters a mode in which the system asks you what to do next. Thus, what you do is, you go back to the source code, to the function with the error, you correct that specific function, compile that specific function (which happens almost instantly), and then resume execution of your program. This means that the previously "invalid operation" will be run again but with the new definition of your function, thus the code will continue running without said bug. So, all in all, it's very nice to use...
- skohan 9y agoThat sounds very nice to work with, and for tools/scripts running on my own workstation it sounds great. For user-facing code running at scale catching more errors at compile-time still sounds better to me.