The Crystal Programming Language Forum

Why to learn Crystal?

If someone asks you why should they learn Crystal what would you tell them?

“Why would you not want to learn crystal?”

  • Super readable
  • It’s fast
  • Concurrency
  • And…

It has a fantastic community!

4 Likes

Friendly like Ruby and efficient as C++ is the first one that comes to my mind.

Expanding on that, one cannot stress enough the benefits of static typing, in particular for larger code bases. Being able to write terse code that almost reads like prose, catch errors at compile time, and have top performance at the same time, imho, is a developer’s pipe dream come true. And being able to transfer existing knowledge from Ruby too? Plus the channel based concurrency, lightweight fibers, easy interfacing with C (or other languages using the C ABI), a comprehensive standard library and a rich ecosystem of shards…

Also, while I expect the main use case being application development, either desktop or back-end, apparently Crystal is just as good for system programming – I didn’t check them out but I read there is people writing operating systems in it and also running it on Raspberry.

This, from a generic, hobbyist coder perspective, but I guess there are good arguments for business too. Developer productivity matters a lot in that context, and once the prototype application works, there’s hardly a need to rewrite anything for performance. And it’s developed and actively used by a firm with an impressive portfolio of achievements. It means it’s not going away, and the creators bet their endeavor on it.

From an education perspective, it’s executable pseudo code. Alright, some scripting languages may fit the bill better, but again, I say static typing, and multi paradigm too.

That it’s open source is an obvious plus for anyone.

Sure, it’s not the only language with some or even most of these features, and some use cases may be better served by other tools, but Crystal sits in a sweet spot for me.

10 Likes

(From an old post I wrote)

In my quest for a powerful programming language for my pet project and after inspecting half a dozen of them (including Go, Nim, D, V and others) I settled with Crystal https://crystal-lang.org

Why Crystal?

  • Ruby-like syntax that is super-easy and pleasant: Making it easy to read, debug, modify and evolve.
  • Concise and brief requiring considerably less lines of code without sacrificing readability.
  • Fully Object Oriented and not opinionated (unlike GoLang).
  • Compiled and Statically-typed language reducing errors and bugs.
  • Much better performance (order of magnitude faster compared to interpreted counterparts: Ruby, python and PHP) and comparable to C. Consider the benefit of going down to 10% of your hosting cost.
  • Can be complied into a single static binary. Making it ideal for limited environments or containerization
  • Cross-platform. Linux and MacOS. Mobile /Windows not sure
  • Built-in testing library (called “spec”)
  • Integrates with existing C libraries.
  • General-purpose: system programming, game and web application development.
  • Supports Generics and has powerful macros

Downsides of Crystal

  • Small community and ecosystem (not many libraries)
  • Slow compiler

I’m sure the listing of pros and cons could go much longer. This is just to highlight the potential.

14 Likes

Pros:

  • Good syntax
  • Powerful:
    • monkey patching,
    • split a big class into several files,
    • spawn,
    • big std
    • typed + type inference
    • easy type conversion
    • Powerful macro (but not really documented)
    • more…
  • Fast
  • Fully Object Oriented
  • Auto generated API doc in HTML

Cons:

  • Small community and the constraints that go with it.

  • Lack of documentation and examples.

  • On VScode the auto-completion doesn’t really work on projects (medium/large). Sometimes it appears, then nothing, sometimes you have to wait a few seconds, most of the time nothing. Ditto for the go to def, etc

  • The compilation time is a time killer. I have a project that compiles (in dev mode) in about 20 seconds Reduce compilation time during development?
    How to be productive with such a long compilation time, it’s dead :frowning:

For the feedback, these defects make me give up.
I was very excited, it’s a language I love. I published lots of packages on Github. However the cons won. I’m migrating all my projects and those of the company where I work, the developers who work with me got tired of it before me (I was the last one hooked to Crystal in the team).

I will continue to use Crystal for small micro-services but no longer on projects that need to evolve regularly.

Crystal has a huge potential. All this can change, I’m sure that in a few years the DX will have been improved. :slight_smile:

Hey @nico, thanks for your honest feedback. Sorry to hear that Crystal doesn’t work for you at the moment.

I’m wondering what we as a community and especially the core team can do to improve on the negative experiences you describe. Maybe you can help with some more details on that.

  • Growing the community is obviously a goal, but it’s hard to push that. Maybe we need more marketing…?
  • Are you missing specific documentation and examples, or is this just a generic observation and maybe related to the small community size (you don’t find as much resources because there are not many people writing about it)?
  • In my opinion, IDE integrations is not a part of the core project, but rather provided by third party projects. Maybe we should invest more in that though, considering the lack of features of a particular integration drives people away from the language.
  • I’m looking forward to the upcoming interpreted mode which will improve developer experience, particularly a shortened feedback loop and powerful capabilities for debugging and exploring solutions.

Just not to give people wrong expectations: there’s no proof the interpreter gives faster feedback cycles for large programs.

Also, many languages are designed with an IDE in mind. I’m sure that’s the case of Java, C#, and there’s a new language called Roc. But Crystal isn’t suitable for IDEs.

Yes I can provide more precision (to be constructive, of course).

For growing the community, in my opinion not necessarily the marketing side (at least for the time being). More docs, short tutorials and examples, … will do the job.

For my part now it’s fine but not coming from Ruby, the first months were hours (days) of searching in Github repositories to find how to do such and such things in Crystal.
A simplified learning curve will make the community grow naturally and more quickly. The larger the community, the more docs, examples and Shards will emerge.
For example in the API there are many things with too little or no doc: Macro, IO::Evented, VaList, Signal, Pointer, OpenSSL::Digest, OAuth2::AccessToken, Mutex, Crypto::BCrypt, some IO parts, …

This doesn’t simplify things but this does not prevent us from moving forward in Crystal.

  • In my opinion, IDE integrations is not a part of the core project, but rather provided by third party projects. Maybe we should invest more in that though, considering the lack of features of a particular integration drives people away from the language.

Third party projects have been done, a lot of effort. But for the moment the tooling in the IDE doesn’t really work.

We can do without it but it is so comfortable and productive, that it can be prohibitive for some to do without. If a goal is to grow the community and having a good tooling with Crystal like other languages have, this should be a priority in my opinion.

  • I’m looking forward to the upcoming interpreted mode which will improve developer experience, particularly a shortened feedback loop and powerful capabilities for debugging and exploring solutions.

It’s the game killer, the developer experience is the basis :slight_smile:


Sorry for my poor English, perhaps it sting the eyes

4 Likes

@nico , lots of good points! :slight_smile:

By It’s the game killer, do you mean It’s the game changer?

1 Like

Oh yes, my bad. It is “game changer” :grinning_face_with_smiling_eyes:
But somewhere without this, it is “game killer”

1 Like