News for hackers. Stuff that matters.
Re:Ruby on WebAssembly by hhw3h on Sunday April 29, 2018 @11:56AM (#16952516)
Just a thought experiment...

Would this allow for full stack ruby apps?

Writing a client side router and controllers in Ruby on Rails compiled to web assembly?

If you could just toggle in production.rb if you want your routing to be client side or server side and the framework could transparently manage that for you.

Re:Ruby on WebAssembly by reese_john on Sunday April 29, 2018 @12:49PM (#16952750)
I believe Hyperloop[0] tries to accomplish something similar

[0] http://ruby-hyperloop.org/

Re:Ruby on WebAssembly by jballanc on Sunday April 29, 2018 @12:12PM (#16952604)
In theory you could already do this with Opal (https://github.com/opal/opal).
Re:Ruby on WebAssembly by lloeki on Sunday April 29, 2018 @03:25PM (#16953485)
Re:Ruby on WebAssembly by nick_urban on Sunday April 29, 2018 @05:56PM (#16954128)
Does not seem to be actively developed, however. Last commit was in early 2016: https://github.com/voltrb/volt/
Re:Ruby on WebAssembly by mshenfield on Sunday April 29, 2018 @05:37PM (#16954041)
Nice.

Anyone else getting a "Connection Lost..." message as soon as they visit the page?

Re:Ruby on WebAssembly by keithnz on Sunday April 29, 2018 @05:41PM (#16954065)
yes, and it's not only ruby doing this, various other languages are doing it also.

So it's going to be interesting to see what kind of disruption that has on javascript on the client side.

Re:Ruby on WebAssembly by Asmod4n on Sunday April 29, 2018 @12:53PM (#16952773)
There is no Ruby on Rails for mruby, yet.
Re:Ruby on WebAssembly by nitrogen on Sunday April 29, 2018 @01:26PM (#16952927)
What are the differences between mruby and MRI that prevent this?
Re:Ruby on WebAssembly by Mikeb85 on Sunday April 29, 2018 @06:07PM (#16954176)
mruby is an embedded language so it's missing a lot of the built-in features that MRI has.
Re:Ruby on WebAssembly by CyberDildonics on Sunday April 29, 2018 @01:40PM (#16952996)
Why would someone go through so much trouble to use a language that will run much slower than JITed javascript?

I think most people miss that right now webasm is good for run speed, size, and loading speed, but is not geared nearly as much towards using any language in a web page, since IO needs to be exposed to javascript.

Re:Ruby on WebAssembly by robotmay on Sunday April 29, 2018 @01:49PM (#16953041)
JavaScript isn't everyone's cup of tea, and performance isn't always a huge concern :)

The more other languages I learn, the more often I come back to Ruby. I'm excited to see it becoming a more portable language, and I think it'll make a good language for web clients someday.

Re:Ruby on WebAssembly by untog on Sunday April 29, 2018 @03:34PM (#16953518)
> performance isn't always a huge concern :)

This is what concerns me a little with WASM. There are already too many web development experiences that prioritise developer experience and neglect user experience, I'm wondering what future we're walking into where we bundle three different standard libraries, ignore binary size, etc etc

Re:Ruby on WebAssembly by morgancmartin on Sunday April 29, 2018 @04:49PM (#16953847)
I've never understood this take on things, though I'm ready to if it can be explained to me. :)

To me, it seems that the user experience vs dev experience trade off is subject to market forces and if it swings too wildly in either direction, a competitor will come through and wipe the floor with everyone else, no? It's always seemed unnecessary to me to worry about the effects of _more_ options, at least in the context of application development anyway.

Re:Ruby on WebAssembly by CyberDildonics on Sunday April 29, 2018 @02:13PM (#16953164)
Again, all the IO still has to be done in javascript, you can only do raw processing in web assembly right now.

If you try to write the web assembly part in ruby, you are sending your users a run time and using an interpreter that is itself being JITed, purely to transform some amounts of data between IO from the user, including any information to and from the DOM.

Re:Ruby on WebAssembly by deeg on Sunday April 29, 2018 @05:53PM (#16954120)
I thought the same thing when Node.js started to become popular: why would anybody go through the trouble to set up an environment to run single-threaded, interpreted applications on a server when we already had C/Java/.NET/etc?

It turns out people like to use the languages/environments they already know.

Re:Ruby on WebAssembly by tyingq on Sunday April 29, 2018 @09:48PM (#16955135)
There are plans for WASM to add features like GC, threads, PIC, direct DOM access, etc. So when those arrive, this can port over and bring less runtime.

And there is currently pretty direct access to a canvas.

Re:Ruby on WebAssembly by mshenfield on Sunday April 29, 2018 @05:44PM (#16954073)
There are lots of things you can do that aren't performance bound: web pages focused on content, 2D games, simple forms.
Re:Ruby on WebAssembly by arkh on Sunday April 29, 2018 @04:20PM (#16953722)
I hope we soon get Lisp on WebAssembly so we can run a full OS (emacs) in the browser.
Re:Ruby on WebAssembly by shakna on Sunday April 29, 2018 @06:07PM (#16954174)
We already have these two:

* Schism [0], R6RS Scheme.

* Arboreta [1], Common Lisp.

[0] https://github.com/google/schism

[1] https://github.com/Arboreta/arboreta-wasm

Re:Ruby on WebAssembly by cobbzilla on Sunday April 29, 2018 @06:38PM (#16954304)
Curious how fast/stable Ruby->wasm is on the frontend. I had a horrible experience with scaling a large rails app, but the usage patterns for server vs client are very different.

I haven't played with wasm yet and am waiting a bit for a "best language" consensus to emerge. If I was to bet on a winner, my money wouldn't be on Ruby, but I've been wrong many times.

Re:Ruby on WebAssembly by wolfspider on Sunday April 29, 2018 @05:46PM (#16954078)
Mruby has captured my attention for quite a while now, especially the ability to compile and run its own bytecode as a module. The memory handling seems good and want to try running it with Cairo GL for iOS sometime for some immediate mode rendering.
Re:Ruby on WebAssembly by choxi on Sunday April 29, 2018 @01:23PM (#16952913)
How would you use features like event listeners and other web APIs from client-side mruby? I guess this is a question about WebAssebly in general: does each language that gets ported over have to re-implement those APIs?
Re:Ruby on WebAssembly by rollcat on Sunday April 29, 2018 @03:03PM (#16953377)
wasm has something akin to a syscall interface to talk to the JS side, but you can't just call arbitrary JS.
Re:Ruby on WebAssembly by steveklabnik on Sunday April 29, 2018 @05:48PM (#16954096)
To clarify this a bit, webassembly modules declare external functions they'd like to call. When you instantiate the module, you hook JS functions up to those names. So, you can "call arbitrary JS" in the sense that there's no restrictions on what JS is in those functions, but you can't "call arbitrary JS" in the sense that the module has to list up-front what it'd like to call and it's the instantiator's job to provide those things or decide to not instantiate.
Re:Ruby on WebAssembly by singularity2001 on Sunday April 29, 2018 @01:43PM (#16953007)
Rubies magic evaporated when I realized that its logic is unintuitive / broken:

``` puts true and not true >>> true x = true and false >>> true if 0; puts 'true';end ```

breaking backwards compatibility with every rails upgrade didn't help.

Similar bad behaviour in kotlin

Re:Ruby on WebAssembly by dragonwriter on Sunday April 29, 2018 @01:58PM (#16953091)
So, your first two complaints are you not understanding Ruby operator precedence, not Ruby logic being broken, and the other is you not understanding Ruby truthiness (null and false are not truthy, all other builtin/stdlib values [and conventionally all other values] are falsely.)
Re:Ruby on WebAssembly by heartbreak on Sunday April 29, 2018 @02:05PM (#16953124)
And the final complaint was about Rails, not Ruby.
Re:Ruby on WebAssembly by abhorrence on Sunday April 29, 2018 @01:48PM (#16953035)
and/or/not have different precedence than &&/||/!.

The symbol versions of each of those would behave as you would expect. However, I can’t say much in favor of the existence of the word forms.

Re:Ruby on WebAssembly by lloeki on Sunday April 29, 2018 @03:27PM (#16953493)
The word forms are not operators, they're control flow, like "if"
Re:Ruby on WebAssembly by weaksauce on Sunday April 29, 2018 @02:43PM (#16953284)
Re:Ruby on WebAssembly by bdcravens on Sunday April 29, 2018 @05:26PM (#16953998)
Hasn't the use of "and" been considered a bad practice for years?
Re:Ruby on WebAssembly by weaksauce on Sunday April 29, 2018 @07:44PM (#16954587)
for boolean operations yes... for control flow it's debatable.