My last article on Crystal lang

If someone wants to have a look at the source code GitHub - MarioAriasC/monyet: An implementation of the monkey language on Crystal

5 Likes

Also keep in mind that TechEmpower Web Framework Benchmarks you’ve linked in article are not exactly apples to apples comparison. Go’s results are for something that is classified as Plt (Platform) and Mcr (Micro) while Crystal’s are Full. You can see that in Cls column on detailed results tabs.

Also they show throughput by default. It’s interesting to check latency tab also. I know throughput for Crystal benchmarks was previously bigger, but at the cost of higher latency.

And last, benchmarks on this site do have a rules, but it doesn’t mean they are always a fair comparison. As with al benchmarks it’s sometimes a game and some cheating which is not always noticed. So a good idea is to compare source for benchmarks to see if it’s a fair comparison.

1 Like

First of all, thanks again for the follow-up articles! I was really looking for them!

I just would like to observe that your final conclusion that “Go has a clear advantage performance-wise” may not be the case, even more so when considering multiple and diverse use cases.

On my research, what I see is that both languages are equally faster and, on the Techempower case, unfortunately I identified many “cheat” cases and, thus, we must take it with a grain of salt (as vlazar already pointed out).

On a more low-level and scientific way of benchmarking, among the many articles out there, I like this scientific paper from Prof. J¨urgen Spielberger from Zurich University of Applied Sciences:

On 5 of 9 tests, Crystal was faster than Go (by a really little margin, but it was), with the special case of C bindings where Crystal was as fast as C and 5.4x faster than Go. On the 4 cases where Go was faster than Crystal, identically, the margin was negligible.

This shows to me that Go doesn’t have a clear advantage over Crystal (nor the opposite) and anyone can write equally (or even identically) fast programs with both languages.

Finally, since binding C libraries is a common practice when searching for even more performance, Crystal is a better candidate in this scenario since it’s noticeably faster for this, adding zero overhead when compared to native C programs, and being 5.4x times faster than Go in average, on the above mentioned paper.

7 Likes

Complementing my previous post, I understand the Crystal frameworks on Techempower benchmark are slower than the Go ones not by merits and demerits of the programming language, but for other technical details, aspects and decisions.

For this reason as well, I am writing a new framework in Crystal to validate a new architecture standard I developed and I will try to (humbly) place it among the top frameworks on Techempower, obviously without the cheats some of the other ones used, but with (maybe) better technical decisions and details.

4 Likes

Nice articles, as usual!

Regarding slices… If I understand correctly that this is for an interpreter, then one way to do things is to parse instructions into an Array. From this Array you create a Slice that never changes. That way you don’t need to concat slices. I do agree that slices aren’t well documented, or at least there’s no tutorial about them.

Finally, I doubt Go is faster than Crystal. Maybe it’s true, I don’t know. But without us having source code to see if we can optimize things it’s a bit hard to know for sure. But it’s totally fine if this is closed source! And as long as it’s almost as fast for you, and you are enjoying the language, then it’s fine. But if you show us the source code, I’m sure me and others will find ways to optimize the code to make it faster than code, while still being idiomatic 99% of the time.

4 Likes

Thanks, the source code is here GitHub - MarioAriasC/monyet: An implementation of the monkey language on Crystal

2 Likes

I should clarify that for my particular use case, Go has a clear advantage.

In previous entries, I stated that I know of several benchmarks where Crystal is faster than Go.

Where was the bottleneck in crystal, if speed was the issue?

ref: Performance - Crystal

Thanks for the post!