from Hacker News

Ruby 3.0 Preview 1

by polysaturate on 9/25/20, 7:08 PM with 203 comments

  • by sdwolfz on 9/25/20, 9:00 PM

    My thoughts:

    - RBS: meh... might get more useful in the future (in 2-5 years maybe).

    - Ractor: Wohooo! I'm writing a DAG library where I was thinking of implementing something like this, good to know I can use it and get real parallelism on top.

    - Scheduler: :shrug: don't know about this one, might be relevant with future concurrent ruby code, any ideas?

    - Rightward assignment: it's a bit awkward but I see the use case, just wish we had the pipe operator too like in Elixir.

    - Endless method: this one is cute, I love it!

    - Find pattern: oh boy, code reviews are going to be interesting now!

    - Hash#except: yes, definitely a welcome one.

    - Memory view: if this helps with numpy style gems it will be great!

    - `send(:"do_#{ meth }", ...)`: don't do meth kids! (it's a joke!)... seems like a reasonable feature.

    - `order of backtrace had been reversed`: good! it was confusing...

    - Promote default gems to bundled gems (rexml): I like this one, if only nokogiri was a stdlib gem or part of core, imagine how much time would be saved instead of having to compile it every time in a `bundle install`.

    - `Promote stdlib to default gems`: what does this mean? Do I now have to add `gem "securerandom"` to Gemfiles instead of having it by default and just needing to require it?

    - Mjit improvements: can't wait to try it!

    Overall, I'm delighted!

  • by reader_mode on 9/25/20, 8:45 PM

    >Rightward assignment statement is added. >fib(10) => x

    This is exactly the kind of stuff I hated when I had to work with ruby in my last gig and why I will never accept a job using it again - soo many pointless and inconsistent ways to do the same thing ... they have method aliases for collection operations like map/filter in standard library ! .NET went with non-standard SQL-like names (select/where) and I'm not a fan but at least they made their choice and stuck with it. And it's inconsistent all over the place - like '!' postfix means "operation mutates the object" in std lib BUT in rails it means the operation will raise an exception and not return an error code.

    Now they add a pointless operator that means completely different thing in other languages to throw off even more people.

    It's just a hell of a language to maintain someone else's code in.

  • by eddietejeda on 9/25/20, 9:03 PM

    If you interested in seeing how the 3x3 initiative* has come along, here are the benchmarks so far: https://github.com/mame/optcarrot#readme

    Personally, I am very excited for this release.

    * Matz's goal to get Ruby 3 to be 3x faster than Ruby 2.

    --

    @sosodev Thanks for the updated info!

  • by rco8786 on 9/25/20, 11:40 PM

    This is all great stuff. I’m rather meh on RBS, mainly because separating types from code is less than ideal but I like the potential here.

    But the right hand assignment operator. What on earth. Nobody asked for that and nobody wants it. Why.

  • by phaedryx on 9/26/20, 5:45 AM

    I have mixed feelings.

    I'm not a fan of rightward assignment because I don't see much value and now the => operator has even more meanings.

    I'm not a fan of endless methods because how lazy do you have to be to not want to type 'end'? My editor does it for me automatically. Now there is even more parsing.

  • by d2161 on 9/25/20, 8:41 PM

    You can test your heroku app on the new ruby 3 preview already! (https://devcenter.heroku.com/changelog-items/1889)
  • by shadykiller on 9/25/20, 8:35 PM

    I love Ruby and great to see Ruby love on hacker news. Just curious on how popular it is in the hacker news community ?
  • by Justsignedup on 9/25/20, 7:58 PM

    Reactor model. Nice. Very nice. So real ruby multithreading at last.

    Okay time to upgrade to latest rails and wait for the multithreaded rails release. :P

  • by jasonhansel on 9/25/20, 9:18 PM

    Question: will the nonblocking scheduler start to make Ruby concurrency competitive with e.g. Node.js and Go? Currently Ruby mostly uses heavyweight threading mechanisms that cause trouble for I/O-bound microservices.
  • by gorgoiler on 9/26/20, 4:59 AM

    It feels like RBS is for library writers, so that they can ship type information to help the consumers of their library. It’s not really aimed at the consumers themselves — the long tail of casual Ruby hackers like me.

    If RBS was for end users, adding types inline with the source code would make more sense compared to the RBS approach: keeping the source file and typedef file in sync.

    That might actually be a pretty smart move. At first it seemed inconvenient to have to maintain a separate file for the type information, but maybe this focus on type-checking being made easy for the 90% of us who hack scripts is a much smarter one.

  • by crb002 on 9/26/20, 4:11 PM

    I wish I had kept maintaining my port of Ruby to the IBM BLue Gene/L, "Blue Ruby". It scaled to millions of cores with MPI. Had distributed versions of familiar Ruby data types. There was no fork() - restriction of the BGL kernel not supporting it - only green threads - making parallel operations truly parallel with independent Ruby VMs and passing code to data instead of data to code.
  • by Jarred on 9/25/20, 8:35 PM

    Does message passing mean it copies objects you send between threads / fibers, rather than sharing memory?

    JavaScript has a similar pattern with Workers, and it makes concurrency for hot code impractical. Serializing/deserializing objects is a lot slower than just not doing that. In JavaScript’s case, you can also use SharedArrayBuffer, but Safari hasn’t re-enabled it.

  • by wbharding on 9/26/20, 12:54 AM

    It looks like the link they provide for comparing the source of 3.0 and 2.7 is busted on Github, but you can get a sense for the scope of this on GitClear's Open Repos https://www.gitclear.com/open_repos/ruby/ruby/releases. Looks like about 4x more repo evolution has gone into this version than previous.

    See also: list of the biggest tickets tackled in 3.0: https://www.gitclear.com/open_repos/ruby/ruby/release/pendin...

  • by riffraff on 9/25/20, 7:43 PM

    the link to the NEWS file is broken, it should be this

    https://github.com/ruby/ruby/blob/v3_0_0_preview1/NEWS.md

  • by desireco42 on 9/25/20, 7:52 PM

    There were times where I would not be able to sleep when such a release was done :). It isn't as much lately, but still, fantastic work by fantastic team. Congratulations!

    There are some seriously good stuff there.

  • by juliend2 on 9/25/20, 8:02 PM

    Happy to see developments on the pattern matching feature[0].

    [0] https://bugs.ruby-lang.org/issues/16828

  • by sickcodebruh on 9/25/20, 10:55 PM

    Didn’t see it linked in the preview announcement, here’s the RBS syntax guide: https://github.com/ruby/rbs/blob/master/docs/syntax.md

    Glanced at it from my phone but it looks good! I’m looking forward to seeing it in RubyMine. Still sad that we can’t write these in .rb files but I wonder if the plan is to go the other way, eventually permit typed code in .rbs?

    Does anyone know what the story will be with third-party definitions? Are we headed towards a DefinitelyTyped style repository for Ruby?

  • by aryik on 9/26/20, 12:46 AM

    Great stuff! Does anyone who’s been in the Ruby ecosystem longer than me have a prediction for when Rails will support Ruby 3?
  • by bilekas on 9/26/20, 2:15 AM

    Am I alone in saying; for some damn reason, I don't like Ruby.. I appreciate what it can do, and indeed what it does.. I just feel like I slipped in between that moment to appreciate it more. I will go and spend some time to learn it more but out of a novelty aspect.. And that makes me feel bad.
  • by jakearmitage on 9/25/20, 10:38 PM

    Endless Ruby is the best Ruby.
  • by aitchnyu on 9/26/20, 11:53 AM

    Not a Rubyist. Would Ractor allow one process to use up all CPUs while avoiding copying objects? Can I build shareable objects with immutable lists and maps right now?
  • by phplovesong on 9/26/20, 8:28 AM

    Look like a great release! Have not used Ruby in years, but i recon the Ractor and Scheduler brings some nice perf improvements.
  • by pw on 9/26/20, 12:07 AM

    Wondering how RBS will compete/compare to Sorbet, which seems like a better solution.
  • by nanna on 9/26/20, 4:31 PM

    Anyone got suggestions for resources to learn Ruby and Rails in 2020?
  • by justinzollars on 9/26/20, 3:58 AM

    Rightward assignment looks gross.
  • by sarfraaz on 9/26/20, 8:58 AM

    I don't know why am I writing this, but..
  • by monadic2 on 9/25/20, 11:44 PM

    Ruby is a really cool language but I'm dying for an update where features are removed.
  • by zelly on 9/25/20, 9:00 PM

    So now there are basically no dynamically typed languages left. There's Scheme, JavaScript, what else? All languages nowadays are converging to TypeScript/Rust. It's kind of sad.
  • by hexbinencoded on 9/26/20, 4:37 AM

    I left Ruby because the performance and security weren't improving and the community was slowly dying. I delved into Go before that got flooded with newbs, then looked at Crystal and Pony, before settling on Rust and Haskell for most things.
  • by stevebmark on 9/25/20, 8:31 PM

    I really wish Ruby would grow up and deprecate method_missing
  • by cutler on 9/26/20, 1:08 AM

    Much as I would love to believe Ruby 3.0 delivers some kind of speed bump my simple test of doing what Ruby supposedly does best - parsing a log file with a regex - shows Ruby 16% slower than the Python equivalent.

      Ruby
      puts IO.foreach('logs1.txt').grep /\b\w{15}\b/
    
      Python
      from re import compile
    
      with open('logs1.txt', 'r') as fh:
          regex = compile(r'\b\w{15}\b')
          for line in fh:
              if regex.search(line): print(line, end='')
    
    On my MacBook Pro (2013) running Catalina Ruby averaged 1.49 secs and Python 1.27 secs. The file `logs1.txt` is a 20Mb Apache log file. Pre-compilation with:

       reg = Regex.compile /\b\w{15}\b/
       puts IO.foreach('logs1.txt').grep reg
    
    ... slowed Ruby down to 1.57 secs.

    Using --jit didn't change Ruby's overall time but considering it adds 700ms to Ruby's startup time execution time was faster.