These are chat archives for opal/opal

13th
May 2015
Forrest Chang
@fkchang
May 13 2015 00:05
@vais, I could certainly write some specs, or at least some pseudo spec. If the caller is in the same place as the where Opal code is compiled, it'd be relatively easy. A potential issue is then you'd have to package the indexing of such which could be quite large. I would probably want to have it on demand the info, similar to source maps, but I guess 1 step at a time.

perhaps @adambeynon has some ideas, but I'm foreseeing something like this

  • static app - prepackage indexing w/app via a compile option
  • app w/ruby based server, possible to prepack via same compile option or, with some sort of rack middle ware that servers up info on demand much like source maps, which accesses on demand some output the compiler emited when it was compiled
    Ultimately in something like opal-inspector, I would override the mapping w/code that is evaluated in browser, so I would also want the ability to send it back to the server, but that's out of scope for the feature I'm asking and more in the middle ware.

So I guess I'd start with the compile option

Vais Salikhov
@vais
May 13 2015 00:10
@fkchang any idea how this is done on MRI (in pry for example)? Would that approach not work for what your are trying to accomplish?
Forrest Chang
@fkchang
May 13 2015 00:14
@vais I don't know how it's done in pry, but I'd guess it has some index and servers up the files off the file system, which described like that is close to what the source maps do
Pry's example might provide insight, wouldn't be surprised if it dropped in to C to do it though. Maybe @elia can provide some source map insights
You ultimate need to index a method entity with code that was compiled, @adambeynon suggested some AST traversing for part of that. Then you'd store it somewhere. Packaging could be as easy as global hash or similar.
Vais Salikhov
@vais
May 13 2015 00:19
@fkchang this does sound very close to what sourcemaps do. I have no idea how sourcemaps work, so that would be the place I'd start to figure this out. And yes, the difference with MRI is that it has direct access to the source files on disk. So, it looks like sourcemaps would play into this one way or another.
Forrest Chang
@fkchang
May 13 2015 00:21
Step one I'd go with fully qualified method names ruby $method_lookup = { 'Mod::Class1#foo' => "def foo (param)\n blah(param)\nend" }
Forrest Chang
@fkchang
May 13 2015 00:32
@vais I added a pseudo spec to opal/opal#840 -- tell me if it makes sense
Vais Salikhov
@vais
May 13 2015 10:26
@fkchang makes sense ;)
Vais Salikhov
@vais
May 13 2015 11:08
@elia, you there?
I'm trying to run bundle exec rake dist on the latest master, and it chokes:
* building math...             done. (development:  10.93KB, minified:   7.63KB, gzipped:   1.26KB).
* building minitest...         rake aborted!
Sprockets::FileNotFound: couldn't find file 'optparse'
  (in /Users/vais/GitHub/opal/stdlib/minitest.rb)
This is in regards to jshint, I want to run it locally, so I need rake dist which I've never used before.
Any ideas?
Vais Salikhov
@vais
May 13 2015 12:04
@elia weird, I checked out your upstream/jshint branch, and I'm still getting an error, but it's a different one:
* building math...             done. (development:  10.93KB, minified:   7.63KB, gzipped:   1.26KB).
* building minitest...         rake aborted!
Sprockets::CircularDependencyError: /Users/vais/GitHub/opal/stdlib/minitest.rb has already been required
Forrest Chang
@fkchang
May 13 2015 14:38
@vais @elia when I was describing the process outload, maybe we could just slightly piggy back on the source maps mechanism. We already map lines of code to source maps, maybe the indexing by method comment simply generates the same sort of mapping of method/comment to source code?
this w/o knowing how the source maps are implemented at all
@jaredcwhite good editorial summary/copy on the opalist! kudos
Jared White
@jaredcwhite
May 13 2015 15:57
@fkchang Thanks man. Yeah, I enjoyed reading about your dev experience on the project.
Jose Bencosme
@jlbenc
May 13 2015 18:47
Hello, all. Avdi mentioned Volt on the Ruby Rogues latest episode (#207, around ~40:00). Go Opal! :)
Rick Carlino
@RickCarlino
May 13 2015 18:47
Awesome!
Jose Bencosme
@jlbenc
May 13 2015 18:48
Simple mention, but nice anyway!
Hampton Catlin
@hcatlin
May 13 2015 20:12
hahahaha
YOU ARE TALKING ABOUT ME
Forrest Chang
@fkchang
May 13 2015 20:12
@hcatlin just about to respond to that tweet
Hampton Catlin
@hcatlin
May 13 2015 20:13
My current startup is an open sourced Ember app with a Rails API backend. I'm not disappointed with Ember, but I'm also not 100% happy with it.
I'm needing to build a simple side-site, that's pretty interaction heavy... and so I've been evaluating different options.
Forrest Chang
@fkchang
May 13 2015 20:14
@hcatlin what are you not happy about wrt to ember? There are certain perks that I think opal brings out of the box, they may or may not address your grievances w/ember
Hampton Catlin
@hcatlin
May 13 2015 20:15
There are a lot of best-practices that aren't written down, and vague references to how you are doing it wrong (by following the public guides)... which is kind of an odd feeling.
And, there are definitely funny edge cases all over the place that aren't covered at all.
Odd behaviours that are hard to tell if it's a bug or something I did or a best practice I never read or, more typically, just an "edge case" that they haven't gotten to yet.
The thing I love is the fast auto-reloader of Ember-CLI.
But, I freaking hate that to upgrade, I have to delete the node_modules and bower_components folder to get it tow rok.
work*
Hampton Catlin
@hcatlin
May 13 2015 20:20
I don't think Opal directly solves any of those, tbh, but I'd rather deal with trying to translate Ruby concepts into interactive apps, then wrangling with weird prototype-object behaviours and weird NPM side-effects.
I kind of think Opal + React could be interesting.
Writing pure Javascript makes me use patterns again, just like when I used to write Java. It makes me miss the feeling I had with Ruby, where I don't feel like I need to implement patterns, since the language makes coding more straightforward.
hcatlin @hcatlin attacks the room with messages
Elia Schito
@elia
May 13 2015 20:24
@hcatlin great to hear that!
Hampton Catlin
@hcatlin
May 13 2015 20:25
Now, I just need to give this a good test run. What's the simplest way to get an opal server running so I can start building an app? Templating + Opal Scripts, etc.
Elia Schito
@elia
May 13 2015 20:25
and welcome! also u'r internet famous ;) and linking your tweet was necessary
@hcatlin check out the rack example in the repo
there's also an adapter for a templating language you may have heard of… if your interested
Hampton Catlin
@hcatlin
May 13 2015 20:27
hahahaha... I just saw it!
Wait... so how does that work?
Does it use the regular Haml gem?
Elia Schito
@elia
May 13 2015 20:28
yep
cool uh
?
Hampton Catlin
@hcatlin
May 13 2015 20:29
oh... so it does Haml->Semi-HTML?
Elia Schito
@elia
May 13 2015 20:29
compiles to ruby first and then to js
Hampton Catlin
@hcatlin
May 13 2015 20:30
is that... efficient?
Elia Schito
@elia
May 13 2015 20:31
it's done on the server, and the client just does string concatenation, so I guess yes
Hampton Catlin
@hcatlin
May 13 2015 20:32
When deploying to production, the compilation is done as part of the asset pipeline in Rails, right?
Elia Schito
@elia
May 13 2015 20:33
yep, it's based on sprockets
Hampton Catlin
@hcatlin
May 13 2015 20:33
I'm assuming Opal in production is a static compiler.
Yeah.
Hmmm..... looking at this just makes me desperately want to make a live reload server.
Elia Schito
@elia
May 13 2015 20:34
@ryanstout has done it for volt
if there's anything for sprockets it should work out of the box
Hampton Catlin
@hcatlin
May 13 2015 20:35
I'm trying to keep a clean API for our customers to use... so that's why Volt probably is too much for me. But, I should learn more about it.
Elia Schito
@elia
May 13 2015 20:36
what I meant is just that it's doable :)
Hampton Catlin
@hcatlin
May 13 2015 20:36
right.
Elia Schito
@elia
May 13 2015 20:36
be back in 15min
Elia Schito
@elia
May 13 2015 20:47
@hcatlin master is advised or 0.8 beta
at least to get working source maps
Forrest Chang
@fkchang
May 13 2015 21:13
@hcatlin re: reload, I plan to enable dev in the browser, so there would be no reload, and better yet, you get to keep your current state, ala lisp machines and smalltalk. To some extent you can do that now w/opal-irb, but my ultimate goal is much more ambitious, ala this prototype https://www.youtube.com/watch?v=TRkhihHVLzQ -- though most people haven't worked w/lisp machines or smalltalk, so they don't really get what I'm pitching, from what I can tell
Hampton Catlin
@hcatlin
May 13 2015 21:16
hahahaa... that's intense.
i'm currently trying to get something to just display on a the page with the sinatra app...
I feel like I'm missing something obvious here.
Like, I know this is general purpose Ruby->JS, and not a framework, but I'm trying to figure out how to work with the browser itself.
Elia Schito
@elia
May 13 2015 21:18
it's either opal-jquery or opal-browser
the alternative is using native.rb
Forrest Chang
@fkchang
May 13 2015 21:19
@hcatlin re, getting started, I feel your pain. I started (but never completed) https://github.com/fkchang/opal-starter-kit w/the intention of making getting started 2 steps --- also to officially document the correct ways to setup
Hampton Catlin
@hcatlin
May 13 2015 21:19
vienna doesn't cover it
oh!... let me check that out.
Elia Schito
@elia
May 13 2015 21:19
vienna it's based on opal-jquery
Forrest Chang
@fkchang
May 13 2015 21:20
@hcatlin opal-browser covers a lot more functionality than jquery, -- canvas, websql, websockets, etc. but you might be more comfortable w/opal-jquery if your a jquery person
@hcatlin re frameworks, there's vienna, lissio that are more mature, and new ones like volt, clearwater, opal-react that I know of
Hampton Catlin
@hcatlin
May 13 2015 21:21
I guess I'm looking for a template folder I can setup...
And where I can just write some CSS and get to building something.
Models are less important...
I guess I mean server-side support, more than an intense browser framework.
The starter-kit seems pretty close.
Forrest Chang
@fkchang
May 13 2015 21:26
@hcatlin yeah, so if opal-starter-kit was coded against like opal 0.5 ish, I've been meaning to revisit. I think the most bells and whistles out of the box is to setup opal-rails
then you can just edit the haml and the opal code w/o having to set stuff up
It's nice to just use the rails conventions, write opal in both *.js.rb files and via the :opal filter in haml
Hampton Catlin
@hcatlin
May 13 2015 21:28
my goal is to have this thing be fully static... so I might give opal-jquery a try.
Forrest Chang
@fkchang
May 13 2015 21:30
@hcatlin I think starting w/opal-rails makes it easy to get started and monkey w/stuff and then you can switch to generating a static app. When I get around to updating the starter kit, I'm going to make the static recipe, include opal server, so you can dev against it, and have a rake task to generate the static app.
meh.
@meh
May 13 2015 21:30
hcatlin, if you want something fully static, check out lissio
hcatlin, I built an Overwolf app with it, just generates the index.html with everything in and it werks
hcatlin, but it's probably going to feel weird if you're used to MVC
Hampton Catlin
@hcatlin
May 13 2015 21:40
that sounds good!
@meh I'm pretty used to new things. ;)
feeling a bit overwhelmed by choice here... looking around the Todo app
Forrest Chang
@fkchang
May 13 2015 21:54
@hcatlin lissio's all ruby - component based approach really appealed to me
Re: choice, I find w/Opal a lot of time I find I "don't need no stinking frameworks", that opal-inspect prototype is mostly just raw opal w/some opal-jquery
Hampton Catlin
@hcatlin
May 13 2015 21:59
GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/helpers.self.map 404 (Not Found) localhost/:15 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/module.self.map 404 (Not Found) localhost/:17 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/class.self.map 404 (Not Found) localhost/:17 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/basic_object.self.map 404 (Not Found) localhost/:18 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/kernel.self.map 404 (Not Found) localhost/:18 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/nil_class.self.map 404 (Not Found) localhost/:18 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/boolean.self.map 404 (Not Found) localhost/:18 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/error.self.map 404 (Not Found) localhost/:18 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/regexp.self.map 404 (Not Found) localhost/:18 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/comparable.self.map 404 (Not Found) localhost/:20 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/enumerable.self.map 404 (Not Found) localhost/:29 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/enumerator.self.map 404 (Not Found) localhost/:29 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/array.self.map 404 (Not Found) localhost/:29 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/array/inheritance.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/hash.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/string.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/string/inheritance.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/match_data.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/numeric.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/complex.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/rational.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/proc.self.map 404 (Not Found) localhost/:31 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/method.self.map 404 (Not Found) localhost/:32 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/range.self.map 404 (Not Found) localhost/:40 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/time.self.map 404 (Not Found) localhost/:40 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/struct.self.map 404 (Not Found) localhost/:40 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/io.self.map 404 (Not Found) localhost/:40 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/main.self.map 404 (Not Found) localhost/:40 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/variables.self.map 404 (Not Found) localhost/:40 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/dir.self.map 404 (Not Found) localhost/:40 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/corelib/file.self.map 404 (Not Found) localhost/:40 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/opal.self.map 404 (Not Found) localhost/:43 GET http://localhost:9292/__OPAL_SOURCE_MAPS__/native.self.map 404 (Not Found)
this is all I get in my app logs... and the page is blank.
This is my attempt at updating opal-todo
any hints?
Elia Schito
@elia
May 13 2015 22:00
self.map comes from sprockets 3
so it might be a good idea to downgrade to 2 until i fix it properly
Forrest Chang
@fkchang
May 13 2015 22:01
@hcatlin Opal-inspector prototype was surprisingly small amount of code too, I talk about how how little code it was and not the need for a framework at about 23:40 in https://www.youtube.com/watch?v=GH9FAfKG-qY -- that video is good coz it's a very broad overview of everything in Opal at that time: has a better opal inspector demo than the dedicated youtube, I show off some lissio too
Elia Schito
@elia
May 13 2015 22:01
sourcemaps will be a hack on top of sprockets until v4 (of sprockets)
Hampton Catlin
@hcatlin
May 13 2015 22:02
np
Elia Schito
@elia
May 13 2015 22:03
about the blank page I need to know which opal version you're using, is it master?
Hampton Catlin
@hcatlin
May 13 2015 22:04
That fixed it! Thanks @elia
Elia Schito
@elia
May 13 2015 22:04
:+1:
Hampton Catlin
@hcatlin
May 13 2015 22:04
and, I got stuff displaying. had the wrong #element
Forrest Chang
@fkchang
May 13 2015 22:06
@elia u did the source maps support, IIRC?
Elia Schito
@elia
May 13 2015 22:09
@fkchang I hacked in something initially, based on comments (similarly to those you see in sass), but then @adambeynon added support at compiler level
Forrest Chang
@fkchang
May 13 2015 22:09
so then @adambeynon is the one to ask to see if we could reuse stuff in source maps to provide the code/comment lookup stuff I want
Elia Schito
@elia
May 13 2015 22:11
yes, sorry
Forrest Chang
@fkchang
May 13 2015 22:13
rats...
expecting @vais to have a stroke of genius now
Elia Schito
@elia
May 13 2015 22:14
well, the compiler stuff is really readable and OO, you have to look into lib/opal/nodes
meh.
@meh
May 13 2015 22:17
as long as it's not parser related it's fairly simple
Jeremy Evans
@jeremyevans
May 13 2015 22:51
I've been playing around with the new Opal::TiltTemplate stuff, and I've found that it doesn't work well when you need to require something in the stdlib or let's says opal/jquery, or maybe I'm doing it wrong
I think if TiltTemplate could optionally call Opal::Builder instead of Opal::Compiler, this may fix the issue
e.g. if you do Tilt.new('foo.rb', :build=>true).render # use Opal::Builder, not Opal::Compiler
Before I head further down that path, I'd like to get a sanity check from an opal developer to make sure that makes sense
Elia Schito
@elia
May 13 2015 22:52
@jeremyevans just to be sure I understand your goal, you still want to avoid sprockets?
Jeremy Evans
@jeremyevans
May 13 2015 22:53
Yes
Elia Schito
@elia
May 13 2015 22:53
ok, then Opal::Builder is the way to go
Jeremy Evans
@jeremyevans
May 13 2015 22:54
OK. So does a :build option to Opal::TiltTemplate to support Opal::Builder make sense?
Elia Schito
@elia
May 13 2015 22:55
like build: true? to which method you want to pass the option?
Jeremy Evans
@jeremyevans
May 13 2015 22:55
Tilt.new
Elia Schito
@elia
May 13 2015 22:57
ok, so, I don't know that well Tilt, but looking at the TiltTemplate source I think it could make sense to just use the builder and let the user control the build with require
basically what you want is to replicate the tilt based Processor from opal 0.7
Jeremy Evans
@jeremyevans
May 13 2015 22:59
Yes, similar, but instead of having sprockets doing things, just leave everything to Opal::Builder, since it seems like Opal::Builder can handle things without sprockets
I mean, if you are using sprockets directives in your code, then using sprockets makes sense, but if you aren't using sprockets directives, it seems unnecessary to try to use sprockets
Elia Schito
@elia
May 13 2015 23:00
yes, I struggled to make them work together but gave up :)
I still like sprockets for the compilation minification etc.
@jeremyevans to skip sprockets you just don't pass a special path_reader
and you can also skip passing an array of already required stuff (prerequired)
Jeremy Evans
@jeremyevans
May 13 2015 23:04
I'm developing with 0.8.0 beta1, do you think I should use the sprockets-specific stuff, or is it safe to just rely on Opal::Builder?
Elia Schito
@elia
May 13 2015 23:05
I'm kinda evaluating if having a "sprockets-free" codepath still valuable as the more I was trying to make it work the more I found I was reimplementing sprockets
your use case makes a point I think
also I think that when I'll switch to the new style of sprockets processor api (#call based) they could share most code, just a supposition though
Jeremy Evans
@jeremyevans
May 13 2015 23:09
It really depends if the long term goal is to depend on sprockets or move away from sprockets. Personally, I like the fact that you can use Opal like any other template library, independent of sprockets. But I may be in the minority :)
Elia Schito
@elia
May 13 2015 23:10
maybe it forces it to stay a bit more general and not too tied to sprockets
anyway for now the builder won't go anywhere, it might lose some sprockets-like features in the future bu that's not a problem I guess
thinking out loud, the other thing that sprockets facilitates on the other hand is plugins and alternative processors like opal-haml or react.rb jsx support
Jeremy Evans
@jeremyevans
May 13 2015 23:14
Good to know. I've got to go now, I'll try to check back in tomorrow.
Elia Schito
@elia
May 13 2015 23:14
@jeremyevans keep me posted on your experience, real world always beats mumbling :P
Jeremy Evans
@jeremyevans
May 13 2015 23:14
Definitely. I'm liking things so far.
Elia Schito
@elia
May 13 2015 23:15
always good to hear!