These are chat archives for opal/opal

23rd
Nov 2014
Gustaf Lindqvist
@gustaflindqvist
Nov 23 2014 20:51
Hi, how close is the Rubyfire alpha or beta?
Adam Beynon
@adambeynon
Nov 23 2014 20:59
@gustaflindqvist very early alpha atm. The core parts (model/router) are based off Vienna
its kind of the successor to vienna
@gustaflindqvist the biggest difference is that in RubyFire, the views can be compiled inside rails (for seo), as well as on the client side
once you have the views loaded, the API for the client is pretty much what Vienna offers now
Gustaf Lindqvist
@gustaflindqvist
Nov 23 2014 21:04
@adambeynon nice, looking forward to test RubyFire. :)
Ryan Stout
@ryanstout
Nov 23 2014 21:14
@adambeynon just curious what the timeline looks like on opal7 (no rush, just trying to plan volt versions around it)
Adam Beynon
@adambeynon
Nov 23 2014 21:17
@ryanstout. ASAP really. Once the caching is done, another beta then final release. Hopefully caching will be done tomorrow or Tuesday
Ryan Stout
@ryanstout
Nov 23 2014 21:17
@adambeynon cool. thanks for the info :-)
Elia Schito
@elia
Nov 23 2014 21:38
@adambeynon @ryanstout was about to ask the same :P
Ryan Stout
@ryanstout
Nov 23 2014 21:51
@adambeynon or @elia have you guys seen this issue: opal/opal#655
took me a while to isolate
Elia Schito
@elia
Nov 23 2014 21:52
surely my fault :D, looking into it
Ryan Stout
@ryanstout
Nov 23 2014 21:53
@elia thanks!
I can try to simplify the key if you want
Elia Schito
@elia
Nov 23 2014 21:54
@ryanstout could be (IMO) 2 things
  1. some class has a bad implementation for #hash
  2. there’s some js local var leaking inside Hash
Ryan Stout
@ryanstout
Nov 23 2014 21:59
@elia it can be simplified to:
    a = {}
    a[{}] = 'awesome'
    puts a[{}].inspect
the weird thing is the equality check works
Elia Schito
@elia
Nov 23 2014 22:04
@ryanstout was n.1
Hash#hash is not implemented :\
Ryan Stout
@ryanstout
Nov 23 2014 22:05
a
h
@elia did you redo how .hash worked?
Elia Schito
@elia
Nov 23 2014 22:06
I’ll go look at rubionius impl :smile:
Ryan Stout
@ryanstout
Nov 23 2014 22:07
I checked out [1].hash Are you doing something so you don't have to compute a real hash?
Elia Schito
@elia
Nov 23 2014 22:09
yep, there’s a naive impl. on Object (or Kernel)
that includes object_id
Ryan Stout
@ryanstout
Nov 23 2014 22:10
cool
if you ever need a real hash, let me know. I had a project where I benchmarked a bunch of JS hash code
Elia Schito
@elia
Nov 23 2014 22:11
yes I need it now :P
Ryan Stout
@ryanstout
Nov 23 2014 22:11
it's surprisingly fast in everything except safari (though they might have caught up now)
oh, are you going to compute a real hash on opal hashes?
Elia Schito
@elia
Nov 23 2014 22:12
rubinius code looks like this btw
  def hash
    val = size
    Thread.detect_outermost_recursion self do
      each_item do |item|
        val ^= item.key.hash
        val ^= item.value.hash
      end
    end

    val
  end
Adam Beynon
@adambeynon
Nov 23 2014 22:13
So, we just need a Thread impl first? ;)
Ryan Stout
@ryanstout
Nov 23 2014 22:13
why is the thread stuff there?
humm. there isn't a way to do like your doing on array? (obviously the hash stuff will have some performance impact)
Elia Schito
@elia
Nov 23 2014 22:14
lol, nope, a closure js var works well enough
Ryan Stout
@ryanstout
Nov 23 2014 22:14
@elia sorry, I don't follow
Elia Schito
@elia
Nov 23 2014 22:15
was replying to @adambeynon
Ryan Stout
@ryanstout
Nov 23 2014 22:15
ok
Elia Schito
@elia
Nov 23 2014 22:15
the thread stuff is there to detect loops, like: a = {}; a[a] = 123
you can look at how #inspect is implemented to see an example
Ryan Stout
@ryanstout
Nov 23 2014 22:17
ah
interesting
anyway, let me know if you want me to see what hash algorithm I used
I might still have my benchmark code around somewhere
Elia Schito
@elia
Nov 23 2014 22:22
I’ll put up a working impl, send the hashing code if you have it at hand
Ryan Stout
@ryanstout
Nov 23 2014 22:47
ok, let me find it :-)
Elia Schito
@elia
Nov 23 2014 22:48
@ryanstout I think we’ll probably need to switch to numeric hashes
Ryan Stout
@ryanstout
Nov 23 2014 22:49
@elia you mean computing a real hash?
Elia Schito
@elia
Nov 23 2014 22:49
heh, yes, for now was some kind of string
Ryan Stout
@ryanstout
Nov 23 2014 22:49
yea
are you using .hash for comparisons also?
Elia Schito
@elia
Nov 23 2014 22:50
you mean in ==, eql? and friends?
Ryan Stout
@ryanstout
Nov 23 2014 22:51
yea
ok, this was the fastest one I had seen: https://github.com/garycourt/murmurhash-js
Elia Schito
@elia
Nov 23 2014 22:51
let me check
Ryan Stout
@ryanstout
Nov 23 2014 22:52
a 32bit hash should work right?
Elia Schito
@elia
Nov 23 2014 22:53
I think so, isn’t all js numbers 32bit anyway?
Ryan Stout
@ryanstout
Nov 23 2014 22:53
I think they are all 64 bit floats
so newer browsers have typed arrays
Elia Schito
@elia
Nov 23 2014 22:54
maybe we can pass class object_id as seed, wdyt?
Ryan Stout
@ryanstout
Nov 23 2014 22:54
so at some point you may want to do some more benchmarks. I thought I tested more implementations, but I only did two murmurhashes and an xxhash version
how is object_id computed now?
just an incrementing value?
Elia Schito
@elia
Nov 23 2014 22:55
yep
via Opal.uid()
Ryan Stout
@ryanstout
Nov 23 2014 22:55
so I don't think you want to have different seeds, because then different objects with the same "value" would be different
you need to be passing in the unique content of the value
Joiey Seeley
@bigtunacan
Nov 23 2014 22:55
@ryanstout, I have a numericality validator working now
Ryan Stout
@ryanstout
Nov 23 2014 22:56
so for primitives, it's just the type and value
Joiey Seeley
@bigtunacan
Nov 23 2014 22:56
I'm going to write some tests for it still
Ryan Stout
@ryanstout
Nov 23 2014 22:56
@bigtunacan in volt?
Joiey Seeley
@bigtunacan
Nov 23 2014 22:56
I'll submit the pull request tomorrow
Yeah; wrote it tonight
Ryan Stout
@ryanstout
Nov 23 2014 22:56
@bigtunacan cool, this is the opal chat, fyi (easy to get confused)
Joiey Seeley
@bigtunacan
Nov 23 2014 22:57
@ryanstout Ack! Sorry guys! I always have both open, meant to send this in the other
Ryan Stout
@ryanstout
Nov 23 2014 22:58
@elia so for primitives, you pass in the type and value (string, number, etc) to the hash, for arrays, you pass in the hash of the nodes, and for hashes you do the key and value's hashes
(and be sure to include type for array and hash)
Elia Schito
@elia
Nov 23 2014 22:59
still there’s the problem of making them order independent
Ryan Stout
@ryanstout
Nov 23 2014 23:00
oh, because hash comparison in ruby is order independant?
Elia Schito
@elia
Nov 23 2014 23:00
I think I’ll try to make it work as it is for now, and try the numeric hashing on a different branch
no, just for Hash#hash I think
Ryan Stout
@ryanstout
Nov 23 2014 23:00
yea, you would need to sort them first
Elia Schito
@elia
Nov 23 2014 23:00
yep
no other way
Ryan Stout
@ryanstout
Nov 23 2014 23:01
is it possible to x-or all of them together or something weird?
probably faster to sort
Elia Schito
@elia
Nov 23 2014 23:01
well excluding the code above from rubinius
Ryan Stout
@ryanstout
Nov 23 2014 23:01
yea, actually, that's probably faster
just compute the hash for each key/value, and x-or together
Elia Schito
@elia
Nov 23 2014 23:02
all hashes are strings right now, which makes sense bc we’re using objects as hash tables
Ryan Stout
@ryanstout
Nov 23 2014 23:02
yea
so you would have to convert the number to a string
but thats doable
Elia Schito
@elia
Nov 23 2014 23:02
to avoid conflicts we have a separate table for strings which are used as hashes directly
Ryan Stout
@ryanstout
Nov 23 2014 23:03
@elia strings used as hashes?
Elia Schito
@elia
Nov 23 2014 23:03
yes, a js object literal is a hash-table after all
and keys must be strings
Ryan Stout
@ryanstout
Nov 23 2014 23:04
yea
Elia Schito
@elia
Nov 23 2014 23:04
that’s why in 0.6 a = {}; a[1] = 123; a[‘1’] #=> 123
Ryan Stout
@ryanstout
Nov 23 2014 23:05
yea, the ruby semantics are so much better, hehe
I just didn't understand what the separate table was for
Elia Schito
@elia
Nov 23 2014 23:05
now trying a simple js .sort() on keys
btw locally your example works correctly now
Ryan Stout
@ryanstout
Nov 23 2014 23:08
Cool
Ryan Stout
@ryanstout
Nov 23 2014 23:13
let me know if I can help with anything else on it. Thanks for working on it.
Elia Schito
@elia
Nov 23 2014 23:19
@ryanstout currently I’m stuck on circular hashes
Ryan Stout
@ryanstout
Nov 23 2014 23:19
humm
yea, thats tricky
Elia Schito
@elia
Nov 23 2014 23:20
it’s easier to output ‘{…}’ than to get a hash :)
Ryan Stout
@ryanstout
Nov 23 2014 23:20
yea
I guess you need to stop once you've seen something already
how does rubinius do it?