Hacker News new | ask | show | jobs
by raitom 3047 days ago
Kinda suprised when I see title like that on HN that not so many people are talking about Crystal https://crystal-lang.org. Basically Ruby with C performances.

So far I’ve been more convinced by Crystal than Elixir as the next language for a Ruby developer.

9 comments

You don't? The joke of the Rust Evangelism Strike Force needs to be updated with the Crystal one, near as I can tell. Nearly every thread where Ruby's discussed has the Crystal Guy (specific identity of any given Crystal Guy up for debate) parachuting in.

Crystal is not the next language for this Ruby developer. Ruby remains it, along with JavaScript when Node makes sense. It often feels like the folks evangelizing Crystal really don't get why people use Ruby--if I need static typing I'm going to go use Kotlin or Rust or C++; looking like Ruby and not having any of the things that make Ruby valuable to me (namely, the features implied by dynamic typing, and to forestall the usual, no, Crystal macros don't replace it) is a demerit, not a positive.

> if I need static typing

And that's when the Static Typing Is The One True Way person parachutes in. :)

It is, but I won't try to sell it to Ruby devs. :P
But Crystal is a totally different language. The syntax and some things like the basic object model look similar, but the whole way you use it and the ecosystem are totally separate. I don't think it's 'basically Ruby' at all - I don't think much of the Ruby ecosystem (Rails for example) would translate onto Crystal.
Departing the Ruby ecosystem is a dealbreaker in many situations. Crystal is faster but you’re gonna spend more time reinventing the wheel and building common tools that are sitting on the shelf in Ruby land. Not picking a side here, just trying to point out why Ruby is still very popular.
Neither are "next languages," all three differ significantly in scope. For the western Ruby dev (meaning Rails people) there is a much clearer and more consistent path forward with Elixir/Phoenix.
After a couple of paid projects with Phoenix I'm not sure it's a path forward. More like a fork in the road to a different destination. I'll steal pattern matching from Elixir and keep using Ruby on Rails. Phoenix adds too much unnecessary complications for the average web app, starting with Ecto. Potentially great when building complex systems, but there are not many of them.

My suggestions are: simple to average web apps, stay with Ruby (Rails) or Python (Django); complex, look into Elixir (Phoenix.)

I never used Crystal so I can't say anything about it.

Would you care to elaborate on the complications you've experienced?

I'm curious because my personal experience has been very much the opposite. I've built nothing but small projects using Phoenix, and I've considered it to be a very straightforward companion whenever I've needed to add a web interface to my Elixir apps.

My experience is that it's not so much that Elixir and Phoenix are complicated, but rather that they're very different from what a Rails (or Rails-like) developer is used to.

There's not just Phoenix' deceptively Rails-ish approach, but also Elixir as a functional (and somewhat strange?) language, and while you can do without knowing much about OTP, it's not exactly invisible.

On top of that, I find that all the best packages embrace this weirdness. Ecto is wonderful, and by far my favorite 'ORM', but it's very different from the more common ORM's. splitting up the view layer in templates and views is, in my opinion, a step up from the Rails approach. But it took me a while to adjust. The sparing use of macros is also 'weird', but again I find it a step up from what came before.

I kind of feel the same way about Elixir/Phoenix as I do about functional programming in general: Whether it's actually as complicated as it is often said to be or not (perhaps just a matter of 'what we learned first'?), I find that once I got over the hurdle of learning the building blocks and mindset, the stuff I could do felt more fun, more expressive and less brittle, and the approach is starting to infect all the other coding I do.

At the same time I completely understand that if you're comfortable with Rails, and it does the job, or if you use a lot of gems that might not have a (mature) equivalent in Elixir, there's no good reason to bother unless you need channels, perhaps. I have the luxury of being able to use my own tech for many projects, as well as the time available to dive into the Elixir/Phoenix ecosystem.

That's a shame, I haven't done much with Elixir/Phoenix but it looked really promising. How frustrating that these things have to be so complicated.
> Kinda suprised when I see title like that on HN that not so many people are talking about Crystal

There is a dedicated contingent promoting Crystal in every thread about Ruby. Don't really know that we need any more (better, perhaps, but not more.)

> Basically Ruby with C performances.

Well, vaguely Ruby-ish syntax, without the dynamic features or ecosystem, and with a static type system.

> So far I’ve been more convinced by Crystal than Elixir as the next language for a Ruby developer.

Not sure what that has the do with the subject here, which has nothing to do with either Elixir or the next language for a Ruby developer.

Language (or tool) evangelism with no connection to be thread beyond offering an alternative to a language mentioned in the thread is basically a uniquely geeky form of threadcrapping, and its really not any better than any other threadcrapping.

I assume if all you're building are command-line apps, that might be true. Generally speaking though, I think most Ruby developers are smart enough to move where the market and ecosystem is, and are not constrained by syntax.
Go to Crystal if you just want to go faster.

Go to Elixir if you actually want to learn more, expand your mind, and are tired of bugs that can only occur in a mutable OOP language. And if you want to take advantage of the extra guarantees provided by a functional language, such as functional immutable datastructures making concurrency idiotproof.

There isn't much that is "mind-expanding" about Elixir coming from Ruby or really any other interesting, dynamically-typed language that I know. It's fine but it's nothing special; BEAM is a better argument for it than Elixir itself.

Maybe rein it in a bit.

Crystal is so strict about type coercions, it's actually way harder to use than you realize.

Seriously, try converting over a decently complex script to crystal from ruby, you'll run into complicated problems.

Elixir is a successful experiment. Crystal could have become a success if they decided to have 100% syntactic equivalence. As it is, it requires rewrites in even trivial console scripts.
This is what baffles me about it. It keeps being touted by some as a "faster Ruby", while they explicitly make decisions that makes it incompatible with Ruby even when it comes to relatively simple syntax.