News for hackers. Stuff that matters.
Re:Web Assembly now supported across all browsers by TekMol on Monday December 04, 2017 @03:15AM (#15842410)
I would try it out, if it would be possible to just type web assembly by hand. Then I would just open an html file or a jsfiddle and play with it.

But as I understand it, it needs a toolchain?

Re:Web Assembly now supported across all browsers by hnarn on Monday December 04, 2017 @03:42AM (#15842502)
Maybe you'll enjoy this: https://wasdk.github.io/WasmFiddle/
Re:Web Assembly now supported across all browsers by TekMol on Monday December 04, 2017 @04:02AM (#15842587)
That's funny.

Never been using C, I guess-coded my way to this little program:

    int pow(a)
    {
     for (int i=0;i<10;i++) a=a*2+1;
     return a;
    }

    int main()
    {
     return pow(1);
    }
And as far as I understand the output, the compiler on the server reduced it to a constant:

    (module
      (table 0 anyfunc)
      (memory $0 1)
      (export "memory" (memory $0))
      (export "pow" (func $pow))
      (export "main" (func $main))
      (func $pow (param $0 i32) (result i32)
        (i32.or
          (i32.shl
            (get_local $0)
            (i32.const 10)
          )
          (i32.const 1023)
        )
      )
      (func $main (result i32)
        (i32.const 2047)
      )
    )
Looking at the wasm code, I really hate it that I cannot edit it by hand and have the browser execute it. That would be fun.
Re:Web Assembly now supported across all browsers by banachtarski on Monday December 04, 2017 @04:57AM (#15842773)
The amount of vigor you espouse an opinion with is astounding relative to how little you know. The point of WASM isn't for you to hand-edit things. It's to provide a unified IR that many lanugages can target (C, C++, Rust being just the beginning). Any language that compiles to LLVM bytecode today can theoretically target the browser now. One thing those languages I mention have in common? They don't use a garbage collector. AKA, you can now write code that will run in the browser with predictable latency semantics.

Then again, I could just be feeding a troll right now, I really can't tell.

Re:Web Assembly now supported across all browsers by pjmlp on Monday December 04, 2017 @08:37AM (#15843649)
Not having a GC is just an implementation detail.

Anyone can implement one and ship it with the statically compiled WASM code, it is no different than targeting an actual machine code, unless we are speaking of CPUs like Intel iAPX 432.

The only issue is having a little bigger download, which is irrelevant in the age where web pages to display static text are bigger than the whole Quake installation.

Re:Web Assembly now supported across all browsers by banachtarski on Monday December 04, 2017 @01:03PM (#15845964)
Yes I'm aware. It's a side-consequence that I just happened to single out. GC is opt-in, not mandatory.

As for the bigger download, I'm hoping we'll be able to load libraries dynamically through WASM so you can cache things like the C runtime separately

Re:Web Assembly now supported across all browsers by pjmlp on Monday December 04, 2017 @02:15PM (#15846567)
Ah ok, sorry I thought it was another kind of remark relating GC just because the interoperability with JavaScript's GC is not yet baked into WASM.

The idea of caching runtimes looks good, but we need some kind of versioning, otherwise it will be yet another WASM.so hell.

Maybe tying them to the origin would be a possible solution.

Re:Web Assembly now supported across all browsers by klibertp on Monday December 04, 2017 @07:25AM (#15843331)
But you can, of course! In the WasmFiddle, which I see for the first time in my life, if you put a `log(wasmCode)` on the right side, you'll see something like this printed:

0,97,115,109,1,0,0,0,1,138,128,128,128,0,2,96,1,127,1,127,96,0,1,127,3,131, .... 2047

You can edit this as you see fit, or even write it by hand if you want. What's wrong with it? It's the same with native programs. You get your executable, open it in the hex editor, do your thing and run the program, done.

I'm not being entirely serious, but that's because you seem to conflate the tooling's features with the WA, or you simply don't understand what assembly really is. As a "child of the web" it's not strange, but you should at least accept your own lack of knowledge and understanding.

In short: there are two programs involved in the WasmFiddle: a compiler and an assembler. You're saying you want to play with assembler - fair enough, you can do this. That you have to write a disasm for this or learn the opcodes by heart, doesn't mean it's impossible. The thing is, no one other than you cares (it's a lie - there are people with a justified, practical interest in this, but it's almost certain you're not one of them) because it's hard and the compiler is going to make a better job at it than you anyway.

In other words, you're saying you don't like WebAssembly because it's an assembler. It's not a problem with WA, but with your expectations.

EDIT: shortened assembly output to make the rest of the post readable.

Re:Web Assembly now supported across all browsers by vanderZwan on Monday December 04, 2017 @09:33AM (#15844052)
> or you simply don't understand what assembly really is

As someone who at one point in his life had a lot of fun writing Z80 for his TI-83+, I do wonder how bit a "market" for a WASM environment oriented towards human editing of the assembly might be. It's probably being built anyway, for the compiler writers. The question is if it might "break out" to other enthusiasts.

It's easy to forget that before higher level languages, assembly was the norm. Assembly at the time was more "human-friendly" to program in too; if you're comfy with C and pointers, going a bit lower really isn't that scary. It's just that the decades of x86 extensions have created hugely complicated beasts that few sane people would dare touch. However, the forty or so z80 opcodes are quick to memorise. I've heard that ARM and 68k is "fun" to work with too (for a certain type of programmer, obviously).

Anyway, the s-expression form of WASM feels like a throwback to the more human friendly CPU days, presumably also because it has to be so platform-independent (and because SIMD isn't in yet). I'm sure there will be enthusiasts playing with it.

Re:Web Assembly now supported across all browsers by PyComfy on Monday December 04, 2017 @06:01AM (#15843028)
Re:Web Assembly now supported across all browsers by a_humean on Monday December 04, 2017 @03:36AM (#15842483)
Yes, WebAssembly is bytecode that is a IR compile target for other languages, which right now is limited to C and C++ via Emscripten, or Rust via its own normal toolchain or Emscripten as well. It has a plain text assembly output called WAT, but its not really meant to be handwritten, but rather reviewed as a build artifact.

You can see an examples in Rust including the readable Wat output here:

https://www.hellorust.com/demos/add/index.html

Re:Web Assembly now supported across all browsers by geokon on Monday December 04, 2017 @06:01AM (#15843027)
I've got to admit, I'm really clueless about these things

But don't we already have a universal byte code with JVM bytecode?

Why did the wheel need to be reinvented here? Are there fundamental issues with JVM bytecode that make it impossible/impractical to have c++/rust/LLVM compile to it?

This isn't a troll question. I'm curious what are the fundamental underlying technical issues that made WebAssembly necessary

(please be nice... c++ developer here.. so I'm really clueless about web stuff. I don't even use the JVM)

Re:Web Assembly now supported across all browsers by m1el on Monday December 04, 2017 @06:20AM (#15843100)
I'll take a stab at your question.

> Are there fundamental issues with JVM bytecode that make it impossible/impractical to have c++/rust/LLVM compile to it?

Lack of pointers. Lack of true structs. Different memory model. Enforced class/object model.

WebAssembly has a memory model which is very close to a generic CPU.

My understanding of what made WASM necessary -

You don't want a GC? You don't get a GC.

You want full control over your memory layout? You get a raw growable slab of memory with raw pointers.

Re:Web Assembly now supported across all browsers by Game_Ender on Monday December 04, 2017 @06:09AM (#15843059)
The first upside is WebAssembly is designed to run C++ at close to native <10% overhead. The WASM team is starting with that foundation then adding features needed for GC and cross language API access (DOM). This is as opposed the Java and C# byte codes which come with a lot of assumptions baked in.
Re:Web Assembly now supported across all browsers by pjmlp on Monday December 04, 2017 @06:48AM (#15843207)
CLR was designed to support C++, hence Maanged C++ and C++/CLI.

Also the reason why the only major revision to the MSIL bytecodes was the support for generics.

Re:Web Assembly now supported across all browsers by TekMol on Monday December 04, 2017 @03:43AM (#15842503)
If I can't just type it and see the result, I am not much interested. I don't like to install software. As a child of the web, my feet are firmly planted into the cloud.
Re:Web Assembly now supported across all browsers by exDM69 on Monday December 04, 2017 @04:50AM (#15842744)
You can do that but why would you want to? The tool you're looking for is wat2wasm, which converts the human readable WAT source to WASM binary, and here [0] is an online tool if you want to tinker with it.

Compiler IR's like WASM or LLVM IR are very laborious to type, they're intended to be produced and consumed by compilers.

You need to write very verbose code with all the type declarations, which aren't automatically propagaged, ie. `(func $foo (param $0 i32) (result i32) ...)` and `(i32.add ...)`. There's very little point in writing code like this by hand, apart from testing and debugging the compiler producing or consuming this code.

It doesn't make much sense to have this "in the cloud" outside of toy tools like this. In any kind of actual work scenario, you'd be running a compiler producing WASM on your development machine and deliver the WASM binaries over HTTP to the client machine. The whole point is to have near-native performance while reducing the compile time on the client side.

But if you want to tinker with it, knock yourself out. Here's the tool:

[0] https://cdn.rawgit.com/WebAssembly/wabt/fb986fbd/demo/wat2wa...

Re:Web Assembly now supported across all browsers by BigJono on Monday December 04, 2017 @06:49AM (#15843213)
I like this answer a lot more than the other ones that are just dismissive.

I think there's at least some value in these "toy tools". Would being able to tinker with WASM not help development of compilers? I place a very high value on understanding as far down the stack as you can, I don't think ignorance of every abstraction layer below the one you're working on is a very noble goal to strive for.

Re:Web Assembly now supported across all browsers by exDM69 on Monday December 04, 2017 @07:08AM (#15843277)
> Would being able to tinker with WASM not help development of compilers?

There are tools, even web based ones, that allow you to tinker with WASM, compile C, C++ or Rust code to WASM, print out the WAT representation, turn WAT into WASM, run the WASM blobs through JS, etc.

These tools are probably very useful for the guys developing WASM frontends and backends. E.g. sharing a piece of WASM code with other developers.

Should the average developer use them? Not really. Maybe spend an hour poking at things to get the general idea of how it works. You really don't need to understand the details of LLVM IR, SPIR-V, WASM or GCC's GIMPLE in order to use those compilers.

Is it a good idea to understand what and how are intermediate representations used in compilers but actually writing that by hand is not necessary or productive.

Re:Web Assembly now supported across all browsers by krapp on Monday December 04, 2017 @07:00AM (#15843253)
WebAssembly is still very new - better tools are bound to show up, but I think GC and DOM support need to be finalized first.
Re:Web Assembly now supported across all browsers by a_humean on Monday December 04, 2017 @03:54AM (#15842557)
I can understand the nostalgia, but that just isn't really true anymore for a lot of front-end web development.

Almost everywhere you look in front-end web today you see a toolchain that includes the node runtime, babel or typescript as a compiler, and some kind of bundler/linker such as webpack or browserify that throws in minification/mangling in as a freebie. That doesn't even cover CSS.

JS/CSS is already a compile target with a build artifact often barely resemble the original source code. WASM is just another compile target that opens up the web as a platform for other languages.

Re:Web Assembly now supported across all browsers by throwaway613834 on Monday December 04, 2017 @03:46AM (#15842515)
> I don't like to install software. As a child of the web, my feet are firmly planted into the cloud.

It's funny, I'm the exact opposite. I don't like cloud apps. One day they're there, next day half their features are removed, next day they're gone. And I can't hack them to make them better fits for me when they keep changing. I want the code to run on my machine so I can do anything I want to it and have a stable environment I can rely on.

Re:Web Assembly now supported across all browsers by TekMol on Monday December 04, 2017 @03:50AM (#15842539)
I don't care if jsfiddle still exists tomorrow. I just use it to quickly try something and immediately share it with others.

I don't put anything I care for on machines I don't own. I own many machines in the cloud. They are beautiful. Because they are all the same. They are virtual. They are cheap. I can create them with a click. There are so many vendors. If one of them would go away, it would not tamper with my ability to create new machines.

Re:Web Assembly now supported across all browsers by xg15 on Monday December 04, 2017 @04:07AM (#15842607)
> I own many machines in the cloud.

> They are virtual. They are cheap. I can create them with a click.

If they are virtual, you don't own them. You own an 'I promise really really hard' of some vendor at best.

Re:Web Assembly now supported across all browsers by TekMol on Monday December 04, 2017 @04:18AM (#15842641)
I own the virtual thing. It's my data. Yes, the vendor could illegaly tamper with it. Or legaly stop providing me service. But the beauty of the cloud is that it would not affect me. Because I can replace any vendor with a click.
Re:Web Assembly now supported across all browsers by stephenr on Monday December 04, 2017 @04:54AM (#15842759)
I think you're confusing the buzzword "cloud" for "rented virtual server".

None of which has anything at all to do with installing a fucking tool chain.

Re:Web Assembly now supported across all browsers by throwaway613834 on Monday December 04, 2017 @04:05AM (#15842601)
> I own many machines in the cloud. They are beautiful.

I was talking about web apps, but w.r.t. VMs... sure, at the price of your pocket though? I can run my home computer all I want and not pay for anything except the electricity and internet.

Re:Web Assembly now supported across all browsers by kowdermeister on Monday December 04, 2017 @03:49AM (#15842532)
As someone who learned programming as the web grow, I was like you, but I now I see WebAssembly as the future of the web. Lots of amazing and horrible things will emerge. It's better to catch up now, than 2 years later when it will be everywhere.

BTW you DON'T need WA if you don't have performance issues with your current web application.

Re:Web Assembly now supported across all browsers by TekMol on Monday December 04, 2017 @04:07AM (#15842609)
I only do what I like. So I don't need to catch up with a technology if I don't like it. And if I need a toolchain, I am not tempted to use wasm.

As for performance: I do a lot of machine learning in the browser. So performance is something that I am interested in.

Re:Web Assembly now supported across all browsers by pjmlp on Monday December 04, 2017 @06:52AM (#15843225)
npm, bower, webpacker,... sounds like a toolchain to me.
Re:Web Assembly now supported across all browsers by danaliv on Monday December 04, 2017 @05:55AM (#15842988)
"There is a principle which is a bar against all information, which is proof against all arguments and which cannot fail to keep a man in everlasting ignorance—that principle is contempt prior to investigation." -William Paley
Re:Web Assembly now supported across all browsers by pjmlp on Monday December 04, 2017 @06:50AM (#15843217)
So you mean applications that I never get to see the code, because they are hidden in servers I don't have access to?

Sounds like a strange duality of criteria to me.

Re:Web Assembly now supported across all browsers by klibertp on Monday December 04, 2017 @06:50AM (#15843214)
I'm pretty sure someone will write a Forth for WA, if it's not done already. You'll even get a REPL for the assembly, then.