News for hackers. Stuff that matters.
Re:Crystal Programming Language by didip on Thursday September 01, 2022 @09:15PM (#32685479)
What is the edge it gives when compared to Rust, Zig, and Nim?
Re:Crystal Programming Language by mumblemumble on Thursday September 01, 2022 @10:09PM (#32685802)
Probably the biggest differentiator compared to those three is that it's object-oriented. Rust, Zig and Nim are all procedural.
Re:Crystal Programming Language by pjmlp on Friday September 02, 2022 @06:29AM (#32689005)
Rust definitly supports COM style OOP, and Nim does have OOP support.
Re:Crystal Programming Language by bovermyer on Thursday September 01, 2022 @09:29PM (#32685562)
Crystal'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.

Re:Crystal Programming Language by db65edfc7996 on Thursday September 01, 2022 @09:40PM (#32685635)
Nim 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).
Re:Crystal Programming Language by cultofmetatron on Thursday September 01, 2022 @10:00PM (#32685745)
there is a runtime. its just baked into the final executable. you can't have garbage collection without one.
Re:Crystal Programming Language by auxym on Friday September 02, 2022 @12:19PM (#32692566)
Nim'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...

Re:Crystal Programming Language by yxhuvud on Friday September 02, 2022 @04:20AM (#32688111)
Everything 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).
Re:Crystal Programming Language by woodruffw on Friday September 02, 2022 @08:30AM (#32689819)
I 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).
Re:Crystal Programming Language by yxhuvud on Friday September 02, 2022 @09:16AM (#32690358)
But 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.
Re:Crystal Programming Language by woodruffw on Friday September 02, 2022 @10:26AM (#32691236)
Which 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.

Re:Crystal Programming Language by heynowheynow on Friday September 02, 2022 @06:44AM (#32689091)
Pony 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.
Re:Crystal Programming Language by hahaitsfunny on Thursday September 01, 2022 @11:07PM (#32686138)
You 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

Re:Crystal Programming Language by bovermyer on Friday September 02, 2022 @06:10AM (#32688872)
Windows support is close. See this issue:

https://github.com/crystal-lang/crystal/issues/5430

Re:Crystal Programming Language by db65edfc7996 on Friday September 02, 2022 @08:07PM (#32697165)
Windows 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.
Re:Crystal Programming Language by zw963 on Friday September 02, 2022 @12:44PM (#32692888)
Crytal can disable GC and runtime too.

https://crystal-lang.org/reference/1.4/syntax_and_semantics/...

Of course, same as Nim, you lose access to most of the stdlib.

Re:Crystal Programming Language by frou_dh on Friday September 02, 2022 @04:10AM (#32688030)
If a language has a string type then it has an edge over Zig.
Re:Crystal Programming Language by kinjba11 on Friday September 02, 2022 @03:43PM (#32694989)
Rust 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.

Re:Crystal Programming Language by sph on Friday September 02, 2022 @04:29AM (#32688167)
Controversial 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.