Live data from Hacker News

Static Typing for Ruby: Adopting Sorbet at Scale

shopify.engineering

41–50 of 72 posts

Re: Static Typing for Ruby: Adopting Sorbet at Scale

#41
post #34

I've been using Sorbet for a while integrated in my SublimeText. I have never added a type signature, not even once. I just use it to prevent me from silly mistakes (like changing a variable name somewhere and breaking code downstream). The immediate red underline, which we are used to having in JS with ESLint, is such a great productivity booster.

It is the same with Typescript. The VSCode Typescript plugin gives you type signatures of DOM Related functions that you would otherwise never get.

Re: Static Typing for Ruby: Adopting Sorbet at Scale

#43
post #4

I wish this had been available years ago! I think Ruby was an excellent replacement for Lua to do ML, once Torch ran out of steam due to LuaJIT memory limitations. However, historically, MRI Ruby was slow and problematic. Personally, I prefer Ruby to Python. Ruby is very close to Smalltalk, with some ideas from Perl and Lisp.

God do I love Ruby. It's just such a beautiful language. Feels more expressive and imaginative than any other language I've touched by a mile. But while I personally enjoy it more than Python, Python will always be the one I would recommend to anyone for work or learning-- it's so much more straightforward and predictable. The "one right way to do things" mentality that pervades python makes things so consistent and…

In the words of David Heinemeier Hansson:

> In fact, Ruby, to me, so much of the enjoyment in Ruby is these incredible subtleties, of how many different ways you can structure a conditional. Like, Ruby has, I don't know even the count, there's gotta be 60 different ways you can say `if something`, right? And it is in those 60 different ways that I find half the enjoyment of writing Ruby. Like, it was one of those things where I knew, very early on, that Python was not a language for me because it said, right in the manifesto, there should be preferably one and only one way to do things. Ruby has the exact opposite approach, there should be preferably ten thousand subtle different ways of doing things, that will allow you to write that particular conditional, with just the right emphasis, do you write it in the front, do you put it at the back, is it multi-line, is it single line? Like, there's so much variety and it's in that variety that I find poetry. And it is the poetry of writing Ruby code, of making those subtle distinctions where, at the end, you can like, "Ehh, should we move it around" like, where I just go like, giggles, right? Like, this where like we talked about that big smile, right? So much of that big smile comes from, not just like solving the problem, but solving it in a poetic way.

Re: Static Typing for Ruby: Adopting Sorbet at Scale

#44
post #42

Semi related: what kind of process do you have that makes you feel confident pushing 40x a day? Do you run some kind of automatic analysis that helps you automate the push completely? What if you know that HEAD has a regression that shouldn't be pushed?

We have a lot of automation and infrastructure in place to give us that confidence. We have an extensive test suite of hundreds of thousands of tests, linting and static checks that run on CI, a deploy automation tool that automatically merges and deploys on green (https://shopify.engineering/successfully-merging-work-1000-d...) and a canary deploy system where we quickly detect regressions that might have escaped our systems to that point. We have a lot of posts about those systems written up in our engineering blog, as well.

Re: Static Typing for Ruby: Adopting Sorbet at Scale

#46

Earlier quoted context omitted.

God do I love Ruby. It's just such a beautiful language. Feels more expressive and imaginative than any other language I've touched by a mile. But while I personally enjoy it more than Python, Python will always be the one I would recommend to anyone for work or learning-- it's so much more straightforward and predictable. The "one right way to do things" mentality that pervades python makes things so consistent and…

In the words of David Heinemeier Hansson: > In fact, Ruby, to me, so much of the enjoyment in Ruby is these incredible subtleties, of how many different ways you can structure a conditional. Like, Ruby has, I don't know even the count, there's gotta be 60 different ways you can say `if something`, right? And it is in those 60 different ways that I find half the enjoyment of writing Ruby. Like, it was one of those thi…

And I love Ruby for exactly that reason. Well said, totally agreed.

Re: Static Typing for Ruby: Adopting Sorbet at Scale

#47
post #21
post #4

I wish this had been available years ago! I think Ruby was an excellent replacement for Lua to do ML, once Torch ran out of steam due to LuaJIT memory limitations. However, historically, MRI Ruby was slow and problematic. Personally, I prefer Ruby to Python. Ruby is very close to Smalltalk, with some ideas from Perl and Lisp.

Hm interesting, for anyone interested, LuaJIT has a 2 GiB limit, which is unsurprisingly problematic for machine learning: https://kvitajakub.github.io/2016/03/08/luajit-memory-limita... https://github.com/karpathy/char-rnn/issues/80

The 2gb limit has been fixed for a many years now with the GC64 mode that was set to the default build mode last year.

Re: Static Typing for Ruby: Adopting Sorbet at Scale

#48
post #4

I wish this had been available years ago! I think Ruby was an excellent replacement for Lua to do ML, once Torch ran out of steam due to LuaJIT memory limitations. However, historically, MRI Ruby was slow and problematic. Personally, I prefer Ruby to Python. Ruby is very close to Smalltalk, with some ideas from Perl and Lisp.

Ruby doesn't have to be slow anymore!

https://pragtob.wordpress.com/2020/08/24/the-great-rubykon-b...

https://speakerdeck.com/eregon/running-rack-and-rails-faster...

Re: Static Typing for Ruby: Adopting Sorbet at Scale

#49
post #5

Isn't crystal lang trying to do the same thing? Why not join forces?

Holy hell, I didn't know there was such animosity between the two languages! I really need to refrain from asking questions on HN!

There's little animosity there really. The answers you got are pretty simple/factual. Nobody's really judging either language here.

Re: Static Typing for Ruby: Adopting Sorbet at Scale

#50
I keep looking at Sorbet, and I have since it was in private beta. It just seems to be so so much work to get anything out of it. Last time I tried it was last year when I was at Rubyconf in my spare time on a microservice.

It's frankly easier for me to rewrite a small service in Rust, and have native typing (plus thread safety, no race conditions, easy parallelism, etc).

While I'm best at Ruby, and have used it professionally for well over a decade - it's wearing on me.

Post reply on HN