Java to c++ is hard

preview_player
Показать описание
Reprogramming game engine from java to c++. Thumbnail is it actually working right now.
Рекомендации по теме
Комментарии
Автор

C's better. BTW uur a nerd L + Ratio. PIn LOL jk unless?

noathan
Автор

"NullPointerException" to "Segmentation Fault"

premiumshiptosts
Автор

Always impressive to me when people create their own game engines. Writing a modern game engine is a monumental software engineering task. C++ is a pain in the ass to write and work with but it underpins everything in computing and is a true computer engineers language. Some people don't like when I say that but its true. Python, Swift etc are all programmers languages. You can do almost anything in modern languages but when you want to build something completely custom, that has never been done before. Its C++.

I work in the games industry and C++ is what we use. One of the projects I worked on along time ago there was a core design flaw from the game designers and gameplay programmers where how they set it up they had hard references to all the game assets and then they were called using macros etc. It worked well in the arcade setting where they were there was a dedicated ram space so there wasn't a lot of delay between loading from disc, loading it into ram and then it would just run the game out of ram for however long the cabinet was powered on.

When the company wanted to port the game to console though, it would have taken a full rewrite of a lot of the games code to take into account what assets needed to be loaded and when because consoles "had" way less ram, the Playstation 3 only had 256 megs of system ram and 256 megs of video ram; then what 20, 000 dollar arcade cabinets would usually have at the time. One option was to compress all the assets and just run it like normal but that would effect the graphical fidelity of the game right? And some compression will probably be necessary regardless but lets try to pull this off with as little change to the raw assets as possible.

The senior software engineer was like, lets write a custom asset loader that we will load into the "Instance" on memory before the main game is loaded into the console. Then we can emulate the asset calls from the game.exe and convert it to ps3 load instructions, that way we can write just a few lines of code into the game files to export what level it is currently on and trying to access to our custom loader and the loader will then reload or deload files based upon this directory/API system that we will write. That way the core game code will think it still has access to all the files it did on the arcade hardware but it actually doesn't and is being loaded from disc and its not going to crash.

I had no clue how to do this, no clue where to start, there was no stack exchange till 2009 and even then it wasn't what it was today. Sony was a pretty good help providing some instructions on how to write software for its custom version of Linux they were running but that was it. We just had to write code and C++ in this environment is the language. You have total control over the hardware that really no other language has; well that is actually still maintained and documented as well as C++ is.

And it worked and the game ended up shipping on PS3. That moment was the first time in my programming career where I really saw first hand what a powerful language C++ can be. Althrough I would never really pick it as a primary language for a solo project, just do to the difficulty and skill required to design a stable C++ application vs a modern language. When you really need full control of a system its the one to go to. Its why I encourage young people who want to be software engineers to still put C++ into their toolkit.

Because of the power, flexibility and speed of C++, its used in games, Earth and Space Exploration (Even the current Mars Perseverance rover's embedded systems are written in C++), it underpins operating systems etc.

Fighter
Автор

I have been coding in Java for the past like 6-7 years in my free time, and this is so relatable. The amount of shit Java does for you is insane. In C++, you have to do everything yourself, and it's pain.

pladselsker
Автор

I did the reverse a couple of times in my work: converted C++ quantitative models to Java (a long story why we had to do it, but..). That's when I learned you can NEVER make a well-written C++ library/application converted and run as fast in Java. Not even close. The best you can do is 2x as slow. All the locality of memory access of a well-written C++ code goes out of window with Java.

rdman
Автор

Youtube algorithm brought me here.
It must have read the title like
"Porting my game engine from java to C++ challenge if it crashes, the video ends"

ptimou
Автор

"Get on RUST bro... Hey bro get on rust... Get on rust bro"

moistoyst
Автор

C++ for java devs: what the fuck is pointer?
java for c++ devs: well, how do download all that shit and why so many directories?

Gameplayer
Автор

This video shows very clearly how sometimes even after spending days on learning something you will still be at a point where you pretty much don't know anything about it

Ayushkumar-scix
Автор

I was like okay meh... then that ending I just burst out laughing.

ghosthunter
Автор

Python was super easy to learn. But it was very confusing going to C++ and not having so many easy functions and things I used so much

ghost_ship_supreme
Автор

you either start with c/c++ or never understand it fully

Lutz
Автор

honestly, amazing tech demo. the way the model rendered at 283 fps on that intel integrated graphics card? shut up and take my money

le
Автор

Dude your game engine is so cool look how many features and errors it has! Can i learn from you (Nah)

kryptermusic
Автор

As a non c++ programmer i should try this!
I really love seeing Debug Assertion Failed
Couldn't be that bad right?

DeveloVooshGWeb
Автор

for anyone thinking about learning c++, unless youre wanting to do it for getting a job and nothing else, I really really recommend choosing rust instead. It's just as fast and fixes many of the problems of c++, and has better, modern language design and tooling.

theroboman
Автор

Here's how you do it: install GitHub copilot, put a comment "translate this Java code to C++" on the top, and then let the copilot do its thing

kassiepovinelli
Автор

Dun-goofing with iterators is just part of the learning curve 🙃

bitshift
Автор

You can choose to write everything the same as you would in Java, it is your choice if you tried to make it more complicated. Even for garbage collection you can use smart pointers. Assuming that I don't use any java libraries that whose counterparts don't exist in C++ I see no reason why you wouldn't be able to rewrite your Java code into C++ code.

smrtfasizmu
Автор

Me as a C++ developer can say that C++ is annoying, but not AS hard as people think. You just need to always use smart pointer, this fixes most of the runtime errors. Ye but there are really stupid things in the language, for example the linker errors are insanity.

CXCubeHD