Right there where it says “public”. What are you talking about?
mozingo
I make games
- 0 Posts
- 4 Comments
I don’t get it. I literally write code that looks like both of these all the time. Null coalescing is cool, and very handy sometimes. In this particular case, I’d probably write it more like the left, since it’s more standard and my coworkers would be more familiar with it, but the right obviously does the same thing and I have no issues reading it.
As someone who makes indie games professionally, I taught myself how to program by making video games. Maybe it’s just my adhd, but I have a difficult time with organized learning, but I pick things up really quickly by doing. I wouldn’t get too caught up in the “I need to learn it the right way before I make games” part, since the making games part is exactly what kept programming interesting and engaging enough to prevent me from getting bored.
Second I also wouldn’t get too locked up trying to decide which programming language to use. Modern programming languages are all conceptually pretty similar. It’s really only minor syntax differences. Learning a new programming language is mostly just a matter of “how do I write a for loop in this language again?” It doesn’t take too long to adapt.
I use Unity and C# right now, and I’m in the middle of learning Godot to make the switch. I would generally agree with what other people have said. C# is a pretty good language to start with. Just low level enough to make sure you learn fundamentals without being so low level that you have to fiddle with memory addresses and pointers like c/c++.
As for codecademy, I tried it when I was first starting out like 10 years ago, so I can’t vouch for it now, but it seemed to very much be “Learn how to type code” and not “learn how to actually program.” Just explaining how to write if statements and for loops isn’t really teaching programming. I still don’t think there’s really a good universal way to teach it, even after taking programming classes in college. Everyone sort of picks it up differently, at different paces, and enjoys different parts of it, so I still think picking a project you think sounds cool and finding and following along with YouTube tutorials and just trying stuff out until it works is a pretty good way to get started. You can always take the time to read a book or take a course after you’ve determined if programming is even something you’re vaguely interested in.



Idk. Depends entirely on what kind of code you’re writing. Singletons are extremely useful patterns for video games, for example. There should never be multiple instances of classes that handle things like game state, achievement unlocking, display/resolution managing, etc.
If they didn’t enforce their own singletonness then you’d have to always launch the game using the exact same startup routines, to ensure that only one of each ever gets instantiated. But game engines typically divide the game into something like “scenes”, which logically divide code and assets to only what’s relevant for that area of the game. When testing a specific level/area/scene, It’s extremely handy to have a singleton class exist in every scene, that acts as that startup routine, so you can start the game from any scene, and when you load in another scene through gameplay, the singleton class itself makes sure no duplicates exist, instead of having some kind of manager that keeps track of all that (which itself would also have to be a singleton, so you’d just be kicking the can down the road).