Live data from Hacker News

Crystal 1.0 – What to expect

crystal-lang.org

201–210 of 351 posts

Re: Crystal 1.0 – What to expect

#201

Earlier quoted context omitted.

C# is tied to .net, and the cross-platform story on that framework is...complicated Java is tied to JVM Swift is tied to MacOS. Of course, with the exception of JVM, they are all nominally "cross-platform" in the OS sense of the word. But I haven't seen any substantial Linux/Mac .Net codebases yet, same with Swift on Windows

Swift is not any more tied to macOS than C# is tied to Windows. Compiler LLVM and everything is open source and cross platform. Not all the libraries but that holds true for C# as well, last time I checked.

C# (CLR specifically) is not tied to windows and hasn't been for a while now. Perhaps the last time you checked was pre 2016 ?

Re: Crystal 1.0 – What to expect

#202

Earlier quoted context omitted.

Would a developer looking a Zig/C++/Rust really also consider Crystal? I figured Crystal was for Ruby developers who want a good static type system.

Ruby is a great language, the only nits I have with it are error handling, types and a bit of the perlisms and shellisms that crept in. If Crystal fixed these I would be interested

Ruby stole elegant word lists %w(tic tac toe) and the regex operator =~ from Perl so I'll keep my Perlisms, thank you very much.

Re: Crystal 1.0 – What to expect

#204
post #110

Earlier quoted context omitted.

Kotlin mostly requires JVM, Crystal does not. Kotlin is heavily oriented towards Java familiarity and interoperability, Crystal is heavily oriented towards Ruby familiarity, and C interoperability. Also, Crystal was first released in 2014, when Kotlin was like 3 years old, and 100% JVM-bound.

Kotlin mostly requires JVM, Crystal does not. With Kotlin native, Kotlin js and most importantly Graal native this is plain wrong.

Is kotlin/native a first class option today for server side programming? Last I looked at it, which was fairly recently, that did not seem to be the case.

Re: Crystal 1.0 – What to expect

#205
Ruby was one of the languages I "cut my teeth" with to some extent, and I've always loved it's syntax and guiding philosophies, but was pulled away to PHP for my job, and ended up using other things for side projects.

So a project that compiles to native code but uses Ruby-like syntax is very much "what I would build if I committed to building a language". But I've kept pushing off learning it on the notion that I could always justify learning other things that were "version 1" and "production ready (whatever that means)".

I'm thinking now is the time to jump in and try this out finally.

Any real world users care to explain some domains that either are or are not well suited for this at the moment? Any "gotchas" with writing C-bindings, should I need to? Or is the library ecosystem fairly strong?

Re: Crystal 1.0 – What to expect

#206
post #150

Earlier quoted context omitted.

C# is tied to .net, and the cross-platform story on that framework is...complicated Java is tied to JVM Swift is tied to MacOS. Of course, with the exception of JVM, they are all nominally "cross-platform" in the OS sense of the word. But I haven't seen any substantial Linux/Mac .Net codebases yet, same with Swift on Windows

The cross-platform story of .NET hasn't been complicated in a while. It's fully cross-platform between Windows, Linux, and macOS and has been for a few years. Edit: I just saw the person that you replied to said the same thing, so I'm not sure why you're pushing that it has a complicated cross-platform story.

So... pretty much everything I could do on .net framework runs on Linux and Mac now? Even Winforms, or WPF?

To be fair I haven't written .net code in like 10 years, and the docs explaining how to navigate the transition from framework to core were extremely confusing. Has that soup of different technologies solidified any?

Re: Crystal 1.0 – What to expect

#207

Earlier quoted context omitted.

Kotlin mostly requires JVM, Crystal does not. With Kotlin native, Kotlin js and most importantly Graal native this is plain wrong.

That is like a hack. You are basically dumping a JIT image to file. That means all sorts of caveats apply such as be real careful about how you use reflection. Also there is no ABI so you cannot use anything like a native DLL. Native compilation while possible is clearly second class on the JVM platform. For Crystal it is first class.

> Also there is no ABI so you cannot use anything like a native DLL.

Pretty sure this isn't the case with Kotlin Native[1].

[1] https://kotlinlang.org/docs/native-dynamic-libraries.html

Re: Crystal 1.0 – What to expect

#208

Earlier quoted context omitted.

Crystal has a GC. I see it as more similar to the likes of Nim, Swift, Java or C#. It's a great language regardless.

Does languages don’t belong together. Java and C# sure. They use sophisticated garbage collectors and target intermediate code. Nim, Crystal and Swift all compile to native code and is designed for that. Swift is not a GC language in the normal sense since it uses automatic reference counting. That is fully deterministic and with low latency. There is no stop the world to collect garbage like with Java and C#. Swift…

Isn't reference counting a form of garbage collection, though? If you want performance then Objective C and Swift aren't the languages you should be using. There's a reason why Apple recommends C/C++ if you need your code to run as fast as possible and also the reason why the high majority of professional games are written in C++ with either a thin Objective C / Swift wrapper.

Also, you can compile both Java and Kotlin to native images with Graal.

https://www.graalvm.org/examples/java-kotlin-aot/

Re: Crystal 1.0 – What to expect

#210
post #117

Earlier quoted context omitted.

> I’ve never declared a variable and not simultaneously thought “this is going to be a float, always a float, never not a float.” Never written generic/template code? Making that much easier is one of the main benefits of dynamic typing.

It's possible—nay likely—that I don't understand the true value of generics. It's something that I've looked into on occasion and it never seemed all that useful to me. Most examples I've come across in the past were C++ and seemed like formalised workarounds for deficiencies in the C++ type system rather than being actually useful. I'm sure I've failed to grok them—or based on the code I write I'm not the target aud…

Crystal does some of what you want:

https://tio.run/##ZVDBbsIwDL33KywmrRcaUXbbhHbeaYdpJ4RQaA1kCk...

Note how the language is pretty smart about flow-typing variables as you narrow down their types. `x` here is typed as a tagged union (String | Int32 | Array(Char) | Float64 | UInt32), but by the time the program gets to the final `else` the compiler has figured out that the String and Array cases have already been dealt with (even though we never mentioned Array by name, just asked if the object implements a method that only Array implements), so it lets us call `x.abs`, which only works for numeric types. Of course, `abs` has different implementations for Int32 and Float64, but the signatures are compatible so the compiler lets it fly, resorting to dynamic dispatch at runtime.

The missing part is that there's nothing like a CAN_SAFELY_BECOME_A operator so I had to implement that test myself (as `try_to_u32`) and call it early to get the flow typing to work.

The Wikipedia article for the concept is https://en.wikipedia.org/wiki/Flow-sensitive_typing

Post reply on HN