Live data from Hacker News

Ruby 3.4 Highlights

blog.sinjakli.co.uk

51–60 of 86 posts

Re: Ruby 3.4 Highlights

#51
post #43

Earlier quoted context omitted.

You'll get Ruby with typings soon when rbs-inline is finalized

Is that really something that's been slated to be added to the language proper? I attended RubyConf and in his keynote Matz seemed pretty opposed to adding types to Ruby source, and argued in favor of automatic typing instead.

You can always use Crystal or Dart if you want builtin types. I like Ruby the way it is an trust Matz with his language design decisions.

Re: Ruby 3.4 Highlights

#52

Is ruby used outside of web dev (i.e., Ruby on Rails)? it seems like a nice cute language but I almost never hear about it.

We use it for microservices that only deal with Json and avro. Of course, we do that on Rails for some reason I'll never understand.

Re: Ruby 3.4 Highlights

#53
post #46

Earlier quoted context omitted.

I constantly run into situations where I need to nest an iterator computation, and things like "it" get confusing. I'm all for adding language features to avoid boilerplate, and it's clearly useful. I just want to call out that anonymous typing can be polarizing in large codebases and maybe only use it sparingly.

nested_example = [1, 2, 3, 4, 5].map do [it, (1..it).map { it * it }] end Has an ambiguity, so you just add |x| to one of them.. nested_example = [1, 2, 3, 4, 5].map do |x| [x, (1..x).map { x * it }] end Seems like a mental over complication of a non-issue to me.

Implicit `it` shadows in other languages like Kotlin just like any other variable scope, and I really can’t say I’ve ever had it be a problem (implicit receivers, on the other hand, can be a right pain in the ass in poorly designed libraries and can I just say Gradle can go right to hell for it).

Re: Ruby 3.4 Highlights

#54

The default block parameter name seems small, but I feel like I'm gonna use it all the time, especially when I'm in the Rails console just trying to debug data

Similar ish but equally cool is Nim's `result` keyword for functions. https://nim-by-example.github.io/variables/result/

Also damn Nim needs to do a much better job with their docs and site. `nim result` returns this very outdated third-party link first and nothing else official.

Re: Ruby 3.4 Highlights

#55

Is ruby used outside of web dev (i.e., Ruby on Rails)? it seems like a nice cute language but I almost never hear about it.

It's used for chef/cinc. I rather like that "recipes" use ruby with an edsl rather than yaml like ansible or salt.

Re: Ruby 3.4 Highlights

#56
post #46

Earlier quoted context omitted.

I constantly run into situations where I need to nest an iterator computation, and things like "it" get confusing. I'm all for adding language features to avoid boilerplate, and it's clearly useful. I just want to call out that anonymous typing can be polarizing in large codebases and maybe only use it sparingly.

nested_example = [1, 2, 3, 4, 5].map do [it, (1..it).map { it * it }] end Has an ambiguity, so you just add |x| to one of them.. nested_example = [1, 2, 3, 4, 5].map do |x| [x, (1..x).map { x * it }] end Seems like a mental over complication of a non-issue to me.

It’s a nonissue in small projects, but I’m not sure I agree that `{ x * it }` is easy to reason about when coming back to this block in 6 months. It’s mostly something that I’ve seen bite engineers during refactoring.

Re: Ruby 3.4 Highlights

#57
post #40

Earlier quoted context omitted.

_1 is also a bit of a footgun. It becomes an array of all block params IF the block has an arity > 1 AND no other block param (e.g. _2) is referenced anywhere within the block. It's an unusually half-baked feature by Ruby's standards. I think there was some hesitation about the name "it" initially, because "it" is an essential method name in rspec, and is used within blocks there.

I pity anyone needing to debug a fiddly Rspec problem in the next few years.

IIRC, the decision was that it in a block is only ever called without arguments, e.g. map { it * 2 }, and it in Rspec is only ever called with arguments, e.g. it "describes a test" do ... end. So it ended up being a non-issue.

Re: Ruby 3.4 Highlights

#58
post #9

Earlier quoted context omitted.

Kotlin also has it, I can tell you that it's really useful

Ruby has had this in the same form as "_1" for a while (and the obvious other indexes in the case of multiple params), but I agree Kotlin's "it" reads much better.

Groovy has had “it” for a while. I suspect it predates Kotlin’s usage.

Re: Ruby 3.4 Highlights

#59

The default block parameter name seems small, but I feel like I'm gonna use it all the time, especially when I'm in the Rails console just trying to debug data

I've not been tracking ruby core discussions for ages now, but I could have sworn that exactly this was discussed and rejected a decade or so ago.

Re: Ruby 3.4 Highlights

#60

Earlier quoted context omitted.

I constantly run into situations where I need to nest an iterator computation, and things like "it" get confusing. I'm all for adding language features to avoid boilerplate, and it's clearly useful. I just want to call out that anonymous typing can be polarizing in large codebases and maybe only use it sparingly.

I doubt I'll use it in committed code very often at all, this feels more like something that's very useful when hacking at something in the REPL

[deleted]
Post reply on HN