3 ms·
I dont think that's the same kind of thing. Your example is a tradeoff that anyone who uses a language that doesn't require explicit variable declaration faces,
by version_five 5y ago
I dont think that's the same kind of thing. Your example is a tradeoff that anyone who uses a language that doesn't require explicit variable declaration faces, and it's pretty tough to argue such languages really shouldn't exist.
Missing an operator resulting in explicit behavior is much more subtle and not even obvious behavior. For those who use python, it is worse.
- shultays 5y agoit's pretty tough to argue such languages really shouldn't exist Well, I agree with OP so that is at least two people. I really don't see it as a good trade.
- SomeCallMeTim 5y ago> ...it's pretty tough to argue such languages really shouldn't exist. "Shouldn't exist" is too strong. Dynamic languages that let you create a new variable via assignment shouldn't be used to create non-trivial software. How about that? Scripting languages have a place. That place is 100% in creating quick-and-dirty scripts and tools. Or in doing some kind of one-off data transform (as is common in machine learning scenarios). Anything that has a life span of two weeks or less, or a code length of fewer than a hundred lines? Yeah, script languages rock for that. Explicit/static typing adds vastly more value to large projects than the cost of the overhead. The fact that you can't really gain that value in Python means that Python should be relegated to quick and dirty scripts. Same for JavaScript, Ruby, and other completely dynamic languages. You'll note that all of these languages are getting types one way or another, meaning that there are a lot of people who do recognize their value. Though TypeScript is years ahead of the rest in the completeness and sophisticated of its type system; bugs like the comma bug detailed by OP, along with simply every JavaScript "wat" bug, simply can't happen in TypeScript in strict mode. And static types enables entire other categories of bugs to be detectable via a linter as well.
- simonw 5y agoI've been building non-trivial software in dynamic languages for twenty years. They work great. I'd take a project in a dynamic language with a decent test suite over a project without tests in a statically typed language any day of the week.
- sixstringtheory 5y ago> I'd take a project in a dynamic language with a decent test suite over a project without tests in a statically typed language any day of the week. I'd take the opposite. I've read too many useless tests in python codebases that can be accomplished by a static type checker. "Decent" does a lot of heavy lifting in your comment. And what about a dynamically typed codebase without any tests? I'm sure they exist. I'd rather dive into a big ball of mud with a compiler that will help point me to my mistakes before I release them, than having to sift through a ball of mud trying to find that mistake with production services flailing. That all being said I've worked with both types of languages in successful projects. But I prefer the development experience of the statically typed variety.
- noogle 5y agoBut a dynamic language needs all the tests a compiled language needs AND type/syntax tests (that are handled by the compiler in a static language). There are reasons dynamic language (or specifically Python), but I haven't heard one explanation how it helps writing fewer tests.
- bilkow 5y agoExplicit variable declaration is just adding a keyword (such as var or let) when you're declaring a new variable instead of modifying one. The cognitive burden of having to memorize and look for which variables are new vs which are being modified is simply not worth it in my opinion, even for a scripting language. Maybe for esolangs, simple math or first time learning programming. In any case, it's a short coming of the language (IMO) but not a deal breaker. We learn to live with it.