From ruby to crystal, any cons?

Hi there, I’m considering to migrate from ruby (rails) to crystal (amber), but the discusion is more tied to crystal than a framework, what are the cons right now at a language level? There’s anything I need to be worried about about some stuff that ruby currently has and crystal is missing? I’m not so concerned about missing libraries right now because that can be solve quite easily.

A bit offtopic, but my concerns to migrate from ruby to amber are that I’ve been working with strong typed languages the pasts years and now coming back to ruby I feel that I lost some of the nice features of strong typed languages (errors at compile time, instead at runtime), I currently facing that some changes made right now you cannot check instantly what impact has in your app, and more when you work in a medium/large team, I know that you may can work on test but for me seems that test for some scenarios are waste of time, while having crystal the errors will instantly popup (as far I read in some articles related to amber).

Regards

You can check [Mini Review] Giving up on Crystal for some cons.
Exact problems mentioned there are debatable, but the points in general are (imho) truthy.

  • Type system. Background with strongly typed languages will help, but there still will be times when you are fighting against type system.
  • The rest of mentioned there points. IDE aren’t clever, compile times could be several seconds, i can’t agree with documentation (IMHO it’s awesome) but maybe I was just lucky, breaking changes occurs, future is uncertain.

For me the only issue I see right now is the version breaking changes, about the compile times, type system, etc I’m not concerned too much, I’ve been playing with rust for few months and I’m kinda used to thing about the types etc, also I fall in love in having static typed, even that I don’t want to write javascript anymore (but sadly I’m not a lover of transpiling too much so Typescript is also discarted for the front end, I just stick with js but that’s another topic).

Well for the time being I will just toy with crystal and put on hold to use it on real projects.

Thanks

1 Like

Maybe you can try it with a small service and see how it goes.

I have not used amber yet, so I can’t say anything about that end of things.

About Crystal itself, I would suggest just doing it. I’m very much in love with the type system it provides and the great standard library.

Using crystal also removes the problem of installing and maintaining a ruby installation on the live system, which I always hated.
It is so much simpler if I can just do dpkg-buildpackage on my laptop and apt install the new version on a system without messing about with RVM or RBENV.

One of the few serious blockers I’ve found, was a really limited way of mocking things in specs.

1 Like

If you want to stick with Ruby there is always the new Sorbet static type checker. However if you do want to switch to Crystal, which I am always a proponent for you have to know a few things.

  1. The compiler is magical, but also a massive pain in the ass. By this I mean that you will be fighting with it constantly. Creating clean runnable code isn’t near as easy in Crystal as it is in Ruby, but you will end up with a better running app in the end.

  2. The ecosystem is still sparse when compared to Ruby’s. There are a lot of shards that are missing or unmaintained, where ruby has thousands of amazing shards that work well and have been out for years. I, and many others, are trying to remedy this, but it takes time.

  3. This leads me to another point, IMHO Amber is not your best bet. I have worked with pretty much every web framework that’s come out of Crystal in the past couple years and I have to say, I did not have a great experience with Amber. I always tend to write database heavy applications and need a framework that works with me in the way that Rails does. The only one that I’ve found that does that so far is Lucky. Not only that, but since they’ve stepped away from the way Rails does things a bit they are able to offer a lot more compile time guarantees, and things run so smoothly.

So to recap: Stay with Ruby if you’re comfortable and don’t mind using the somewhat hacky approach that is Sorbet. If you switch to Crystal be prepared to ask a lot of questions and maybe write some shards of your own to fill holes in the ecosystem. We’ll be here if you need us.

1 Like

@norman784 How has it been after a couple months?

@girng I didn’t wanted to commit yet to use in a project, so I’m waiting to find the right pet project to test this out (something small that could possibly take only a few hours to convert to ruby as a fallback, if needed), some things that pushed me away to trying it was the breaking changes (without notice, that was mentioned in earlier posts).

I’m still kinda following the crystal development and waiting too when it get’s closer to a stable API.

@watzon sorbet looks a cool tool that can be integrated easily in the test, I might check that out in a near future, thanks!

1 Like

@norman784 Good to know! FWIW, it’s pretty stable! I know @sdogruyol uses Crystal in production. And I’m using it for a soon released online aRPG. I’ve seen some other people in gitter mention they use it at their company as well. But it’s understandable you want to wait for a firm release :) I hope you decide later down the road, please be sure to keep us updated

Hi !

At Plezi we use Crystal on production for a little service.

This service should be bigger, but the lack of good MongoDB ORM stopped us.

Also, for side projects, I use Crystal (Amber) and the SQL ORM are bad too, it’s difficult to build complexe queries and fetch results, and all ORM are ActiveRecord based.
(I’ve tried to port ROM, but it’s too hard in Crystal)

Despite theses problems, Crystal is ok for production nowadays, the compiler prevented a lot of nil errors, and changed our Ruby coding style to be more secure.

I’m investigating crystal as well. One thing that is important to me is having a robust XML parser/generator. Is there anything like Nokogiri available?

There is https://crystal-lang.org/api/0.29.0/XML.html in the stdlib. Is also https://github.com/kostya/myhtml which i hear is pretty good.

1 Like

Thanks. I had no idea that this amount of functionality was built into the language. :slight_smile:

There’s also https://github.com/madeindjs/Crystagiri

I never used it but it could also be useful. And if you just need the basics of XML processing then the XML module in the standard library might be all you need.

1 Like

Check out https://crystalshards.xyz/ as well!