5 ms·
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: -
by rishav_sharan 5y 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. :/
- akavel 5y agoWhat'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 :)
- rishav_sharan 5y agoMostly 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.
- dom96 5y agoAuthor 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/ https://forum.nim-lang.org/
- ziotom78 5y agoI 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.