4 ms·
I'm curious if Crystal was considered given its speed and similarity to Ruby.
by joemccall86 8y ago
I'm curious if Crystal was considered given its speed and similarity to Ruby.
- hamandcheese 8y agoI really like Crystal, but the lack of any large corporate sponsors or large production systems using it (that I’m aware of) means I would probably never choose it for anything besides toy projects.
- dtn 8y agoApparently Yahoo jp have used it in one of their internal tools https://twitter.com/taichiro_dev/status/1047803131986292736 https://twitter.com/taichiro_dev/status/1047803131986292736
- jashmatthews 8y agoRust not having a GC and additional runtime is a large advantage when writing native extensions for Ruby.
- goatlover 8y agoBut does Crystal have either of those? It's also a statically typed, compiled language. Rust would require a complete rewrite of the code, while Crystal would only be partial.
- dragonwriter 8y agoHaving a runtime and GC is not unusual for a statically-typed, compiled language. Crystal, in fact, has a runtime, that runtime has a GC, and the language FAQ notes that removing the GC would be impossible without complete redesign of the language.
- jashmatthews 8y agoCrystal has both garbage collection and a wider runtime for fiber scheduling for evented IO etc. It's only superficially similar to Ruby.
- djur 8y agoCrystal has meaningfully different syntax from Ruby in some important places: * Strings cannot be single-quoted in Crystal. Single quotes are used for character literals, like C. * The two languages differ substantially in how keyword arguments are specified. In Crystal, any argument can be specified by name as well as position. * In Crystal a 'rocket-style' dict literal (i.e. `{ "foo" => "bar" }`) is a different type (Hash) from a 'keyword-style' dict literal (`{ foo: "bar" }`, a NamedTuple). * Hashes are typed (inferred at the time of creation). You can't use keys and values of different types than what was in the hash when you created it. You _always_ have to specify a type for empty hashes, which means that any Ruby code that does `x = {}` and then stuffs things into `x` has to be rewritten. * NamedTuples raise an error if you try to read or write a nonexistent key. Hashes raise an error if you try to read a nonexistent key. * Crystal does not have singleton classes (`class << self`). The Module class doesn't exist. You can't execute code in class definitions (like constant initializations). Generally speaking, a lot of the very dynamic Smalltalk-y features Ruby devs take for granted are not present. * `private`/`protected`/`public` are keywords, not methods, and they must be applied to each method individually (`private def...`). There's a lot else. Now, a lot of these changes are good and fix issues that Ruby can't because of the need for backwards compatibility. This isn't a criticism of the language. The fact remains that Crystal's superficial similarity to Ruby hides a lot of substantial differences (a problem Elixir suffered from for a while as well). Translating simple code by hand is not difficult, but rewriting a larger project would be a huge undertaking.
- yxhuvud 8y ago> Hashes raise an error if you try to read a nonexistent key. Depends on what method you use to read it. If you use [], what you describe is true, but if you use the nilable variant, []?, it is not. But yes, having to handle and think of nilability is certainly a big change that will affect a lot of code.
- Thaxll 8y agoWho's mad enough to use crystal in its current state?
- yxhuvud 8y agoIt is the perfect language for advent of code!
- agumonkey 8y agoI'd be worried of a false sense of similarity. Recently there was an article about crystal, some comments said Ruby was ~one inspiration and not the main goal. You could spend more time fighting your old habits with something that doesn't translate 1 to 1.
- Scarbutt 8y agoI'm curious why do you think developers should seriously consider a programming language that is still in flux and has no ecosystem?