4 ms·
What is the edge it gives when compared to Rust, Zig, and Nim?
by didip 4y ago
What is the edge it gives when compared to Rust, Zig, and Nim?
- bovermyer 4y agoCrystal's performant enough, but its key differentiating feature is its Ruby-like syntax. It's easy to write, and comparable in performance to Go and similar. Rust, Zig, and Nim are solving different problems.
- db65edfc7996 4y agoNim and Crystal feel like they are in exactly the same space? GC, fast, single executable compilation without runtime (I would also throw Go into this list).
- cultofmetatron 4y agothere is a runtime. its just baked into the final executable. you can't have garbage collection without one.
- yxhuvud 4y agoEverything has a runtime nowadays. Even C, even if it isn't all that large (including for example the memory structures necessary to keep malloc and free working).
- woodruffw 4y agoI think that’s too expansive of a definition of “runtime.” The context required by C and Rust programs is generally internal, meaning that interacting with the dynamic allocator doesn’t require the programmer to be aware of the implementation’s invariants. This is in contrast to a managed language like Java, where using a managed object from C via JNI requires coordination with the runtime (which in turn preserves the invariants).
- yxhuvud 4y agoBut you have to know that as well for C - there are for example several Linux system calls you really should not call manually because that would fuck up the internal state in LibC. Yes, the runtime is really small, comparatively speaking, but it is still a runtime.
- woodruffw 4y agoWhich system calls are you thinking of? The only ones that I can think of would be brk(2) and sbrk(2), but any recent libc should be resilient to calls to those. That being said, I'll grant that the distinction between "tiny runtime" and "no runtime" isn't useful and that C can be said to have a runtime insofar as most systems provide a `crt0` or equivalent.
- auxym 4y agoNim's new ARC gc, which will be default soon-ish in 2.0, does not have a "runtime" as commonly understood. It is fully deterministic, so it simply injects alloc/free calls in the generated code at compile time. It even has an option that can show you where the calls are injected. https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...
- hahaitsfunny 4y agoYou can ditch Nims GC and runtime and bring your own if you want. Of course you'd lose access to most of the stdlib but this is why Nim can be used and is popular for embedded / bare metal. Tmk Crystal still lacks Windows support as well and probably other os's / archs's compared to Nim
- bovermyer 4y agoWindows support is close. See this issue: https://github.com/crystal-lang/crystal/issues/5430 https://github.com/crystal-lang/crystal/issues/5430
- db65edfc7996 4y agoWindows support has been a target since 2013. That's too long for me to put any credibility in projections on when it will be generally released.
- zw963 4y agoCrytal can disable GC and runtime too. https://crystal-lang.org/reference/1.4/syntax_and_semantics/compile_time_flags.html#stdlib-features https://crystal-lang.org/reference/1.4/syntax_and_semantics/... Of course, same as Nim, you lose access to most of the stdlib.
- heynowheynow 4y agoPony does stricter sharing semantics than Rust (multicore) with actors and allegedly one of the fastest GCs ever developed. Its community is even smaller than Crystal's. Pony was developed essentially as a PoC to demonstrate the GC.
- mumblemumble 4y agoProbably the biggest differentiator compared to those three is that it's object-oriented. Rust, Zig and Nim are all procedural.
- pjmlp 4y agoRust definitly supports COM style OOP, and Nim does have OOP support.
- frou_dh 4y agoIf a language has a string type then it has an edge over Zig.
- sph 4y agoControversial in this forum, but its GC. In some applications memory allocation is not that important, so it's nice not having to think about it at all. I've gone deep into Rust recently, but Crystal might still eat Python's lunch, a language I've fallen out of love with.
- kinjba11 4y agoRust doesn't have a garbage collector, meaning you have a steep learning curve around the borrow checker. Zig aims to be a C replacement, with manual memory management as well. Nim is very close to Crystal. Some parts that might lead you to prefer Crystal however: - Nim compiles to C code, meaning Nim is coupled to what C can do. I find compiling to C to be distasteful, C is not meant to be a compilation target. We should be getting away from C, IMO. Nim is limited to what C can achieve, and the design of the language trends towards "here's how this translates to C" as a result. Compiling to C is also an extra layer of abstraction, as now for instance with debugging you have to go through the C layer. Crystal like Rust uses LLVM - Crystal also uses Ruby syntax, which many prefer. I have grown to dislike semantic whitespace such as how Python works, so this is a plus for me. - Crystal has a garbage collector, period, and leans into that. Whereas Rust, Zig, and Nim want to give you complete control over memory, Crystal is more focused on being a better high-level programming language, competing with the likes of JVM/NET/Go/Ruby. This focus is likely Crystal's main edge. The only other single-executable opinionated GCed language is Go. Crystal's type system is much better than Go's. If Crystal can reduce compile times and capture some of Go's pragmatic aura, it will see more success.