Hacker News new | ask | show | jobs
by rishav_sharan 1793 days ago
So I am currently making an api server in Crystal and I adore this language. I would add some pros/cons for folks who are interested in trying it out;

Pros:

- Elegant syntax. Crystal is highly inspired by Ruby and it has a lovely elegant syntax. Syntax is important to me and the clutter of symbols and the busy syntax is why i struggle with Rust.

- gorgeous type system. F# is the only other language I can think of which has this lovely and complete a type system. The way Crystal handles Nil (its a type) just feels great in practice.

- Perf wise, Crystal is blazing fast. It seems to be marginably faster than most compiled languages like Go, Nim etc in the benchmarks. Though at that level the difference isn't much.

- batteries included stdlib

- decent documentation. It could be better but imo its good enough. I rarely have to look beyond the documentation if I get stuck anywhere.

- small but amazing community. the folks in the community like Ali, blacksmoke, Oleh, Ary and many others etc are super helpful and always ready to teach a newcomer.

Cons:

- Lack of Windows support. The biggest elephant in the room. the good news is that this is under development and even in this release a lot of progress towards a Windows event loop was made. But if you are going to do web dev, you can always go with wsl for the compilation as most of us do.

- Slow compilation speed. Its faster than Rust/C++ but if you are coming from an interpreted language the 5-10 seconds it takes to compile your small project rankles a bit.

- DB drivers need to be better. They currently don't support pipelining, ssl, async etc. Not a big deal as the Crystal drivers are performant enough. but I think if these were there, Crystal would get at least 20-30 ranks in the techempower Fortunes benchmarks.

- IDE tooling is not yet there.

- Small community and hence lack of community packages. Often stuff will have to be done by hand. Things like oauth, openssl conversions etc will need some work from you.

- no http/2 support

- The lack of a BDFL and corporate sponsorship. This means that the language growth is less structured and highly dependent on the community leaders.

Here is an old comment I wrote about Crystal on HN. it is still as true today as it was then;

----------------------------------

I have a love-hate relation with Crystal. Every few months, disenchanted with the core maintainers' priorities, lack of platform and tooling updates and overall deadland syndromes - I denounce Crystal, promise I will never use it again, startup a golang or Rust project, make some non trivial toy stuff and then come crawling back to Crystal. I hate the fact that I love this language and the fact that nothing else (except perhaps f# and nim) seems to have the same effect on me.

My favorites Crystal features are its do-end syntax, dat sexy type system hnnnnghhh... , domain modelling using sum types, null checking using types, ultra simple OOPs, insanely productive std and its sheer performance.

The bits about the language I detest are the overuse of macros, the utter lack of any platform (windows, http/2 etc.) or tooling improvements (IDE support, slow compilation). The core maintainers are amazing but have a weird obsession with just refactoring the language semantics. Things which really would matter for any language usage are just relegated to GH issues which haven't had any comments on it for months (if not years).

The lack of a BDFL and corporate sponsorship really hurts Crystal bad. Its a language without directed growth. For a language which seems to be used the most for web servers, it lacks http/2, db pipelining and async db drivers. There have been plans for redoing the http module for years but it hasn't been done yet.

Yet, I love this language despite all its shortcomings. I find it to be one of the most readable languages out there. The community is full of amazing individuals who are ever helpful and welcoming. The core maintainers are super talented developers who really value quality of code.

Right now I am working on an api servers and have 3 early implementations - one in Rust-actix, one in pure crystal (no framework) and one in Go-Fiber. The joy of using Crystal and feeling like I am in control of the project are reasons which are pushing me towards using Crystal for the project. But I know that by the next few years, we likely still wouldn't have http/2, async drivers, nice IDE support and many other features that I really need.

And so, I will likely have to go with Go. (Rust syntax is just too complex for my taste. And I am not talking about the celebrated borrow checker).

I like go.

Go is simple.

Go is Productive.

Go is... just not Crystal.

-----------------

Epilogue: I did not go with Go. Its error handling and opinionated formatting turned me off so much that I have returned back to crystal. :/

6 comments

What's stopping you from going with Nim? Honestly curious, I have my own love-hate with that one, so I have some guesses, but I'd find it fun to "fact check" those and compare opinions :)
Mostly a lack of good web frameworks which are performant and have good devex. Jester the main Nim framework doesn't even have a webpage and that doesn't inspires any confidence. Httpbeast may be fast but it feels like just a PoC. It doesn't even have docs.

Prologue is the most promising one IMO, but it is still very new and its performance isn't as good. But I do keep a check on it.

Overall, Nim needs something like Lucky, Athena, Azu Toolkit etc to feel like a serious web dev language.

That said, I have always been thinking of rolling with just the stdlib stuff so I may do that one of these days.

Author of Jester here.

I agree that a nice website would be great to have for Jester (and I do intend to create one), but I think you place far too much importance on Jester having one. Jester/HttpBeast is used in production by big web apps[1], why doesn't this inspire enough confidence and possibly even more than the other web frameworks you've mentioned?

I think there is an inherent bias that all humans have for shiny design, you should definitely keep it in mind when choosing a technology.

1 - https://forum.nim-lang.org/

I understand that it is frustrating to hear somebody telling you that they lack confidence in your tool simply because it «lacks a webpage», maybe after you have spent so much time creating and polishing it!

However, considering the huge amount of languages/webframework pairs (D+Vibe? Nim+Jester? Crystal+Whatever? Go? Rust? etc.) available today, it is understandable that people pick simple criteria like this to decimate their number of choices. The alternative to start playing with each tool for a few days to rank them and pick the best choice is obviously not possible.

For me, it’s also because of IDE tooling. Nim syntax supports so many different call styles that when you press dot for autocomplete you always see so many options to the point it’s not helpful anymore. I’d love to know if there’s a way around that issue.
Most of this is still true, but this is the most balanced review of Crystal I've have read so far here.

Although I use Rust most of the time, I keep having a look at Crystal and appreciate its simplicity and can get alot of things done with it rather than fighting with the borrow checker.

Very happy to see it reach 1.0 and further.

> and corporate sponsorship

Well there are companies (and smaller individuals) that are still sponsoring it every month. [0]

[0] https://crystal-lang.org/sponsors/

Compared to the Google sponsorship of Go and the Amazon sponsorship of Rust, a few thousand from unknown vaporware companies isn't really a level comparison.

(disclaimer: I was once a coffee sponsor of Crystal myself)

> a few thousand from unknown vaporware companies isn't really a level comparison

I see, So: "If a company that I don't know about is putting money into a language, it's doesn't really fit my definition of 'real' sponsorship"

It still counts as sponsorship whether if it is a FAANMG company or a tiny startup and there are companies that use Crystal that are sponsoring it monthly. No need to move the goal posts here.

Probably the Golang people did the exact same comparison to Rust when that reached 1.0 in 2015; way before the Rust foundation was formed or any company sponsoring Rust other than Mozilla.

So perhaps Ocaml (The language that Rust was first written in) doesn't count as well since that has a couple of so called 'unknown vaporware companies' and zero FAAMNG companies on the list of 'sponsors' then? [0]

[0] https://ocaml-sf.org

You're right, the name of the company or FAANG-ness doesn't matter. I didn't claim only FAANG sponsorship matters, but it is important and even more important, the amount of $ does.

I also never said it wasn't "real" sponsorship or didn't count. Don't put words in my mouth. I said it isn't a level comparison.

> any company sponsoring Rust other than Mozilla

Mozilla? never heard of them. I only know FAANG apparently /s

Also, Ocaml has supporters such as Bloomberg and Mitsubishi. Not exactly mom-and-pop startups.

Again, I'm not exactly sure what you're arguing. I'm literally a sponsor of Crystal. I put my money where my mouth is.

> but it is important and even more important, the amount of $ does.

Also you:

> Also, Ocaml has supporters such as Bloomberg and Mitsubishi. Not exactly mom-and-pop startups.

Perhaps Jane Street is also another mom-and-pop startup then. /s

So they (Bloomberg, and Mitsubishi) somehow matter because they're "Not exactly mom-and-pop startups" even though you also said, "the amount of money they are giving matters". Given the OCaml sponsorship levels [0], Bloomberg (Silver) donates around $1250 - $2084 a month and Mitsubishi (Bronze) around $416 - $1249. That is still less than the monthly amount that either Nikola Motor or 84 Codes is putting in combined.

Nikola Motor isn't not a startup and still sponsors and uses Crystal. It seems that they have alot of money left over every month to throw at Crystal even before it reached 1.0.

> I said it isn't a level comparison.

Then congratulations to Crystal for getting sponsors (and companies sponsoring it) even before 1.0 then. They'll probably get more even after 1.0 then.

Never saw that in Rust before the foundation was formed (which should have been done earlier) since its actually Google again (not Mozilla) feeding the majority of the sponsorship funds to Mozilla.

> Again, I'm not exactly sure what you're arguing. I'm literally a sponsor of Crystal. I put my money where my mouth is.

Good and so do the companies that still use Crystal to this day even before 1.0. At least individuals can sponsor it as I mentioned previously. Unlike Go, whose fate is ultimately in the hands of Google for any decision they make for the language.

[0] https://ocaml-sf.org/becoming-a-sponsor/

This is an excellent summary, at least for the pros and cons.

I find your take on the project leadership interesting, because it is a spot-on description of everything I found to be wrong with Elm. That BDFL was/is not so benevolent. Or maybe he’s well-meaning but terribly annoying. And the language has a mich better claim to being dead than Crystal, where I had not noticed any loss of momentum or activity on GitHub.

(You may well be right on those points as well, as you are clearly more knowledgeable about the dynamics)

> Elegant syntax. Crystal is highly inspired by Ruby and it has a lovely elegant syntax.

Agree 100%. I still haven't written any Crystal, but I read through parts of the code-base, out of curiosity, and it is some of the most pleasant compiler code I've ever read.

You might enjoy Zig then, although it's closer to the Go or C spirit and shares a decent number of the Crystal shortcomings you've mentioned.

It's still pre-1.0 but you might find it interesting, but maybe not for what you're working with right now. https://ziglang.org

I absolutely love Zig, but based on what they praise Crystal for, I don't think they'd enjoy it. Polar opposite syntaxes, do-it-yourself type system, batteries-not-included standard library, and manual memory management? Probably not what they're looking for.
i am intrigued by Zig and have been following it for a while. But i plan on seriously trying it out after the following are availabe; self hosted compiler, http server (or at least a standardized interface) in stdlib and a package manager. Otheriwse the language would not be productive for my needs.
> clutter of symbols and the busy syntax is why i struggle with Rust

Funny you mention this because all the clutter and symbols (operators) in Ruby's syntax is why I never liked it.