Minecraft

Pages: 1234
closed account (9jNRX9L8)
Would minecraft be faster if it was written in C++ rather than Java. Also what language would make it the fastest (apart from machine lauage).

Also, would it be possible to program a version of minecraft in C++ that could connect to other servers with minecraft Java. Like could you have a minecraft client in C++ that acted like it was minecraft in Java.
Last edited on
You assume that the language being used has anything to do with the execution speed.

Java has overhead because of the way it is compiled and executed, not because of the language itself.

You also seem to assume that C++ does not compile to machine language.

Networking is completely unrelated to programming language.
Last edited on
Would minecraft be faster if it was written in C++ rather than Java.
depends on the compiler/jit-compiler, how well the code was written, how well its optimized, and certain things on your computer.

Also what language would make it the fastest (apart from machine lauage).

language has nothing to do with speed.

Also, would it be possible to program a version of minecraft in C++ that could connect to other servers with minecraft Java
why couldnt they? its just about transfering and interpreting data. you could write it in python.

You also seem to assume that C++ does not compile to machine language.

it doesnt have to. most people use compilers and tool chains, but you can compile it to c (like the very first c++ compiler did), ruby, java, python, or php. there are also c++ interpreters.

Networking is completely unrelated to programming language.
i wouldnt say completely unrelated. true the teaching remains the same, but we use programming languages to implement some of the theories and ideas (protocols come to mind).

as to the ops second half of the post: yes, but unless mojang does it i doubt it will be done, because of legality reasons.
This is a wrong question. Languages don't automatically make programs run slower or faster. Efficiency depends mainly on the design of the program.

I've read a paper some time ago about the experiment in which a group of people was asked to develop a certain program using different languages. The problem was about string manipulation and handling lots of data mostly. It's interesting that C and C++ programs were amongst the fastest, but also the slowest. Programs written in higher-level languages were generally more similar to each other performance-wise. The conclusion was that that the main reason of this was that Python/Perl/etc developers always used high-quality built-in data structures and functions their languages provided, while C and C++ developers were more likely to create their own (even through C++ has e.g. std::map, it was rarely used). Of course those home-made utilities were usually poorly developed, not to mention they required additional development time.

As you can see, it's all about the programmers.
do you think you can find it? im not doubting you. i just love reading papers like those
o.O thats really cool
Personally I think Java is pretty wasteful on resources especially when it comes to trying to free resources. But mostly I feel that Minecraft is just written SOOO bad, if you where to put it into C++ it'd probably be just as bad even though it's running directly through machine code.

If someone went and optimised the game (or better yet just rewrite the entire thing) then it'd run so much better in either language... Although at a personal opinion I reckon this optimised version could run quicker in C++ with it being able to manually free resources and not having to interpret from byte code.

EDIT:
Little Bobby Tables wrote:
as to the ops second half of the post: yes, but unless mojang does it i doubt it will be done, because of legality reasons.


Hmmm... I'd expect it'd be fine if it was just a pure copy of the Minecraft client, where you'd still have to have a valid purchase from Mojang to play the game and you use your username to login and play. If you tried selling accounts yourself specifically for your C++ version then I'm sure they'd have trouble with you quite quickly!

Although if anyone was to attempt a C++ copy then it's always best to ask directly for permission to freely distribute your client.
Last edited on
SatsumaBenji wrote:
If someone went and optimised the game (or better yet just rewrite the entire thing) then it'd run so much better in either language
Optifine

SatsumaBenji wrote:
Personally I think Java is pretty wasteful on resources
Shh... You will attract rapidcoder.
@MiiNiPaa: Mojang have actually done a great job of optimizing performance in recent versions of the game, so much so that a large majority of players have experienced degraded performance when using Optifine. As such, Optifine is generally discouraged from use now.

For me in particular, with Vanilla I get 100+ fps consistently, whereas with Optifine installed with any combination of settings I can never break 30 fps.
Last edited on
closed account (9jNRX9L8)
The language used very much does affect the program. If minecraft was written in machine language it would run almost instantly.

Also yes I know C++ does use a bit of machine language though it doesn't matter because all programming languages use machine language somehow. You don't just have a programming language. There just a language. You write it into a file and then compile using a program. All that program does is read the language and converts it into machine language.

Though it depends on the language because if a C++ compiler converted a line of code printing hello world into three lines of machine language then clearly if a Java compiler converted it into one line then it would be more efficent and less laggy in Java.
Last edited on
The language used very much does affect the program. If minecraft was written in machine language it would run almost instantly.
How can you know that? Have you ever heard about algorithm complexity? You see, some task accomplished using algorithm #1 can take bilion years to complete, even if you do every micro-optimisation known to mankind. But using algorithm #2 it can complete is seconds.
Toggy11 wrote:
Though it depends on the language because if a C++ compiler converted a line of code printing hello world into three lines of machine language then clearly if a Java compiler converted it into one line then it would be more efficent and less laggy in Java.


Except C/C++ compiles mostly to machine code, and Java compiles to it's own specific byte code, which although this may be less than machine code (I don't know if it is or not) it still has to be run through the Java runtime which is executing it's own code and having to reinterpret the bytecode into the native machines opcodes for execution anyway... Personally I can't see how running an interpreted language (that also requires a runtime to be executing as well as the program written in this language) can ever be faster than any program you've compiled directly into machine code.

Now if you forget it's Java and just say it's any interpreted language, and any compiled language (and imagine both are equally optimised). Surely pure machine code would always win over interpreting on the go?
closed account (9jNRX9L8)
Yes, that was just a example SatsumaBenji.

Abramus, try rewrite that in a much simpler way seeing as I didn't even understand a sentence of that because you formatted it so badly.
closed account (N36fSL3A)
If minecraft was written in machine language it would run almost instantly.
Actually no. You can't just write a program in another language and it'll make it instantly faster. You have to optimize it appropriately.

I'm sure that good Java code is better than terrible machine-language code. Of course the lower-level you get the more access you get to optimization. In turn it makes you as a programmer more responsible for the program.
Last edited on
SatsumaBenji wrote:
Java compiles to it's own specific byte code, which although this may be less than machine code (I don't know if it is or not) it still has to be run through the Java runtime which is executing it's own code and having to reinterpret the bytecode into the native machines opcodes for execution anyway... Personally I can't see how running an interpreted language (that also requires a runtime to be executing as well as the program written in this language) can ever be faster than any program you've compiled directly into machine code.
http://en.wikipedia.org/wiki/Just-in-time_compilation
So what I'm getting from this is that the JRE is basically a compiler that only compiles the sections of the code as it needs them (like an interpreter) but then keeps most of this in memory so it isn't having to re-interpret. Is this the jist of the idea?

I know that interpreted languages are of great use in many systems and I can see how this would have substantial benefits over just a standard interpreter. Although I can't see where the claimed performance advantages to statically compiled code come from... I'll have to keep reading later.

But still I think the majority of us here have said that it don't particularly matter, if you want to make something quicker then optimise the code rather than the language.
No matter what language you use, the limit is always how the generated code is executed. C and C++ typically convert almost directly to assembly/machine language, and C/C++ compilers are very good at optimizing for advanced hardware that uses pipelining, branch prediction, multiple issue, etc.

Languages like Java are typically compiled to bytecode the JVM understands. Either it has to be converted to machine language at runtime, or machine language has to simulate running the bytecode (hence the "Virtual" in "Virtual Machine").

If Java were compiled to assembly/machine code, you would lose things like runtime reflection, which Minecraft uses heavily.


The language used does not matter. The way the language is compiled and executed does matter, as well as the way the code is designed.
If Java were compiled to assembly/machine code, you would lose things like runtime reflection

You can have runtime reflection even in C++. It will just look awful and unwieldly to use.

I know that interpreted languages are of great use in many systems and I can see how this would have substantial benefits over just a standard interpreter. Although I can't see where the claimed performance advantages to statically compiled code come from... I'll have to keep reading later.

http://en.wikipedia.org/wiki/Java_performance#Just-In-Time_compilation
http://stackoverflow.com/questions/538056/jit-compiler-vs-offline-compilers

I will search for article with result of decompilation JIT compiled Java code and corresponding C++ one. In short: Java took advantage of SSE instructions where C++ code could not because it was compiled for generic PC. On platform with first version of SSE C++ code outperformed Java one.
I don't understand the advantage of JIT over compiling on first run:
http://www.cplusplus.com/forum/lounge/127389/
Pages: 1234