4
\$\begingroup\$

I'm thinking about making a game engine, as a learning project.

I know Java the best, and I figure most of the code is not going to be running that much of the time, given the 20/80 rule. Why not write most of it in a language I know? For the part that has to be really fast, like the renderer, I was thinking of writing that in native code.

Is this approach of using two languages a good idea, or a terrible one?

\$\endgroup\$
10
\$\begingroup\$

Yes, some parts need to be really fast. Now are these part written in Java slow? Did you measure and considered that it would really be an improvement to figure out how to plug everything that needs to go fast in native language?

This seems to me like it's premature optimization. Unless you realize that these parts are really a bottleneck and that the only way to fix it is to use native code, you should not bother.

As @Steven mentioned, the transition may be very expensive.

Typically, the way to use more that one language is to use one 'compiled' language (Java, c#, c++), and one script language (lua, python, xml-based) to do some more changing stuff.

\$\endgroup\$
2
\$\begingroup\$

Writing engines in multiple languages that work together can offer many benefits, but almost always results in higher complexity and higher cost for maintenance.

For your first engine, you want to deliver a finished and working product, so the most important thing is to keep complexity down. Java is fast enough.

Another way to look at it is this: No matter how many languages you use, you are pretty much guaranteed to miss out on some clever optimizations that would make the engine one or more orders of magnitude faster. In comparison making the engine 10-50% faster by using C/C++ and SIMD instructions isn't that big of a deal. And forget about getting even close to these 50% if you don't know C/C++ yet, you'll be lucky if you can break even.

\$\endgroup\$
1
\$\begingroup\$

There are a lot of engines that work this way. The important thing is to make sure you don't transition from one language to the other too often as there is usually a cost there.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.