Jumping from processing to c++

Hi there, i want to start learning c++, in the past i studied it, but felt that it was very complicated, and get frustrated. Then i start learning processing and now i think that i have good knowledge, and understanding of most of the concepts of OOP. My question is, what are the similarities between processing and c++, and what resources did you recommend me? also, the main function in c++ is the equivalent to the draw function in processing?
Thanks!

2 Likes

sure you know that the way to a GUI window is much longer
as with processing
but that is the interesting thing,
if you want to fly over my first steps about this
you might see some ideas how to begin:
beginner C++ to GUI (on RPI )

that is not a tutorial, because i not know any of that languages,
it is a LOG what i try,
the whole idea was that i needed to get a overview what is possible
for entry level linux / languages-compiler but with the interest to learn GUI

the specialists at the RPI forum are hardcore terminal users
and the internet is full of terminal hello world examples…
but getting / making a operable window seems to be same unsupported
like with windows.

2 Likes

this looks really nice. i’m gonna try it.
Thanks!

Similar to Processing but in C++: https://OpenFrameworks.cc

Although nowadays they claim learning Rust is better: :gear:

And it seems there’s even a somewhat Processing Rust crate for Processing: :card_file_box:

3 Likes

Rust is a good call! Definitely worth considering instead. There’s also https://github.com/nannou-org/nannou for Rust.

Can even run Rust (along with C/C++) on the JVM these days :laughing: https://www.graalvm.org/docs/reference-manual/languages/llvm/#running-rust

3 Likes

As @GoToLoop mentioned, openFrameworks is the C++ equivalent to Processing which uses Java. The OF Book is a good place to learn: http://openframeworks.cc/ofBook/chapters/foreword.html

openFrameworks, like Processing, also comes with many examples that you can run demonstrating different features.

BTW, openFrameworks also provides setup, draw (and update) methods.

I spent the last two years developing an app in OF. I found that doing experiments in OF easy, but going further to develop a real app and learn modern C++ takes some time.

In my case it was more than a year even if I knew Java and many other languages. The good thing is that I learned much about lower level graphics and memory and I could write programs that ran without skipping a single frame at 60 fps. I found doing vector math very nice with operator overloading (writing a+b*c instead of PVector.add(a, PVector.mult(b, c)). Also nice was that you could ctrl+click on any OF function and see its source code (and even change it, if you dare), so there’s a weaker distinction between your code and the framework.

C++ has existed for decades and there are many versions. Things were done differently in different decades. For example old programs often use raw pointers, but in recent versions of C++ they are avoided in favor of references and smart pointers, just as an example.

Sorry for the bla bla bla :slight_smile:

4 Likes

Many thanks, I saw through the first chapters of the book, and it looks really promising. And seems to be one of the best ways to start learning c++ from a processing background. I’ll be working with matrix and vectors, i could use octave, but, I see that c++ is more flexible. One of the things that never understood was the pointers and the importance of memory usage given in c++.
Thanks for telling me your experience, I really appreciate it, because now it encourages me to learn it more deeper, knowing that it’ll no be as easy as I first thought.

To clarify, the above statement is not true. Java has a main function but Processing users using the PDE with standard pde files do not get the chance to work with the main() function directly. Processing hides that from you and you get the setup and draw methods to do your things instead. If you want to see this in more detail, you can create a simple application and export it. Then search for the java files in the exported directory.

I have never used OF. In general, I would suggest to review pointers’ basic concept and do simple exercises as in the case of working with strings. You see, Java has done most of the memory handling for you when it comes to strings. In my limited experience in C/C++, the concept of a string is an array that ends with a special character ‘\0’. If you do not manage this character in string operations, your algorithm will start loading data from other memory segments. Inconvenient and dangerous from a pedantic or professional perspective. Small details like this makes C/C++ a bit harder as there is more responsibility on your shoulders and more bugs to tackle. On the other hand, drawing operation are possible in OF as well and in C. In C as in Java, there is an overhead that you need to pay/implement to get started. I like Processing because it takes care of this extra overhead and you can focus in the coding part immediately. Fast, simple and effective. My two cents,

Kf

2 Likes

That’s a cstring. And that’s what I meant with doing things in different ways in different decades. I would avoid cstring, and use std::string instead. C++11 and newer is not “that” different from Java (although this sentence would start a war among purists :stuck_out_tongue: ). I’ll say it like this: I never used “new” to allocate memory in any of my C++ projects, and therefore never had to use “delete” to release any memory.

2 Likes