427 points · by lifthrasiir · 8y ago · 308 comments
http://8bitworkshop.com/v2.1.0/?platform=mw8080bw&file=gfxte...
Most of the execution time is spent in SDCC's register allocator, which was recently rewritten to generate better code but unfortunately is a lot slower than the old allocator.
https://www.destroyallsoftware.com/talks/the-birth-and-death...
As ridiculous and played-for-laughs as it is, it's looking more and more accurate (in one form or another) every day.
With this webassembly VM, early bound (precompiled) lower level languages may not have a strong advantage over late bound, dynamic ones, because the compiler is part of the OS layer (as it should be).
The world seems to be slowly moving, in a roundabout way, towards the OS-browser idea from Alan Kay.
The major issue with web apps is that the customer (or depending on the company bag of meat that watches the ads) has no control over the app or the data. They will be abused by the company in all sorts of creative ways.
And yes, those VMs could be local-only, but why would Google, MS or Mozilla want that? The former two are heavy in the cloud+ads business, the latter was pushing FirefoxOS. Why would web developers want that? All the stuff they write is online-first.
I would like to believe that this is done in the name of performance, but my gut tells me this is done in the name of keeping one step ahead of the ad blockers.
As it stands now, I feel that I as a user have no defense against tracking and fingerprinting except by monitoring and controlling access to the DOM at the level of individual operations. I am afraid this is only going to get worse with WebAssembly. "Audit the code yourself" no longer a viable solution except for a handful of experts.
On the bright side, perhaps WebAssembly will lead to fewer ways of interacting with the DOM, which could make it easier to detect malicious/undesired interactions.
Case in point: The Web.
I assume the ads would be at the messaging system, so even if a variable contains 'iphone' the ads start to appear.
Joking aside, we need a better security system because we never know if an arbitrary compiler is not embedding a malware payload.
https://www.destroyallsoftware.com/talks/the-birth-and-death...
The advantage of wasm is that all the people running Chrome today already have it.
Webassembly solves a problem that existing low level bytecodes like LLVM IR do not intend to solve. LLVM IR is not stable across LLVM versions and usually is optimized for a specific architecture.
JVM bytecode is stable but high level. LLVM IR is unstable and low level. WebAssembly is stable and low level.
They all solve different problems.
https://www.destroyallsoftware.com/talks/the-birth-and-death...
(It has 128 but pointers, btw - so it’s future proof for at least 20 more years)
Like most things that become very popular, the web is becoming an os-like platform because it solves a problem. Putting your application at a URL is hugely more accessible than asking someone to download something. Maybe not to us HN readers, but to my mom, who's skeptical to a fault of anything that says download, it's huge.
HTML+CSS+JS is everywhere and complete in a way that literally nothing else is. Yeah C is everywhere but (before nowish) you couldn't write a C application once and have it run the same pretty much everywhere.
But chuck, you say, HTML has notoriously bad compatibility and working with it is frustrating. I propose to you that HTML and CSS have so many compatibility problems because of how pervasive it is and has been for so long, and how many different implementations of it exist. Anything is bound to develop compatibility issues when it gets as large as the web.
But you're right, it's suboptimal and other tech has tried to be everywhere. Java and Flash did try, but have you ever used a java applet? They're fine I guess, but they're stuck in a square on the page. You can make a java or flash object take up the whole page and completely control the website but then you run into accessibility issues and complexity on your part.
Javascript has grown organically over the past decades for a reason, and it's being used in this fucked up way because, all things considered, it's the best platform for the job right now
Precise control over memory layout and allocation which can translate into massive performance gains of several orders of magnitude.
LLVM IR isn't stable accross LLVM versions.
Webassembly is the solution to a problem that stayed unsolved for decades.
There is no alternative to webassembly. It is in it's own category.
Probably the closest competitor you could find is LuaJIT with it's FFI module but LuaJIT wasn't designed as a compilation target. It'd suffer from the same problems that asm.js did.
JVM bytecode is stable but high level.
LLVM IR is unstable and low level.
WebAssembly is stable and low level.
Precise control over memory layout and allocation which can translate into massive performance gains of several orders of magnitude.
"Can translate" is not "translates to". Performance gains can be achieved when executing an efficient instruction set over a performant VM. Are you arguing that the JVM falls short as opposed to a browser in that regard?Also, with most operating systems, physical memory is abstracted from user-mode processes entirely. Kernel-mode is a different story, but I fail to see how a browser/WASM in user-mode do better than a JVM in user-mode in that regard.
LLVM IR is unstable and low level.
Interesting. What makes an instruction set "stable"? Is this about being backwards/forward compatible? About being encoded/decoded efficiently?What about the actual APIs exposed by the browser to WASM? Are those considered "stable"? Browsers today "break" all the time - inconsistencies between minors of the same browser, let alone different browser vendors.
Trying to replace native applications with runs-in-the-browser RIAs is nothing new, but we're at least finally agreeing on the language/implementation, so maybe this time will truly be different.
There is one thing that is new: the users do not need to install a separate piece of software, and it's kept up to date by the browser vendor - which means for enterprise users one less piece of software to certify/test for updates/compatibility, and for private users one software less which installed adware on each update (Java IIRC still does) and has that "risky" association like Flash does.
I think a lot of techies underestimate people's willingness to install stuff on their PCs, especially when that stuff is needed to do tasks they really want and are a couple of clicks away.
Every programmer knows html though not the frameworks. But these are seperate.
This time will truly be different because it developed out of a document viewer.
If so, I am skeptical especially with end of moore's law.
Edit: I was a bit mis-informed, the design document is an interesting read.. https://github.com/WebAssembly/design/blob/master/Rationale....
But that 50GB is probably for more then 100 hours of playtime, which amounts to a persistent 145kb/s. With some caching up front, I think this could actually work. There literally is no need to have everything on disk before starting. Maybe a few hundred megs before starting, but even that is less then a few minutes on most connections, which is a lot faster then downloading the full game before starting.
(Web workers are around since ca. 2010 so this is not very new)
What I find most painful about this development is that this new platform requires Javascript and wrapping everything inside an HTML document.
(It's the other way around, if you want to keep using Javascript, the expectation is that you'll start to depend on WebAssemby in the future.)
However, 8 years later, things really don't seem to be moving in that direction. Native is always going to be one step ahead in terms of speed and ability.
We would need to see native features start to stall so the web can catch up in ability, and websites need to do a lot of work to catch up in speed.
Back when the first iPhones debuted without an app store, Apple claimed that everyone could just use web apps. That didn't last long.
* Easy distribution without installation
* No worries about dependencies for end users
* Much more consistent, and in most cases, better security
* Cross platform
* No walled gardens
* Only Linux end users have to care much about dependencies
* You're kidding right?
* Sure, if you only target one browser your code will probably work more or less the same on that one browser on at least some of the OSs it runs on
* There aren't any walled gardens in PC Destkop land worth talking about, other than maybe the package repositories of Linux distributions.
Browsers as a better software platform, will significantly accelerate the rate at which software eats everything.
Most software should ideally just work, no installs, period. The browser can act as that platform and it can go a lot further than it has so far. More to the point, there is no other future outcome than the browser becoming that vehicle, nothing can stop it from moving that direction at this point.
You don't need something equivalent to maximum native performance to do what 99% of users want to do. The rare edge cases that need extreme performance will remain native.
Browsers probably will win, but mostly by accident and as a result of network effects rather than any inherent qualities. As a platform it's positively awful, though it is getting better in fits and starts.
Ideally we'd have proper sandboxing, proper compilation, proper libraries, proper access to hardware. Alas, all of that good stuff is basically a historical footnote at this point.
I select software because it does something that I want, in a way that I want it done. I avoid web-based software when possible because it has a tendency to shift underneath me and break the way that I want the software to work....or the company decides that it needs to pivot, and I lose access to something I was depending on.
Software that installs comes closer to "just works" than software hosted online, IMO. Make it available in the repo/store/whatever, and that gets rid of a lot of install friction.
> You don't need something equivalent to maximum native performance to do what 99% of users want to do. The rare edge cases that need extreme performance will remain native.
Throughput? Probably not. But please fix the dang latency. It makes software just painful.
Web browsers grew up with an always-on Internet connection -- continuously pushing updates to code and data. This has expanded to continuous updates "all the way down" (the native code browser auto-updating on top of an auto-updating OS).
Rebuilding core features such as these, even if by selecting unencumbered open-source libraries, basically means winding up in nearly the same place (since browsers are competing to optimize their implementations). Finding a way to connect to the browser foundation underneath whatever layer in the stack begins feeling bloated is worth evaluating, but there are diminishing returns.
I’d be all for this, honestly, except that the existing containers (yes, even Jetty) are too heavyweight for this use case.
What you really want is a stripped down server runtime that loads and starts your application’s archive, fires it up on a (possibly random) local port and opens a stripped down Chromium instance that loads the app from that port.
Of course, that sounds a bit like Electron.
This is sarcasm, right? If it is, it's damn good.
Sadly it does not work in Safari or Safari Tech Preview, but it works in Firefox 57 (known problem, see https://github.com/tbfleming/cib)
Now let's see if wasm performs well enough on Android phones, and I guess we are finally arriving into the software deployment heaven.
Or am i wrong?
As i've said before, little by little we're witnessing the end of Javascript dominance.
In the mid-term, there will be no more reasons to do that. Just compile those languages straight to Webassembly.
Second main issue is speed. qsterix isn't as memory-heavy but runs all Tetris game code inside KDE JavascriptCore, which as part of the KDE/Emscripten build is transpiled to JS. In other words, http://vps2.etotheipiplusone.com:30176/redmine/emscripten-qt... is JavaScript inside JavaScript, and on my reasonable-but-not-last-week-new i3 box, I experience a small pause that I can't explain when I hit the spacebar to drop a block.
Half of me wants to warn everyone from opening these on their phones or tablets, the other half wants to know how badly everything crashes. :P
Note: I tried opening the Kate demo a week or so ago on a marginally older version of Chrome, and the download phase hung. It worked this time though.
While Kate is already quite funny, I'm looking forward to someone porting Linux to the browser, so we can have a clientless desktop environment delivered from a serverless cloud ;) I really want to run vim/g++ in a terminator on KDE on Linux on my phone connected to a keyboard+screen (once, for the laughs).
Keeping code alive would also make long-term archiving of obsolete software viable, more so than just putting the code online, anyway. This is important because so much of our culture has been expressed by and tied up in software.
On a serious note though, this is an awesome example!!
It seems like there's some sort of memory leak, though. If you press the Run button over and over, you'll get a little message every 2*N runs about expanding memory arrays by double.
Neat though.
So with a lot of these neat things where we compile stuff or run a Linux kernel in the browser, we've pretty much come full circle? It's like running cygwin in wine or an NES emulator inside of Windows 95 VM.
The obvious answer is that it makes applications portable, which is great. The other key component I think is delivery. You don't ever install anything, it just exists when you ask for it. That is something native applications have never done, and not even something like JVM has done even though it addresses portability too.
It is also nice that it is seamless with the browsing experience, but I have to wonder if it hasn't just turned out that the typical browser interface is a better interface for computing than most popular OS have been? As the OS and browsers start to see parity, are there lessons from browsers that we can integrate into the OS?
For one example take WebGL. For decades OpenGL had been a native API prioritizing performance first and security last. It wasn't until browsers decided to expose OpenGL that the necessary work was done to make a graphics API safe for untrusted code. And who did that work? The browsers had to do most of it themselves.
Rob Pike wrote in the year 2000 that systems software research was irrelevant (http://herpolhode.com/rob/utah2000.pdf), and it seems to me that not much has changed since then. How many ideas from the last few decades of operating systems research have actually been put into practice?
The real problem is more fundamental: people want their software to keep working. As Rob Pike put it in the talk linked above, "to be a viable computer system, one must honor a huge list of large, and often changing, standards: TCP/IP, HTTP, HTML, XML, CORBA, Unicode, POSIX, NFS, SMB, MIME, POP, IMAP, X, ... With so much externally imposed structure, there’s little slop left for novelty."
For example, I'm sure some software out there is using the OpenGL API in a fundamentally insecure way. Changing the API to be safe would break this software. And maybe that would be a good tradeoff, if reworking OpenGL were the only thing you needed to do to safely run untrusted code. But almost every part of the system would have to change. You'd be left with a system which breaks or degrades pretty much everything you try to run on it.
I would say that the browser most certainly has the biggest attack surface of any software in regular use. Your average browser is insanely complex. In fact, it is the only piece of software on my computer that scares me.
Multiple JITs, font rendering, parsing, layouts, compression, image handling, sound and of course about a billion edge cases because somewhere along the road we decided that faulty code is OK. Everything with tonnes of state that interact in ways that can't ever be fully tested or verified (because of an almost infinite variety). Let's also not forget that a large part of that is done at the very bleeding edge of CS research. I wouldn't trust anyone to do that in a safe way.
To me, a kernel seems simple in comparison.
No browser has provided that either. In fact, browsers are by definition a security anti-feature because they are always connected to the network and the customer/user data lives on the network.
Even if they manage to solve the problem of computers getting hacked when visiting websites they are very unlikely to solve the problems of tracking and private data vacuuming.
The JVM more-or-less managed it. Modern hypervisors do it - you could use something like Qubes and run completely untrusted code in its own isolated VM. It's not that academics weren't working on this stuff, adoption is where it fell down.
- Sandboxed, web apps can't wander around in your filesystem, and you can even prevent them from knowing anything about you (private mode). That's good for privacy and security.
- You bypass the apple/google store, their paytoll, capricious criteria and how they promote apps
And I think asm apps (not websites) will have a great success when asm has become a full VM not just because of these reasons, but also because it will make it possible to develop cross-platform in a language that isn't javascript. Some people love javascript, I personally hate it. C++ devs will be able to develop in C++, I expect C# and Java dev to be able to write their apps in C# or Java, and I am sure even more languages will join the party. That's a great thing.
I always say that this situation is a bad solution to a bad problem. Had Apple, Microsoft and the FOSS world agreed on some standards, native code could be portable and the norm.
It's interesting to notice these things repeating themselves, I bet at some point maybe the OS and the computer merge more and we will have again more systems like we did when the Internet became to rise.
Disclaimer: I don't have an android phone anymore and I have no idea how available/useful these actually are
Actually, this used to be common, and still is for things like game consoles. You used to stick the floppy disk in, and run the program directly from there. No concept of installing anything. Indeed your computer may not have even had writable storage to "install" anything onto. At worst, if you did have a hard drive, you were free to copy the (single) executable onto your drive so you didn't need to rummage through your stack of floppies to find the program every time you wanted to run it. That was the extent of installing something.
The situation where your program consists of multiple files, each of which had to be copied into some special location on your hard drive by an "installer"--is a relatively new (since the 90s?) concept.
It's actually refreshing nowadays when I stumble upon one of those rare applications where everything comes in a single executable file and it can be run from anywhere. Dying breed.
Native apps struggle with this.
Things that are easy to monetize tend to attract more effort than things that are possibly impossible to monetize, or have very limited monetization options.
I'd be aware of promoting anything that takes control away from the user. The web is fine for sharing knowledge and communication (and pictures of cats) but let's not put everything in it or we'll certainly regret for giving away the power to control our software.
2. It's not $750, there are multiple editions available, the more expensive ones include more plugins, instruments, loops, etc.
3. Cloud-based startups are nice until they reach the end of their wonderful journey, sell out and you're out of a tool.
Soundtrap is charging $15 because that's what it's worth. Although if the cloud is mandatory it's worth zero in my opinion.
In my opinion its because operating-system design wasn't sexy after browser-companies came and ate the OS-guys lunches with all that big bubble fuss. So the OS guys went all apathetic and forgot that a majority of their OS is a freakin' browser, and .. here we are. Inception.
Its great we can compile C++ to 'native' assemblies now. We've always been able to do this, btw. The only difference is the delivery mechanism ..
Not counting applets and Web Start?
> not even something like JVM has done successfully.
That's an understatement. Anybody trying to write a multiplatform complex desktop application around 2000 would have learnt that it was way much harder that it sounds today. Browsers were in a very reduced group of success cases.
Edit: also dont forget that there was a war about what tools and languages would become dominant. Unlike alternatives, most web tools were free.
Windows 10 is working on adding tab navigation to all windows: https://arstechnica.com/gadgets/2017/11/tabs-come-to-every-w...
Though I wonder why Firefox OS has failed this hard. I never looked more into it, but isn't it a platform centered around having web apps as native apps? I think some day every OS will be similar, so was it ahead of time?
The other key component I think is delivery. You don't ever install anything, it just exists when you ask for it.
That is precisely why I made the jump from Delphi to ASP.NET back in 2003, and now the jump to Angular2+.Relevant XKCD:
"Installing" https://xkcd.com/1367/
That's what Java was supposed to be.
It's probably that simple.
If you have a thing and you need users, are you really going to deliver it as a Qt app? Unless you're bitcoin, it's hard to think of a case. I'd say "or a game," but many are webapps. And at this point some of the hollywood-grade games might figure out a way to be coming to browsers soon. Unreal did it.
Unity already supports the web, but I don't think that'll matter for AAA games. People who buy computers specifically to play them will care about the slight performance hit and not want to keep the games they bought and spend a lot of time with as bookmarks to web pages. Non-performance intensive tools, even large ones, have already moved to the web. This will likely continue because there is not other platform delivering its level of portability and ease of delivery.
It's a bummer because the web just kind of sucks. It was made for documents, damn it. Something like a java browser could've succeeded as jars are already very portable. This could've worked pretty well for small and large tools alike. But since the HTML stack is already widely adopted I guess we'll have to make the pain go away somehow. At least webassembly solves the problem computationally intensive tasks. The UI component is still quite a mess, but that's getting better too. I just find it annoying that they have to call everything Web-(what it traditionally was). It's basically the new reality, being used on non-web platforms as well as on the web.
Maybe this will change in the upcoming years though also, I have a feeling the client/server bridge will be getting closer and closer as we reach more performant ways of loading code from the servers but executing natively on the client/computer/handheld/phone whatever.
Also, WebGL compatibility is still far away from really doing any production apps (I mean, to reach a state where you can guarantee your app to work on at least most computers people have). Many platforms/GPUs/driver combinations just point out blank refuse to work, or the browser has blacklisted problematic combinations, as these can in reality cause crashing of the whole OS and computer, this has happened to me many times while developing WebGL applications.
Not yet, the though I think this will be true eventually
Was this not the tacit reason for Microsoft's burying of Netscape? A browser that is a portable platform for applications was a threat to its de-facto near-monopoly in operating systems for personal / end-user computing.
But seriously, maybe that’s the next step in this crazy ride we’re all on.
Most similar tools are marketed as antivirus products, and are only available via enterprise licensing and/or SaaS reporting. An example of a hardware virtualization based option: https://www.bromium.com/platform/our-technology.html
If want to play old classic games like Heroes3, AoE2, Diablo 2 on Windows you have to install it using WINE.
These days, you can compile a Qt app with a web view with a single source for all three major platforms.
C and C++ are the exception as they were tied to nothing more that a basic POSIX like compatibility.
That is one reason I chose it. Choice is good.