DEV Community

Discussion on: 100 Languages Speedrun: Episode 49: Crystal

Collapse
 
jstanley0 profile image
Jeremy Stanley

lol, although I do Ruby on Rails for my day job, running Rails on Crystal was nowhere in my mind. Rails relies heavily on stuff like #method_missing? that could not exist in a compiled language.

I should have been clearer--I was thinking less about an actual compiled Ruby implementation and more about a compiled language that preserves Ruby's syntax and expressiveness as much as possible. Over the holiday break I used some Advent of Code problems to try and learn a few new languages, including Rust and Swift. I noticed places where these languages borrow from Ruby and I thought, why not just go all in? So I'm excited to see there exists a language that does just that.

Really enjoying this article series, btw!

Thread Thread
 
jstanley0 profile image
Jeremy Stanley

and I could be clearer again, by "compiled language" I mean one that outputs a standalone binary... JIT compilation like TruffleRuby feels more like an optimized interpreter to me - not one I was familiar with before, though, and it looks like they're doing a better job of optimizing performance than JRuby or MRI 3.

of course, now I'm remembering how you pointed out the apps on my phone are compiled from some form of bytecode into ARM64 machine code at runtime. so what even is a compiler anymore?

Thread Thread
 
taw profile image
Tomasz Wegrzanowski

Crystal can't support runtime method_missing, but it covers some cases with compile time macros.
It might be good enough for DSLs.

For things like ORMs, all Crystal web frameworks seem to use explicit column lists in the model.

The compiled vs interpreted distinction is really blurred as most languages use some sort of JIT, but some are a lot more compilation friendly than others. Like in Ruby Integer#+ can be redefined at any time while the program is runtime, that's really difficult to JIT efficiently, and who's actually doing it anyway, even in Ruby?