The really hard part about MineCraft isn't rendering, though; it's multiplayer.
Only good desktop or laptop machines can run it well. Runs like shit on average machines (lets not even mention mobile). This is after several months of dedicated optimization time to reduce resource usage and minimize build size.
Overall, you are faaaar better off writing it in JavaScript with one of the pure js engines if you are going to go this route.
Sometimes the language is less of a good choice. E.g. i did a small toy project in coffeescript about two years ago, and found to my horror, that if your function ended in a loop, it would return an array. Always. This isn't possible to accidentally do in the host language, so I'd say it is a bad fit (for game development, where you care about such things).
You have to be explicit in Vanilla JS to return things or it just return null. Coffeescript explicitly returns the last line every time.
This is probably as a result of CoffeeScript's Ruby-esque syntax and semantics. It does mean you can write some very clear and succinct code at times, but the tradeoff is that it can have unforeseen performance implications.
There is no inherent size advantage of doing things in Javascript vs. cross-compiled to asm.js. For instance, three.js is 100kByte minified and compressed, that's in the same ballpark as the (admittedly simple) demos here: http://floooh.github.io/oryol/
Once you are over the static overhead for the C runtime and web-API-wrappers of roughly 30..50kByte, emscripten demos don't grow much faster than minified and compressed Javascript code.
[edit: typos]
There are other issues as well. The biggest offender being the inflexible heap size, e.g. when you launch an asm.js module, you pass in an array buffer as the heap which cannot be resized. If you need more memory than this, you are SOL.
This wouldn't be that bad, except in practice it needs to be ridiculously small if you want to run on most machines. 256MB, which not much memory for a game at all, will fail to allocate, or kill the tab on about 33% of machines (being generous. For us its probably more like 50% of machines, but we make educational games that need to run on university machines, which are uh, on the lower end).
Either way, as a result, a great deal of the optimization time I mentioned was spent getting all of our games to run with under 128MB heap.
That said it's definitely possible if you're careful (I'm not sure this is quite as true for a voxel game though, but I could be wrong). My complaint wasn't about the idea of using asm.js, it was the idea that Unity would produce a good result. It just doesn't.
However, I remember that the first Unity HTML5/WebGL demos a few years ago were much smaller, a complete zombie FPS had a 3.5MB upfront download which is actually pretty decent.
I tested several real world web sites, like google search, github, google docs - only around 30% of javascript loaded into browser is actually invoked at run-time. Maybe in your case the usage ratio is much lower?
Would it be helpful to remove unused code with a tool like this https://github.com/avodonosov/pocl ?
Google products (google docs for example) use Closure Compiler for dead code elimination, but anyway, after clicking almost every menu item in document editor, only around 45% of code was invoked.
If that 26mb web site was available online, I would be interested to measure it's code usage ratio.
BTW, the idea is not radically new. Java loads classes only when they are accessed first time.
Operating systems load native applications by mapping executable file into virtual memory. The pages are loaded into physical memory only when CPU tries to access them.
There are other actively developed Web-friendly WebGL frameworks, like Goo Create, PlayCanvas, BabylonJS and many more.
I suspect Minecraft has a much harsher profile, since it's possible for every player to be loading a different piece of the world with minimal overlap, and world-pieces involve a lot more state that needs to be preserved/calculated/saved.
Think of two players running towards each other, and shooting at each other. By the time the player (or even the server) receives the data saying the other player has fired their gun, they've both moved to completely different positions.
(There is a good set of articles on this by a game developer, I can't find them now)
https://developer.valvesoftware.com/wiki/Latency_Compensatin...
https://developer.valvesoftware.com/wiki/Source_Multiplayer_...
The world pieces are a very specific set of permutations, which could easily be loaded in to a graphics card's memory at the start of the game. All you are really tracking are which pieces are where, and by the game's nature, there aren't that many pieces or positions they can be in...
https://github.com/SirCmpwn/TrueCraft
May give you some insight into how Minecraft multiplayer (or any other detail of Minecraft) works. The server code is in the TrueCraft directory.
Imagine using a stack of divs like this: https://hcgilje.files.wordpress.com/2011/01/stack.png
If each of those stacked divs represents the faces of all the 16x16 cubes in that plane, then you'd only need 48 draw calls in total. The hard part would be baking the cube textures in to a giant 'megatexture' the first place, but that could be prerendered if you didn't need animation. You'd actually need 96 images because each 'layer' would need 2 sides, but I don't see why it wouldn't work.
A few years back, I wrote a tech-demo^W game for Ludum Dare (http://ludumdare.com/) based on using GLSL shaders to ray cast within a cube containing voxels. I then used these cubes as 3D "sprites" for the game.
See http://matt-williams.github.io/ld29/ for the game and http://ludumdare.com/compo/2014/04/28/voxel-map-algorithm/ for a write-up of the technology.
Heck, I'd even go so far as to venture that Java webapps run better than WebGL+JS. Perhaps I'm just biased/bitter because the open source radeon driver does nothing good by way of 3D acceleration.
I upload a WebGL demo to github-pages, and publish the URL.
I don't have to worry about code-signing, app-review-process, and don't need to wait days or weeks until the code is 'up'. For iOS this is the only way to get simple demos out.
Users only need to know a URL, they don't need to download or install stuff, they don't need to find the executable after installing, there are no scare-dialogs about installing unsafe executables, no virus scanner warnings, etc...
It removes all of those from the equation, web tech will be available on most platforms i want to use, so i'm free to choose the best for what i want without worrying if a ton of my software is supported.
The arrow buttons on the remote act as up/down/left/right and the "OK" button acts as enter. It actually ended up needing very little in the way of custom code to work, but like i said this was a pretty small toy app.
Still, if you want an example of a real "web app" that runs on all of those platforms, just look at netflix.
Web is an amazing distribution channel. The whole world is a click away from using whatever you build. Think about how technology distribution evolved in the last few years.. We used to buy Encarta/encyclopedia from a retailer. Now, with the web, you get the whole encarta (and more) with a click.
Seriously, I just wasted an hour trying to get Hetzner's KVM java web app to run on my Mac, because after having a couple of tickets closed and finally calling support directly, I was told firmly that the applet was from a third party vendor over whom they had no control, there was no other alternative, and they had no plans to support a better way to access the KVM.
I had to use Safari instead of Chrome, then CAREFULLY upgrade Java making sure Oracle didn't trick me into installing any toolbars, then find the Java control panel in the system preferences, which was just too awesome to be constrained by the limited confines of the Mac system preferences windows, so I had to read about how "The Java Control Panel opens in a separate window" because obviously it is so much more important than all other control panels, so I then pressed the "Reopen the Java Control Panel" button, which did what it promised after a half second pause, then I had to click around to the Security tab to find the Exception Site List, press the "Edit Site List..." button to bring up the "Exception Site List" dialog in all its glory and splendor, then press the "Add" button, then type an https url with a numeric ip address and port number into the field, then click a long series of "OK" buttons window close icons, then go back to the web browser, refresh the page, click through another series of threatening warning dialogs, to finally get a bottom of the barrel KVM applet.
And it was convinced I was using a German keyboard, so I couldn't find the punctuation characters I needed to type shell commands, and the Z and Y keys were switched. I had to press and shift-press every key to make a little table of substitutions, and then punch each character in carefully instead of touch typing.
One new thing I found during my Java adventure: the system Java control panel has an "Advanced" tab, and if you scroll way down to the bottom, there is a checkbox labeled "Suppress sponsor offers when installing or updating Java". It was un-checked by default of course. I suspect it's not actually hooked up, it's just a placebo, and exists to make me lower my guard next time I install a Java update. I'm not falling for it.
[1]http://www.oracle.com/technetwork/java/javase/downloads/inde...
[1] http://gadgets.ndtv.com/apps/news/oracle-says-it-is-killing-...
Also as long as you use `backface-visibility: hidden`, then any cube faces that are turned away from the viewport get passed over after a very initial fast check.
But, for those thinking they're going to make a minecraft clone with this it's not going to work. Making games is all about drawing as little as possible and making as few draw calls as possible. Since CSS only supports planes (3d rectangles oriented in space) that means every cube is 6 draw calls and worse, if you want the browser to draw them correctly they have to be sorted. So let's say you had a 16x16x16 voxel area, that's potentially 24000 planes+ and 24000+ draw calls. That assumes worst case, all cubes with transparent bits like tree leaf blocks. For comparison many AAA games do little than 5000 draw calls per frame, possibly less.
Compare to a functional minecraft clone all of that would be condensed into a single mesh representing a 16x16x16 area. One draw call.
So yea, neat demo but you're going to quickly hit the limits past a few boxy logos
If you're looking for something that actually does do the optimizations necessary for a minecraft clone in the browser see http://voxeljs.com