Live data from Hacker News

Ruby 3.2.0 is from another dimension

tomaszs2.medium.com

261–270 of 341 posts

Re: Ruby 3.2.0 is from another dimension

#261
Just some anecdata but I'm not seeing such dramatic improvements with YJIT, actually in my limited testing it's much slower...

Ruby 3.2.0, on a M1 MacBook Pro hitting a simple healthcheck route in a production Rails 6.1 app with wrk (`wrk -c8 -t8 -d30s http://localhost:3000/healthcheck`):

- 423 reqs/second with JIT disabled (using 229MB of RAM)

- 74 reqs/second running with `RUBYOPT="--yjit"` (using 385 MB of RAM)

I must be doing something wrong?

Re: Ruby 3.2.0 is from another dimension

#262
post #70

Earlier quoted context omitted.

??? Python was huge in the 90's? News to me. No one I knew knew about it until like 2010.

Can I assume the '85' in your username indicates a birth year? Zope was a Python project from the late 90s, and had quite a bit of attention and traction in the early cms/publishing days. That brought Python attention, and certainly gave it some mindshare in the late 90s.

Zope is still alive, it seems, although I haven't touched it in 20 years: https://zope.readthedocs.io/en/latest/news.html#what-s-new-i...

Re: Ruby 3.2.0 is from another dimension

#263
post #52

Earlier quoted context omitted.

One aspect in which Ruby is much more consistent than Python: sorted(arr) arr.sort() versus arr.sort arr.sort!

Personally I think the Python syntax make its more explicit which is an in-place sort vs returning a sorted copy. And also what's a method call vs an attribute access. Someone new to Ruby will be WTF is the ! for?

> WTF is the ! for?

This takes so little time to learn. Same with ?.

While ! is not always the same meaning, it exists when there is a non-bang version; and it means "watch out, this does some sh*t". Maybe it means mutating the source, or maybe it means "doesn't take the usual path", as with Active Record stuff (raising an exception if validations fail on save instead of just returning false).

And the ? is a godsend, as you can clearly indicate functions which return a boolean (or intentionally truthy) value. As naming functions is a chore, and one which can have significant impact on code readability later, the ! and ? have good value when used properly.

For example, Python's sorted() vs list.sort(). If you are new to Python, and you see sorted(list), you may wonder if that is telling you if the list is sorted or sorting the list. It's actually also very awkward, because most functions are named as their actions in present tense, not in past tense. The built-in Python function "sorted" really should be "sort".

In the list of Python built-in functions, you see present tense verbs like slice(), sum(), round(), etc. Those are inconsistent with sorted() and reversed(). When we see a past tense verb, it feels like a question. With Ruby, if it's a question, it ends with a ?.

BTW, why the hell is Python sorted() and reversed() not just called sort() and reverse()?

And while I'm ranting about inconsistencies, Python my_list.sort() mutates my_list, while sorted(my_list) doesn't. In Ruby, my_list.sort returns my_list sorted, without mutating. my_list.sort!. That is consistent and concise, and the bang warns you that it is destructive.

Re: Ruby 3.2.0 is from another dimension

#264

Earlier quoted context omitted.

Personally I think the Python syntax make its more explicit which is an in-place sort vs returning a sorted copy. And also what's a method call vs an attribute access. Someone new to Ruby will be WTF is the ! for?

When i learned Ruby, it wasn't really a WTF for me - I just learned that '!' methods are destructive, while non-'!' aren't. However, the destructiveness semantic has been significantly overloaded over the time, so each Ruby (Rails) project probably interprets them in a different way, and it ends up having arbitrary semantics. I'm used to it, but I personally think that for the reason above, it's not a good syntax/sem…

> arbitrary semantics

I wouldn't go so far to say it is arbitrary (unless someone uses it wrongly :) ).

As far as I know, a bang name only exists if a non-bang name exists as well. And the one with ! indicates an unexpected or comparatively dangerous outcome, such as a mutation, raising an exception, bypassing some normal check, etc.

Re: Ruby 3.2.0 is from another dimension

#265
post #10

Perhaps the official release info is of more interest. This blog post is quite 'inspired' by it. It does mention the source but I do not see the added value of the blog post over the official release info: https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-rele...

Thanks. I didn't read the article because it sounded clickbaity. Official release is much better.

Re: Ruby 3.2.0 is from another dimension

#266
post #70

Earlier quoted context omitted.

??? Python was huge in the 90's? News to me. No one I knew knew about it until like 2010.

Can I assume the '85' in your username indicates a birth year? Zope was a Python project from the late 90s, and had quite a bit of attention and traction in the early cms/publishing days. That brought Python attention, and certainly gave it some mindshare in the late 90s.

I don't think Zope/Plone had hardly anything to do with Python's rise. While a number of significant sites were built on Zope or Plone, the relative ease with setting up such a site meant that little or no code-level modification or extension was necessary.

Re: Ruby 3.2.0 is from another dimension

#267

Earlier quoted context omitted.

did you benchmark Jruby or TruffleRuby? Did you compile c-ruby with jemalloc? Normally the "ruby is slow" argument, is based on not being involved with ruby and solving real problems with it. Some people will just LOL this argument even harder if you add development time and code maintenance costs on that equation.

> did you benchmark Jruby or TruffleRuby? Did you compile c-ruby with jemalloc? Jruby a little faster than CRuby (it used to be more significantly faster, but CRuby has seen more recent performance increase); TruffleRuby is, OTOH, not slow like other implementations. > Normally the "ruby is slow" argument, is based on not being involved with ruby and solving real problems with it. Ruby is abstractly my preferred lang…

> That’s just equivocation; time and cost to market is an orthogonal concern to execution speed, not a component of it; yes, Ruby has a decent code-writing experience, especially for small systems.

Probably you meant rails here. I don't see why ruby should be a problem for something not small, moreover, you should first define what a small system is, specially if you count the LOC of all the gems that you use..

Re: Ruby 3.2.0 is from another dimension

#268
post #245
post #108

Earlier quoted context omitted.

I had over million euro of machinery stop because a rarely reached branch had one line with one less space due to missing linter run. Apparently Python 3 still doesn't fully parse and validate code on load, or somehow it made a valid if nonsense AST out of that.

I know it's offtopic, but this is really a case of using spaces where tabs are the correct choice ;)

Perhaps, but should _that_ choice (or more likely, misconfiguration of a system) be so dangerous?

Re: Ruby 3.2.0 is from another dimension

#269

Earlier quoted context omitted.

They did apparently manage to make their interpreter figure out where mismatched "end" statements are most likely to be, which was one several serious pain points for me with the language. I don't think the execution model you mention, which results in the absurdity of C style transitive includes polluting the global namespace, will ever be changed though.

> They did apparently manage to make their interpreter figure out where mismatched "end" statements are most likely to be, which was one several serious pain points for me with the language. Searching for a mismatched/missing _end_ is preferable to having a line or block get accidentally unindented and end up still "working" (running) while producing very confusing results. Moving blocks of code in Python requires gr…

> To be fair though, my vim-memory of using % to bounce between start/end brackets doesn't work in Ruby because of the begin/end words instead of matched symbols :(

Put "runtime macros/matchit.vim" into your .vimrc. Or for even better support add the matchup plugin. https://github.com/andymass/vim-matchup

Re: Ruby 3.2.0 is from another dimension

#270

Earlier quoted context omitted.

I use Python every day and I like it. However, functional semantics are not elegant at all IMO. Using list() and map() all over the place is not cool, and like many others say, list comprehensions, though concise, are not always that readable (and I say this as someone who reads and writes plenty of them). Lambdas are not great, either. In Django in particular, async feels like an afterthought, compared to other fram…

Python lambdas are not great but Ruby not having first-class functions is also not great. Neither are perfect and there is no syntactic reason outside of variations of personal taste to choose one language over the other. There are a boatload of compelling reasons to choose Python for its libraries and documentation and adoption level, though.

> Ruby not having first-class functions

This is simply false. Ruby has first-class functions.

Not only that, it has blocks, which few other languages have. Ruby optimizes for the common use-case of a method that takes a single callback/piece of code, and I miss it in most other languages, including Python.

In Python, the "with" statement is super special. But in Ruby, it's just a method that takes a block. And any method can take a block, not just one per class.

https://yehudakatz.com/2010/02/07/the-building-blocks-of-rub...

Post reply on HN