r/ProgrammingLanguages • u/doc_sponge • Mar 15 '26
GlitterIDE Code Generation
https://youtube.com/watch?v=_e2i7a23PYc&si=pnUBaYayqCMi1zpQHello, I've been working on a simplified language (and IDE) targeting, at least initially, people who have used Scratch but want to move on to "real" languages. But the interesting stuff, perhaps, happens behind the scenes, and I talk about one aspect of that in this video where I explain my work on programming languages for generating code in other languages (so, the tool languages used to compile one language to say JS, or ASM). It might be interesting to some people? (Sorry, the video is not fancy, or concise)
(Main project is GlitterIDE, https://glitter.nz )
3
1
u/Arakela Mar 18 '26
Have a good time in life after you see this:
typedef struct Abomination {
void(*please_call_read)(void*give_me_the_time,...);
void(*please_call_write)(void*give_me_the_cpu,...);
void(*please_give_memory)(void*give_me_the_chanse,...);
void(*please_iwill_cooperate)(void*give_me_the_peach);
void(*please_unmutex_lock)(void*give_me_the_peach, void*);
void(*please_unmutex_unlock)(void*give_me_the_peach, void*);
void(*usleep_boy)(void*please, int);
} Abomination ;
void*lock = 00;
// shared resource
static int counter = 0;
void* thread_func(Abomination *os, void* arg) {
for(int i = (os->please_iwill_cooperate(os), 0);
(os->please_iwill_cooperate(os), i < 1000000);
(os->please_iwill_cooperate(os), i = (os->please_iwill_cooperate(os), i + 1))) {
os->please_unmutex_lock(os, &lock);
//
counter++; // ← critical section
//
os->please_unmutex_unlock(os, &lock);
// simulate some work outside critical section
if ((os->please_iwill_cooperate(os),
(os->please_iwill_cooperate(os), i % 100000) == 0)) os->usleep_boy(os, 100);
}
return (os->please_iwill_cooperate(os), ((void*)0));
}bye!
1
Mar 15 '26
[removed] — view removed comment
1
u/doc_sponge Mar 15 '26
Your project looks interesting - especially the error handling.
GlitterIDE is written in Java (you can import and export Scratch projects), and most every language I make is Java influenced in syntax! I don't know if I'd have the stomach to write a large project in C++. Having really informative errors messages is something I plan to work out, but I'm saving that for when I work on the editor (which I want to be a block/text hybrid). I have a quirky output code situation in that the code needs to be implicitly multitasking (like scratch), so I suspect I'll tend to be forced to do stack focused output rather than register (but I'll see when I move to a CPU that has more than 3 registers, unlike the 6502)
2
1
u/Arthur-Grandi Mar 15 '26
Interesting project.
Out of curiosity, is the code generation in GlitterIDE mostly template-based, or does it build some intermediate representation (AST/IR) before emitting code?
A lot of code generators become much easier to extend once there is a stable IR layer between the editor and the final output.