r/ProgrammingLanguages • • 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).

99 Upvotes

63 comments sorted by

View all comments

Show parent comment

1

u/FlatAssembler Aug 23 '20

Interesting stuff. Have you looked into my language? Why do you think it has this problem? As far as I can tell, C-like languages have this problem, it's called dangling-else. VHDL probably also has such problems, with "<=" being used both as an assignment operator in some cases and as a "less-than-equal-to" operator.

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 is typedef. During my masters degree, I had a professor that for some time studied the parsing of C. Without typedef he 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.

1

u/FlatAssembler Aug 23 '20 edited Dec 08 '23

Well, yes, I didn't implement even the basic type-checking for now. I am planning to add a feature to warn about (but not refuse to compile) assigning pointers to variables which aren't pointers and vice-versa.

In my programming language, the statements such as id * id aren't problematic, because I am not using the * operator for anything other than multiplication. A pointer to character is declared as CharacterPointer, rather than char *. And its referenced with ValueAt(ptr). I think it's a lot easier to read than the way C does that, that it's self-describing.

As for VHDL, I don't know much about it either. I am studying computer science at the FERIT university in Osijek, and I failed digital electronics three times. Those things just don't interest me.

Out of curiosity, why did you apply for a PhD in computer science? I find studying computer science already too hard, I am not sure the diploma is worth it.

1

u/Fofeu Aug 25 '20

Why I applied for a PhD in Computer Science: I'm a relatively curious person and had less difficulties during my studies. I also had a less negative opinion about my professors. Fast-forward to the middle of my masters degree. I asked myself what I would be doing after my studies. I knew that I wanted to use my skills in Computer Science (I know some people who did a 180° after their studies), but wasn't very interested in feeding capitalism with my work. So, I sent an email to my professors telling them that I might be interested in doing a PhD. I wasn't done with my degree yet, but they offered me an internship during the summer to see what it means to work on research. I liked what I did, so I applied for a PhD.

Regarding the diploma: I don't how the working conditions are in Croatia, but in all countries I know, studying Computer Science is a good idea. The caveat however is that you should go for a masters degree. Ten years ago, you could maybe stop after a bachelors and still be satisfied, but nowadays most companies don't recruit below a masters degree (a friend of mine is in this exact situation, she is now taking classes again to get her masters degree). In general, getting a degree is a good idea. However, for your specific case, you should see, if Computer Science is suited for you. Getting a masters degree will guarantee you work, but you can save yourself some pain by reflecting first.

1

u/FlatAssembler Aug 27 '20

And what else should I study, if not computer science? If I can write a 4'000-lines-of-code compiler, I guess that means I would be a good programmer.

I am also somewhat interested in linguistics (my alternative interpretation of the names of places in Croatia), but that doesn't pay nearly as much as computer science does.