TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A look at Crystal, a programming language for humans

245 pointsby fork-bomberabout 2 years ago

28 comments

lgreivabout 2 years ago
I wish Crystal would take off. It has so many things going for it (many of them mentioned in the article): performance, useful tooling such as an opinionated formatter, an integrated RSpec-like test framework, a powerful standard library, an awesome type system that gets out of the way most of the time, a familiar syntax.<p>So far I have been building some smaller personal CLI tools and a few web apps (with the Lucky framework). I’ve also tinkered with running it in AWS lambda functions in a custom (albeit unfinished) runtime.<p>Coming from a decade of Ruby, due to the similar syntax and mindset Crystal is my go to for cases where I need performance or runtime-less execution (e.g. in containers from scratch that contain only the binary and dependencies, if needed).<p>Crystal&#x27;s standard library provided enough functionality for me in the past to get away with only few dependencies per project, which is great for supply chain security and complexity. Some of it&#x27;s highlights are:<p><pre><code> - an ergonomic HTTP::Server and client - OAuth &#x2F; OAuth2 clients with token refresh - JSON&#x2F;YAML&#x2F;XML parsing&#x2F;generation&#x2F;mapping - JSON&#x2F;YAML mapping to classes - native templating similar to ERB</code></pre>
评论 #35826527 未加载
评论 #35870327 未加载
评论 #35828618 未加载
评论 #35839523 未加载
评论 #35830596 未加载
评论 #35828158 未加载
评论 #35831829 未加载
评论 #35834217 未加载
评论 #35826867 未加载
ubertacoabout 2 years ago
I love Crystal, and have loved it for several years. It was my go-to for Advent of Code or small fun projects for a while.<p>Eventually, I got so tired of constantly jumping between browser docs and my editor because of the lack of a working and useful language server (yes, I know about Scry and Crystalline, but neither of them actually do autocomplete outside of maybe 2% of cases), and I got so used to an amazing tooling experience when writing F# (my other favorite language) that I just kinda dropped off using Crystal.<p>Things I would&#x27;ve written in Crystal, I wrote in F#. If I _really_ needed a static binary, I picked up Rust (though I love Crystal&#x27;s syntax _so much more_ than Rust&#x27;s).<p>If Crystal gets a good language server, heck yeah I&#x27;ll roll with it. In the meantime, it just sorta feels like a missed opportunity.
评论 #35829050 未加载
评论 #35830084 未加载
compumikeabout 2 years ago
We&#x27;ve been happily using Crystal in production at Heii On-Call (free website &#x2F; cron job monitoring, free critical alerting to iOS&#x2F;Android apps, on-call scheduling) [1] specifically for higher-throughput components of the overall system, such as the API server [2] and the system that continuously does website monitoring [3]. For context, we do use Ruby on Rails for the main website frontend.<p>Really I find Crystal to be <i>so</i> much more ergonomic and pleasant to use than Go or Rust, though I could see that being a matter of opinion. Very concise, very readable, very fast once compiled.<p>Porting utility classes from Ruby is so easy too. I end up spending more time porting unit tests than porting the underlying code. And the testing story (Crystal&#x27;s &quot;spec&quot; [4]) is really nice.<p>If you want to try Crystal without installing anything, I made a &quot;crystal-docker-quickstart&quot; project template you can clone [5]. You can safely try out Crystal and have your first static binary compiled in about 15 seconds via something like:<p><pre><code> git clone https:&#x2F;&#x2F;github.com&#x2F;compumike&#x2F;crystal-docker-quickstart.git my_app cd my_app .&#x2F;d_dev make &amp;&amp; out&#x2F;my_app </code></pre> Lastly, I&#x27;ve found that the Crystal community [6] is small but friendly and helpful. It&#x27;s at that magical stage of an open source community where people are extremely competent and responsive, but not (yet?) burned out from dealing with so many people.<p>[1] <a href="https:&#x2F;&#x2F;heiioncall.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;heiioncall.com&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;api.heiioncall.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;api.heiioncall.com&#x2F;</a><p>[3] <a href="https:&#x2F;&#x2F;heiioncall.com&#x2F;outbound_prober" rel="nofollow">https:&#x2F;&#x2F;heiioncall.com&#x2F;outbound_prober</a><p>[4] <a href="https:&#x2F;&#x2F;crystal-lang.org&#x2F;reference&#x2F;1.8&#x2F;guides&#x2F;testing.html" rel="nofollow">https:&#x2F;&#x2F;crystal-lang.org&#x2F;reference&#x2F;1.8&#x2F;guides&#x2F;testing.html</a><p>[5] <a href="https:&#x2F;&#x2F;github.com&#x2F;compumike&#x2F;crystal-docker-quickstart">https:&#x2F;&#x2F;github.com&#x2F;compumike&#x2F;crystal-docker-quickstart</a><p>[6] <a href="https:&#x2F;&#x2F;forum.crystal-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;forum.crystal-lang.org&#x2F;</a>
评论 #35843625 未加载
prh8about 2 years ago
Real world example for Crystal: our overnight sitemap generation (built using Ruby, as part of our Rails app) took 6 hours to generate 20 million links. At some point due to infra changes, it stopped running to completion. Since then, we ported it over to Crystal, with the main code virtually unchanged (library to help generate sitemaps has matching API). Just had to set up basic database mapping for a few tables. That version is now in production, and it now processes 30 million links in about 30 minutes.
评论 #35835977 未加载
评论 #35835846 未加载
zw963about 2 years ago
For friends from China who are interested in Crystal,i create the Github crystal-china org, <a href="https:&#x2F;&#x2F;github.com&#x2F;crystal-china">https:&#x2F;&#x2F;github.com&#x2F;crystal-china</a>, and I also hold <a href="https:&#x2F;&#x2F;crystal-china.org" rel="nofollow">https:&#x2F;&#x2F;crystal-china.org</a> domain name, although there is still no time to build a website.<p>Let us discuss use Chinese in TG,Discord, and do something together.
jwoertinkabout 2 years ago
Lucky core dev here! I&#x27;ve been using Crystal in production since about 2017. I love the language, but there&#x27;s definitely some hard tradeoffs which are mentioned in this thread. Our larger app has some serious compile time issues. We deploy with github actions, and it takes about 30min to build the production binary, compile assets, and push the binary to the server. But overall, I&#x27;ve found my apps are way more stable, and really fast as well as running on much smaller machines. The tradeoffs for us are definitely worth it.
评论 #35832154 未加载
pantulisabout 2 years ago
As a very anecdotal data point, I once created a pet project that interfaced with a CouchDB endpoint and inserted some keys with dates in a complex nested JSON structure and deployed it to Heroku. (It was ment to be called as a Apple Shortcut)<p>It took me half a day with Ruby, two days with Crystal and a little more than a week with Rust. The Crystal experience was very very smooth coming from Ruby. With Rust it felt like I was wrestling with the compiler.
评论 #35827768 未加载
zerrabout 2 years ago
The minimum requirement for a language to take off: first class Windows support. The current preview support is good enough to start playing. A high-performance (C-like, LLVM based) and a very high-level language with Ruby-like expressiveness coupled with static typing and compile-time (as well as runtime) safety, and with the ability to produce standalone native executables make it really one of a kind.
评论 #35829114 未加载
评论 #35831513 未加载
评论 #35828279 未加载
评论 #35839146 未加载
评论 #35843659 未加载
notmypenguinabout 2 years ago
There’s really a lot to be said for an easily readable relatively terse language that compiles to a tiny binary executable with low memory usage and can be run as a service, profiled, etc.<p>We use it extensively in production. I really would only ever consider Rust as an alternative, it’s <i>that</i> good.
评论 #35827817 未加载
transfireabout 2 years ago
Crystal should get more attention, from desktop application developers in particular. Crystal makes it much easier to maintain large performant code bases.<p>Basically working with Crystal is much more like working with Python or Ruby, but with performance comparable to C. Unlike Rust or Go where you get the performance, but you don’t get the huge bump in productivity b&#x2F;c youre working at a lower level of abstraction.
评论 #35827716 未加载
anta40about 2 years ago
Windows support is still under development, yes?<p><a href="https:&#x2F;&#x2F;crystal-lang.org&#x2F;install&#x2F;on_windows&#x2F;" rel="nofollow">https:&#x2F;&#x2F;crystal-lang.org&#x2F;install&#x2F;on_windows&#x2F;</a><p>I&#x27;ll stick with Nim then, it&#x27;s Windows support is much better. Of course for backend dev, Linux is usually #1 choice. Let&#x27;s try Crystal.
评论 #35833840 未加载
mrkeenabout 2 years ago
&gt; I remember when I first learned about type inference, one of my first thoughts was, why can’t we just create a statically typed language that does type inference for everything. The compiler would still have to figure out the types at compile time anyway, and I’d save myself a few keystrokes.<p>&gt; Turns out this is what Crystal does. It does aggressive type inferencing, and only asks you to declare types when it can’t figure it out.<p>&gt; Crystal does not have a global type inference engine
评论 #35827963 未加载
评论 #35827584 未加载
alex_lavabout 2 years ago
I find myself getting pretty immediately turned off by IMO kind of silly and unverifiable catch phrases languages use as marketing tools. Crystal uses &quot;a programming language for humans&quot;, much like EmberJS&#x27;s &quot;for _ambitious_ web developers&quot;. As I skim the Crystal page, it&#x27;s not clear to me what is supposed to stand out as a language that makes it &quot;for humans&quot; any more than any other language? It just seems silly.
e12eabout 2 years ago
&gt; I recently implemented a Brainfuck interpreter in the Crystal programming language<p>Aw, a bit of a missed opportunity to write a crystal version of the impressive (but probably dated?) &quot;How I start&quot;-article for Nim:<p><a href="https:&#x2F;&#x2F;howistart.org&#x2F;posts&#x2F;nim&#x2F;1&#x2F;" rel="nofollow">https:&#x2F;&#x2F;howistart.org&#x2F;posts&#x2F;nim&#x2F;1&#x2F;</a>
Alifatiskabout 2 years ago
I&#x27;ve had my eyes on Crystal for a couple of years, the only drawback is Windows support. When that&#x27;s done, I might use it!
评论 #35828181 未加载
p0w3n3dabout 2 years ago
In my opinion a new programming language nowadays should focus on (in this order):<p>1. easy interfacing with existing library ecosystem (like e.g. C interfaces)<p>2. nice testing framework<p>3. good IDE with good context help and refactor plugins<p>4. syntactic sugars and improvements over other languages
评论 #35827542 未加载
评论 #35827102 未加载
评论 #35828109 未加载
评论 #35830560 未加载
评论 #35827805 未加载
评论 #35830581 未加载
remramabout 2 years ago
I wish they had used the headline to say something about the language rather than the useless tagline &quot;for humans&quot;. Is it imperative, functional, object-oriented? For embedded, scripting, system programming?<p>Is it new? A dialect of something else?<p>Nope, all I know is it&#x27;s &quot;for humans&quot;, and possibly computers can run it too (?)
评论 #35828948 未加载
b33j0rabout 2 years ago
Just a tip. I scrolled multiple screenfuls and actually know less now about this language.<p>Put the recipe at the top.<p>We want to know what it will produce. If you have a heart-warming story about how you learned it in the tootledge of Chef van Rossum, tell that story below the fold.<p>I want a sense of the flavor before your whole life story :)
评论 #35828688 未加载
EyeSayUntoTheeabout 2 years ago
Crystal has already &quot;taken off&quot; for me, in the sense that it does everything I need it to do. The standard library is replete with http client and server, as well as JSON, and a host of other useful bits, just have a look: <a href="https:&#x2F;&#x2F;crystal-lang.org&#x2F;api&#x2F;" rel="nofollow">https:&#x2F;&#x2F;crystal-lang.org&#x2F;api&#x2F;</a><p>Wrapping of C-libraries is a relatively painless experience: <a href="https:&#x2F;&#x2F;crystal-lang.org&#x2F;reference&#x2F;1.8&#x2F;syntax_and_semantics&#x2F;c_bindings&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;crystal-lang.org&#x2F;reference&#x2F;1.8&#x2F;syntax_and_semantics&#x2F;...</a><p>I can use any&#x2F;all command-line utilities with an IO buffer (image processing, other out-of-band processing)<p>The stock &quot;DB&quot; module supports Sqlite, MySql, and PostGres out of the box.<p>SPEED: anyone &quot;sticking&quot; with RoR is not paying attention here: Crystal is a compiler and spits out a binary executable with low memory usage compared to it&#x27;s interpreted cousin. This binary executable can be run by systemd as a normal system service, started with command-line options, etc. Apples-and-Oranges comparison: I&#x27;ve turned a nodejs-based app that used roughly 600mb memory into an executable using 12mb. The latter has also not leaked any substantial amount of memory after running for 5 months straight now (still says 12mb) so, take that as you wish...<p>For me, Crystal has already arrived. I don&#x27;t need group approval for this to be the case. I can happily use version 1.7.3 for the rest of eternity, so I don&#x27;t see this rug being pulled from out from under me in the near future. Perhaps use private shard repos if this is your actual concern.
LVBabout 2 years ago
Slow compile times were a real issue for me when I was trying to leverage Crystal. This is acknowledged as a significant (and challenging to solve) issue: <a href="https:&#x2F;&#x2F;dev.to&#x2F;asterite&#x2F;incremental-compilation-for-crystal-part-1-414k" rel="nofollow">https:&#x2F;&#x2F;dev.to&#x2F;asterite&#x2F;incremental-compilation-for-crystal-...</a>
评论 #35830893 未加载
brightballabout 2 years ago
I’m honestly more interested in jRuby at this point. I think the coming combination of jRuby with fibers is going to become extremely compelling based on the early numbers that Charles Nutter was seeing. This is approaching BEAM levels of concurrency.<p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;headius&#x2F;status&#x2F;1653051050285203456?s=46&amp;t=alZCBpHQmrOiijvY9w8DwA" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;headius&#x2F;status&#x2F;1653051050285203456?s=46&amp;...</a>
评论 #35839431 未加载
singularity2001about 2 years ago
They seem to suffer from similar problems as Julia: Type inference for large projects seems to be extremely difficult and results in huge compile times &#x2F; startup times and or runtimes.
评论 #35833473 未加载
slondrabout 2 years ago
I never saw the pitch of crystal compared to Ruby with RBS.
评论 #35832617 未加载
rvbaabout 2 years ago
As someone who isnt a programmer, why are those &quot;guides&quot; done so poorly?<p>def double(val) val + val end<p>The example does not show what happens when you try to connect text and a number. Will it glue them together? Give an error?<p>Also, &quot;for humans&quot;, the whole x = x + 1 is illogical.
pmarreckabout 2 years ago
it’s = “it is”<p>otherwise it’s “its”<p>he or she makes this grammatical error multiple times<p>if you don’t know which to use, if you can substitute “it is” and it makes sense, then use “it’s”, otherwise not
coryafabout 2 years ago
Looks fine I guess, but (like Ruby) it&#x27;s not as intuitive as Python, and I have a lot of hopes that Mojo will bring about a performant Python like programming experience
评论 #35828542 未加载
评论 #35828318 未加载
varjagabout 2 years ago
There are two types of modern programming languages: those that look like C and those that look like Python.
评论 #35826870 未加载
评论 #35828303 未加载
评论 #35826827 未加载
评论 #35827912 未加载
评论 #35829067 未加载
Izmakiabout 2 years ago
So it&#x27;s Python but with small syntactical differences?
评论 #35826906 未加载
评论 #35828827 未加载
评论 #35826995 未加载
评论 #35826875 未加载
评论 #35827430 未加载