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

0 Upvotes

11 comments sorted by

View all comments

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

u/nelson_fretty 6d ago

Yes that’s why I was thinking of going native

1

u/nelson_fretty 6d ago edited 6d 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