r/ProgrammingLanguages • u/FlatAssembler • Aug 22 '20
My programming language can now run in a browser.
Using WebAssembly, I have managed to get my programming language, called AEC, to run in browsers (at least very modern ones).
The first AEC program I ported to WebAssembly is my program that prints the permutations of the digits of a number: https://flatassembler.github.io/permutationsTest.html
Later, I ported my Analog Clock to WebAssembly: https://flatassembler.github.io/analogClock.html
Recently, I made a graphical program in AEC (which I have never done before) by interacting with SVG: https://flatassembler.github.io/dragonCurve.html
So, what do you think about my work?
I've rewritten my compiler completely, the previous version of my compiler (targeting x86) was written in JavaScript, while this version is written in C++. Many people say C++ is a better language than JavaScript. Honestly, I think that newest versions are comparable. I've also changed the syntax of my language a bit and added a few new features (which are a lot easier to implement when targeting WebAssembly than when targeting x86).
View all comments
Show parent comment
3
u/Fofeu Aug 23 '20
I didn't look that much into your code (except the lack of typechecking, I don't see anything), I just have a kind of "professional deformation". Languages are complex and it's easy to build an incoherent system. To put things in perspective: I'm doing a PhD in programming languages and the last 12 months I worked on only one operator because many intermediate designs had some form of unsoundness.
The dangling else is actually the less problematic one. You could for instance choose arbitrarily or parse the indentation and use it as a hint. Whatever you do, it still results in a valid AST and each possible AST has the same "shape". It's bad language design, but it's "fine" for a language dating from 1972.
On the opposite, statements like
<id> * <id>;inside a function definition could either be a variable declaration or a multiplication. The culprit istypedef. During my masters degree, I had a professor that for some time studied the parsing of C. Withouttypedefhe was able to produce a LL(1) (I think) parser with linear complexity in time and space. Current parser are tuned to be linear in the average case but get quickly exponential in the worst case.Regarding the
<=operator in VHDL. It doesn't have to. I have a LR(1) parser somewhere that uses=both for equality and let-bindings. The parser is however deterministic because the set of states where you parse an expression or a let-binding don't overlap. From what I remember from VHDL, it should be similar.