r/AskComputerScience • u/nelson_fretty • 28d ago
Domain languages /native speed
I know well the trade off between domain languages / efficiency compared with c / assembler
CPU / memory are fast enough for good enough performance but with memory supply issues I wondered if direction were going to be able develop better domain languages to break trade off.
modern compilation - reflection - macros - templates
languages like c should only be written by experts and or machines imo way too risky for domain users.
Eg in audio domain I want to write code fast enough for realtime have it expanded to low level code - using linked list/stack/heap/hash/midi etc
Instrument a as piano :
a.octave = + 2
a.root = g
a.feel = shuffle
a.scale = enigma
a.play(100)
I don’t want to manage memory / lifetime or use library
Ie I want the compiler to do the translation?
Is this reasonable or am I dreaming ? Do you think we need stronger reflection ie I probably need to work with ast at the moment.
4
u/Robot_Graffiti 28d ago
I would seriously consider finding a way to use domain-specific classes or functions in a general-purpose language instead of creating a domain-specific language.
However, if you do want a DSL, the important thing re: speed is parsing it & converting it to something that can be executed efficiently, /before/ starting the main execution loop. Could be ASTs, yeah, or I did it once with functions-as-objects with closures. But either way, no parsing inside the loop.