Do you ever think of developing in other languages than C++?
-
- KVRian
- Topic Starter
- 1097 posts since 28 May, 2010 from Finland
I don't like C++. It's unnecessarily complicated.
I'd switch it to a higher level language such as C# or even Python, if it was possible.
Do you ever think of doing VSTs in another language?
I'd switch it to a higher level language such as C# or even Python, if it was possible.
Do you ever think of doing VSTs in another language?
- KVRian
- 1324 posts since 15 Nov, 2005 from Italy
phyton is a scripting language, while C# is interpreted (not compiled). I don't think any of them would be suitable for commercial plugins, even tho C# is actively used for game programming and phyton for sound design / research software.
my 2 cents,
Luca
my 2 cents,
Luca
-
- KVRian
- 853 posts since 13 Mar, 2012
No, multiple reasons for it:Fluky wrote: Do you ever think of doing VSTs in another language?
- Foodprint. My VST binaries usually have size of between 200kB and 800kB.
I just see no point on forcing the user install 100+ MBs of .NET framework, python interpreter+libs ect to run that little binary.
- Peformance (high level)
While one could argue that C# can reach faster integer-calc performance than C because of JIT compilation, hotspot optimization, ect.... this kind of features are a no-go in DSP because they come with a cost: a lot of management overhead.
JIT compilers, garbage collectors, ... this is all stuff that leads to an (even more) unpredictable behavior when it comes to timing. Your FFT needs to transform that block in time.. not like, the first transform will take 1second because we need run JIT'n'stuff first.. be next will be MUUUCH faster (unless grabage collection runs at the same time .. -.-)
The best thing you can have for DSP is a real-time system. Code that runs on a framework like .NET or Java, with JIT, garbage collection ect enabled, is the exact vice versa of a real-time system. It is unpredictable in every regard when it comes to timings.
- Peformance (low level)
Some DSP coders like to use low-level CPU assembly instructions to speed up certain things.
Try to run SSE/NEON/AVX/... code from your python script
~~ ॐ http://soundcloud.com/mfr ॐ ~~
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
C++ is the definite best language for lots of things: performance, modularity, efficiency, big applications...
That being said, C++ is not the best for prototyping, and the learning curve can be steep, depending on the target (pure templates code would be harder than dynamic polymorphism-based apps).
That being said, C++ is not the best for prototyping, and the learning curve can be steep, depending on the target (pure templates code would be harder than dynamic polymorphism-based apps).
-
- KVRian
- 908 posts since 10 Jan, 2010
you might be able to get away with a mix of python and C++, but i don't know if i'd recommend it.
python is actually use a lot in the scientific and 'big data' analysis communities, _but_ most of what they run isn't _really_ python... one big strength of python is being able to use other libraries natively, and the reason python is good at numerical analysis is the C++ numerical python (numpy) package.
without the C++ acceleration, python is almost always much, much slower (up to 100x slower) than straight C++, but it works.
It's not a bad model... parts of the code that need optimized go to the fast but more difficult (and dangerous layer, parts that don't need the performance can be implemented in a higher-level, easier to program language (like library management maybe - python makes it dangerously easy to create an sqlite DB on disk, for example). but I'd imagine that in a VST, nearly everything is on the critical path, and it is a lot of overhead to include the interpreter.
python is actually use a lot in the scientific and 'big data' analysis communities, _but_ most of what they run isn't _really_ python... one big strength of python is being able to use other libraries natively, and the reason python is good at numerical analysis is the C++ numerical python (numpy) package.
without the C++ acceleration, python is almost always much, much slower (up to 100x slower) than straight C++, but it works.
It's not a bad model... parts of the code that need optimized go to the fast but more difficult (and dangerous layer, parts that don't need the performance can be implemented in a higher-level, easier to program language (like library management maybe - python makes it dangerously easy to create an sqlite DB on disk, for example). but I'd imagine that in a VST, nearly everything is on the critical path, and it is a lot of overhead to include the interpreter.
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
-
- KVRist
- 327 posts since 13 Nov, 2002 from Germany, Darmstadt
Rust would be my first choice. D and Nim would be two further candidates for plugin development. I think at least one person on this forum actually developes his plugins in D.
Unlike Java C# always gets compiled before execution. (C# code gets compiled into il, il gets compiled into native machine code before execution.)C# is interpreted (not compiled).
- KVRist
- 168 posts since 19 Apr, 2014 from London
What is it exactly you find complicated about C++? Maybe you could consider coding in plain C for a while.
-
- KVRian
- 853 posts since 13 Mar, 2012
We should have brought up this point earlier .. if C++ seem to be unnecessarily complicated, why not sticking with C?Miles1981 wrote:numpy is pure C code :p
Besides performance, modularity, efficiency .. there is one more thing C++ is really good at: it allows you to make easy things, extraordinary complex.
Templates, (multiple) inheritance, operator overloading ... can be cool things, but also bring unnecessary complexity if used just for the sake of using it.
Example?
I need a sine generator...
example C++ approch:
hm.. I need add wavetable class, and wavetable class factory to init with sine, and a interpolation class, which is then used by OSC class which writes to the Amp envelope class... maybe should design a IStream interface, so OSC and Amp cna be replaced .....
example C approch:
void create_sine_samples(float* buffer, int nbuffer, float frequency, float phase);
hope you get what i mean
~~ ॐ http://soundcloud.com/mfr ॐ ~~
- KVRAF
- 7365 posts since 9 Jan, 2003 from Saint Louis MO
In my day job I write C++ and C# regularly, plus a bit of maintaining other peoples' VB and Fortran. Previously, I also worked with Java, and a couple of graphics shader languages and proprietary languages. In my hobbies I write in C and C++. Of them all I prefer C++.
But it's not something language-specific. It could be argued that C inherently discourages that kind of insanity, but C++ doesn't specifically encourage it.
Your C++ example is just overdesign (unfortunately all too common). I think Design Patterns was one of the worst ideas in the business because it leads people to think "which patterns can I use to do this thing?" instead of "what is the clearest, simplest way to do this thing?"PurpleSunray wrote:Example?
example C++ approch:
hm.. I need add wavetable class, and wavetable class factory to init with sine, and a interpolation class, which is then used by OSC class which writes to the Amp envelope class... maybe should design a IStream interface, so OSC and Amp cna be replaced .....
example C approch:
void create_sine_samples(float* buffer, int nbuffer, float frequency, float phase);
But it's not something language-specific. It could be argued that C inherently discourages that kind of insanity, but C++ doesn't specifically encourage it.
-
- KVRian
- 853 posts since 13 Mar, 2012
I haven't said that You can do that create_sine function in C++ too.foosnark wrote: But it's not something language-specific. It could be argued that C inherently discourages that kind of insanity, but C++ doesn't specifically encourage it.
It's more of what you said above - the typical C++ coder thinks like an architect, the typical C coder like a bricklayer.
Now it depends what you want to build.. if you just want to build 4 walls and a roof, you don't need an architect.. actually the bricklayer will be finished with that house while the architect is still working on the preview model.
IMHO most VST plugins fall into the 4-wall and a roof type of program.. no need for an arhcitect, just get the stuff done..
But again.. nothing directly related to C++, but more to the mindset of the C vs C++ programmer.
~~ ॐ http://soundcloud.com/mfr ॐ ~~
- KVRist
- 168 posts since 19 Apr, 2014 from London
I don't think the problem is design patterns, because they are very necessary where needed, it's simply inexperience and bad schooling.
With experience in working with arrays you will have no trouble writing code that works directly on data pointers. With experience in using the right c++ libraries you'll be able to write array-safe code. With experience and proper schooling in using design patterns and OOP you'll know when it is necessary to use each particular feature.
Knowing your std::map inserts at O(log N), meaning inserting M elements is M log N, compared to bubble insert's M*N is one thing, but then there is the wisdom to realize that this particular piece of code you are writing has relatively few inserts so you could just bubble insert.
Software Engineers are often told not to directly access arrays, instead using std::vector or std::array for built in bounds checking, plus safe inserts, which is cool, less error prone, but can cause people to go through hoops trying to adhere to that religiously where it is could / should be ignored (particularly if they have to write C code ).
With experience in working with arrays you will have no trouble writing code that works directly on data pointers. With experience in using the right c++ libraries you'll be able to write array-safe code. With experience and proper schooling in using design patterns and OOP you'll know when it is necessary to use each particular feature.
Knowing your std::map inserts at O(log N), meaning inserting M elements is M log N, compared to bubble insert's M*N is one thing, but then there is the wisdom to realize that this particular piece of code you are writing has relatively few inserts so you could just bubble insert.
Software Engineers are often told not to directly access arrays, instead using std::vector or std::array for built in bounds checking, plus safe inserts, which is cool, less error prone, but can cause people to go through hoops trying to adhere to that religiously where it is could / should be ignored (particularly if they have to write C code ).
Last edited by avasopht on Mon Apr 18, 2016 4:50 pm, edited 1 time in total.
- KVRist
- 168 posts since 19 Apr, 2014 from London
Good point, when working lower level you tend to think bottom up, high level, top down. I remember this point being made with RosAsm.PurpleSunray wrote: I haven't said that You can do that create_sine function in C++ too.
It's more of what you said above - the typical C++ coder thinks like an architect, the typical C coder like a bricklayer.
Now it depends what you want to build.. if you just want to build 4 walls and a roof, you don't need an architect.. actually the bricklayer will be finished with that house while the architect is still working on the preview model.
IMHO most VST plugins fall into the 4-wall and a roof type of program.. no need for an arhcitect, just get the stuff done..
But again.. nothing directly related to C++, but more to the mindset of the C vs C++ programmer.
-
- KVRian
- 653 posts since 4 Apr, 2010
You're not going to get the joyful blend of simplicity and power of Python (nor the slowness, fortunately), but for the "unnecessarily" part, have you tried C++11? For me, it made C++ noticeably less tedious. (Further improvement in C++14, but '11 was the biggest increment.)Fluky wrote:I don't like C++. It's unnecessarily complicated.
Of course, with the popularity of C++, you get plug-in frameworks, all kinds of libraries including templates, efficient compilers. So, a nicer language may end up a more tedious development project overall. I guess you know all this—I mainly wanted to point out C++11 improvements.
My audio DSP blog: earlevel.com
-
- KVRian
- Topic Starter
- 1097 posts since 28 May, 2010 from Finland
C++11 might be it, but in my beginning journey of programming in C++ I've been mostly just confused about the amount of structures that one must manage, compared to say Java or C#. It takes the fun out of programming having to type all sorts of nonsensical things (syntax) not related to the problem.earlevel wrote:You're not going to get the joyful blend of simplicity and power of Python (nor the slowness, fortunately), but for the "unnecessarily" part, have you tried C++11? For me, it made C++ noticeably less tedious. (Further improvement in C++14, but '11 was the biggest increment.)Fluky wrote:I don't like C++. It's unnecessarily complicated.
Of course, with the popularity of C++, you get plug-in frameworks, all kinds of libraries including templates, efficient compilers. So, a nicer language may end up a more tedious development project overall. I guess you know all this—I mainly wanted to point out C++11 improvements.