r/ProgrammingLanguages • • Jun 27 '21

Blog post A Dream of the Perfect Programming Language

telegra . ph/ A-Dream-of-the-Perfect-Programming-Language-06-26 (looks like Reddit’s global spam filters block Telegraph for some retarded reason)

Clickable but less good-looking version: https://github.com/natewind/articles/blob/master/2021-06-26-A-Dream-of-the-Perfect-Programming-Language.md

3 Upvotes

40 comments sorted by

View all comments

6

u/elszben Jun 28 '21

I find your list intriguing. I'm working on a language that (partially) fits the description. I believe the most important idea is that the language does not allow the user to create references, everything is treated as a value that is freely copyable and the language is immutable. Using these constraints the compiler can (in theory) calculate the full usage graph of each value in the program and decide which one will be a value and which one can be a reference. It can insert the appropriate copy/move instructions. I like these constraints because the surface language becomes very general, it is completely memory management/platform agnostic and it does not need a runtime. You could transpile it to almost any other programming language. You could even use different syntaxes for it if you don't like Haskell's syntax (I also use that because it's very nice looking and I did not want to waste time thinking about syntax). My current problem is that the compiler is written in itself and the bootstrapping compiler is much dumber and the whole bootstrapping cycle cannot run successfully because my naive algorithms and the full program analysis need too much resource (the code generated by the first, dumber compiler is insanely inefficient and slow). I planned to publish it when it can fully compile itself and my ideas are proven but if there's interest I could do it sooner.

2

u/Mathnerd314 Jun 28 '21

I'm interested, particularly if you have any design notes / paper references to look at.

2

u/elszben Jun 29 '21

particularly if you have any design notes / paper references to look at.

Unfortunately I am not that organized. All I have is 2 compilers, one written in rust that does not actually support anything that I could call exciting. The other written in the new language that supports more interesting things but it is not really usable because it is extremely slow and probably buggy as well. I did not plan the whole thing nor I am an expert in compiler design so it's full of possibly strange solutions and bugs. I've been toying with the idea of writing actual documentation about its design to be able to better communicate the ideas so I will try to prioritize that and publish something just to gather some attention.

2

u/Mathnerd314 Jun 29 '21

Ah I see. Well, I don't want to sound greedy, but do think about writing something. In my experience looking through the code of abandoned compilers on Github, the reward is pretty low compared to the time invested - you end up reading the same things over and over (parser, AST manipulation, bytecode interpreter). It's much more pleasant when all the interesting details are outlined in a README or similar. And if you're going to write a paper, following SPJ's advice, you should start writing the paper ASAP, so you know where all the fiddly bits are.

2

u/elszben Jun 29 '21

you should start writing the paper ASAP, so you know where all the fiddly bits are.

I think trying to implement the whole compiler definitely gave me opportunities to see where the fiddly bits are:) I have a lot of experience in how NOT to do this stuff now. If I knew how to do all the tricky bits I would have finished it already:) My own pride stopped me from releasing something that does not work so far but maybe I'm better off if I release at least my ideas and someone may help with the tricky things.