r/AskComputerScience • u/nelson_fretty • 6d 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.
1
u/hayztrading 6d ago
C#
1
u/Robot_Graffiti 6d ago
Yep. JITed languages like C# etc can give you a great feature set without running painfully slow. For typical business code it's something like maybe 80% the speed of C++. That's pocket change compared to the 10,000× difference you can see between the best algorithm you can think of and the O(n³) nonsense the worst guy in your team will write.
1
u/T_Thriller_T 6d ago
Many Python liibraries do already break down their set of instructions to internally use a C or C++ library.
I know the terms extend and bind. I am not sure what either actually mean.
Apart from that a MAJORITY of python is powered by CPyrhin, which is mostly written in c.
So ther interpreter takes python codes, parses it into bytecode based on C.
The overhead is not from inefficient usage of memory (mostly) but mostly in the interpretation.
(All of this as far as I remember)
Nonetheless, I think even this overhead diminishes for some libraries which do literally nothing but abstract a C/C++ library.
Numpy, scientific math, and TensorFlow (machine learning, data stream oriented work). Both even bring their own data structures, so as long as you take care actually using and not casting from/to them, you'll be good.
The issue is more on the side of "I don't want to manage memory or use a library".
The efficiency (partially) comes from doing either of the two. Because not every data structure is similarly well suited to support your algorithm. The pure access overhead when using the wrong data structure can cause considerable delays - and break real time requirements.
1
1
u/nelson_fretty 6d ago edited 5d ago
Seems compilers are not up to scratch for what I was thinking - may need to use binary / assembler ie think like a compiler - not sure if it’s possible to abstract stuff on other side without creating own language
1
u/braaaaaaainworms 6d ago
Stop worrying about performance if you don't have concrete performance goals that you need to hit. Rust will be fine if you cooperate with the borrow checker
1
u/AdLogical7286 6d ago
When he said he want performance but doesn't want to manage memory by self, rust was the first language came in my mind
1
u/nelson_fretty 6d ago
Need to rewind - I have 64gb but most folks only have 4/8gb
1
u/braaaaaaainworms 5d ago
There probably aren't going to be enough people using your software to worry about it right now
1
u/gofl-zimbard-37 6d ago
Have a look at Paul Hudak's "The Haskell School of Expression". It's pretty out of date, but has some interesting ideas about multimedia.
4
u/Robot_Graffiti 6d 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.