1. 7
  1.  

  2. 5

    This is an interesting way to phrase the now oft-repeated (particularly in functional programming circles) idea that mutable state is a bad idea. I wish the “Considered Harmful” phrase would go away (I like Dijkstra as much as the next guy, but he didn’t even make the title, his editor did), but otherwise this is a reasonably well done article.

    1. 1

      The “X considered harmful” phrase definitely comes with it’s own baggage. Whenever I come across an article that uses it, I almost always read it, because it piques my curiousity. On the other hand, I almost always go into the reading expecting to disagree with the author. Perhaps because it has been overused as a meme, and it’s meaning diluted?

    2. 1

      Most imperative languages aren’t even as nice as the example in the right hand column; in e.g. Python you’ll have “x = 42” and “x = 5” and the declaration and reassignment look exactly the same. I’ve long said any language I designed would make a distinction between the two (and := for reassignment seems like the most obvious answer). Are there languages (other than OCaml) that do this?

      1. 1

        Languages that require declaration generally don’t use the same syntax for declaration and assignment; there are a few languages, like Python and Tcl, where this is not the case. But declaration and assignment use different syntax, and declaration is mandatory, in assembly, Pascal, C, C++, Java, OCaml, the ML family in general, Haskell, Perl with use strict;, JS with "use strict";, and Golang.

        Unfortunately, in nearly all of these cases, the syntax to declare a variable is longer than the syntax to mutate one. Golang in particular adopts your := suggestion, but uses it for a type-inferred declaration, rather than mutation. This seems backwards to me. It seems to me that it would be better to use = for declaration and something much more discouraging for mutation, like # or #@ or ideally something that it will be hard to figure out how to even type, such as or or ⇐̄.

        Python and Tcl are at least a step ahead of languages like most Lisps, Perl without strict, JS without strict, old Fortran, and BASIC, where declarations are inferred but implicitly global!