Crystal for Rubyists(crystalforrubyists.com) |
Crystal for Rubyists(crystalforrubyists.com) |
Conversely Perl and C++ made me miserable, as I tried and tried and gave up learning them. I prefer Excel formulae to working with them.
As an alternative to Chapter 2 I’ll also share https://github.com/compumike/crystal-docker-quickstart my project template which lets you get a Crystal (currently 1.6.2) dev environment running with just Docker. Good for kicking the tires, which is what I think your audience is probably wanting to do! And then eventually can install a binary package as you suggest.
Windows status: https://github.com/crystal-lang/crystal/issues/5430
My impression is that not many Ruby programmers have switched to Crystal. The slow(ish) Crystal compilation will not please Ruby users. And Crystal for Windows is still in beta.
Despite these factors, Crystal is a pleasure to use - fast, readable, and a well-featured standard libary.
> Dynamically typed
As someone who has experienced the joy and at least some feeling of safety from moving to typescript from javascript, I would seriously question that dynamic typing is awesome.
Do you know something like awesome-training resourses for Crystal?
https://learnxinyminutes.com/docs/crystal/
https://rosettacode.org/wiki/Category:Crystal
Otherwise I'll be starting with Crystal as well if I decide to do AoC in it, so I don't know of any other resources either.
Man, there have to be better alternatives than this.
Did you try “crystacean?” Chuckles in .rs.
I don't know what's the general opinion, but distribution for dynamic languages is a nightmare (and I'm including intra-machine, ie. switching between environments).
Personally, I'd be thrilled to trade off speed of compilation for distribution simplicity!
> My impression is that not many Ruby programmers have switched to Crystal.
This depends on the context of moving - professional projects, or hobby programming. Every once in a while somebody pops up saying that they've switched for hobby projects (mostly, scripts).
I'd love to switch, also professionally (that is, for certain parts of my professional project), however, lack of (release quality) parallelism is a dealbraker for me. It's mostly a matter of long-term trust - I personally don't trust a programming language that in 2022 doesn't support parallelism. Ironically, Ruby now has it (even if in limited form).
Development of 3d party libraries are also in vicious circle (few libraries -> few devs -> few libraries). Lack of (release quality) AWS SDK, for starters, is a dealbreaker.
Technologies like Docker have made distribution a lot easier. I haven't used tools like chruby or rbenv since 2014 when I started using Docker because Docker manages your app's runtime environment. You pull down your built image on your server and run it. There's no complication, sprawling of version managers or surprises.
Personally I think having a fast dev feedback loop is critically important. It's something you experience hundreds of times a day as you're developing your project.
Weird statement. Software distribution generally is just a terrible mess, regardless of what sort of language it's written in. The one exception is JS, which happens to be dynamic and also has what is probably the most reliable and ubiquitous platform available—so much so that its distribution story is often credited, rightly or wrongly, as the only reason anyone actually uses it.
Crystal achieved basic Windows support as of 2021/11/18. https://github.com/crystal-lang/crystal/issues/5430
As of Crystal 1.5.0, Windows support is basically there. https://crystal-lang.org/2022/07/06/1.5.0-released.html
However, Crystal aims to support the lowest common denominator between POSIX and Windows, so not all of the Windows standard APIs are supported out-of-the-box. Other Windows specific libraries will need to be created specifically for Windows users/developers.
it's the same thing for Elixir as well. they have successfully wooed a few Ruby programmers but not many have completely switched to using Elixir. Again some companies using Elixir are those that want to migrate away from Ruby.
it takes quite a while for a new hot language to become extremely popular and then go on to replace other popular mainstream languages.
As I mainly use ruby for scripting, Crystal has been replacing ruby's role for me for 3+ years and I don't even find anything that really missing, except for maybe a decent ORM like Sequel.
I also found that the Crystal LSP server was painfully slow, and there seems to be a lack of robust developer tooling in general. Has that improved in the last year or so?
It’s like saying pizza is awesome, therefore ice cream is not.
Both are awesome! It just depends what you’re trying to achieve at that point in time. A language’s type system is not, in absolute terms, an advantage or disadvantage. It’s just a design choice, each with their own trade-offs that we must consider.
I don't like having to write things like `List<int> list = new List<int>`... I find myself thinking, "Why do I need to tell the stupid compiler in the very same line that a new List<int> is a List<int>? Wtf else would it be?!"
When I write in a language such as Kotlin, that's statically typed but has type inference, I feel basically the same lack of resistance as I feel working in dynamically typed languages. Of course, even in such languages, there'll be times when the coder must specify a type, or should specify one for various reasons, but I like when the compiler at least makes an effort, haha.
I like Ruby a lot (and I've tried out Crystal in some recreational programming stuff and like it a lot too), and I think I'd still like it just as much without the dynamic typing.
Ruby does not do as many automatic casts as JS. In this regard it may be seen as "stronger".
Could you state the problem more concretely? Javascript is a cross between Java and Lisp, having a Java-esque C-like syntax, and lisp-like function-as-a-first-class-citizen behavior. Typescript brings it all the way to C#; so the C-like territory is firmly covered. An ML-family language, especially something like Haskell, would only reinforce the admiration for static types. Which languages would lead to the conclusion that dynamic typing is awesome? Lisps?
Crystal has static type checking though.
But used the way the OP is using it, strong vs weak is different from static vs dynamic.
What would you say some of the strengths of Ruby's type system are?
I usually only need to run it a few times towards the end of writing a feature to see if the compiler or specs catches any errors.
I'm constantly editing code then directing my attention to my browser to see the results. This is independent of CSS or JS changes that might be picked up by asset watching tools like esbuild or tailwind's CLI tool.
EDIT: Wow that took a long time to realize what you meant...haha no, truly not good, and thinking about it my comment "A developer who uses crystal?" is now terrible too.
Problem solved
Github's Hub tool is a good example.
It was originally written in Ruby. This requires that the user:
- may need to handle a certain environment in terms of Ruby interpreter (potentially install a new version)
- may need to handle a certain libraries group (gemsets in RVM)
- needs to install dependencies
- needs to handle switching to the appropriate Ruby interpreter version and libraries group
Especially point 3 is a pain.
Even just installing everything as system Ruby won't work, because often, different Ruby interpreter versions are required.
Once they moved to Golang:
- the distributor compiles for different platforms
- the user downloads the given version for their O/S
That's all.
>> the distributor compiles for different platforms
Most people aren't doing that for you. There are lots of tools out there where you do need to still manually compile it yourself and make sure you have the appropriate dependencies which will still be painful. That being said, I agree that shipping a script can be a problem, but lots of people use Brew and that seems to work ok.
Where does the generalization to dynamic vs. static languages come from?
> Github's Hub tool is a good example.
I gave an example already (a counterexample, that is—JS). Was there something wrong with that?
[^1]: https://sorbet.org/