C V.S. C++ should I learn C or C++

I've been trying to figure out a way to learn C and it's gotten me very confused on what the difference between C and C++ are. Also can you write in both C and C++ on the playdate? Which should I learn?

officially C unofficial c++ does exist using playdate-cpp repo on github. Historically C existed before c++, c++ adds classes, polymorphism, all kinds of other handy things in the standard library like vectors, maps etc and a lot of other extensions over C but playdate officially only supports C and lua. Most people code the games in lua. While playdate-cpp does work, there is always a chance an sdk update might break it, and this had been the case for quite some time with the REV B changes to the sdk but it's all been fixed but that does not mean it could not happen again. If you want to be sure things will always work use either lua or c

Full disclosure of my biases

I'm a maintainer of the playdate-cpp and playdate-cpp-extensions open source projects, so to answer one of the questions you asked directly:

Yes, you can write in both C and C++ on the Playdate.

With the extensions library, you'll barely need to interact with the C API at all. Start there and look at the examples if you're curious.

If the SDK releases a breaking change, there may be latency in support, but those projects both endeavor to keep up with Panic, and we'll try to keep the latency as short as we possibly can. After all, we want the latest and greatest too.


An actual attempt to answer your other questions without bias:

What's the Difference?

A lot of confusion between C and C++ comes from the idea that "C++ contains the C language," which is true, for the most part. Basically, as @joyrider3774 points out, there are a ton of constructs built both into the language of C++ and its standard libraries that are exceptionally useful and make life easier, but if you're compiling C++ you can still write C syntax if you have to. This is not the case the other way around.

Which should I learn?

Let me be the person who answers questions with a question: with what languages are you most comfortable today?

At this point, well-written C++ code looks nothing like well-written C code, despite the fact that you can write C in C++, so the transferable skills between the two languages start to become quite abstract. However, if you know other languages, there may be parallels which would make picking up one or the other easier, and any suggestions will be more useful.

What would I pick in a vacuum:

General guidance, pick the one that lets you write less code.

I really like C as a language, and Panic's API is exceptionally friendly as C APIs go, but C requires you to write a lot of code, and the more code you write, the easier it is to write bugs, particularly if you're just learning a language. I don't find bugs particularly great fun to find/fix, and even less fun to find/fix the more code there is.

That is the key compromise to Panic's Lua API, and the reason they encourage people to start there: it takes care of the obnoxious bits, and allows you to write less code. You'll take a tradeoff in performance, but you'll write fewer bugs, and getting your ideas out will be easier, so you'll have more fun.

Thinking in those terms, C++ makes a similar compromise with different ratios: you're going to write more code than you would in Lua, but still far less than you would with C, and IF you do it correctly, you'll get the performance of equivalent C code.

C++ is an object oriented language, it allows you to create classes (for example: Player, Monster, Equipment, Sword, TitleScreen, GameLoop, etc.), and define what they do and how they interact together. You can create parent and child classes to define common behaviours. Memory management is also a bit easier in C++.

There a lot of other additions as well (operator overloading, parametrisation, abstracts, constructors, vectors, iterators, etc.) but it would be too long to detail here.

However, I really like C. It is the base of a lot of modern languages and learning it should help you understand how memory is handled by modern languages. If you are really new to programming, I think it is a better choice. It has a softer learning curve (in my opinion) and may be easier to start with since it is fully supported by Panic.