How fast is Crystal Lang?

preview_player
Показать описание
Today we run a basic speed test in Crystal, C, Ruby, and Python to answer the not-so-old-question:
IS CRYSTAL LANG REALLY FASTER THAN C?

If you would like to run this test on your own you can find the code in the following Git repository:

Let me know how it works out for you and post your times down below!

If you have any questions please leave them in the comments and I'll be sure to get to them.

Thank you for watching and be safe!
Рекомендации по теме
Комментарии
Автор

Watching this in spring of 2024. Crystal has improved over the last three years. Have you done this comparison again, and with --release, and including Zig, Rust and Go in the competition?

DrunkenUFOPilot
Автор

As mentioned before, Crystal compiler has the --release flag for this kind of benchmarks

CristianMolina
Автор

crystal should be built with the —release flag (sorry if this has already been mentioned).

Great video!

thats_mr_rob
Автор

Just a tip: when benchmarking a compiled programming language, always make the program to read the input from a file or from stdin. Otherwise, the compiler can just optimize the entire operation at compile-time (constant-folding), since it has all the data in the program.

anarcho.pacifist
Автор

That's why Linus Torvalds once said: "Nothing's better than C"

azyn
Автор

you really should compile with release flag or optimization on 3, with C/C++ it does matter, but not like with nim, where in debug mode the compiler gnerates several runtime checks, like array size etc... but with flag danger it reaches c performance

carpal
Автор

This test is quite rough but it put Crystal in the right light. Crystal has been created to be almost as fast as C while still being as easy to use and as easy to read as Python and Ruby. It completely succeeded in both tasks. Use Crystal to easily and quickly develop fast, compiled programs and stop worrying about its actual performances.

AlessandroBottoni
Автор

Since Ruby+Rails gets killed by JavaScript+Node "because Ruby is so slow and JavaScript so fast" and Crystal+Amber could be the successor of Ruby+Rails, it would be really interesting to have JavaScript included in this test!

berlinerfamily
Автор

Hey good video can you make another performance test with golang, crystal and c

prpatel
Автор

I hope CRYSTAL and ZIG gets more attention

smitxp
Автор

I kinda wish you'd have tested Zig as well. Would be interesting to see how it compares to C.

ThePC
Автор

-O3 on gcc, god.... Why are you testing debug build?

DrNoxer
Автор

As far as i got you bench timestamp in bash script or something.
I would recommend create benchmark function in each language and put it before and after your test function, then just print difference between this timestamps.
The problem is that if you used something like Java and you also used python and ruby, they all are compiled to byte-code. Before evaluation part they verify the byte-code. So if you just excluded compilation step, you measure not the "real" time. Ruby, python or Java (i know you haven't use itz but...) can spend different time on verifying, so it's not the right way to compare.

Иван-усн
Автор

Hope you can compare Nim, Crystal, Zig, Vlang. For example.

eduardabramovich
Автор

Has someone tried Nim? It looks like a super fast python

BrdButtwski
Автор

Hi, nice test. I like the syntax of Crystal. How about crystal coding in Windows ? I mean, for desktop applications. Is it worth to learn it ?

kcvinu
Автор

I ran the Crystal code with and without the --release flag... 3.72s without the flag cf. 0.25s with the flag.

talkthoran
Автор

so,for this test,crystal should be 0.48~0.49 seconds

billyzheng
Автор

The video would be perfect if you also showed rust.

zdwd
Автор

This comparison is saying nothing as different languages behave differently with different algorithms. So you need to test at least several algorithms to make any conclusions. But I think C will be winner anyway.

phat