4

Just curious as to whether or not the command system is a unique language, or if it is based off another coding language; and if so, which one?

6

It's custom

It's actually quite interesting to look at this language in a programming sense.

Minecraft's commands by themselves are limited to a small set of built-in functions (the commands) with positional arguments, which may or may not be optional or overloaded (e.g. the second argument for /tp) depending on which function it is. Without command blocks, a program is only a single function call.

Now, command blocks, especially in 1.9, add some functionality to the system. Impulse/Chain represents several functions executed in a row, where the conditional setting can cause the program to skip function calls depending on the result of previous function calls. Repeat/Chain command block lines represent infinite loops (while True {do something}).

So far, we have a very basic language with basic control elements. However, so far, we have not taken the game world into account, which can be read from and written to by commands, making it Minecraft's equivalent of system memory. And it does a horrifyingly bad job at that.

There is a three-dimensional memory called blocks, which is bounded in one dimension, and unbounded in the other. However, not the entire range of positions in the latter two is made accessible by the runtime environment (Minecraft) at all times (due to chunk unloading). This block memory stores a "number" from a very very strange list (block id, potentially block state and potentially tile entity data).

And there is another type of memory storage called entities, which comes with three-dimensional floating point coordinates, and a couple of other predetermined parameters that can be accessed by some of our functions. Some of these parameters are changed by the runtime environment in a way that is largely out of our control.

To make things even worse, our programs have to be written directly into the blocks memory, and the position of your functions determines their execution order, somewhat akin to Befunge. Parts of your program stored in inaccessible sections of block memory simply don't execute at all.

Granted, most programs access only a very limited subset of this system memory. But the fact remains that this system memory exists, and can be used at least theoretically, and that's unlike every programming language I've come across so far.

  • 1
    Most modern computers are von Neumann machines, where the instructions are stored in the same place as the data, and the execution order is dependent on their memory location. – OrangeDog Feb 24 '16 at 18:33
  • 1
    @OrangeDog good point actually... – MrLemon Feb 24 '16 at 19:17
  • 1
    Reminds me of "Hitchhiker's Guide to the Galaxy" - " And you yourselves shall take on new more primitive forms and go down into the computer to navigate its ten million year program. I shall design this computer for you. And it shall be called..." Minecraft :P – Ben Feb 24 '16 at 23:48
  • This answer has to be updated to include scoreboards and the new function command along with .mcfunction files. But great answer :) – David Callanan Mar 9 '19 at 12:36

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.