7 ms·
Are you implying that it's impossible to write maintainable code in any dynamic language?
by ayrx 12y ago
Are you implying that it's impossible to write maintainable code in any dynamic language?
- GreaterFool 12y agoIn lisp you have the power to easily invent abstractions. Strip things down to a bare minimum and you can see that your code is good. And write some tests just in case. OTOH in strongly typed languages with rich type systems the actual code might be uglier and more complicated because you're constructing a proof of something. The property might be week (tests needed!) or strong (tests? what tests). Depends how far the rabbit hole you want to go. At least that's my view on this.
- kd0amg 12y agouglier and more complicated because you're constructing a proof of something It's rare for the programmer to actually produce proofs that a piece of code meets the spec given by its type[1]. Those proofs are generally produced by the type checker, possibly with occasional hints from the programmer. 1: Even in Coq, detailed specs for some code are typically given (and proven) separate from the code itself rather than in that code's own type.
- mpdehaan2 12y agoType errors in programs don't come up nearly enough to warrant languages completely dwelling on them so much. Now, say, consistent argument order does help a lot if you are writing your own libraries, but I wouldn't place the blame there on the language.
- rkrzr 12y agoType errors come in more shapes than the obvious one: e.g. Untyped data structures like dictionaries are a frequent source of error in Python (KeyError e.g.) or non-uniform lists. These are pretty common bugs, I'd argue, which simply cannot happen in statically typed languages like Haskell.
- pjc50 12y agoDynamic languages rely on test suites to catch bugs. The test suite is also software that must be maintained. Statically typed languages apply typechecking as a "test" to the entire program at load time. People have written and maintained code in typeless assembler, including for mission-critical systems. It's just more work and requires a different kind of rigor. The larger and more complex your system gets, the more useful typechecking becomes. "Maintainable" is not a boolean, it's a cost function.
- s_kilk 12y agoNot impossible, but in my experience it takes disproportionately more work than if you have a decent type-system to help you out. In a dynamically typed system, every expression and line of code is a liability, and requires a large weight of tests to have any confidence that it might work.
- bitwize 12y agoNo, but depending on the size of your code base and your available budget, it can get prohibitively expensive really quickly. Static typing eliminates entire classes of bugs. The cost of the up-front inconvenience to the programmer is tiny compared to the ongoing maintenance costs of possibly-incorrect, we-won't-know-for-sure-until-that-code-path-executes-in-production dynamically-typed code. This is dependent on many variables but a good rule of thumb is that for any project bigger than a doddle, it's a safe bet to just fucking use a statically typed language.