Mindwerks / wildmidi

WildMIDI is a simple software midi player which has a core softsynth library that can be used with other applications.
https://github.com/Mindwerks/wildmidi
Other
199 stars 40 forks source link

Pros and cons to moving to a OOP platform ... #184

Closed chrisisonwildcode closed 3 years ago

chrisisonwildcode commented 6 years ago

I have been looking at switching to c++ at the least maybe even c#, one as a learning platform but also to allow wildmidi to progress into its fullest potential. My main concern is backwards compatibility. So lets discuss and inform on the pro's and cons of moving to an OOP platform please.

sezero commented 6 years ago

I don't see what c++ would bring to the table for wildmidi.

As for me: I know very little about C++, and nothing at all about C#, so I won't be able to do anything with wildmidi if such a switch happens.

For me, priority should be fixing the existing bugs and keeping it in plain C.

Ghabry commented 6 years ago

I'm not part of the Wildmidi project but in my opinion there is no direct reason to switch to C++. Can you proof that a C++ switch would increase the productivity when improving Wildmidi? When you want to keep the old C-interface (Otherwise you generate work for all projects that depend on Wildmidi) you actually have to do the work twice: You need to create C++-Classes for OOP and you have to write a C-interface that wraps the C++-stuff in a way that is compatible with the old interface. Switching to C# is a bad idea because it makes the code almost unportable. You need an extra runtime (Mono) to use it which only runs on the major platforms und is heavy. I would take another library when this happens. Instead better write a binding to the C-API (the technology is called P/Invoke) or use a SWIG interface spec to generate bindings for other languages.

psi29a commented 6 years ago

I am against C#, not on principle but because of the requirements in order to run... meaning it isn't portable enough.

C++ on the other can be interesting, but I would see that as a fork of the project.

I'm fully committed to C usage for this library, there's nothing wrong with C for such a simple library.

afritz1 commented 6 years ago

If switching to C++ (or adding a branch) was on the table, I would recommend using no less than C++11. However, I have a tiny bit of experience developing for the 3DS, and it only supports C++03, so that may be one barrier to switching (otherwise you may have to look to libraries like Boost).

One point of modern C++ is zero-overhead abstraction, meaning that code using standard types and containers will compile down to something identical to the equivalent C code, while at the same time being safer and easier to maintain. In some cases performance may even be better because the compiler has more information to work with.

It really depends on how much you plan on leveraging features like enum classes, lambdas, standard library types/functions, and for-each loops. Also, since lambdas are implemented on the stack, one can frequently do functional programming in C++ while still having fast code. Changing to C++ just for classes, stronger scoping, and type safety is not really the point when there's a whole list of standard tools available for everyday use-cases.

sezero said: For me, priority should be fixing the existing bugs and keeping it in plain C.

psi29a said: I'm fully committed to C usage for this library, there's nothing wrong with C for such a simple library.

These are both good reasons to continue using C for WildMIDI. I'm not pressuring you to use C++ at all. As a side note, I like C# but I would not recommend it here.

Maybe if I want a break from my own project I'll look into a C++ fork of WildMIDI, but it might be a little pointless depending on what everyone's goals are (i.e., whether you want to support 3DS and < GCC 5).

Ghabry commented 6 years ago

No idea what the official Compiler of Nintendo is but at least the devkitARM homebrew Compiler for 3ds is GCC 7.2. I already ported c++11 code to it and worked fine. Even gcc 4.8 supports a subset of c++11 already so using it is quite safe by now.

psi29a commented 6 years ago

We've been using C++11 for awhile now at OpenMW, I've been fooling around with C++14 an 17 (to remove dependency on Boost). That being said, I don't see how moving to OO (regardless of language) will solve any problems with WildMIDI.

We could start taking advantage of C11 features that could benefit WildMIDI however. https://en.wikipedia.org/wiki/C11_(C_standard_revision)

rofl0r commented 5 years ago

linus' take on turning nice C software into ugly C++: http://harmful.cat-v.org/software/c++/linus

sezero commented 5 years ago

linus' take on turning nice C software into ugly C++: http://harmful.cat-v.org/software/c++/linus

Oh yeah.

sezero commented 3 years ago

This is a WONTFIX