5 ms·
Crystal is not a replacement for Ruby. In the same way that many Algol-like languages are not a straight swap for each other. Don't get me wrong, Crystal is a n
by igravious 9y ago
Crystal is not a replacement for Ruby. In the same way that many Algol-like languages are not a straight swap for each other. Don't get me wrong, Crystal is a nice idea but say goodbye to all that yummy Ruby meta-programming which is one of the key things what makes the language so appealing in the first place.
- eropple 9y agoExactly. As a Ruby developer, Crystal makes me itch. It jettisons exactly what Ruby is valuable to me for: quickly and dynamically building fluent-feeling libraries and tools. It's fast, but I don't need fast--if I don't need Ruby's metaprogramming, I have other, better, established languages to use for those tasks. (Kotlin, C#, Rust, whatever.) Elixir is kind-of in the same boat for me. I think it's neat and has its place, and BEAM is really cool, but it doesn't scratch the Ruby itch for me. I just don't care about it looking vaguely like Ruby if it's not actually gonna be Ruby.
- dragonwriter 9y agoElixir is, in my view, an even-more-awesome Erlang with an unfortunate and distracting cosmetic resemblance to Ruby. Ruby is awesome, as is Elixir, but very different awesome.
- eropple 9y agoAgreed, to be clear. I think Elixir is cool. It just keeps getting framed as a "better Ruby"--though Phoenix might be (probably is) a better Rails.
- sam0x17 9y agoHave you used a recent (2017) version of Crystal? Quickly building fluent-feeling libraries and tools is exactly my use case for Crystal. For me, everything that Ruby is valuable for is retained. I'm able to do all the things I did in Ruby just fine, and it prevents me from doing a lot of things I shouldn't have been doing. We recently migrated our app from Rails to Crystal (using the Amber framework) and our code base is now 2/3rds the size and we eliminated hundreds of bugs in the process simply from static typing and explicit nil handling. Our response times are also now all under 30ms where we were at 100ms+ before.
- eropple 9y agoUntil I can perform runtime define_method calls and dynamically construct classes, it doesn't matter what Crystal does. It's fundamentally antithetical to my needs. (JavaScript isn't, but JavaScript is kind of clunky.) I have Kotlin, C#, C++, and Rust if I need static typing. Ruby is for when I don't.
- yorwba 9y agoHow late at runtime do these dynamic definitions need to be possible? Just at startup or also after the program has been running for a while? I occasionally wonder whether it might be possible to accommodate more dynamic language features with a compiler that treats them like a macro system that is expanded statically, such that no actual dynamicism is necessary at runtime.
- sam0x17 9y agoThis is exactly what crystal does
- sam0x17 9y agoYou can do all of that with really easy to write crystal macros.
- eropple 9y agoYou can dynamically build at runtime an HTTP client from an OpenAPI spec (unavailable until runtime, to be clear), method-by-method, using macros? Tell me more.
- sam0x17 9y agoGot me there. First time I've ever in my life heard of a legitimate example where you really do need dynamic methods.
- 9y ago
- sam0x17 9y agoTake a look at macros in crystal and I promise you 99% of the time you will be able to do what you did in Ruby. Practically everything people do that is "necessarily dynamic" could be done with macros at compile-time. You CAN do things like define the behavior for when a method name is unmatched on an Object or (at compile time) do some string processing and define a bunch of methods based on the results.
- pankajdoharey 9y agoMeta-programming in Crystal exists through Macros.