I wish I was a Crystal developer
Embed Crystal code directly in Ruby
41–50 of 65 posts
Re: Embed Crystal code directly in Ruby
#42Everything old is new again… https://github.com/seattlerb/rubyinline (2002)
I don’t think the author is claiming that code interop is new. But this does seem to be the first attempt at interop between crystal and Ruby, which is notable because crystal is effectively a typesafe Ruby.
Re: Embed Crystal code directly in Ruby
#43I read that during the first run, it will be slower because of the crystal code being compiled. Is the compiled code stored somewhere? I am asking this because in that case, can’t I run it myself and share the code with the precompiled parts so others don’t have to experience the slow start?
So it looks like you could easily check that in with your gem.
I don't actually see any object code in the directory but this is a new project so they may not cache that yet but I don't see why they couldn't in future. e.g. as a build step when installing a gem.
This seems to be a fantastic bit of work so far with a lot of potential for the future.
Re: Embed Crystal code directly in Ruby
#44Re: Embed Crystal code directly in Ruby
#45Re: Embed Crystal code directly in Ruby
#46Ha. TIL you can do 1_000_000.times do ... (equivalent to 1000000.times do ...). That's really nice.
Re: Embed Crystal code directly in Ruby
#47Re: Embed Crystal code directly in Ruby
#48Has anyone used both in any serious project, and if so can you compare? I've spent a tiny amount of time with Nim but found documentation, training videos, books etc extremely thin on the ground. Lots of Nim projects on github are ancient and haven't been updated in years. Chat GPT never gave me working code. How is Crystal in this regard? How would you compare their std libraries and available modules?
Re: Embed Crystal code directly in Ruby
#49Earlier quoted context omitted.
You won't ever see fast compilation times with it, and here's why: > type annotations are rarely necessary, thanks to powerful type inference. This keeps the code clean and feels like a dynamic language.[1] I prefer Sorbet[2] for Ruby, which is pretty fast and a reasonable compromise. People complain about the verbosity, but you can't have both speed and type inference. Pick one. Some of the verbosity in Sorbet, howe…
Do you have some examples of programs using generics in Sorbet you would prefer worked better or differently?
Re: Embed Crystal code directly in Ruby
#50Earlier quoted context omitted.
Do you have some examples of programs using generics in Sorbet you would prefer worked better or differently?
I'll have to dig deeper into it to put together some sorbet.run code and identify which issues are the most serious. I'll share with the community group whenever I have things worth posting. That said, in general, I often end up rewriting things a different way if something doesn't work, and the vast majority of the time that is good enough for me. But it takes time to find the one solution that doesn't create unacce…
Makes sense, this is a big one for us too. For example, we'd like to do a better job of typing the T::Enum `serialize` and `deserialize` methods, but that's blocked on having a better mechanism for type_members that are equivalent to type_templates. I have done some prototypes to build this feature (you can find them in my draft PRs) but none of the solutions I arrived at were particularly satisfying. It's on our list to fix for sure.
> Adding more polish to the ergonomics [...] would lead to better "just-works" type support
People mean a lot of different things by this—I'd love to hear more about what kinds of ergonomic improvements would help. For example, some people say ergonomics to mean only tooling improvements, while others mean something else (e.g. type system improvements).