Rust newcomer from OOP (Java)

I am coming from Java with no real C/C++ experience. I've been reading up on Rust and like so many others I've read/heard, it changes the way you write's amazing.
But, I'd like to delve more into it so I can develop apps for work. I'm not a full-time programmer. More of a hobbiest that programming has been incidental at work...who doesn't love getting paid to learn and test code!
While learning the basics of Rust, I find myself being pulled back into the OOP mindset. I need help to separate. So, one idea was to start converting my current applications from Java to Rust. But, my programs rely heavily on JavaFX GUIs. In my view, Rust is perfectly setup for E-C-S. I've been looking at OrbTk to convert to, but ECS is new to me. Coming from OOP I'm having to unlearn OOP to understand ECS. Does anyone have any recommendations for articles, books, etc. that's "ECS for Dummies Coming from OOP" that can step-by- baby-step help not just learn, but UNDERSTAND ECS?
I apologise if this has been asked numerous times.

There are some really good videos on YouTube about ecs. To me, the best way to unlearn a way of thinking that I find myself stuck in is to listen to other people who just went through the process themselves and have arrived on the other side.

I've seen a fantastic presentation where a guy talks about an RPG he was trying to make, for years, and he talks about the issues he ran into with OOP -- and how ecs not only solved a bunch of those issues but also made his code far more maintainable (meaning he could experiment a lot more without having to refactor class hierarchies and such).

Unfortunately, I can't find the clip right now. I even think I posted a link to the presentation on these forums before, but I can't seem to figure out how to use the search function. If I find the link later I'll edit this post and add it.


Do you mean this: IRDC US 2015 - Brian Bucklew, Data-Driven Engines of Qud and Sproggiwood - YouTube


Yes! That's the one -- thank you!

1 Like

Thanks! I'll have to check it out!

I've tried searching for ECS on YouTube, but I must not searching correctly. Most stuff I find is more intermediate level. I need something real basic.

First of all, I have heard from a lot of people that it is harder to rewrite something in Rust because the structure of your old program will most likely not be easy to recreate in Rust. For example, you most likely have a lot of multiple ownership in the original code base. I would either choose to solve a new problem or resolve the old problem without looking at your old code base.

Second, Rust doesn't have many OOP concepts, but Traits are kind of like Interfaces except more flexible. For example, you can implement a Trait on an existing type. If you make a new Trait, you can implement it for Vec. Or you can implement Traits for complex types like Vec<Vec<i32>>. There are other differences but I will not go into them here.

Third, I haven't heard of ECS used outside of games. Also from what I have heard GUIs in Rust are tricky. There aren't many libraries for doing it. And most of them are wrappers around existing libraries in different languages. It might be better to start with projects that don't need GUIs.

1 Like

Speaking as a "Rusty old man" myself I find this question faintly amusing. Bear with me whilst I try to explain why:

I was first introduced to programming, in BASIC God forbid, in 1974. The following year we were expected to be familiar with assembler.

Of course there was no OOP in this picture, no classes, no objects, no structs even. Only arrays. Two dimensional if you were lucky.

So what did we do when we wanted to write a game or some such that had a bunch of conceptual objects, like players, planets, aliens etc, that had many properties, like (x, y) coordinates, velocities, masses, weapons etc?

The only thing we could do. Define a bunch of arrays to hold all the properties of all those "objects". X [
] and Y[ ] for positions, V[ ] for velocities, M[ ] for masses and so on. Then every "object" in our programs got an ID which was basically an index to be used into all those arrays to find out what it was and perform processing on.

As such, I was never sold on the OOP model. Where everything is an object of a class, perhaps derived by inheritance from something else for whatever reason. Classification is hard to get right, never mind inheritance trees. Languages like Java are the peak of this madness where it's not even possible to write code as we used to, with free functions and arrays (As far as I know).

Only in the past couple of years do I find that people have started to question the OOP model. Usually after finding that they are in a mess after years of development.

And then I find the game devs have been ignoring OOP and doing what we did back in the day. For performance reasons.

The amusing part for me then is that what was "normal programming" now has a fancy name "Entity Component System".

Of course I hope "ECS" includes more than we had. For example managing the creation and destruction of said entities. Back in the day we just made arrays "big enough" and recycled elements as best we could. Also I suspect there are easier ways of programming such a thing with a modern language like Rust, I have yet to look into that.


I have to respectfully disagree to a small extent.

  1. Absolutely it's difficult in the beginning of learning a new language to rewrite from one language to another. But, correlation and failure provide some of the best learning. It depends on if you're up to the challenge. Also, be rewriting from a common language to a newer language helps promote the new one.

  2. Totally agree...Rust is not really OOP because of interface inheritance or composition. But, I as I delved more into the subject of inheritance, I realized, I already write my Java using interface inheritance up to the point I refuse others' code like JavaFX.

  3. Check out OrbTk. It's written using ECS concepts. They took the idea from the gaming industry and said "hey it works here, what about in Rust's way of doing things?" From what I've seen, it totally falls in line with Rust's composition and interface inheritance. But, that's where I get stuck....the full understanding of entities, components, states...I think I have a crude basic understanding. I watched a video on YouTube on the data-oriented implementation of a gui by using ECS concepts and why it was chosen but I could only grasp portions of it. I attribute that to being out of touch with programming for such a long time and coming back to it....think BASIC, Pascal, MSDOS 3.3, etc.

1 Like

To me the best resource is Herbert Wolverson's roguelike tutotial. It teaches ECS and is aimed at people new to the language.

I think this is also relevant, they talk about the fact that the video and blog post describe a data-oriented design more than ECS.


That is kind of my point. Why make things more challenging for yourself? My advice would be not to look at the old code but to just try to recreate the functionality.

THANK YOU! I had not heard of this. This looks promising. I have been planning to build an app that would use rust for core logic but than use something else to do the UI. Maybe even having to use different languages/frameworks for different platforms. OrbTk might allow me to just write it all in rust.

I wouldn't worry about it. Not many people understand ECS. It might be an old idea but it is newly popular. Also frameworks aren't easy to learn.

1 Like

YES! Totally check out Orb! It's all Rust and from my understanding, used to build Redox-OS, a basic OS made from Rust.

There's definitely cool projects out there built on Rust, and I see opportunity for some projects I've been trying build. I was about to get into C/C++, but I like how the compiler is (annoyingly) helpful in guiding safe coding.


Just WOW!!

This was EXACTLY what I was looking for!

Thanks so much!

1 Like

A post was split to a new topic: Performance of OrbTK

This might also be a good video to watch

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.