Python features that can be removed
Python is more than thirty years old at this point and has accumulated some cruft. A new language has the opportunity to remove some of it.
Language design and implementation
Python is more than thirty years old at this point and has accumulated some cruft. A new language has the opportunity to remove some of it.
It is an enormous amount of work to design and implement a language the scale of Newton. Just learning the type theory takes years. I knew nights and weekends would not suffice, so the first thing I did was quit my job. Which raises the question, how am I financing this?
Newton’s type system takes a lot of ideas from Haskell and inherits many of the same concepts. One such concept is “skolems”. But what does it mean?
How does one encourage the use of immutable data structures
when the established idioms center on imperative for loops,
without creating a rift in the language?
I have been mulling over this question and think I found a good answer.
It turns out that pattern matching on Python-style tuples requires existential types. This is the second time I encounter them, so I figured it is a good opportunity to show how they arise in practise.
Python’s print function is difficult to type check because it takes an arbitrary number of arbitrary arguments. We cannot give it a fixed number of type parameters, like other polymorphic functions. Is it even possible to accomodate a function like this in a statically typed language? I think so.
I am now able to compile small but useful Newton programs that exercise the full feature set to Python! This is a major breakthrough because until now there was always something that would break when you tried something more complex.
Newton will follow Python except when there is a strong reason not to. This statement contradicts something I wrote earlier, that generators will be immutable. But now I’m beginning to think I want both behaviors. I don’t mean making mutation optional, I mean two separate languages, one with mutation and one wholly without.
When I started generating Python, I only thought of it as a stepping stone towards generating machine code or C. But over time, I realized the ability to generate Python is valuable in itself, just like Typescript does for Javascript. The question is, what degree of compatibility should I aim for?
Before I start generating C, I want to be able to loop over generator expressions. Having to iterate using C-style loops would be such an anticlimax. But there is a lot of work before I get there and I want to validate the approach first.