Anyone have any experience with Crystal?

crystal

#1

Does anybody have any experience with running Crystal in production?


#FutureRuby - what do you think the future of Ruby looks like?
#2

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:


#3

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

https://github.com/manastech/frank - Sinatra inspired
https://github.com/Codcore/Amethyst - Rails inspired


#4

Nice find @tak1n!

Wonder if anyone has done any speed comparisons yet?


#5

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: https://github.com/kostya/benchmarks

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


#6

Thanks Benny - some interesting results there… Crystal sure is fast!!

Wonder where Elixir would be in it…


#7

You may find this interesting regarding Crystal:

Differences from Ruby?


#8

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:


#9

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.


#10

Great talk that - wonder how it compares to Elixir.

Good to see Soundcloud using it :slight_smile:


#11

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.


#12

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


Have fun with Crystal!


#13

Thanks for adding us @yahhonob :+1:


#14

Haven’t seen it, but another talk:


#15

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?


#16

Hoop - build native Mac apps with Crystal


#17

Opinionated post about Crystal/Ruby :smile:

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


#18

This video has some good information.

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


#19

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.”


#20

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