Hacker News new | ask | show | jobs
by exabrial 2042 days ago
Isn't crystal lang trying to do the same thing? Why not join forces?
5 comments

> Isn't crystal lang trying to do the same thing?

Nope, Crystal is a statically-typed language with distinctly different than Ruby semantics that features Ruby-ish syntax.

Sorbet is an optional static type system for Ruby.

They aren't trying to do the same thing. One is trying to appeal to the aesthetic preferences of developers who like Ruby with static typing, the other is trying to enhance the Ruby ecosystem with static typing. There's only a superficial similarity between these things.

Beyond the syntax looking a bit similar, Crystal is a very different language. Porting over a production application such as Shopify isn't something you do in an evening.
It goes past syntax. Yes, they're different languages, but syntax, behaviour, stdlib are so close you can port non-trivial libraries between them in a relatively short time.
The key word there is non trivial. Something with as many moving parts as Rails is non trivial, and Crystal doesn't have the run-time metaprogramming that Rails makes extensive use of. A trivial example is ActiveRecord generating attribute methods from your `select` operation.
I don't think rails is a fair example. Rails loves its runtime metaprogramming and that is not where crystal offers much, but I don't think it invalidates the overall similarity. There's trivial (scripts with simple flow), non-trivial (libraries with heavy oop design and a little bit of trickery), and there's almost everything else before we get to rails itself.

Just like in C, you have trivial, nontrivial, complex apps, then there's still a long way before production OS kernels at the extreme.

Many advanced libraries don't use metaprogramming much, and even if they do, it can be often made either more explicit or shifted to compile time.

Edit: The downvotes are interesting since the portability claim comes from my experience doing just that.

Shopify uses Rails. To your original question, which you've answered yourself: that's why they haven't joined forces. They were very clear in the article about the size and activity of their codebase, and their commitment to Rails in particular.
That wasn't my question :-) I was only addressing the syntax similarity bit since it's repeated write a lot.
Like others have stated in the thread, Crystal is a different language that shares some its syntax with Ruby. Our aim is to keep our Ruby codebase but adopt static types gradually.
Is there any runtime performance gain to be had in the interpreter at runtime when adding types. I understand the benefits to your workflow but is there an opportunity to allow the interpreter to do less work when types are used?
Currently, no. On the contrary, since Sorbet syntax is pure Ruby, it needs a runtime component, so there is actually a small negative impact in performance at runtime. The reason why we cannot use types to make the interpreter do optimizations is because the interpreter is not aware of types.

Having said that, such optimizations are indeed possible and we are already thinking about how we can use the type information we have to that effect. There are still many things that need to line up for that to be a thing, so we are not expecting any new developments on this soon. But this is a very exciting direction for our Ruby Infrastructure team at Shopify.

It's one thing to adopt a layer of static typing on top of your massive production codebase, it's another to switch languages entirely.
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.