Aglang
- 13 Devlogs
- 55 Total hours
A basic esoteric language made to be similar to Assembly. Both a compiler and an interpreter (web and local) are implemented.
A basic esoteric language made to be similar to Assembly. Both a compiler and an interpreter (web and local) are implemented.
NOTE FOR THE SHIP: you dont have to try everything! even just the online interpreter is fine, it includes examples!
im ready for the ship!
i completed the vscode extension, and (for the third time) I. HATE. MICROSOFT. this might sound excessive, but anyone that ever tried reading their docs can surely understand, right? right…?
but finally, after like 2 hours, i made the most basic of extensions! it has syntax highlighting (the thing that i wanted most) and a simple statement templating snippet.
and now, i can pretty confidently say that aglang is completed! surely i wont abandon the project, that would just be a waste of the 50 hours i spent on this, but i consider the project to be mostly finished.
see ya soon!
why did i decide to do this lmao.
lets go in order: first of all, i added transpiling! currently, only C is supported as target, but i plan on adding python soon.
it actually wasnt that hard, especially considering i basically never wrote C in my life.
but this was the least interesting part of this devlog, cause i managed to optimize the compiler a bit! now this… this was hard. but now, when printing many characters in a row (like in the hello world example), instead of printing each character one by one, the full string gets stored in the .text (or .data on windows) section of the assembly and gets printed once! this reduced the size of the hello world program from ~1kb down to 633b, almost half!
needless to say that this needed a few attempts… now the project’s folder looks kinda full… but oh well!
and i can AGAIN say that GOD I HATE WINDOWS: it took a while to get shadow allocations right, especially since pushing to the stack in aglang means pushing to the stack in assembly too, so i had to keep track of where the old and original pointers were before allocating it.
i fully expect this optimization to have some bugs, since i dont really trust the logic i wrote.
i didnt add it in the transpile feature, since i imagine that modern c compilers optimize it on their own.
now i promise that ill get to writing the vscode extension!
well this took a while.
so, i came to the conclusion that an lsp server is kinda overkill, so, to make up for it, i decided to make an interactive lesson system on the website, like svelte!
and well i didnt expect it to take 7 hours…
i have to admit, it came out pretty good! they have code challenges, too :D
anyways, for the autocomplete feature, ill still make it into the vscode extension (if i dont give up on that too)
oh and i added shareable code in the web interpreter!
the windows compiler is here!
and i can finally say GOD I HATE WINDOWS why was it so simple in linux with just a syscall and in windows to not pull my hair out i have to link c with the executable lmao
but, a wise man once said:
the past is gone, think about the future…
or something like that idk
while i worked on that, i ended up even fixing some problems too, so thats good. and i made the cli a bit prettier too, with spinners!
in the meanwhile i was looking at lsp servers too, and they look… overly complicated… yep i guess i already did enough today not gonna get into allthat!
see ya tomorrow!
there now is a compare statement in aglang!
i had this idea for a while, but i thought it would make the language too easy… but i ended up making it anyway!
together with it, i made labels too!
so if, for example, you wanted to skip a section of code if the number 2 is bigger than 1, you would write it like so:
10?1; $ compare 2 (10 in binary) and 1 (still 1 in binary) $
^.; $ if 2 is bigger, jump to label . (labels are can only be named with dots, it would have been to easy otherwise :) ) $
(other code...)
~.; $ define label . $
(do more stuff...)
and this makes the fibonacci example easier, since now, instead of using counters in the stack, you can simply check if the current number isnt 233 and go back to a previous label.
i still have to implement it in the web interpreter, but i guess it shouldnt take long!
next step: windows compiler! (note: will probably require mingw to be installed)
the first ship is done!
but before getting to the actual devlog, i want to respond to some of the best feedback i got:
and now, back to aglang developments!
the first version of aglang is finally completed! i want to thank everybody for the feedback i received, it even gave me some ideas, thanks!
in these 3 hours, i improved the website, so now instead of just the compiler it even has a full homepage with downloads: this was on my checklist for a while, but first i wanted to ship a first version to get some initial thoughts.
next up for this project, i have a two ideas:
and a few other things if i have the time:
whooo! the documentation is done!
im officially ready to ship! i finished writing the documentation and the repo readmes, and im ready to release this into the wild!
the docs are availabe in the cli’s repo, but they’re linked in the website too.
this took a few days, since i was working on another personal project, but im finally back!
the web interpreter is done!
after almost 1000 lines of svelte and 8 hours of boredom, im happy to announce that the js implementation of the aglang interpreter is completed! it is now available at https://aglang.0xf1.dev (the dns changes might take some time to fully propagate, so if it isnt loading, it probably will in a few hours…)
it is basically a 1:1 copy of the rust code, but prettier! ahem… because of the ui, not the code… and i even designed a logo for it! in it are all the valid characters in aglang.
in the meanwhile, i fixed and refactored the loop system in both the js and rust versions.
the next steps are writing the docs, preparing a good readme and then i can finally ship the project! see ya then!
and p.s. i havent optimized the website for mobile, but i imagine nobody uses stardance on a smartphone, right?
no yeah im officially going crazy
so, after a bit, the compiler is DONE!
now it spits valid x86-64 asm and even automatically compiles it to an executable with gcc!
and i even managed to make a fibonacci sequence example program! (it only computes numbers up to 144 since its the highest fibonacci number in the unsigned 8bit integer limit) but to make that, i had to spend HOURS thinking about how to do it.
the problem was that in Aglang, you have 2 registers and a stack, and for that fibonacci program i couldnt make it print random ascii characters, but instead the actual numbers in the decimal system: for that i tried making loops that converted a number into the digits that composed it, buuuuut you still need the 2 registers to keep the fibonacci numbers you have!
i even surrendered and tried asking gemini, but it would go absolutely CRAZY: it would give really long responses and contradict itself in the code… a bit of like when you ask an ai to give you the seahorse emoji.
so, the ultimate solution was to implement a “numeric value” parameter to the stdout argument.
therefore, now, if you write something like
01000001>\#;
you would get the actual 65 number instead of the character ‘A’ and all the problems would go to the compiler and assembly!
but i dont care now, cus its DONE!!!
the next steps, i think, should be making a js interpreter, so that the language can be tried online without downloading anything, so ill work on that tomorrow…
it was the comments IT HAD ALWAYS BEEN THE COMMENTS
i think im about to go crazy, cuz im trying to manually write assembly to know that the compiler should write, and trying the basic alphabet loop i couldnt get it to work, no matter what it was always printing ▒.
i tried everything, i even managed to get SATAN ITSELF to write my output (check attached image)… but finally… i tried deleting the comments i put with the original aglang line… and it worked.
i found out that the stdout token in aglang (“\”, i even have to write it twice here in the post because stardance has the same problem lmao) was making nasm think that i was trying to escape the newline after the comment, thus making the next assembly line part of the comment.
as you can see from the logged time it literally took over 2 hours of my life because of a single backslash.
so i uhh… kinda refactored everything?
i realized that to make the compiler i had 2 options:
aglang run ./main.ag
the next step is building the compiler itself, but ill leave that to tomorrow. (and i think itll just support linux elf64 x86-64 architectures, sorry arm friends!)
oh wait! i forgot to tell y’all why the name “Aglang”! nothing special actually, “Ag” just stands for “Ugly” lmao
the interpreter is done faster than i expected and after some issues i settled on the syntax. ive added comments (kinda hated working on them), changed the input structure a little bit (now the input gets directly stored on the stack).
the next step is building a compiler to x86-64 assembly, i dont think i’ll make it for other architectures. i guess it shouldnt be that hard since the language’s features are pretty similar to how assembly works (obvious foreshadowing)
this example outputs every uppercase letter in the alphabet:
01000001>''; $ move 65 (A char in ascii) to reg2 $
11010>:; $ push alphabet counter (from A to Z) into stack $
[ $ loop (ends when first value in stack is 0) $
''>\; $ output the letter $
1010>\; $ newline $
''+1; $ add 1 to the ascii value to go to the next letter $
:>'; $ move counter to reg1 $
:!; $ pop old counter $
'-1; $ remove 1 from the counter $
'>:; $ push the updated counter to the stack $
]
(the text between the $ are comments)
i’m finally building a language!
Aglang is an esoteric language (like brainf*ck) with 15 possible characters (not including the 0’s and 1’s of binary literals) where you are given two 8-bit registers and a stack: their values can be moved and deleted and arithmetic operations can be done with their respective characters.
i’m currently building an interpreter in Rust, but i hope once im done with that to start creating a compiler to x86-64 assembly.
i’ve attached a scheme made in KDE Drawy (i changed it like 8 times already) describing the language (sorry it’s in italian and my writing sucks), an aglang snippet and the parsed output in the interpreter.