DOTS and the future of C# in Unity

The reason for this thread is to express my general feelings about the direction Unity is taking and maybe get some clarifications from the more informed part of the community.

Have to admin I’m yet to try digging into ECS and Jobs and trying to make some prototypes using them. Still, I’ve been watching the latest features in Unity 2019.x and their roadmap on GDC and I’ve got a strong impression that Unity considers the old GameObject system as “legacy” and really pushes DOTS hard as the one and only way of coding in “Unity 2.0” (newest features require DOTS etc.). I understand all the performance and scalability benefits of ECS/Jobs, so no need to explain it here… It’s beside the point.

They marketed Unity from the start as the tool to “democratize game development”, meaning the barrier of entry must be very low. For me personally probably the main selling point of Unity was it’s easy-to-use and easy-to-understand MonoBehavior system. It’s a bit messy, yes (as I’ve now discovered), yet it was still way ahead of how most people made games before - strongly (over)using OOP with huge ugly inheritance trees etc. Here I could clearly break my game into self-contained components, so in effect I got a nice ECS structure with small SOLID classes.

Yes it arguably wasn’t a true ECS (code and data is not explicitly separated into different classes), but I’ve arranged groups of related MonoBehaviours and learnt to think about them as “systems”. For example you could have a Pickup behavior and an Inventory that you add to your player. Together they form a “Pickup/Inventory” system that’s pretty well defined and separated. The only problem was that the system had to be “smudged” between all related components somehow and unless you have a strong convention for this, you can make a mess.

Nevertheless the old way allowed me to use the full power of C# with it’s wide assortment of existing tools and libraries, strong features, etc. It really allows you to think less about implementation details, more about WHAT you want in your game. That’s to me the whole point of “democratized development”. It should be easy to hack together a simple game. All you had to do to make it performant enough is to make sure your garbage collection is under control, that you don’t produce anything in every frame, that kind of stuff.

Now here’s where I see a problem with current trend. If we go full DOTS with HPC# instead of the old C#, completely moving into the territory of “performance by default”, Unity will lose it’s main selling point and the main reason people started using it in the first place. Easy prototyping, high productivity for making smaller games.

I want to remind that maybe 99% of Unity games are simplistic Mobile games that will NEVER have 10000 objects flying around the screen and interacting in a complex way etc. They maybe have 10 characters at most, 50 dynamic objects, some static background - that’s it! More just doesn’t fit to the mobile screen and doesn’t make sense for most types of games with 3 to 5 minute play sessions. I’m all for huge battles and complex visual effects in high-end PC games, but it should not be forced!

IMO, the best way for Unity moving forward (I mean the future, after DOTS is 100% integrated) is to keep focus on normal C# way of coding, with DOTS support being optional for those who actually need it. Also in most games I think both systems should seamlessly coexist. The “hybrid” mode shouldn’t be considered as a temporary solution, a “transition” phase. But a legitimate way of balancing between productivity and scalability of your games in those critical places that actually NEED this “highest possible performance”, NOT in the whole game!

I’d be personally happy if I could use ECS with old Vector3, Quaternions etc. but without all the crap that MonoBehaviors have in their bloated base classes. And occasionally inject some hard-core HPC# Jobs for specific systems like special effects, bullets, etc.

1 Like

You realise you are basing your opinion on an unfinished system? There are powerful and easy to use editing tools coming, just look at the preview videos of “Project Tiny” for a glimpse of what is coming soon.

I fully trust that Joachim and his team share your concerns and want the barrier of entry to be low, and easy to use. Give them time to deliver that vision :slight_smile:

The first step is to deliver “ECS Core 1.0” and then a lot of frameworks and tools will follow after that.

Regarding game objects and the old types like Vector3… personally I’m glad to see them go! In my current project we’ve even moved away from them as much as we can. You can totally use the new types like float3 without ECS or even Jobs.

2 Likes

ComponentSystem already does this. It has full C# support and runs on the main thread, but doesn’t have the bloat of MonoBehaviours. Most prototype MonoBehaviours can be one-to-one mapped to a ComponentSystem, IComponentData, and an IConvertGameObjectToEntity. Sure, the expansion from 1 thing to 3 things might be intimidating, but those 3 things are really just different #region s of a MonoBehaviour put into different types. It’s maybe 12 additional slocs?

I also heavily recommend paying more attention to Project Tiny. While this forum is tackling DOTS from a performance perspective, Project Tiny is tackling DOTS from the other direction with a focus on ease of use and rapid game dev and iteration.

1 Like

No one takes away the ability to code in OOP and with game objects. If you don’t care about performance or the battery life of the mobile devices, you can go nuts with the “old ways”. For the rest of us, there will be a more performance-targeted system to use.
Other than the Unity Physics what " (newest features require DOTS etc.)" do you mean by this exactly? If you stay on GOs and OOP, you don’t need it. You can go with the PhysX as usual. They’re working on the PhysX 4.1 as well.

So I really don’t understand what would be taken away from you exactly?

You clearly haven’t read my entire post or haven’t got my point. Right now sure they allow to use GameObjects and C# during transition. What about in 4-5 years? Will we see C# gone and have to write 100% of our code using HPC# instead? Ultra-high performance is great, but in the same vein one can recommend to write your entire game in Assembly for “performance by default”. Is it practical? Probably not.

My point is there are critical parts of games that really benefit from this optimized way of coding, but I think probably 90% of code is something that’s executed occasionally. UI events, various game triggers, etc. All this code could still use full C# for high production speed without sacrificing to much “battery life” or overall performance because of it’s non-critical nature.

I get it saying OOP is shit is considered cool on this forum, but in practice, all paradigms have certain applications. Trying to implement complex modern application (which games are) in just a single programming paradigm - might be really bad idea in the long term. I’m not defending the way MonoBehaviors are made (they are bad), but people use inheritance a lot in a non-MB context all the time.

Project Tiny seems like another castrated version of Unity. It’s a great idea for web and low-end mobile games, but kinda the opposite of what I want. That is a powerful game engine that allows me to iterate fast while using all of the modern features and all of the power of C# with it’s libraries etc. No 3rd party C# code will even compile in Burst!

I did read your post, but you clearly don’t read the forums, because Joachim and other Unity engineers and evangelists stated multiple times that retiring Monobehaviors and/or the OOP isn’t and won’t be on the table any time soon.
So you’re fighting with your own imagination. No one wants to take away it from you.

BTW, I share your view on the ‘use every paradigm for the problem it fits the best’ wholeheartedly. But OOP is shitty from performance point of view whatever we do. It’s okay to develop the main menu and some other auxiliary parts in it if you need performance, the rest has to go to the DOTS part. If it does not matter (prototyping) also can go to OOP. You shouldn’t reuse the code regardless.

WTF? Of course, they won’t. Burst solves a problem for a narrow subset of C#. No virtual calls. So you can throw away 90% of all libraries right away. You cannot keep your cake and eat it at the same time. If you use OOP and all what comes with it, you shouldn’t expect great performance (there is so much you can do about it). Software development does not work like that. And BTW, even if you work in OOP, when you write your game’s tight game loops, it’s highly advisable to steer away from these things, use as much static linking and simple function calls as possible instead of an elbow-deep class-hierarchy and reflections.

1 Like

Calm your digitals. ECS/DOTS is not replacing anything and monobehaviour is staying. So I guess the thread’s done.

3 Likes