Anyone have any experience with Crystal?

Does anybody have any experience with running Crystal in production?

2 Likes

I was just looking at Crystal the other day!

I thought this was a pretty good post about it and how it differs to Ruby: http://crystal-lang.org/2013/11/14/good-bye-ruby-thursday.html

Iā€™m also surprised more people are not talking about it - it seems to be the closest thing to Ruby out there (that isnā€™t an official AltRuby) :ok_hand:

If anybody is interested in current state of web frameworks in crystal.
Found these 2:

GitHub - manastech/frank: A small Sinatra clone for Crystal - Sinatra inspired
https://github.com/Codcore/Amethyst - Rails inspired

1 Like

Nice find @tak1n!

Wonder if anyone has done any speed comparisons yet?

For the language itself, I think the creators made some benchmarks showing the performance against ruby etc.
The language itself is faster than ruby because itā€™s compiled.

Also found this benchmark: GitHub - kostya/benchmarks: Some benchmarks of different languages

For the webframeworks I think manastech (the company behind crystal) is using frank for some of their apiā€™s in production.

1 Like

Thanks Benny - some interesting results thereā€¦ Crystal sure is fast!!

Wonder where Elixir would be in itā€¦

You may find this interesting regarding Crystal:

Differences from Ruby?

Nice one George. There are more differences in the link I posted (in post #2 - though I guess youā€™ve read it already).

I think itā€™s definitely worth keeping an eye on :+1:

I just watched this.

PolyConf 15: An Introduction to Crystal / Erik Michaels-Ober

I like that it runs/compiles Ruby code. :smile: ā€¦ and itā€™s faster then ruby considerably.

4 Likes

Great talk that - wonder how it compares to Elixir.

Good to see Soundcloud using it :slight_smile:

There are some good comments about Crystal here: https://www.reddit.com/r/programming/comments/30symw/crystal_rubyinspired_compiled_language/

Is this better in performance than Elixir?, besides Elixir compiles to BEAM and Crystal to LLVM, what are other advantages?.

asterite:
We donā€™t have benchmarks against Elixir nor Erlang, so I canā€™t say anything about the performance. But since Crystal compiles to native code and Erlang/Elixir runs in a VM, my guess is that Erlang/Elixir is slower. But this is just a guess, and Iā€™m sure in some benchmarks Erlang/Elixir will win, in others Crystal will win. But benchmarks arenā€™t very useful, real programs and how they behave is what matters.

One advantage of Crystal is that it is statically compiled. That means that you canā€™t have type errors. If I write a program 1.length I wonā€™t be able to make an executable out of it, it wonā€™t compile. In Elixir I can have String.length(1) in some part of my code, and I can have that running and as long as that path isnā€™t visited at runtime everything will be fine. But when it is visited, boom, error.

At least I feel this personally, but when I program in a dynamic language, unless I test everything, everything, I canā€™t be sure I wonā€™t have an ā€œundefined method ā€˜xā€™ for SomeTypeā€ at runtime, or some silly mistakes. With Crystal you canā€™t have these silly mistakes, which gives you a lot of confidence when your program compiles, and makes it easier to refactor your code, even if you donā€™t have tests for everything. Of course you can have type casts fail at runtime, like in other languages, but these are explicit and less often.

Another advantage is that it doesnā€™t need a VM. You compile the executable and thatā€™s all you need (plus dynamic libraries if you use them). With Erlang you need to distribute the .BEAM but have the Erlang VM in that machine.

Yet another advantage is that thereā€™s no VM boot time, so Crystal is ideal for writing command-line interfaces.

Of course dynamic languages have advantages too, you have to choose the right tool for the right job :slight_smile:

I would love to see some comparable benchmarks with Elixir - could be a huge selling point for either language as I think both languages will appeal most to Rubyists.

Hi! ,I list up where the Crystal communities are, and more information about Crystal Lang

Have fun with Crystal!

2 Likes

Thanks for adding us @yahhonob :+1:

Havenā€™t seen it, but another talk:

I tried the default http server (the API seems awesome and the language feels fast)
the starting time and request per second
i havent watched at the memory and cpu stats but itā€™s fast :smiley:

ā€œbenchmarkā€ mbp retina

go app in prod with some code in it
36k

crystal default http server
http://crystal-lang.org/docs/overview/http_server.html
36k


linux ruby 2.1.6 (previous stable)
server puma (I will make a test on 2.2.2 unicorn too)

rack / roda (micro-framework like sinatra, improved routing and as lightweight as a rack app)
20k

sinatra hello world
5k

rails
i donā€™t want to know - oh my activesupport - rails with actioncontroller::metal as default controller should go faster but not fast enough, you should unload activesupport from rails-api :smiley: - Lotus maybe?

1 Like

Hoop - build native Mac apps with Crystal

Opinionated post about Crystal/Ruby :smile:

http://serdardogruyol.com/why-crystal/

2 Likes

This video has some good information.

Ary Borenszweig & Juan Wajnerman - Crystal: a programming language for humans & computers - Curry On

3 Likes

This Christmas eve something curious happened: we were happily coding in Crystal when, one moment when we took our eyes away from the screen, a translucid figure appeared nearby. The entity approached and said: ā€œIā€™m the Ghost of Christmas Past. Come with me.ā€

We saw ourselves coding a new language that would resemble Ruby but be compiled and type safe. At that moment the language was really like Ruby: to create an empty Array you would write , or Set.new to create an empty set. And we were happy, until we realized compile times were huge, exponential, unbearable, and got sad.

We spent an awful time trying to make it work with no avail. Finally, we decided to make a change: speficy the types of empty generic types, for example of Int32 or Set(Int32).new. Compile times were back to normal. And we were kind of happy again, but at the same time felt that we were leaving behind some of Rubyā€™s feeling. The language diverged.

We looked back at the Ghost of Christmas Past to ask him what did all of that mean, but we found a similar but different figure in its place. She said: ā€œIā€™m the Ghost of Christmas Present. Join me.ā€

There was a thread some time ago in crystalā€™s google group regarding itā€™s usage in production

https://groups.google.com/d/msg/crystal-lang/fXTAMilSo_Q/lMxM46mACgAJ

3 Likes