1. 7

  2. 2

    I am a wannabe language designer.

    This blog post explains to me why Python feels so much more right than other languages. It seems Guido understands, at least intuitively, something I learned the hard way: consistency makes good programming language design.

    If a language uses something in two different places and they do two different things, from the perspective of the user, that is not consistent. A good example is static in C. It can mean “private to this file” when applied to a function and “private to this function and a global variable” when applied to a variable inside of a function.

    Another thing he gets absolutely right is this:

    Features of a programming language, whether syntactic or semantic, are all part of the language’s user interface.

    People don’t think of programming languages as having a user interface, but they do because users use them. In fact, a programming language could be thought of as a user interface to a programming toolbox.

    As such, programming language design is not about features (though they are important), it’s about presentation of orthogonal, composable tools in an interface that is intuitive and consistent to the user.

    1. 1

      I agree with the thesis: Programming language design is user interface design. However I disagree with Guido’s implicit put-down of people who have different UI requirements from him as “puzzle solvers”, even as I agree that most attempts at language design contain bad UI decisions.

      Different languages embody different ways of thinking that appeal to different people. There is no single UI that is best for all people and all problem domains. I’ve met many people who hate Python because of indentation as syntax. I met a Perl programmer who said that “Perl fits my brain”, and who found Python unusable in part because Python’s approach to modelling scalars, strings and lists is so alien compared to the natural way that Perl works. (I find Perl very unnatural.)

      I consider Python unusable precisely because it is Pythonic, but it’s hard to put this into words. One issue is that functional programming is not Pythonic. Lambda expressions are not Pythonic (according to Guido) and are deliberately restricted to make them less useful, and proper tail calls are not Pythonic. Lambda, reduce, filter and map should be removed (but Guido didn’t win that battle). Another way of putting it is that I expect programming languages to consist of simple, orthogonal and highly composable primitives that can be plugged together any way that makes sense, both at the syntax level and at the semantic level. Scheme has this characteristic to a much greater degree than Python, both in the syntax and the semantics. So do functional programming languages. The kind of syntactic and semantic composability that I value is not Pythonic.

      1. 1

        OTOH, the failure to come up with a good multiline lambda syntax has, IMO, been a long term, fundamental hinderance to the development of Python as a language and has led to layers of hacks (e.g. with) to deal with the lack.

        1. 6

          tbh, I’ve never found myself needing lambdas in Python. The statement-oriented nature of the language and the ability to write a function definition basically anywhere means that any place I would reach for a lambda in another language (filtering over a list), I just give the “anonymous function” a name and then use that name immediately below. It’s “hacky” or “uglier”, but it’s also immediately obvious what’s happening and not any slower.