Ask HN: The Crystal programming language – what are your impressions?
It's a compiled language with Ruby-inspired syntax (but not identical to Ruby). It has fast performance and a good standard library. Version 1.0 of the language was released in March 2021.
Some disadvantages:
- Compilation is a bit slow
- Small community
- Few learning resources
- Windows version is still under development (not 1.0 ready)
I'm impressed by the language and find it very likable. It's not often discussed on HN, which is a shame.
If you are using Crystal, or have taken a look at the language, what are you thoughts on the language?
48 comments
[ 3.1 ms ] story [ 97.0 ms ] threadWhat was missing at the time was the equivalent of the gem ecosystem. I'm not sure if that has changed.
Here's the talk if you are interested: https://www.youtube.com/watch?v=B6Hx5wgNFL0
https://crystal-lang.org/community/
https://shardbox.org
https://shards.info
https://crystalshards.org
IIUC Nim also compiles to ISO-compliant C, so you can distribute it more easily (?).
Not necessarily 'lacking' if Nim didn't exist, but lacking in comparison. And for a bleeding edge GC'd statically-typed language that compiles using LLVM I think Pony is more interesting than Crystal, also Ruby-ish syntax.
A part of distribution is mature, easy to install and use toolchain. Another is a wealth of accessible packages. A third is being able to run on popular platforms. The only way to beat JS is eventually wasm.
B _ _ _ _ _ R
Every programmer needs to confront that the fact that their opinion about what really matters, isn't the same thing for them as it is for others. And even more so, what really matters changes based on what context you're using the language in, and what you're building.
There is not a single metric that decides if a programming language "wins" or not. What does that even mean?
For me, Clojure won a long time ago, because what does matter is simplicity. But I also realize that this is a personal opinion, not something that I spread as "fact" for others to finally realize.
Yes there is: it's the number of currently running processes described by that language. In practice this means counting every tab in every browser on every device on Earth. Even the largest DC operators in the world, Amazon, Google, Microsoft, NSA, etc who run sophisticated bespoke software distribution systems that support all kinds of runtimes, cannot compare in number to everything else. (Although it wouldn't surprise me if one or more of them attempts to maintain a stateful process for every man woman and child on Earth. That's still not enough.)
I take it as you see "success" in terms of programming languages as something objective then, not subjective?
Languages are tools that solve a problem, and it is possible for them to both be used by relatively few people and still successfully solve a problem.
For example, though Elixir is not as popular as Go, Elixir might win for me because I think it has a better concurrency model. Elixir is not globally used more than Go, but nonetheless it is my winner, and the people who pour their time into the product have still done an admirable job.
It's a discussion of "why" programming languages succeed.
If we were robots, we would sit 8 hours a day in grey cubicles to write Java and Javascript because they have the biggest ecosystem and mindshare, increasing our productivity.
But I'm a human, for my small projects I optimise for other metrics than hireability. And truth be told, even at work sometimes I try to make my code writing a little fun with smaller ecosystems that spark joy.
Worse, the use cases that crystal aims to solve for ruby, are not things that would attract people to ruby in the first place. Few people need a compiled language and reach for ruby, to find it lacking, and then look at crystal. The people with problems that crystal solves were never looking at ruby in the first place. They're not interested in tricks like `1.day`.
* It has nice features, seems decently fast (I wasn't able to fully test just how fast)
* The language is complicated, there's so many built-in language constructs it doesn't fit in my head cleanly. I often found myself forgetting about entire features of the language by the time it was appropriate to use them
* The stdlib is decently documented, has good coverage
* Type system is top notch, tagged union types are the future of static typed languages IMO
* It's very not mature. I encountered many poor error messages, seeming compiler errors, poorly documented behavior, etc.. It has potential, but I wouldn't recommend it for production use today.
Not that it isn't complicated, but how much experience have you had with Ruby before trying Crystal?
Unfortunately it has a small community. For instance in my opinion one would rather build a web application using ruby than crystal. The only ruby-like language that has gained some level of success and popularity is elixir.
It absolutely is. In fact, it's how I found out about the language. There's been several conversations about it and each release is posted on HN. For example: https://news.ycombinator.com/item?id=27903288
Crystal as a language is fantastic IMO. The type system literally forces you to consider race-conditions. Never had a language make me eat my vegetables in such a way. The code runs incredibly fast (on par with Rust and Go).
However, like the points you listed, it's hasn't "gone critical." It needs the basics to get even a hundredth of a percent of traction: cross-platform, IDE support, and some "killer" use-case.
Five hours ago, we were asked "Is Rails still relevant", and one answer is that crystal is a better option: https://news.ycombinator.com/item?id=31170481
Three days ago, we had a post on Sorbet and multiple replies push people back to Crystal: https://news.ycombinator.com/item?id=31159010
And another thread thirty days ago about Stripe's use of Ruby has multiple suggestions people use crystal: https://news.ycombinator.com/item?id=30833555
The pattern goes back a long way and /r/ruby sees regular announcements for new Crystal releases. On this thread someone notes they had a Crystal talk at Ruby conference.
I refer to these because it's appears that several people in this thread have noted a lack of hype and interest, but I feel there's a lot of hype - it's just that it seems to be heavily directed at the existing Ruby users which may not be excited just because it "looks like Ruby".
I can't take my existing Rails apps and just compile them with Crystal. If I'm going to use a different language, a whole range of options exist. I'd consider Elixir, Clojure, Rust or Python. Meanwhile, there are plenty of people pushing me not to use Ruby over concerns about performance, typing, and things that Crystal claims to solve. If the Crystal community wants to reach those, they need to be aware of who is currently avoiding Ruby and thus the current outreach.
Why would you consider Python?
Maybe ask Nikola Corporation? [0]
[0] https://manas.tech/blog/2020/02/11/nikola-motor-company/
The article I linked shows that there is a company that is using Crystal in production. Correct?
That said it might as well be a toy language, in my opinion, because I don’t think it has the support or community to power a serious production project
It’s more production ready than much I’ve encountered elsewhere with less need for external “shards” or libraries.
The executables are small and to give you one example: a nodejs app that used 500mb of ram is now consuming 25mb as a crystal executable that doesn’t require any minding and happily runs for months with no change in the overall memory consumption or evident leakage. This executable was built on the same machine it runs on and can use normal systemd units and controls etc.
The standard library is built for purpose and has most of what you need.
I agree that compile times are slower than ideal but not like c++ slow or anything, like 30 seconds for one app that’s roughly 30k LOC fwiw.
I use a combo of standard lib .ecr server rendered templates and named js bundles from the frontend build toolchain to speed up the dev cycle. Most backend functionality in crystal works as intended once it compiles.
I really wouldn’t consider anything but Rust an improvement (gets rid of our Boehm GC) as crystal is just nicer to work with than Go, and less hassle or nonsense than c or c++…
Obviously it blows the doors off anyway interpreted even with native extensions… it is FAST
My impressions:
* it feels pretty fun and productive. Right now only Elixir feels better than that, so it's good to have fun on the system programming space.
* it's too slow to compile. This is a major pain point for me, iteration speed should be priority #1. I'd love a REPL.
* it's incredibly easy to hack on the compiler. I sent today my first PR to fix a bug in the stdlib.
* great stdlib, needs better documentation, again Elixir would a great inspiration for how to write docs. I'd love more monadic functions to deal with nils.
* github feels healthy and very active, but the whole ecosystem feels like it's stalled in the past 2 years. Pretty much nobody talks about it, most deps haven't been updated in years, it has a ghost town feel.
* it would fit nicely in my list of favourite languages. Zig for very low level, Crystal for native high level, Elixir for daemons and long running services.
Verdict: I like it a lot, it could be my favourite system programming language, but outreach and hype would give me some hope it's going somewhere and not dying a slow death.
Personally my biggest issue is the compile times. For web app development where you may be saving frequently and using hot reloading it’s to slow, it’s lagging.
If non-production compile times were reduced by 60-80% I could envision interest and adoption increasing quickly.
It has a Ruby-like syntax but performance is better than Ruby. The creators of this language say that in many cases the speed will be close to C++. Also, programmers who know Ruby will not have much problem using Crystal.
The language is still in development but I think that it has a future. Another important thing is that the community around this language is growing very fast and there are many jobs for developers who know this language.
I think that Crystal could be another option for languages such as Java and C# because it has similar features like static typing, compiles to native code, etc. The tooling is a little bit rough around the edges, but I think that's to be expected for a language that's only been around for three years. The community seems really active and helpful, though, and I have no doubt that these tools will improve over time as the language develops.
I recommend Crystal to anyone who's had trouble with Ruby's speed or who wants more type information available. Definitely check it out!