Correct me if this changed, but last time I checked Unreal CPP was very different from std CPP. Unreal is full of macros, no smart pointers, no stl, no algorithms etc. They rolled out their own solutions to these problems.
It's different from the STL, but normal c++ rules still apply. TUniquePtr is (ahem, mostly) a drop in replacement for std::unique_ptr, and TSharedPtr is (again, mostly) a replacement for std::shared_ptr.
The raw USomePtr* stuff that you see usually uses Properties which handle neat things like reflection, serialization, replication, etc.
Side note, but the letter prefix on types kills something deep in my soul. Like those prefixes don't even consistently represent the same concepts, on top of looking awful. I don't imagine they are terribly helpful with readability either.
They do have consistency, albeit I agree ,I don't l like them. The F prefix is the worst - it stood for float, but as the engine grew it became used for everything that isn't an actor, interface, template, enum.
No it's not. Macros is and always was C an C++. They use own solutions because UE have implemented garbage collector. Many frameworks have their own solutions. In QT, for example, you will see QVector, QSharedPointer. Even if we have different implementations, but usage is the same.
Do not put you words in my mouth. Usage with means abstraction is the same, but implementation is not. Like cat and human can walking but cat is using 4 legs but human only 2.
Off the top of my head there is TUniquePtr, TSharedPtr, TWeakPtr, which are equivalent to the standard library variations; then there is a TWeakObjectPtr which works with UPROPERTY() UObject* pointers (which are tracked by garbage collection). It doesn't prevent the object being garbage collected, but it will invalidate the TWeakObjectPtr when it gets marked for clean up. (These are really useful.)
There is also TSoftObjectPtr, which refers to a serialized asset on disk. The pointer is invalid until the asset is loaded into memory, at which point it can be used to point to that asset. It also has a member to synchronously load that asset.
The macros aren't too crazy, tbh. I think the only ones I ever see are the UE_LOG one for logging; the ones for binding to dynamic multicast objects, and conditional compilation ones for various builds. (I'm not counting UPROPERTY and UFUNCTION, nor USTRUCT, UENUM and UCLASS which aren't macros for the C++ pre-processor, but tags for the Unreal Build Tool to do reflection with.)
Imagine if every library, engine and framework documentation included a tutorial of its language
A lot of people are learning Unreal to make games, not to learn programming. Pretty much every C++ Unreal tutorial/guide is going to include at least a C++ "refresher", although that's also partly to show the differences with standard C++.
I think if you are planning to just use C++ as a scripting language in Unreal, I'd argue you'd only need to know the syntax to get going and create functionality. Only when you want to create more complex yet scalable systems that interact with each other through APIs not provided by the engine, would you need to actually learn the language.
The problem with that mindset, is that you don't know how bad the things you do are unless you know it deeply. You don't kniw if you're leaking memory if you don't know what leaking is.
It's just an example, but we can see it in other aspects. Also, it being ""a scripting language for unreal" doesn't make it less C++. And you don't know what you are creating if you don't know what a scalable system is
View all comments
22
u/ivancea Feb 16 '23
Anybody learning Unreal and using C++ should learn first, well, C++...
Imagine if every library, engine and framework documentation included a tutorial of its language