Hm well no it doesn't quite like that
C++ is a compiled language. Game Maker isn't as much a full programming language as it is just a scripting interface with which is interpretted on the fly without any optimizations.
Java is somewhere in between. Java compiles down to what's known as "byte code." Byte code isn't pure machine code like a compiler would do on C++, but it's still compiled nonetheless at a level which is higher than machine level, but still mechanically optimized for speed and efficiency. This bytecode is then executed on the fly similar to Game Maker, but it works much faster in edition to being a much more robust programming language. What matters here is that the bytecode from java can then be executed on the Operating System it's running on, which makes it extremely portable as no matter the platform you're compiling it from, it will still compile to the same code, as opposed to C++ which is comparably less portable depending on what compiler you use. Java will not execute as fast as any code that's optimized in C++, C, or even more low level like assembly by design, but nowadays java's nearly as fast as it nonetheless.
Of course there needs to be a client or "runner" if you will to interpret that code. Java's as Sani's said widely adopted, which is why you can even run it from your browser. Game Maker, being created by pretty much one person, lacks that sort of open-ended portability. Game Maker, although quite a deal faster now that it's engine has been moved from delphi to C++, is still very flawed and is no where near as fast as java or most other languages for that manner.