SuperCollider - Python?

Well, all popular scripting languages (Python, Ruby, JS*, Lua**, etc.) allow “declaring classes on the fly” and replacing existing classes.

In Python, classes are refcounted, so that old Foo instances still refer to the old Foo class while new Foo instance refer to the new Foo class. The same goes for JS and Lua. I would consider this mostly unproblematic.

(In Ruby, replacing classes actually seems to change existing instances (!), which is a bit more funky.)

In fact, it is rather weird for a scripting language to have an extra compilation step for classes. In case of sclang, I think the reason is mostly historic. By precompiling all classes sclang can build a “global method table” so that method call becomes a simply array lookup – instead of a more expensive hashtable lookup. Also, it does not need to walk up the inheritance chain. This has been an important optimization in the late 90s, but in 2023 computers are fast enough to deal with dictionary based method lookup.

Note that some method call optimizations can still be achieved without precompilation. See for example: Performance – Wren.

The simplest would be a “file-watch”, which would react to every change in the file and could trigger tests or something similar.

This does not really solve the problem that a recompilation of the class library destroys all interpreter state. I find this very annoying when developing my own classes.

*) Classes in JS are really syntactic sugar for prototypical inheritance
**) Lua does not really have a class system, but you can easily emulate with tables and metatables. (You can actually do the same in sclang with IdentityDictionary resp. Event)

1 Like

Sorry, I just couldn’t leave it like that :slight_smile:

PSA: if you are about to make an off-topic comment that is likely to generate its own side discussion, consider using “Reply as linked topic”!

Those are not really relevant discussions, re this particular point. I really don’t care that much about this. But it is a fact that this ‘feature’ produces errors, then you need to create other tools to fix those and so on and so on

I was not engaged in any “war”, I was bringing attention to some relevant aspects.

Sorry?

PS: I remember someone talking about the economics of programming languages, and how their development are related to capitalist investment etc. A lot of the way things go are not really rational in the same way we discuss logic, mathematics, computer science, language design, creativity, music, art, life, etc

I am not the one who said this! (Also, I don’t think it was meant in a hurtful way.) I don’t think there is any reason for being angry at me…

I haven’t said that either. I’m cool, bro

1 Like

C++ does not receive Python code directly; instead, “bindings” are created to allow C++ to call Python or, more commonly, Python to call compiled C++. This is done by embedding C++ code into Python as extension modules to improve performance, or by using a C++ library from a C++ program written in Python.

1 Like

I did some work using FFI. At least in theory, in Python, the overhead for callbacks cannot be avoided, which is the “safe” equivalent of Haskell ffi. At the same time, the other Python threads are allowed to run regardless.

All this means two good things for the user: it’s a simpler mental model (you don’t need to think about callbacks and memory), and it is predictable, no big surprises.