These are chat archives for opal/opal

17th
Jul 2015
Christian Käser
@dfyx
Jul 17 2015 10:45
@meh, @adambeynon, @elia Now that opal 0.8 is out, when will opal-rails follow?
Elia Schito
@elia
Jul 17 2015 10:46
@dfyx will take care of that shortly
Christian Käser
@dfyx
Jul 17 2015 10:50
@elia Great
I have an in-house rails app that currently runs on opal 0.7
Rick Carlino
@RickCarlino
Jul 17 2015 14:36
Does opal have SimpleDelegator?
Gabriel Rios
@gabrielrios
Jul 17 2015 14:39
Yes
Forrest Chang
@fkchang
Jul 17 2015 17:58
anyone on?
Elia Schito
@elia
Jul 17 2015 18:16
Sup
Torsten Rüger
@rubydesign
Jul 17 2015 18:19
quiet here, @fkchang i’ve been meaning to say: That new hope talk was excellent. One of the best ever, both in content and presentation. It’s what got me to pick it up, thanks!
Mitch VanDuyn
@catmando
Jul 17 2015 18:50
@fkchang, am now...
Forrest Chang
@fkchang
Jul 17 2015 19:03
@dancinglightning thanks, I put a lot of work into that talk
Torsten Rüger
@rubydesign
Jul 17 2015 19:05
@fkchang well it was great. btw wasn’t there some class browser ?
Forrest Chang
@fkchang
Jul 17 2015 19:07
Anyways, I was thinking about some form of web_require for opal. In opal-irb (and by proxy opal-playground) I implemented a require_js - demoed here where I require_js raphael.js to mess w/it http://git.io/vmGmQ. I was figuring if we had some sort of cdn where we compile all the opal libs, that could be useful for real time experimentation, I don't think I'd do that in a production app. Related, we could do a web_require on opal code itself if we setup the right type of repo, a rubygems for opal, per se, where we could resolve dependencies because we know where the code would live
thoughts?
@dancinglightning I demo'ed my "opal-inspector" prototype -- if you saw @catmando and my conversation here yesterday, I talked a bit about it. Long story short, I plan to borrow smalltalk and lisp machine stuff to make really cool opal tools, I'm kind of blocked on that feature I want @adambeynon but I'm looking to some workarounds to get something to show
Mitch VanDuyn
@catmando
Jul 17 2015 19:13
@fkchang so if you do a web_require 'my-opal-lib' it would just work? Neat idea. Could it be somehow integrated with sprockets so that in a production environment it grabs all the stuff while it builds the assets?
The problem would be preventing unwanted config changes when new version of a gem were released. For that you are back to some kind of gemfile / gemfile.lock structure right?
Forrest Chang
@fkchang
Jul 17 2015 19:16
@catmando that's the idea. It's thought from the perspective of adding code at runtime. My initial thought is I'm in opal-irb (or playground, or the future opal-inspector) and I just want to pull something in that I didn't already have required on the server side (which is currently not possible -- you have gem install, require, etc... and restart app). So for experimenting or development that's useful, but I see that once I've figured out what I want to use, that I'd do it the normal way. That said, @ryanstout made some mention of wanting to be able to load something like opal-irb on demand, but not always, where something like this would be useful
Mitch VanDuyn
@catmando
Jul 17 2015 19:17
@fkchang, but perhaps it could all be implicit... so you web_require a file, it checks (server side) to see if that file has been required before. if not it gets it and adds it the assets. If its already there you have the one then you stay with that version, until you do some explicit action to remove.
Forrest Chang
@fkchang
Jul 17 2015 19:17
If we setup some sort of opalgems server, web_require could hit that, it'd know how to traverse the directories and compile to js in the browser. Dependencies on other opalgems could be resolved by convention
etc. But an reasonable low fruit would be to have compiled versions of all the opal libs, and just use require_js (I think that should work)
then I could require_js opal-react, for instance on opal-playground right now and mess w/it
But if I'm the only one who wants this feature, I wouldn't spend much effort on it
@catmando ur web_require is something to think of
Maybe we don't need a repo, we could crawl source on github as long as we can figure out conventions
for web_require that is
Torsten Rüger
@rubydesign
Jul 17 2015 19:21
@fkchang maybe i misunderstand, but could this not be a opal.server feature, or a sinatra app that you write.
Forrest Chang
@fkchang
Jul 17 2015 19:23
@dancinglightning to serve as the "opalgems" server?
I would've imagined that @adambeynon @elia and @adambeynon must've have thought about something like web_require/opalgems before
Mitch VanDuyn
@catmando
Jul 17 2015 19:25
however... all that said, how much does this really buy over simply releasing a gem?
Forrest Chang
@fkchang
Jul 17 2015 19:26
maybe there's some insights
@catmando the whole point is to be able require things at run time
the analogy is real irb, where anything I've installed, I can simply require it and then use it
Now if you haven't installed, you still have gem install it, but everything is available at run time
Gems are fine when you already know you want it, then u install, require it in your app etc.
Mitch VanDuyn
@catmando
Jul 17 2015 19:28
I see, well in that case, I think you can still use all the existing gem infrastructure.
Forrest Chang
@fkchang
Jul 17 2015 19:29
Again, if no one finds it useful, not something I'll spend a lot of time, but low hanging fruit is if opal-react or opal-pixi is compiled to js somewhere, I can just require_js them right now in anything that has opal-irb included and mess w/it, and I could do that right now -- that meets the need of "adding functionality at run time"
Torsten Rüger
@rubydesign
Jul 17 2015 19:31
@fkchang I went through playing with 4 different opal libraries in 2 days. Never saw it as a problem to stop my server, change the gemfile, bundle and restart. It was the reading up and getting to know the libraries that took more time.
Mitch VanDuyn
@catmando
Jul 17 2015 19:31
Hmmm... I sort of see what you mean. Certainly some way to add more to opal-irb at run time is good, but not really sure
Torsten Rüger
@rubydesign
Jul 17 2015 19:32
I do think that an irb on a running app (in dev mode) would be useful though
or a class / object inspector. a debugger as it were
Mitch VanDuyn
@catmando
Jul 17 2015 19:33
I'm with @dancinglightning. And beyond understanding the library, lets say you did automagically pull in opal-react, well that's nice but to make it useful there are going to have to be other stuff added.
Gabriel Rios
@gabrielrios
Jul 17 2015 19:34
@fkchang This might be useful, mostly for opal-irb indeed (and maybe opal-repl). But what I find really interesting about require_js is that we might want to use it on wrappers, right now everytime someone is going to use opal-pixi, opal-react and other libraries there’s the need to add the script tag, which someone might not be expecting
Torsten Rüger
@rubydesign
Jul 17 2015 19:35
@fkchang didn’t mean to take the wind out there. I do think it’s good that you are thinking of how to improve development. It’s been the same for too many decades
Mitch VanDuyn
@catmando
Jul 17 2015 19:35
I think its a good feature, but I think there are bigger fish to fry that will get generate opal excitement.
Forrest Chang
@fkchang
Jul 17 2015 19:35
@dancinglightning running opal-irb on apps is really handy. I've used the "live gist" to even help a coworker debug by setting up the situation that went wrong
Gabriel Rios
@gabrielrios
Jul 17 2015 19:35
Anyway there was a opal-cdn thing, that looks down right now (https://github.com/opal/opal-cdn), and I remember @ylluminate talking about having a central cdn for all opal gems
Forrest Chang
@fkchang
Jul 17 2015 19:35
W/o opal-irb, it'd be so hard to get the situation over to him
Mitch VanDuyn
@catmando
Jul 17 2015 19:38
I am just thinking if we want to do this then just make it work with standard gem structure. Have opal-irb redefine require, so that it "knows" how to go the gem server find the gem extract the needed opal code, and pull it down. It might be easier to set up a rails / sinatra server that does the donkey work and caches the results.
Forrest Chang
@fkchang
Jul 17 2015 19:39
@dancinglightning no worries, a bunch of the stuff I have in mind, most people won't be able to appreciate until they use it. Some folks in the Ruby world are familiar w/the smalltalk dev env (see avdi's recent gushing on smalltalk for someone who has recently discovered it - or rediscovered it). I believe I am the only person I know in the Ruby community who has ever used a lisp machine, so there's somethings I'll borrow, that pretty much no one in the ruby community has seen.
@gabrielrios my quickie require_js implementation was to insert a <script> tag into the DOM, so as such, there can be a timing issue, if you look at the git.io link above, my code has a delay to ensure raphael is there, so I wouldn't use it for actually running of an app. My workaround in opal-irb is some view helpers that insert the additional js requirements, like <%= OpalIrbUtils.include_opal_irb_jqconsole_requirements %>
@gabrielrios I should check out opal-cdn, that might dovetail w/require_js just fine
@catmando if u come up with a good scheme for using the gem structure, I'm all for it
Torsten Rüger
@rubydesign
Jul 17 2015 19:43
@fkchang ok, haven’t used lisp, but been very interested in smalltalk (==read blue book twice) for 2 decades. And as much as i hear your ideas i do appreciate the direction. Since that is new there are bound to be hits and misses. Always thought that while a good idea, the image is what braught smalltalk down as much as anything
Mitch VanDuyn
@catmando
Jul 17 2015 19:44
@fkchange - I will definitely be thinking about it
Forrest Chang
@fkchang
Jul 17 2015 19:44
In the near term, I kind of don't want to include every opal lib under the sun in opal-playground in case someone might want to use it
that being said, I could do it differently, since I just got an idea talking about
@dancinglightning the real key, and I mention this in my new hope talk, is that having the "IDE" run in the same env as the application (i.e. an opal app in the browser with opal tools right), give you many of the capabilities of the small talk image. How did implement code complete in like 2 pages of code for opal-irb (still ongoing)? Because opal-irb lives in the app, and can just ask the classes, objects, etc.
I'm ok w/thinking web_require isn't needed, or worth the ROI. If I had that "lookup code and comments by name", I'd build the small talk object browser tool
require_js works now, and I could change how I include extra opal libs in opal-playground, so I don't need web_require at the moment
Elia Schito
@elia
Jul 17 2015 22:43

I would've imagined that @adambeynon @elia and @adambeynon must've have thought about something like web_require/opalgems before

@fkchang https://github.com/opal/opal/blob/master/stdlib/opal-parser.rb#L12-L19

Ryan Stout
@ryanstout
Jul 17 2015 22:43
@elia is there any benchmarks for compile time?
seeing about 2x slower compile times in 0.8
Elia Schito
@elia
Jul 17 2015 22:44
interesting
Ryan Stout
@ryanstout
Jul 17 2015 22:44
might be something I'm doing
Elia Schito
@elia
Jul 17 2015 22:44
not that i know
Ryan Stout
@ryanstout
Jul 17 2015 22:44
wasn't sure if anyone else saw a slowdown
Elia Schito
@elia
Jul 17 2015 22:45
if you do any test would be interesting to see the results
Ryan Stout
@ryanstout
Jul 17 2015 22:46
so I think maybe its related to Opal::Processor.load_asset_code running on the main page load
before I was just loading the urls directly, and it would compile each one in parallel (I think), but now it looks like it does each compile synchronously on the main page load first
Elia Schito
@elia
Jul 17 2015 22:47
that could be given it has to look into sprockets
Ryan Stout
@ryanstout
Jul 17 2015 22:49
my initial page on an empty app is now 2.5 sec (before loading any scripts), but before it would load everything in 1.3 sec
total page load time is 7 seconds
:-(
are you seeing anything like that on your apps?
does sprockets do the compile on the initial page load so it can show you an error if any of the dependencies are broken?
Elia Schito
@elia
Jul 17 2015 22:50
alas I lack the pre/post delta no having a "pre"
is it rails or volt?
Ryan Stout
@ryanstout
Jul 17 2015 22:53
volt
I guess I can make some tests
Elia Schito
@elia
Jul 17 2015 22:54
yep, i guess the loading part could be cached too
Ryan Stout
@ryanstout
Jul 17 2015 22:54
sorry, which loading part?
is the compile on the initial page not cached?
Elia Schito
@elia
Jul 17 2015 22:55
Opal::Processor.load_asset_code
I see about a second on my rails app consumed by javascript_include_tag
but never investigated to see if its the load asset code call
Ryan Stout
@ryanstout
Jul 17 2015 22:58
a second for the initial page load?
Elia Schito
@elia
Jul 17 2015 23:01
have a partial for the <head> which takes about that time
in dev only of course
@ryanstout bedtime, keep me posted, would be definitely good to improve perf
Ryan Stout
@ryanstout
Jul 17 2015 23:06
@elia thanks for the help. I'll see what I can figure out.