These are chat archives for opal/opal

23rd
Apr 2015
Ryan Stout
@ryanstout
Apr 23 2015 00:29
does that give a significant performance improvement?
George Plymale II
@ylluminarious
Apr 23 2015 04:44
sorry, don't mean to interrupt the conversation here, but just a quick question about accessing js properties in native opal. i have an example here: http://cl.ly/0K0x1k3H1t0Y that models a problem i am currently having. if you run the code, you get an error saying that element.$name() is undefined (which is the code on line 21). the only way i can see to bypass this error is to do something like this: http://cl.ly/1I2O1t3X0W0O. however, i'd prefer to find a solution for this in native opal. does anyone have any ideas?
Elia Schito
@elia
Apr 23 2015 07:50
@ylluminarious alias_native is for methods, not for properties, including native should already set a method_missing handler that will respond with the property value iirc
…but apparently I don't recall correctly >.<
The solution seems to be this:
problem is that native doesn't cross the border of bridged classes I think, but when an Array, which is bridged contains native elements it fails because the Array already is marked as "opal-ready" and thus Native won't check/wrap its contents cc: @meh @adambeynon
Elia Schito
@elia
Apr 23 2015 08:37

does that give a significant performance improvement?

@ryanstout only on math ops, on that it's dramatic, it's the difference between method call with proto chain lookup and func call (which is substantially inlined by all browsers)

Adam Beynon
@adambeynon
Apr 23 2015 09:41
@elia @ryanstout also, on non-math object (i.e. anything not a number), the extra overhead is tiny (< 0.05% according to jsperf)
the only downside is ugly generated code
but then, source maps..
Elia Schito
@elia
Apr 23 2015 09:43
@adambeynon you had a look at the failures that come up when enabling the optimization?
Vais Salikhov
@vais
Apr 23 2015 12:13
@elia how do you run the specs with optimization enabled to see the failures?
Vais Salikhov
@vais
Apr 23 2015 12:18
@elia right, I got that, but how do you actually execute the specs with that option enabled? I was looking for some env var or something... I mean bundle exec rake ???
Elia Schito
@elia
Apr 23 2015 12:19
@vais no, you just change the default value, that's our aim anyway, to enable them by default
but I must confess that having a way to run specs with different option combinations is a very good idea
and probably worth adding some of them as travis builds
Vais Salikhov
@vais
Apr 23 2015 12:20
Ahh, I see, it's easier than I thought :) I'll give it a try...
Elia Schito
@elia
Apr 23 2015 12:21
awesome ✨
Adam Beynon
@adambeynon
Apr 23 2015 12:22
@elia just hit an interesting milestone with an Opal app. The “main” one I work on has just hit 2.0mb minimised javascript. the code base is now epic.
Elia Schito
@elia
Apr 23 2015 12:22
hey!
any chance I can put my :eyes: on it?
Adam Beynon
@adambeynon
Apr 23 2015 12:23
ls -al app/assets/javascripts/views/*/.* | wc -l
193
that is a lot of view classes!
Elia Schito
@elia
Apr 23 2015 12:23
indeed
Adam Beynon
@adambeynon
Apr 23 2015 12:24
I gave up on the idea of going from haml views -> react.rb
rewriting all those will be painfull
Elia Schito
@elia
Apr 23 2015 12:25
yes, the best would be to have haml compile directly to a react tree that can be compared to the currently rendered one and then perform its minimal updates
Vais Salikhov
@vais
Apr 23 2015 12:29
@elia setting compiler_option :inline_operators, true, :as => :inline_operators?, I am seeing 4 errors for the entire spec suite, in Array#-, Array#+, String#*, and String#+. Are those the failures you are referring to? Is there anything else?
Elia Schito
@elia
Apr 23 2015 12:30
Don't remember honestly, I quickly tried enabling it a month ago I think and lacked the time to look in detail
@vais give a try to rake mspec_phantom which uses phantomjs and sprockets to run the specs, just to add a different code path
Vais Salikhov
@vais
Apr 23 2015 13:05
@elia brew install phantomjs-ing now. I'll try to wrap my mind around it over the weekend.
Vais Salikhov
@vais
Apr 23 2015 13:32
Hmm... @elia with or without optimizations, here is what I get:
$ bundle exec rake mspec_phantom
Starting MSpec Runner...
[filters] Adding 43 spec files...
[shared] Adding 160 spec files...
[lexer] Adding 1 spec files...
[parser] Adding 30 spec files...
[rubyspecs] Adding 298 spec files...
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on localhost:9999, CTRL+C to stop
TypeError: undefined is not an object (evaluating 'args[0]')

  /Users/vais/GitHub/opal/lib/mspec/opal/sprockets.js:34 in global code
Am I doing something wrong? I.e. does rake mspec_phantom work for you?
George Plymale II
@ylluminarious
Apr 23 2015 14:34
@elia thanks for the advice earlier! sorry, i didn't reply sooner; i was sleeping.
Forrest Chang
@fkchang
Apr 23 2015 16:17
@elia @adambeynon wrt haml-> react, how about paggio on both sides? opal-react's html dsl resembles paggio quite closely.
Elia Schito
@elia
Apr 23 2015 16:23
Paggio makes total sense unless you want to avoid migration from haml:)
Forrest Chang
@fkchang
Apr 23 2015 16:48
@elia a haml -> paggio converter shouldn't be too hard, no?
though I had a problem trying to add paggio to my opal-rails app by itself the other day, not certain what the issue was but even the simplest example sent Chrome into some kind of infinite loop, @meh thought it might be an inspect bug
Also, I'm seeing a bunch people seemingly reinvent paggio, I think in part cuz ppl don't know it exists, or all the functionality that's in opal-browser. I will not, if you're using rails and opal-rails that jquery and opal-jquery are already bundled in. This time around I decided not to fight what was already there, but I strive towards jQuery free apps where possible
meh.
@meh
Apr 23 2015 16:51
@fkchang yeah, I tried to look but I couldn't see any issues with the inspect code, I'll have to dig deeper, did you try with other browsers?
Forrest Chang
@fkchang
Apr 23 2015 16:53
@meh I should try, but I backed away to get the task at hand finished. If I have time, I'll setup the simplest opal-rails w/paggio project that duplicates the erro
meh.
@meh
Apr 23 2015 16:53
@fkchang cool
Forrest Chang
@fkchang
Apr 23 2015 17:17
@meh creating the project from scratch was not too hard https://github.com/fkchang/test_paggio_and_rails -- I'll not that it does the same thing to safari. app/assets/javascripts/test_paggio.js.rb is the file
Jared White
@jaredcwhite
Apr 23 2015 17:51

@adambeynon Got a quick question on Promises, not sure if I'm doing something wrong or ran into a limitation. I'm trying to run some code whether the promise is resolved or rejected, for instance in an HTTP request via opal-query:

  HTTP.get('/fooling/jsonstest').then do
    alert 'good!'
  end.fail do
    alert 'oops!'
  end.always do
    alert 'finished'
  end

But the "always" block doesn't actually happen always. My expectation would be to get "good!" + "finished" alerts if the request was successful, and "oops!" + "finished" alerts if not. Any ideas?

Adam Beynon
@adambeynon
Apr 23 2015 18:42
@jaredcwhite that would be my assumption as well. I’ll check with @meh as he implemented it.
but yes, that should be the case
meh.
@meh
Apr 23 2015 18:51
@adambeynon @jaredcwhite it's like that by design, I don't know if it would be possible to implement it like that since a rejection is short circuiting.
Adam Beynon
@adambeynon
Apr 23 2015 18:52
@meh does Promises A have anything similar to #always?
meh.
@meh
Apr 23 2015 18:53
adambeynon, I don't remember, I think not, #always was more like an lias to .then(&block).fail(&block)