Live data from Hacker News

Ruby 3.0 Preview 1

ruby-lang.org

141–150 of 207 posts

Re: Ruby 3.0 Preview 1

#141

Earlier quoted context omitted.

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

Ractor is "actor-like" and looks a bit like a mix of both Elixir/Erlang and Go.

Indeed, anyone who has used actors IRL projects it goes well beyond just isolation and message passing. That’s just the foundation which higher abstractions are built, which is why it’s still comparable to Go/CSP at this level.

Re: Ruby 3.0 Preview 1

#142

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

Totally agree.Different approaches to the same thing won't add points to the language.

P.S. the 'endless method definition' is meaningless, too.

> def square(x) = x * x

The original reason of this proposal was:

> Ruby syntax is full of “end”s. I’m paranoid that the ends end Ruby. I hope Ruby is endless. --mame (Yusuke Endoh)

It sounds like "let's add a new syntax for lisp because it has too many brackets"

Re: Ruby 3.0 Preview 1

#143

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.

Completely unnecessary syntax.

It does nothing but add complexity.

Re: Ruby 3.0 Preview 1

#144
post #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…

So why would you not just default to always using .size?

Re: Ruby 3.0 Preview 1

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

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

but that same thing will happen if the powerful voices are the ones taking the decisions for the whole language.

Re: Ruby 3.0 Preview 1

#146

Earlier quoted context omitted.

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…

Why wouldn't you share your Ruby code with others? As a Ruby developer I an assure you, us Rubyists can work and understand each other's code.

To be frank, the language just isn’t boring enough.

In my experience, a company’s code should be like the style of English used in an instruction manual. It should clearly and plainly express the business logic behind the company’s mission.

Ruby is more like writing poetry. There’s nothing stopping one from writing boring, unambiguous, clear code in Ruby of course. As a Ruby developer, I’m sure your code looks very clear.

The reality is that other languages make it easier to enforce clarity. See gofmt for example, which standardizes Golang’s formatting, taking one more axis of “creativity” away from the less disciplined developers.

Re: Ruby 3.0 Preview 1

#147
post #124

Earlier quoted context omitted.

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…

So why would you not just default to always using .size?

There are no guarantees that the count will remain correct after the first run of the query.

Re: Ruby 3.0 Preview 1

#148
post #124

Earlier quoted context omitted.

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…

So why would you not just default to always using .size?

You usually want to know when you're hitting the database. "Hit the database if the value isn't cached" is useful behavior, but should probably be telegraphed a bit more precisely than just the word "size".

Re: Ruby 3.0 Preview 1

#149
post #84

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

The programs aren't doing the same things. The Ruby one seems to buffer the matches into a huge string then print. Don't know how different it would be but better to compare apples.

Probably the equivalent thing to test would be

      regexp = /\b\w{15}\b/
      IO.foreach('logs1.txt') do |line|
        puts line if regexp.match?(line)
      end
I imagine this will in both cases mostly be testing the computer's IO.

Regexp.compile doesn't do anything substantially different from Regexp.new or a literal (i.e. it doesn't optimize the regular expression or something) so I think the difference is just random fluctuations.

Post reply on HN