this post was submitted on 12 Jul 2023
20 points (100.0% liked)

Programming

13373 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS
 

I learned about Crystal from somebody's Lemmy comment a couple weeks ago. Amazing and under rated language.

Their announcement is pretty lackluster tho lol.

top 14 comments
sorted by: hot top controversial new old
[–] [email protected] 8 points 1 year ago (3 children)

I have never heard of Crystal before. Can someone give a quick explanation of what this language is good for and why it is exists? There are already so many languages out there.

[–] [email protected] 7 points 1 year ago

Ruby but compiled for better performance. The compiler is smart and automatically detects and applies typing.

That's from when I looked into it a bit a few months back.

[–] [email protected] 5 points 1 year ago

It looks similar to Ruby but with an appropriately modern static type system and a macro system instead of runtime metaprogramming.

It also has its own concurrency story, as far as I remember.

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago) (1 children)

The easiest way to think about it that is kinda right, and what got me into is "It's like compiled Ruby and nearly as fast as C".

Crystal is a language with syntax modeled after Ruby, which is considered one of the most human friendly languages (it's way easier to understand than C and most others). Ruby and Crystal are "object oriented". Like if you wanted to know what I had for lunch using Crystal you'd ask me, an "object" last_meal = kool_newt.stomach_contents, as where in C, you'd cut me open and look.

Where Ruby is a dynamically typed (it figures out whether things are Strings or Arrays, etc on the fly as needed, handy but very slow) scripting language, Crystal is statically typed, so you have to be conscious of types while you code. And where with ruby you end up with a script, Crystal code is compiled into a binary.

Where Ruby is good for small/medium websites with a modest traffic, or for prototyping ideas in an easy language, or making smaller utilities, Crystal can handle massive traffic, and make fast production level apps and tools without the difficulty of C or Java.

I'm using Crystal and Kemal (Kemal is akin to Ruby's Sinatra) for web dev, and trying to make my own DNS utils (I want dnsip, not a fan of drill, dig, and other tools).

If you know Ruby, Crystal is an easy jump.

[–] [email protected] 2 points 1 year ago

Thanks, that's a good summary.

[–] [email protected] 6 points 1 year ago (1 children)

If you find Crystal intriguing I suggest to checkout Elixir. And if static typing is more to your liking, then Gleam.

Both run on the BEAM (Erlang VM) which has a very robust concurrency model and resiliency built into the way you build applications.

I've been using Elixir for years now professionally (fullstack) and I honestly never want to go back.

[–] [email protected] 3 points 1 year ago (1 children)

I've looked into Elixir a bit, I'd probably be into it or Rust if Crystal didn't exist, more so than Go. Something about languages that run in a VM turns me off tho, reminds me of Java too much I guess. I've never heard of Gleam, that makes two languages I've learned of due to Lemmy in like 3 weeks!

[–] [email protected] 3 points 1 year ago (1 children)

I wouldn't dismiss VM languages outright. I'm also not a fan of the Java VM but the two VMs are very much very different. Also Erlang (and it's VM) were built for telecommunication, and the problems they tried to solve 30 years ago with it are very similar to modern backend engineering problems.

Erlang is in large parts also what allowed WhatsApp to scale to it's userbase with only 30 engineers.

[–] [email protected] 1 points 1 year ago (1 children)

Elixir runs on the Erlang vm? What is the difference between the two?

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

Between Elixir and Erlang, or between the Java and Erlang VM?

Elixir and Erlang are distinct languages. Here the comparison to the Java VM is apt, in that it's like Java and Clojure. Different languages, same VM.

If you want an overview on the differences between the VMs then that would be too much for this comment. Here is an article on Erlang Solutions talking about some of them more in depth. If I piqued your curiosity I can also highly recommend this talk from Sasa Yuric. It's not long and very concisely captures what makes the BEAM so nice to use.

[–] [email protected] 1 points 1 year ago

Between Elixir and Erlang. Erlang is what's used in telecom right? Is Elixir as well? Is Elixir like a new improved Erlang? I've heard so much about Elixir recently.

You have piqued my interest, I've recently gotten back into programming (I do "devops" for work) and don't really consider myself a programmer, but I find languages fascinating. I was lucky enough to join a study group on compiler design with an Apache project leader and while it was over my head, I learned a lot and enjoyed it.

(I know I could look this up, but enjoying the conversation :)

[–] [email protected] 1 points 1 year ago (1 children)

Anyone programming in crystal here? How is the LSP/editor story now? I've seen a couple of really nice projects in crystal - an OS on reddit, and kagi which I use daily now.

If they have a better LSP implementation and editor setup from what they used to have a year or so ago, it would be really nice.

[–] [email protected] 1 points 1 year ago (1 children)
[–] [email protected] 2 points 1 year ago

Language Server Protocol. It's how programs (language servers) can talk to your editor (like vs code or nvim) and provide refractors and intellisense and what not.

load more comments
view more: next ›