Live data from Hacker News

Ruby 3.0 Preview 1

ruby-lang.org

121–130 of 207 posts

Re: Ruby 3.0 Preview 1

#121

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…

I don’t think anyone expects you to maintain two files. The idea is that RBS is an interface that is tooling agnostic. The idea is to have tooling (sorbet, etc.) generate those files for you.

Re: Ruby 3.0 Preview 1

#122

>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…

I would never share a Ruby code base with anyone either. It’s like issuing kindergartners a can of silly string and asking them to be sensible with it.

I consider myself a sensible developer, but even I’ve had some childish moments with Ruby: doing something I thought was clever and productive but which really just made my code inscrutable and unmaintainable...

...by other people. The flip side is I can just about figure out what I was trying to do when I read my own code: enough so that I still always use Ruby for personal projects.

Ruby is just too much fun and critically, to date, it’s the only language where I can write a page of code at the same speed I am thinking. It also usually executes first time without any errors, which is a joyous thing.

I am not claiming to be some kind of 10x uber hacker. Ruby just happens to be an incredibly wonderful language for thinking aloud with code.

Re: Ruby 3.0 Preview 1

#123
post #66

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.

Ruby already had a sort of limited form of rightward assignment, in exception rescue:

    begin
      #... do something
    rescue StandardError => ex
      #... handle exception
    end
The ex here can be any assignment expression, it's not just a lexical variable. So you could already do this:

    class Guru
      def meditate=(exception)
        puts "caught #{exception.inspect}"
      end
    end

    # later ...
    rescue OutOfCheeseError => Guru.new.meditate
i.e. creating a nice opportunity for passing error handlers around as an argument; or, this worrying idea:

    rescue TransactionError => Thread.current[:exception]
and now I'm afraid you can do this:

    Cat = Struct.new(:name) do
      class  Cat.adopt

Re: Ruby 3.0 Preview 1

#124

>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…

The thing that most annoyed me about Rails (not Ruby) was that

    users.size
    users.length
    users.count
are all valid, all useful, all have different meanings, are all present in plain Ruby but with different meanings, and contain absolutely no information about what they do.

For reference, .length loads everything and gets the length of the collection, .count runs a SQL COUNT query, and .size uses length if the query has already been run and .count if it hasn't.

Re: Ruby 3.0 Preview 1

#125
post #32

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.

In theory the scheduler should be similar to NodeJS and Ractor should be similar to Go if they’re both applied correctly.

Isn't Ractor based on the Actor model and not CSP?

Re: Ruby 3.0 Preview 1

#126

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.

How do you choose all this? I haven't been able to make a single decision for what language to use at work for the past 15 years. I thought wouldn't touch C#, ruby, delphi, kotlin and python but it all happened because someone was paying.

Re: Ruby 3.0 Preview 1

#128
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.

Re: Ruby 3.0 Preview 1

#129
post #120
post #98

Earlier quoted context omitted.

But that's what I love about Ruby! There's so many great ways to express logic, making Ruby a language that really rewards exploration. Of course, when working with a team on a production application, you'd set up standards everyone can agree on and understand with rubocop or prettier-rb (which I loathe and will not touch with a 10-foot long pole for my personal projects). That's also great for onboarding newcomers -…

> you'd set up standards everyone can agree on and understand with rubocop or prettier-rb Things like that just often lead to bikeshedding. And then worse, powerful voices may approve ideas that work for them and not everyone else, or even more worse crippling a language to be too safe or bland to be truly useful. I got into an argument a couple weeks ago whether an unprotected eval() in python should make it's way i…

That's a problem with culture, not with the language. You can't say "you can get into accidents if you drive a car, so you're not allowed to drive"; you try to fix it by setting rules into place. At any rate, if you don't like bikeshedding, there's great, well appreciated standards in place for ruby which you can take up as-is: there's AirBnB, standard-rb/ prettier-rb and rubocop's default config. No bikeshedding involved, pick one and run with it

Re: Ruby 3.0 Preview 1

#130

>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…

Happy someone else echoes my sentiment too, especially when Ruby seems to be beloved by everyone around. So many ways of doing the same thing; unnecessary cognitive burden for both reading and writing.
Post reply on HN