Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Stephen Becker IV
    @sbeckeriv
    https://github.com/malept/thermite 0.13 was released yesterday and added "Support for building static libraries"
    Steve Loveless
    @turboladen
    ooo
    that’s awesome
    Tasos Laskos
    @Zapotek
    @d-unseductable Is Ruru still alive? Even the website is down: http://www.this-week-in-ruru.org/
    Daniel P. Clark
    @danielpclark
    @Zapotek development has resumed in the repo.
    Steve Loveless
    @turboladen
    Awesome!
    Marc Siegel
    @ms-ati
    @d-unseductable Is there some existing documentation how the following 3 items interact in Ruru:
    1. Ruby VM GVL
    2. Ruby Heap
    3. Rust Heap

    Q1: Do the parameters in a Rust method count as references to prevent the Ruby VM from garbage collecting the parameters while the Rust method is running without GVL?

    Q2: Does calling let mut hsh = Hash::new(); in Rust allocate the object on the Ruby heap, or a separate heap?

    Q3: Does Ruru call finalizer on the above Hash automatically when its ownership scope ends? Or is it subject to garbage collection at a later time?

    Q4: Are Ruby objects instantiated from Rust different in any way from the Ruby objects passed into Rust as parameters, or returned from Rust to Ruby?

    ...apologies if I've missed where the above are documented!
    Steve Loveless
    @turboladen
    i’m no ruru expert, but i do believe all of the ruby stuff from ruru is essentially delegated to ruby’s C API via the ruby-sys crate. not sure if that helps at all
    ruru types are just wrappers around the ruby C types
    Marc Siegel
    @ms-ati
    Hmm
    So there needs to be some statement about memory-VM model, don't you think? How does ruby-sys code executed without GVL become safe? I suspect it does not, and only pure Rust code would be safe?
    Steve Loveless
    @turboladen
    i do believe all of the code you write with ruru is, by default, executed using the GVL.
    afaik, ruru is really just a wrapper around ruby’s C API. …which will let you opt out of using the GVL if you want to, but you have to be explicit about that
    i don’t disagree that some docs on the topic would be helpful though :)
    Daniel P. Clark
    @danielpclark
    What's the ruru equivalent of Class#allocate ?
    Daniel P. Clark
    @danielpclark
    I found a rough way to do it
    let mut path_instance = Class::from(
        Class::from_existing("Pathname").send("allocate", None).value()
    );
    Joseph Giralt
    @joegiralt
    Hi all, i have a question. I'm currently in the process of writing a gem that inspired by lodash/fp. I did this just to really wrap my mind currying and functional programming. while i was in the process of doing this i came across ruru. i thought about replacing each daft_funkt function with a native rust function but I'm not sure if there would be any performance benefit to doing so. Is this just a awful idea? Am I on to something here? More importantly, is this even possible?
    Steve Loveless
    @turboladen
    @joegiralt I’m no ruru expert, but I’d wager that your functions would need to do a fair amount of work in Rust code to make the tradeoff worth it. In other words, if you make a Ruby library that calls Rust, but it just calls Ruby code right back, you’ll not get a ton of benefit. However, if your Ruby calls Rust and you have Rust code do some things in Rust, that’s where you’ll see the biggest benefit.
    And for me, the ruru that I’ve done ends up with both native Rust code and Ruby code for working with the same Ruby objects—that code ends up in two different places (Rust files and Ruby files), which can make maintaining things more work.
    Joseph Giralt
    @joegiralt
    one of the beautiful things about Fp is it allows you to compose functions
    Steve Loveless
    @turboladen
    It has, however, ended up with some great performance gains and some nice type safety.
    Joseph Giralt
    @joegiralt
    that's good to know.
    thanks for the response!
    Steve Loveless
    @turboladen
    welcome!
    you might try some benchmarking? maybe that’ll show that it’s worth it?
    Joseph Giralt
    @joegiralt
    definately.
    first I'm going to have to really learn me some rust :)
    Steve Loveless
    @turboladen
    Well, ruru was a big springboard for me to jump in to Rust from Ruby. I really wanted to see what I could switch to Rust, but still use in Ruby-land, so I started here. It was a bit rough since, IMO, there are some things in ruru that aren’t quite super straightforward from a Rust perspective (Rust code, wrapping C code, which does Ruby things). ruru is a great library though—I’m sure you’ll get some traction with it.
    Dmytrii Nagirniak
    @dnagir

    Hey guys, I was trying to follow the basic example with the String#blank? so basically just copy pasted it from README into a Rust crate.

    Then compiled it (as per https://github.com/d-unseductable/ruru#how-do-i-use-it) and fired up the (pry) console hoping to see the magic.
    Unfortunately got this, so scratching my head a little.

    > library = Fiddle::dlopen('rust/play/target/release/libplay.dylib')
    > Fiddle::Function.new(library['initialize_string'], [], Fiddle::TYPE_VOIDP)
    Fiddle::DLError: unknown symbol "initialize_string" from (pry):17:in `[]'

    Any pointers please?

    > ruby --version
    ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
    
    > irb # then:
    > RbConfig::CONFIG['configure_args'].include?('--enable-shared')
    => true
    
    > rustc --version
    rustc 1.27.0 (3eda71b00 2018-06-19)
    
    > cat Cargo.toml
    [package]
    name = "play"
    version = "0.1.0"
    authors = ["<me>"]
    
    [lib]
    crate-type = ["dylib"]
    
    [dependencies]
    ruru = "0.9.0"
    Dmytrii Nagirniak
    @dnagir

    Recompiling the crate seems to have fixed this, so not sure what was going on TBH :innocent:
    But now a different error that seems to come from Class::from_existing("String")

    Error: [BUG] Segmentation fault at 0x0000000000000438
    C stack:

    0   libruby.2.5.dylib                   0x00000001084ddc87 rb_vm_bugreport + 135
    1   libruby.2.5.dylib                   0x0000000108362258 rb_bug_context + 472
    2   libruby.2.5.dylib                   0x0000000108450b31 sigsegv + 81
    3   libsystem_platform.dylib            0x00007fff7ac5ef5a _sigtramp + 26
    4   libruby.2.4.0.dylib                 0x0000000108a57fe1 ruby_xmalloc + 17
    5   libruby.2.4.0.dylib                 0x0000000108b256fa st_init_table_with_size + 74
    6   libruby.2.4.0.dylib                 0x0000000108a2f80e rb_enc_init + 110
    7   libruby.2.4.0.dylib                 0x0000000108a30be5 rb_usascii_encoding + 21
    8   libruby.2.4.0.dylib                 0x0000000108b4f3c7 rb_intern + 23
    9   libplay.dylib                     0x00000001087bf1ec _ZN4ruru7binding4util11internal_id17hdb1af469e236d7dcE + 108
    10  libplay.dylib                     0x00000001087bf149 _ZN4ruru7binding4util12get_constant17ha4887c45800de38aE + 41
    ==>>>>>> 11  libplay.dylib                     0x00000001087c0caf _ZN4ruru5class5class5Class13from_existing17h9fe2a0f2fe1e0735E + 63
    12  libplay.dylib                     0x00000001087b8e2e initialize_string + 30
    13  libffi.dylib                        0x00007fff79298f64 ffi_call_unix64 + 76
    14  libffi.dylib                        0x00007fff7929977c ffi_call + 808
    15  fiddle.bundle                       0x00000001087af6fb nogvl_ffi_call + 27
    16  libruby.2.5.dylib                   0x000000010848a762 rb_thread_call_without_gvl + 82
    17  fiddle.bundle                       0x00000001087af187 function_call + 823
    18  libruby.2.5.dylib                   0x00000001084d15bb vm_call_cfunc + 283
    19  libruby.2.5.dylib                   0x00000001084baa04 vm_exec_core + 12196
    20  libruby.2.5.dylib                   0x00000001084cbe8e vm_exec + 142
    21  libruby.2.5.dylib                   0x000000010836c0f1 ruby_exec_internal + 177
    Dmytrii Nagirniak
    @dnagir
    Looks like this fails on stable but is fine on nightly (rustc 1.28.0-nightly (60efbdead 2018-06-23)). Very unfortunate :(
    Steve Loveless
    @turboladen
    @dnagir i just ran through the steps for this using rust 1.26.2, ruru 0.9.0, and ruby 2.3.3 (although I thought I was running 2.5.1)—it worked fine. Once I realized I was running 2.3.3, i switched to 2.5.1 and got the ruby crash
    I just switched ruru to use master and that seems to work ok though
    [dependencies]
    ruru = { git = "ssh://github.com/d-unseductable/ruru.git" }
    Steve Loveless
    @turboladen
    ruru 0.9.3 is about a year and a half old, so it might be worth using master anyway
    Dmytrii Nagirniak
    @dnagir
    Thanks @turboladen. Using master is not ideal unfortunately.
    Dmytrii Nagirniak
    @dnagir
    Just a quick question?
    Can ruru support DSL for (nested) modules/classes? Can we override methods on an existing Ruby class C that is in A::B module?
    Steve Loveless
    @turboladen
    Yes!
    On mobile here, so will be brief... just follow the same pattern you would in ruby. IIRC with ruru there’s at Class::get_nested_class() method to open up the class so you can define the method.
    Daniel P. Clark
    @danielpclark
    Hey all. Just wanted to give you a head up that I've made an official fork of Ruru called Rutie. Lots of additional work has been done and it is actively maintained.
    Steve Loveless
    @turboladen
    fwiw, I’ve switched to rutie for a few projects and it’s been great. Thanks for picking that up @danielpclark
    Marc Siegel
    @ms-ati
    @danielpclark in the interests of making the state of things discoverable, have you opened a PR to Ruru to add information about your fork near the top of the README?
    even if your PR is never responded to, it will appear in searches and be more discoverable than this random message I happened to see in the gitter chat room ;)
    Daniel P. Clark
    @danielpclark
    Will do @ms-ati, thanks.
    And thank you @turboladen
    Steve Loveless
    @turboladen
    👍