These are chat archives for opal/opal

19th
Jul 2016
Ilya Bylich
@iliabylich
Jul 19 2016 00:33
@dougo Opal doesn't have optparse (because Opal is mostly for browser). It could be used with Node but its implementation is quite complex - https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb. I didn't check but I'm quite sure that Opal can't properly compile it. That code is quite complex, at least stuff like do_something or return and those ruby-specific regexpes are not completely supported by Opal yet.
Probably it's possible to implement a minimal simplified subset of optparse
I guess if you want to use it with Node you should use Node libraries
Forrest Chang
@fkchang
Jul 19 2016 05:33
This message was deleted
Torsten Rüger
@rubydesign
Jul 19 2016 11:28
@elia Just saw the libraries compilation, great work! It says contribution and suggestions welcome at the bottom. If you make that a link or a mail, people might know where to put those suggestions. My suggestion would be to make a table or something, so the right column would be easier to scan. Another one would be to included liveliness, as that can be an issue with some of them. That would obviously only work if the list is generated.
Mitch VanDuyn
@catmando
Jul 19 2016 11:50
@qudware I don't know anything about firebase, let us know how it goes...
Guillaume Grossetie
@Mogztter
Jul 19 2016 12:35
@iliabylich I think this a "concurrent" issue. I can reproduce this issue when saving the whole javascript file produced. If I delete everything but "rescue_spec" then I get no error
Ilya Bylich
@iliabylich
Jul 19 2016 12:37
@Mogztter Then it can be some shared state between tests
And you are the only one who can catch it :smile:
Guillaume Grossetie
@Mogztter
Jul 19 2016 12:38
@iliabylich indeed, I will dig a bit further and let you know
lucky me :smile:
Guillaume Grossetie
@Mogztter
Jul 19 2016 12:44
seems like return_spec and rescue_spec are conflicting
ScratchPad is a good suspect
Guillaume Grossetie
@Mogztter
Jul 19 2016 12:55

The compiled code is:

(a = $rb_plus(a, (function() { try {
        console.log("self.$b()", self.$b());
        return self.$b()
      } catch ($err) {
        console.log("err", $err);
        if (Opal.rescue($err, [$scope.get('StandardError')])) {
          try {
            return c
          } finally { Opal.pop_exception() }
        } else { throw $err; }
      }})()));

When return_spec and rescue_spec are enabled, self.$b() 1

But when return_spec is disabled, an exception is thrown and rescue is working
so something is mocking self.$b() function in return_spec
    describe "downstream from a lambda" do
      it "returns to its own return-capturing lexical enclosure" do
        def a
          ->{ yield }.call
          return 2
        end
        def b
          a { return 1 }
        end

        b.should == 1
      end
    end
hm hm
Ilya Bylich
@iliabylich
Jul 19 2016 12:59
Yeah, it can be the issue
Guillaume Grossetie
@Mogztter
Jul 19 2016 13:00
but why am I the only one to reproduce this issue ?
I can confirm that the full test suites is working for me if I comment out downstream from a lambda spec
Ilya Bylich
@iliabylich
Jul 19 2016 13:03
usually rubyspec uses eval to evaluate the code directly in the context of the current example
Guillaume Grossetie
@Mogztter
Jul 19 2016 13:03
we can also rename b function to something less generic. Do you know why "inner" functions is visible outside ?
Ilya Bylich
@iliabylich
Jul 19 2016 13:04
For me rescue_spec gets executed before return_spec
That's why there's no conflict
Guillaume Grossetie
@Mogztter
Jul 19 2016 13:05
lol
Ilya Bylich
@iliabylich
Jul 19 2016 13:05
proc do
  def m
    p 'm called'
  end
end.call

self.m
Because blocks are evaluates in the outer context
And there's no private in opal
Guillaume Grossetie
@Mogztter
Jul 19 2016 13:06
got it
Ilya Bylich
@iliabylich
Jul 19 2016 13:07
Rubyspec defines method :b on the Object
And it makes it available everywhere
Guillaume Grossetie
@Mogztter
Jul 19 2016 13:08
For me rescue_spec gets executed before return_spec
Even with a french locale, return_spec should come after rescue_spec if sorted by filenames :wink:
but I guess we are not explicitly sorting files
Ilya Bylich
@iliabylich
Jul 19 2016 13:09
Could you check an output of tmp/mspec_nodejs.rb?
Guillaume Grossetie
@Mogztter
Jul 19 2016 13:10
I have one
Ilya Bylich
@iliabylich
Jul 19 2016 13:10
Yes, testing.rake has all the code for compiling rubyspec. It simply uses Dir['spec/ruby']
Guillaume Grossetie
@Mogztter
Jul 19 2016 13:11
what do you want to know about my tmp/mspec_nodejs.rb ?
Ilya Bylich
@iliabylich
Jul 19 2016 13:12
The order of require 'ruby/language/rescue_spec.rb' and require 'ruby/language/return_spec'
Guillaume Grossetie
@Mogztter
Jul 19 2016 13:12
  self.$require("ruby/language/return_spec.rb");
  self.$require("ruby/language/def_spec.rb");
  self.$require("ruby/language/throw_spec.rb");
  self.$require("ruby/language/rescue_spec.rb");
seems pretty "random"
but each time I'm running the order is the same

Rubyspec defines method :b on the Object
And it makes it available everywhere

So the only way to fix this issue is to rename b function ?

Ilya Bylich
@iliabylich
Jul 19 2016 13:46
No, it should be changed from def b; ...; end to eval('def b; ... end')
Guillaume Grossetie
@Mogztter
Jul 19 2016 14:23
Ok thanks for your help, I will create a pull request
Ilya Bylich
@iliabylich
Jul 19 2016 14:30
Wait, looks like it's a bug in Opal
When you explicitly define a method in it ... it doesn't appear on every object
(At least this is how it works with MRI)
But this method becomes available in other examples
(Which means that it should be fixed in rubyspec :smile: )
Guillaume Grossetie
@Mogztter
Jul 19 2016 14:36
Ugh! That's beyond my skill set :worried:
Ilya Bylich
@iliabylich
Jul 19 2016 14:49
This example shows the difference between explicit def and def in evaluate:
describe "Description" do
  evaluate <<-ruby, "Test 1" do
      def m1
        123
      end
    ruby

    m1.should == 123
  end

  it "Test 2" do
    def m2
      456
    end

    m2.should == 456
  end

  it "Test 3" do
    lambda { self.m1 }.should raise_error(NoMethodError)
    lambda { self.m2 }.should_not raise_error(NoMethodError)
  end
end
And it passes on MRI (didn't check on Opal yet). We need to modify rubyspec to have only examples like "Test 1". Tests like the second one are polluting global MSpec environment
Guillaume Grossetie
@Mogztter
Jul 19 2016 14:56
Yep I understand and you don't want to modify ruby/spec to surround every declarations with evaluate
I read again your message
you don't want to modify mspec runner ?
to invoke test on a new @env object ?
I can certainly add evaluate blocks on rubyspec :smile:
Ilya Bylich
@iliabylich
Jul 19 2016 15:01
Yes, we should replace every occurrence of explicit def in rubyspec to evaluate("def ...", &block)
Ilya Bylich
@iliabylich
Jul 19 2016 15:12
@Mogztter ruby/spec#275
Guillaume Grossetie
@Mogztter
Jul 19 2016 15:12
Thanks :+1:
I'm experimenting with evaluate, but maybe the maintainer (@eregon ?) has a better idea
Forrest Chang
@fkchang
Jul 19 2016 16:07

@/all I have a weird bug working with opal 0.10.1. When I compile the static file I get weird characters in front of methods names

 Opal.defn(self, '$attr_reader', TMP_14 = function ːattr_reader($a_rest) {

See the character in front of attr_reader? Anyone seen this or have an idea. I have with both ruby 2.3.0 and 2.2.1 against opal 0.10.1

Elia Schito
@elia
Jul 19 2016 16:31
@fkchang you're probably missing the utf8 meta tag in the html head tag…
@iliabylich what node version are you using to run the ruby spec?

@elia Just saw the libraries compilation, great work! It says contribution and suggestions welcome at the bottom. If you make that a link or a mail, people might know where to put those suggestions. My suggestion would be to make a table or something, so the right column would be easier to scan. Another one would be to included liveliness, as that can be an issue with some of them. That would obviously only work if the list is generated.

@dancinglightning they're taken from @fazibear's awesome opal page (link is at the top of the page)

Torsten Rüger
@rubydesign
Jul 19 2016 16:36
@elia yes i understood that, my suggestion was mostly formatting, and asking if they are manually taken or by script
Ilya Bylich
@iliabylich
Jul 19 2016 16:37
@elia 0.10.25
I guess it's quite old :smile:
Elia Schito
@elia
Jul 19 2016 16:37
@iliabylich got some regexp errors on node 6 last night
but wanted to check with you to ensure it was that
@dancinglightning sure, sorry for the short reply. the content is taken by a script to preserve the attribution etc. let me grab the link of the rake task
Ilya Bylich
@iliabylich
Jul 19 2016 16:40
@elia What is your version? I could try it locally
Elia Schito
@elia
Jul 19 2016 16:40
v6.2.2
Torsten Rüger
@rubydesign
Jul 19 2016 16:40
@elia ok, i'll check it out, thanks
Elia Schito
@elia
Jul 19 2016 16:41
👍🏼
Forrest Chang
@fkchang
Jul 19 2016 17:01
This is not opal related, but it's inspiring to me https://medium.com/radical-ux/nobody-hires-steve-jobs-bcc94fdf7acb#.u1p7mfld8
I was thinking the key to opal
's success would be to fit in better w/JS and other things to be popular in the Ruby community. Perhaps that's the wrong approach. In years of evangelizing, I've reached what, a handful of people? For myself, and I think I've been leaning that way for a while, maybe it's just "forget the rest of them, let's just make something 'insanely great' for my fellow opalists", but I suppose if we are to do a Steve Jobs approach, it' s not just focus on the product, but also the customers.
Forrest Chang
@fkchang
Jul 19 2016 17:06
So then I guess my thought of customers must be wrong? The rank and file (or even people of prominence) in the Ruby/Rails community largely don't care, so maybe I should stop trying to speak to that crowd. Why opal? For me, in 1 sentence, bringing the Joy of Ruby to everywhere that that Javascript exists. I guess it's still JDD (Joy driven development). I've been evolving towards that as my main message, maybe that's the unifying theme among "customers"
Torsten Rüger
@rubydesign
Jul 19 2016 18:34
@fkchang just 2 cent: I guess you can count me in as one of the handful :-) (i would think it's more but to the point) I think the customer is a rails developer. And so the product should be well integrated into rails, and one that provides benefit. Ie does more than one can do without feeling the pain of coffee script, but without abandoning rails. It seems to me there is lots of experimenting with pure client going on, which is great for play, but no use in production. And very real efforts for frameworks (clearwater, volt) just miss the customer imho, ie lack integration.
Torsten Rüger
@rubydesign
Jul 19 2016 18:51
@elia ok i had a look. Up to fazibear if he wants a table layout.
Doug Orleans
@dougo
Jul 19 2016 19:28
@iliabylich I was asking about optparse because it's used by Minitest, but opal-minitest has option handling disabled because of the lack of optparse in Opal. It uses phantomjs, not Node, but it's still a command-line use case. But, I just realized I could parse the command-line options in the Rake task (in plain Ruby), and pass them as a pre-parsed hash to Minitest inside Opal.
But tying this into @fkchang's topic, I think "Opal is mostly for browser" is maybe not the best stance to take.
or maybe it is... as long as that includes headless browsers. :)
I'll admit that the only reason I use opal-minitest is for unit testing my code that is intended to run in the browser.
hayley
@hayley
Jul 19 2016 19:34

@fkchang for me, the whole JDD is a big thing. Coffeescript was a decent improvement to the syntax, but I always missed the power of Ruby's standard library. Before, I switched to opal, I had started using http://sugarjs.com/ (which now seems abandoned), but it wasn't the same. I feel like half of my love of ruby is simply all of the useful things that are built-in to the language.

I kinda mentioned this once on the reactrb channel, but maybe opal itself could use something like https://react.rocks/ - I know that site has been hugely influential about getting me inspired about react in general. awesome-opal is a great start, but for someone like me, the "gallery" style (screenshots, etc) is what I really like to see since you can get more of a feel of something from a screenshot than from a text description.

My answer above... in 1 year we have reduced our code size by almost half, we have a much better UI, maintenance is easier, and we are not done yet... by end of year I expect this to be almost 100% ruby.
hayley
@hayley
Jul 19 2016 19:57
@catmando "You need permission to access this published document." :D
Mitch VanDuyn
@catmando
Jul 19 2016 19:57
rats...
hayley
@hayley
Jul 19 2016 19:58
As a shortcut, anytime I'm posting something where I feel permissions might be a problem, I try loading the page in Chrome's incognito mode to see what happens.
try that :-) Thanks @hayley
hayley
@hayley
Jul 19 2016 20:18
@catmando Nice. I have a random thought just for the heck of it: how hard would it be to show the difference? Like, not just as a chart, but something along the line's of atom's minimap (which obfuscates the actual text too) where you'd concatenate the entire v3 and v4 codebases into two tiny images that you could show side by side.
Mitch VanDuyn
@catmando
Jul 19 2016 20:23
that chart is about as close as you are going to get to that... there are just to many file changes if I understand what you are suggesting
hayley
@hayley
Jul 19 2016 20:28

@catmando it's just kind of an out there idea to begin with, but if you were using git and could easily check out the last version of v3 versus what you have now, that's what I'd use...

I might actually try to build a visualizer for myself if it doesn't already exist, but how I'm imagining it would work is that you'd point this image generator script at a project directory. And then it would go through and then produce one really long image à la atom's minimap (see the right side of the image in the screenshot on https://atom.io/packages/minimap).

I don't know, I'm thinking this counts more so as "fun" than useful, but it could be interesting as a before/after comparison tool.

Forrest Chang
@fkchang
Jul 19 2016 20:36
@dancinglightning regardless of whether the rank and file Rails dev is the target audience, I definitely think that better Rails integration benefits, simply because most Rubyists, and I'm assuming most opalists use Rails, so there's a lot of JDD to be exploited there.
@dougo I think a big thing for me is really "joy of Ruby everywhere there is JS", that's what is a big draw to reactrb (aside from the fact that react's component based framework is the 1st JS framework that sat well w/my way of thinking), is that if you can do reactrb (via react.js of course), then you can web, mobile (react native), and desktop (electron and friends), as well as some of the other fringe rendering platforms that react has reached (u can write terminal console apps w/react for example, flipboard made a react-canvas for performance, etc.)
but there are other options because JS is literally everywhere
@hayley a react rocks equivalent would be nice, not certain there is enough content yet for such, I guess the next best thing is the awesome-opal page
Doug Orleans
@dougo
Jul 19 2016 20:43
JS is everywhere, but Ruby is also most places too, so it's hard to see a case for Opal where MRI works just fine.
which is what I assume @iliabylich was getting at with "Opal is mostly for browser".
meh.
@meh
Jul 19 2016 20:45
dougo, yeah I don't get the point of running Opal on Node.js, other than helping with running tests or whatever
Doug Orleans
@dougo
Jul 19 2016 20:46
maybe if you need better threading, but then why not go to Elixir...
Forrest Chang
@fkchang
Jul 19 2016 20:47
@dougo in the case of reactrb, it's not just 1 language, but 1 way to write apps for desktop, web, mobile
Doug Orleans
@dougo
Jul 19 2016 20:48
sure, but that's basically the same as "for browser". it's just that the brower is also on desktop and mobile.
Forrest Chang
@fkchang
Jul 19 2016 20:48
u could do mri/jruby server, opal web, rubymotion ios, etc... but 1 language (sorta), and 3 ways (arguably still a diff in web front vs back, but reactrb lets you do server rendered views w/the same views you have on the front end, though opal lets u do that too w/erb and haml)
node.js vs MRI, I don't have a compelling need for it at the time, but I could imagine that it might better if you wanted truly the same language on both sides vs close to the same langauge w/MRI and opal, and for the same perf reasons that ppl dropped MRI for node, would apply except that you can write ruby on node via opal
JRuby brought "joy of ruby wherever the JVM is" for the most part, though I continue to see issues w/resources and start time. They continue to get better, but it affects the speed cycle, lessoning the JDD for me. Also, there are a number of gems which are neglected for JRuby. Still feels like JRuby and JRuby on Rails is a 2nd class citizen, despite JRuby being the most performant of Ruby implmentations
meh.
@meh
Jul 19 2016 20:51
dougo, but Node.js is not multi-threaded
Doug Orleans
@dougo
Jul 19 2016 20:52
good point :)
Forrest Chang
@fkchang
Jul 19 2016 20:52
It does seem that JS will have greater reach than the JVM, esp. in new horizons, for example IOT seems to be embracing JS, and you can dev for Windows 10 desktop and Mobile via js/HTML etc...
I'm back to "Joy of Ruby everywhere JS is", in some cases, where better integrated the JDD is there
Ride the JS train, after all, why not?
@catmando I'm gonna tweet that slide
Doug Orleans
@dougo
Jul 19 2016 20:54
so far the MRI train still services most of the stops I want to visit :)
Forrest Chang
@fkchang
Jul 19 2016 21:00
@dougo no problem with that. I think similar to @hayley's notion of having something like react rocks, until a good example of how awesome it IS (vs could be), it'll be a hard sell. One of these days, I'll get one of my startup ideas up with an "all ruby stack" and then I can show it
Mitch VanDuyn
@catmando
Jul 19 2016 21:04
@fkchang yeah you should...
I will on reactrb as well
hayley
@hayley
Jul 19 2016 21:34

re a react.rocks type of site, I'd actually be willing to come up with something at some point both opal/reactrb related (could be the same site and just filterable by specific technologies used), but I'd probably say my big concern is I don't want to get in a position where I feel like I'm stepping on toes.

Like from watching some of the "awesome" lists and their pull requests, some of them are taking curation seriously and rejecting pull requests if they don't think something is awesome enough. Granted, that would be a problem with a text-only list: if it grows too large, it's hard to find the best of the best since there's zero filtering. Whereas a web page could kind of skirt around that via a voting/rating system or taking things like github stars into account.

Personally, I feel like there shouldn't necessarily be curation (because likely every project is going to be of interest to someone), but obviously there needs to be a way for the most useful things to be easily findable.

Mitch VanDuyn
@catmando
Jul 19 2016 23:13
Seems like rescue Exception => e no longer has a backtrace on e... does anybody know why?
Mitch VanDuyn
@catmando
Jul 19 2016 23:35
NVM firefox issue (I guess) works fine in chrome as always...