Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
G. Gibson
@mistergibson
lol
JavaScript is just a hobbled language - no match for the elegance of Ruby IMO
Forrest Chang
@fkchang
@mistergibson yes, I never think those thoughts about Ruby
Mitch VanDuyn
@catmando
its not javascripts fault. Really. The problem is that JS had to freeze much faster than ruby so had no chance to evolve. In a perfect world instead of JS we would have gone directly to a WASM like VM, with a JS on top letting alternative languages flow from day 1.
G. Gibson
@mistergibson
true enough
maybe it will evolve into a WASM world at some point
I'd dig that - then we could do any language on top of that.
Tomasz Wegrzanowski
@taw
hi guys
so back to my opal-d3 library, I use opal-rspec for testing it, but that doesn't support opal 0.11
what are my other testing options?
Frederic ZINGG
@fzingg
@taw I'm sure you will get some help about that in this Chat room, but I will ask also in the ruby-hyperloop chat room.
Elia Schito
@elia
@taw opal-rspec @ elia/master kinda works (still WIP tho)
Frederic ZINGG
@fzingg
@taw According to my Hyperloop team collegues you can also use the last version of HYPER-SPEC, which works well for testing OPAL 0.11 also.
source 'https://gems.ruby-hyperloop.org'
gem 'hyper-spec', '1.0.0-lap18'
Torsten Rüger
@rubydesign
Hi all. I'm trying to write a 3d tool. Currently looking at seen.js as best contender. Has anyone seen a better small library (ie not three or babylon with Mb footprints)
Tomasz Wegrzanowski
@taw
thanks, I'll take a look at these options
Billy.Zheng
@zw963
@elia , I update your's awesome tetris app to use opal 0.11, and create a PR here
The next step is: i want deploy this game into my home page, with only one app.min.js and one index.html, awesome!
Elia Schito
@elia
@zw963 thanks! great! :smile:
Mitch VanDuyn
@catmando
@elia so what does #$! do? Is the other weird syntax like that?
Jamie Gaskins
@jgaskins
@catmando Inside strings and backticks, ivars and globals don't need a full #{} and can just use #, and since $! is the current exception within a rescue block, throw $#! between backticks is a re-raise of the currently rescued exception.
Mitch VanDuyn
@catmando
Huh! There u go. Tx @jgaskins
Billy.Zheng
@zw963
@all, http://game.zw963.online, online tetris game, original write by @elia for a opal talk, I just bundle into app.min.js and index.html, and threw it into my site. how to bundle inspire by @barriehadfield another project.
Sebastian Fiedlschuster
@fiedl
Hi all, I’m trying to integrate opal successively into an existing project. But I’m struggling with a basic concept: How can I export a class in opal such that I can use it from a typescript file?
# foo.rb

class Foo
  def bar
    "barbar!"
  end
end
// otherfile.ts

import { Foo } from './foo'
console.log((new Foo).bar());
Elia Schito
@elia
@fiedl all Opal classes are defined on Opal, which is a property of window, e.g. window.Opal.Array, that is the same as what MRI does because essentially every ruby constant is also a global
so the TS code would something like this: console.log(Opal.Foo.$new().$bar()); but I'm guessing, I don't know TS
Sebastian Fiedlschuster
@fiedl
Thanks @elia. Trying this I get TS2304: Cannot find name 'Opal‘.
Elia Schito
@elia
maybe, assuming you have an opal.js somewhere you need to add import { Opal } from 'opal'
@fiedl is there a way to require js stuff that doesn't use modules?
Sebastian Fiedlschuster
@fiedl
I’m not sure, but I’ve seen something like this: import * as showdown from 'showdown‘; instead of const showdown = require(‚showdown‘).
Elia Schito
@elia
then probably require('opal') will suffice
Sebastian Fiedlschuster
@fiedl
I think, it’s import * as Opal from 'opal‘;. This reduced the amount of errors significantly :)
Elia Schito
@elia
:smile:
@fiedl are you using sprockets, webpacker or something else?
Sebastian Fiedlschuster
@fiedl
ERROR in ./node_modules/opal/lib/opal-node.js
Module not found: Error: Can't resolve 'fs' in 'node_modules/opal/lib'
webpack
well, more precisely, I’m using ionic, which uses webpack
Elia Schito
@elia
ok, I'm not too familiar with any of those, how are you fetching the opal code? also which opal version?
Sebastian Fiedlschuster
@fiedl
unit testing with karma
opal 0.6.4
Elia Schito
@elia
oh my, :)
Sebastian Fiedlschuster
@fiedl
I’m using the opalrb-loader from https://www.npmjs.com/package/opal-webpack
Ooops, I’ve just seen on https://github.com/opal/opal/releases that the current release is 0.10.5. But I just did npm install opal :)
Elia Schito
@elia
latest version is 0.11, need to check releases
@fiedl maybe you can start experimenting installing the gem and compiling via the CLI
Sebastian Fiedlschuster
@fiedl
https://npms.io/search?q=opal has opal as first result with version 0.6.4.
Elia Schito
@elia
opal --compile --arity-check foo.rb > foo.js should work
@fiedl yeah the npm package is outdated
Sebastian Fiedlschuster
@fiedl
:-)