Readit News logoReadit News
_odey · 5 years ago
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!

djur · 5 years ago
"Default gems" means that they're packaged as a gem but always implicitly available, as if you had included them in your Gemfile.

"Bundled gems" means the same thing, but you do have to include them in your Gemfile.

https://github.com/janlelis/stdgems#about-the-gemified-stand...

_odey · 5 years ago
Thank you for clarifying this for me. In that case, the rexml gem situation sounds like a demotion...
ioquatix · 5 years ago
Latest talk about scheduler: https://www.youtube.com/watch?v=Y29SSOS4UOc

Recent summary of scheduler, a little bit out of date (changes to interface): https://www.codeotaku.com/journal/2020-04/ruby-concurrency-f...

joelbluminator · 5 years ago
I will watch your presentation but if u could put my mind at ease: Is the scheduler a kind of event loop (like Node) implemented in Ruby? So if I wanted to use this thing everything I write would have to be callback based ?
tomstuart · 5 years ago
You may be interested in precompiled native Nokogiri: https://github.com/sparklemotion/nokogiri/issues/2075
JohnBooty · 5 years ago
My thoughts:

- A Ruby "Preview 1" release? Oh crap, I have to start Christmas shopping soon.

onekorg · 5 years ago
I just realized why I have a lot of christmas memories of me sitting around with family while reading hacker news comments in a thread about a ruby release.

Never noticed it's always released on December 25th.

burlesona · 5 years ago
Yeah playing with new Ruby is one of my favorite parts of Christmas :)
czbond · 5 years ago
This is funny. Need more inside engineering jokes...
transfire · 5 years ago
> Endless method: this one is cute, I love it!

Now they just need to make it defless too.

UncleOxidant · 5 years ago
> - Endless method: this one is cute, I love it!

It's a weird name for it. It should probably be called something like 'equational method definitions'

coldtea · 5 years ago
>It should probably be called something like 'equational method definitions'

Yeah, that's not weird

baggy_trough · 5 years ago
It's sort of a pun, because the method doesn't need an "end".
inopinatus · 5 years ago
It's a bit of whimsy from the originator of that feature:

https://bugs.ruby-lang.org/issues/16746

reader_mode · 5 years ago
>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.

JohnBooty · 5 years ago
I love Ruby, but I agree with you about disliking that kind of thing.

I've done Ruby since 2014 or so at a few shops. My general anecdotal experience:

- Lone Ruby coders often use a lot of that cutesy/obscure/dense stuff.

- Teams of people writing Ruby, with healthy code review practices, tend to value simple, easy-to-read Ruby.

- A lot of Popular Ruby gems (and projects at aforementioned Ruby shops) have Rubocop-based style guides. Rubocop has some very strict ideas about Ruby coding style. The defaults are mostly quite sane and it's easy to disable/customize the ones you disagree with.

Not making excuses for some of the more florid parts of Ruby's syntax and stdlib, but in practice I do find things are manageable!

d3nj4l · 5 years ago
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 - they can get their feet wet with "standard" ruby at work, and then experiment with it more deeply in their own time, finding themselves in the ways they choose to express their logic. And then, every now and then if you find something really elegant and beautiful in your own exploration, you can introduce it to your team and add it to your team's style if they all agree on it. Between a language that makes all the choices for you, and a language that gives you the freedom to choose how you do things, I'd pick the latter nine times out of ten: at least in the latter, you can restrict yourself from the more wild stuff, but in the former you're forced into a narrow band of choices. I sure didn't ask for right assign, but I'll be trying it out in my personal projects!
bb88 · 5 years ago
> 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 into production code of a fortune 500 company. The coder's argument was that, "Well the language has it so why not use it?"

"Because with great power, comes great responsibility..."

strken · 5 years ago
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.

nsomaru · 5 years ago
So why would you not just default to always using .size?
majormajor · 5 years ago
I learned Ruby by itself and only worked on Rails code later... so I've had a lot fewer core Ruby complaints then most.

But Rails has definitely become a PR problem for the language in terms of how many complaints like this it leads to.

joelbluminator · 5 years ago
Ugh yes I don't like this as well. Even if they're all useful, I'd do it with one method that accepts some optional arguments, this is unnecessarily confusing.
gorgoiler · 5 years ago
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.

joelbluminator · 5 years ago
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.
philwelch · 5 years ago
Ruby can also be an extremely decision-fatiguing language to write code in.
steveklabnik · 5 years ago
! means “dangerous”, not mutation. Yes, that’s how it plays out because it is one kind of danger, but it’s not inconsistent.
choward · 5 years ago
It's also not supposed to be used unless you have another method with the same name.

Also, what kind of danger are we talking here? I consider mutation dangerous. Danger could also mean it has side effects or that it can raise an error.

I wouldn't call it inconsistent but I would call it arbitrary.

I would rather just name the method "#{base_method}_#{why_its_dangerous}". For example take ActiveRecord::Base#save and #save!

#save mutates and I would consider that dangerous. #save! can raise an error. I would rather name #save! as #save_or_raise_if_invalid. I know it doesn't look as pretty and takes longer to type but I really don't care. Then again, I'm not a big fan of exceptions so I would never call it.

jrumbut · 5 years ago
I love all that stuff in Ruby to-date (used in it's appropriate place, following convention, etc) but the rightward assignment feels useless to me.

I have no idea why the few languages that allow it do so. I've never wanted it and I can't imagine it makes parsing simpler in a language where you are sometimes compiling code at runtime and where parsing is already pretty wild.

I've said this before and been wrong so let's hope this turns out to have excellent use cases.

levi0214 · 5 years ago
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"

shakna · 5 years ago
> It sounds like "let's add a new syntax for lisp because it has too many brackets"

You'll find wisp [0] implemented for several of the larger Schemes. Often because the rationale for adding another syntax can be more nuanced and actually benefitial than a quick joke. [1]

Whilst you're right that caution absolutely applies when modifying a language's syntax, there may be a case for it that reduces friction for the programmer. The change might have been proposed with a joke. I doubt the entire rationale ended there, however.

[0] https://srfi.schemers.org/srfi-119/srfi-119.html

[1] https://srfi.schemers.org/srfi-110/srfi-110.html#rationale

nitrogen · 5 years ago
This is a feature present in Kotlin, and it's useful for mathematical functions and simple-but-not-trivial getters.
wrp · 5 years ago
Ruby has been referred to as Smalltalk meets Perl, and the problem of dealing with other people's code is one of the main things that kept me in the past from using Perl on text processing projects. The problem of collaborating in Perl was lessened a lot by adhering to Damian Conway's Perl Best Practices. Is there anything similar for Ruby?
burlesona · 5 years ago
Rubocop and you're done. It's the first thing I'd add to any team project just because life's too short for an inconsistent codebase.
ashtonkem · 5 years ago
Ruby’s heavier use of key words rather than symbols saves it from the worst of Perl.

Yes, there’s still some symbols, but nowhere near as many.

cageface · 5 years ago
In a sense Ruby is sort of a cleaned up Perl but maybe not cleaned up enough.

I fell totally in love with it almost 20 years ago but these days I think we have better languages to choose from even if their ecosystems aren't always as rich.

cutler · 5 years ago
You mean like Dart and Go? For expressivity I'll stick with dirty old Ruby, thanks.
chrisoverzero · 5 years ago
>.NET went with non-standard SQL-like names (select/where) […]

Which names do you believe are standard?

rpastuszak · 5 years ago
Arguably, select/where are less familiar than map/filter to many. I'm not saying that either is a standard, but I can imagine the confusion if you come from say, JS background.
philwelch · 5 years ago
Not who you’re responding to but from context I would assume map/filter, as he said.
EdwardDiego · 5 years ago
`where` is intuitive as a synonym for `filter`, but it's the `select` that always threw me as a synonym for `map`.

I get that they're trying to expose an SQL-like API, but yeah, map is always about mutation, but `select`only does mutation sometimes in SQL.

crehn · 5 years ago
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.
dmix · 5 years ago
Best practices are extremely common in Ruby. Something I long missed writing JS which only came about as the language started to really mature with ES5/6. Ruby seemed sufficiently mature and sufficiently best practiced in basic training and widespread usage where it wasn’t a problem.

It’s not anything like C++ or C where the whole coding practice and culture changes depending on your framework (like using Unreal or doing Linux programming). The best practices were the same across the board.

Basically my experience with writing it for a decade doesn’t match these critiques. The quirks in Rails were easily ironed out among intermediate developers. It’s not like it requires advanced programming knowledge to just do what everyone else is doing, which is often share in best practice documents and popular libraries/tutorials/books or (less so) rubocop style plugins.

eddietejeda · 5 years ago
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!

sosodev · 5 years ago
That README isn’t up to date. The benchmark has seen significant performance improvements since then.

https://benchmark-driver.github.io/benchmarks/optcarrot/comm...

czbond · 5 years ago
I have been out of the ecosystem for a while, but use Ruby frequently. So the 3x3 is coming along? More up to date places I could see benchmarks or similar?

Note: I have been using Roda with Ruby 2 and it is pretty fast. Can't wait to see what it would be with 3x3.

thatguyagain · 5 years ago
This might be a bit of a novice question, but will this affect the initializations of ActiveRecord objects in Rails anything?

For example, processing a large CSV file and inserting new rows in a database from it has always been extremely slow using Ruby/Rails unless you basically just write raw SQL that copies from the CSV and don't do any initializations of Rails models, #create, etc. I wonder if this will improve these things at all, but my guess is that it has to do with memory usage and not the speed of Ruby?

rco8786 · 5 years ago
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.

inopinatus · 5 years ago
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 << self
        def all() = @all ||= Set.new
        def adopt=(...)
          all << new(...)
        end
      end
    end

    "Astrid" => Cat.adopt

rco8786 · 5 years ago
Oh the error handler example is kinda cool, especially paired with inline rescues

    def my_method
        .. code ..
    rescue FileNotFoundError => FileNotFoundHandler
    rescue StandardError => StandardErrorHandler
    end
But yea, as is so often the case with ruby, you can really shoot yourself if you try hard enough :P

djur · 5 years ago
What's strange is that it seems to have been an offshoot of the pipeline operator (|>) work from last year[1], which was originally proposed as having an assignment syntax like

  foo |> bar(20) |> (x)
where x is assigned to. People didn't like that syntax, and there were issues with = being higher precedence than |> [2]. This new right-assignment operator was created in response to that [3].

The weird thing is that the pipeline operator got killed, so the original reason for r-assign no longer exists. It looks to me like there's just some people on the Ruby team who took a shine to it.

[1]: https://bugs.ruby-lang.org/issues/15799 [2]: https://bugs.ruby-lang.org/issues/15799#note-22 [3]: https://bugs.ruby-lang.org/issues/15921

burlesona · 5 years ago
The examples given were all things that would be nice to do in the REPL. What I don’t understand is why not just define it in the repl, then, like ‘_’.
jaynetics · 5 years ago
Because changing or pre-processing the language syntax is far beyond the scope of any REPL. Assigning the latest return value to a variable named '_' is very straightforward and does not require dealing with the syntax.
phaedryx · 5 years ago
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.

dmix · 5 years ago
JS has already adopted the endless style and it’s obvious when to use it and where a single line adds needless complexity. It’s really an overrated barrier to entry with a high return value in code simplicity (particularly aesthetically, which goes a long way with Ruby).

I have no comment on the rightward bit though. That is more... radical. Until I see how it is adopted generally.

levi0214 · 5 years ago
Completely unnecessary syntax.

It does nothing but add complexity.

d2161 · 5 years ago
You can test your heroku app on the new ruby 3 preview already! (https://devcenter.heroku.com/changelog-items/1889)
faitswulff · 5 years ago
I was just looking for this a few days ago. Thanks!
shadykiller · 5 years ago
I love Ruby and great to see Ruby love on hacker news. Just curious on how popular it is in the hacker news community ?
chrisseaton · 5 years ago
> Just curious on how popular it is in the hacker news community ?

Seems to be well represented by successful companies here.

https://www.ycombinator.com/topcompanies/

swat535 · 5 years ago
You know I've long stopped caring about how popular a language is in the community.

As I get older the question I ask myself is do I honestly enjoy using it? If the answer is yes, then I put it in my programming toolbox and ignore the hype.

tartoran · 5 years ago
Love the attitude, but sometimes it is not beneficial to stick to a programming language that you simply like if you need to make a living out of it. If a programming language is decreasing in popularity it becomes harder to get work. If a programming language is not popular but it has a niche and one is in that niche then it's all good.
cutler · 5 years ago
That's fine for personal use but professionally the main criterion is how widely the tool is used to solve business problems for paying customers.
koffiezet · 5 years ago
I only ever tried out a rails tutorial once, and coming from a C/C++ background, but having used with many languages, too many things felt like magic back then, but no further experience with the language itself, so can’t really judge it.

However, now I’m on the operational side of things, and there are 2 types of applications I avoid to deploy/maintain, mainly because of their runtime: Java and Ruby apps. It’s very likely the Ruby runtime has improved, but we actually set up a haproxy with multiple instances of the same ruby app, which we just restarted every 2 hours, just to keep it running properly. Upgrading ruby back-then was a mess, and could break a lot of things. I can’t comment on the language itself, but the runtime left a very bad impression. I since then (4/5 years ago or so) have successfully avoided ruby, so it’s possible things have improved, but first impressions last...

Glyptodon · 5 years ago
I wouldn't call Ruby a high performance language, but your experience seems weird. Even four or five years ago I would consider Ruby one of the most painless languages for dealing with upgrades and new versions of things: install ruby with a version management tool, install your app from gemfile, run your tests, good to go. I regard it at one of the first languages to have effective tools for dealing with versioning and upgrades. I still find it easier to deal with than Python by a solid amount.
throwaway189262 · 5 years ago
I hate deploying Ruby and Python because all the system packages they tend to use. Getting something working typically involves a bunch of crash/install cycles and some manual compilation and package downgrading.

Go is easiest if we're talking about pre compiled binaries. If you include builds, dependency hell is real.

C#, JS, and Java have been easy for me. Install JVM/CLR/Node and run one command. Old school Java with EE servers and Tomcat and such was a nightmare but everything I've done recently is self hosting

weaksauce · 5 years ago
the magic in rails is not really magic once you get used to the fact that all those magic incantations are just method calls inside the class. every class in ruby is just a series of method calls. you can write a class that, when it's read from the file and interpreted will just print something...

class Foo

  puts "bar"
end

will just print `bar` when it's parsed.

so something like has_many :baz are just the method call `has_many(:baz)` defined by active record. that creates a few functions using meta-programming. the other thing that ruby uses a lot of are blocks which are just anonymous functions. `do |a,b,c| puts a; end` just a function passed to the method that can be invoked by the function. I think those things are the ones that trip people up the most with when learning.

theonemind · 5 years ago
Reminds me of http://harmful.cat-v.org/software/ruby/rails/is-a-ghetto . "The main Rails application that DHH created required restarting ~400 times/day. That’s a production application that can’t stay up for more than 4 minutes on average."

Not that Ruby = rails

Justsignedup · 5 years ago
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

sosodev · 5 years ago
I suspect it will be quite a while before we see Ractor being used in Rails. Ractor is very strict about data isolation to prevent race conditions and existing code will need significant refactoring.
joelbluminator · 5 years ago
I don't understand what you mean by "real multithreading". What I understand from Ractor is that it makes it safer to write concurrent code (e.g there are constructs that keep you from mutating shared data). But there is still a global VM lock, or is that gone in Ractor?
lucraft · 5 years ago
I believe the VM lock is now per-ractor, so no longer global no. Then there are constraints on what can be shared between ractors to ensure safety.
dorianmariefr · 5 years ago
puma, the default webserver when using rails, is most-likely what would be using ractors
sosodev · 5 years ago
Here's schneems, a Puma maintainer, talking about Ractor, Rails, and Puma https://old.reddit.com/r/ruby/comments/ivasiq/we_made_puma_f...