News for hackers. Stuff that matters.
Re:An Introduction to Crystal by shric on Sunday February 21, 2021 @04:30PM (#26217421)
> Crystal’s build times are reasonable. Compiling my project Azula takes ~16s with the release flag. Compiling our barebones project above takes ~8s.

8s to compile a hello world is "reasonable"? Am I missing something?

Re:An Introduction to Crystal by mhd on Sunday February 21, 2021 @05:20PM (#26217853)
> Am I missing something?

One of its main competitors hasn't exactly been up to Turbo Pascal levels with their own compiliation performance.

Re:An Introduction to Crystal by ilumanty on Sunday February 21, 2021 @06:32PM (#26218463)
It's not the Hello World that takes 8s to compile, it's the author's project Azula (https://github.com/azula-lang/azula)
Re:An Introduction to Crystal by oisina on Sunday February 21, 2021 @04:37PM (#26217490)
this is with the release flag! normal compiling is a good bit quicker - sorry, should've mentioned that!
Re:An Introduction to Crystal by viraptor on Monday February 22, 2021 @12:03AM (#26221055)
It's not an actual hello world. "puts "hello world"" compiles in 0.7s in debug mode. In release mode it takes 7s with cold cache and 0.6s with warm for me.
Re:An Introduction to Crystal by doomrobo on Sunday February 21, 2021 @05:29PM (#26217947)
Not to mention memory intensiveness. Compiling a medium sized project (https://github.com/iv-org/invidious) on a DigitalOcean $5/mo droplet will throw an out-of-memory error unless I give it a few gigs of swap space
Re:An Introduction to Crystal by tutfbhuf on Sunday February 21, 2021 @04:20PM (#26217324)
The biggest selling point of Crystal is being a very high level language, but at the same time very performant. Think of a Ruby variant with Go speed.

I would like to have something similar for Python.

Re:An Introduction to Crystal by RaycatRakittra on Sunday February 21, 2021 @04:25PM (#26217371)
Have you taken a look at Nim? https://nim-lang.org
Re:An Introduction to Crystal by tutfbhuf on Monday February 22, 2021 @11:15AM (#26226193)
Not yet, but I have it on my watchlist. I wait for wider (rust-like) adoption of Nim, because most of my programming tasks are heavily dependent on the ecosystem and requires a fair amount of libraries.
Re:An Introduction to Crystal by cb321 on Monday February 22, 2021 @11:47AM (#26226619)
Do you have any specific libraries that you are missing? The packages list [1] has almost 1600 packages.

Also, the FFI in Nim is basically just declaring some C function as a `proc`. So, wrapping existing C libraries is as easy as Cython for Python. You can even jump start things by running `c2nim` on a header file.

[1] https://github.com/nim-lang/packages

Re:An Introduction to Crystal by tutfbhuf on Monday February 22, 2021 @03:48PM (#26230379)
We use the Neo4j graph database quite extensively, so a Neo4j driver / client SDK would be nice. And for intra service messaging we need a google cloud pubsub client library.
Re:An Introduction to Crystal by cb321 on Monday February 22, 2021 @04:07PM (#26230622)
Not sure how well it works (and I have no setup to test), but there is this [1]. It's pretty old and Nim has evolved quite a bit in the last 4 years. It probably doesn't compile, but it might not be hard to spruce it up (not that this would be a great "intro project"). { EDIT: Open source is often pretty thankless. It might be that if you asked nicely of that repo owner that he would do the sprucing! :-) }

I know there are a few different protobuf impls floating around. Not sure how much google pubsub needs beyond that. It's probably not so far away. Maybe you can be the one to do the pubsub wrapper. :-) (I'm only trying to encourage, not enlist/conscript.)

[1] https://github.com/cmacmackin/nim-neo4j

Re:An Introduction to Crystal by tutfbhuf on Monday February 22, 2021 @04:19PM (#26230778)
I appreciate your effort, I also have a hacker spirit / hands on mentality for my own hobby projects. But in this case I simply cannot "sell" it to my team. We really need something already production ready with community support behind it.
Re:An Introduction to Crystal by cb321 on Monday February 22, 2021 @04:32PM (#26230944)
Oh, and, FWIW, most of the time Nim code runs much faster than Go. More like C/C++/Rust speed.
Re:An Introduction to Crystal by cb321 on Monday February 22, 2021 @04:25PM (#26230863)
Ok. Well, then...maybe your next hobby project should be in Nim. :-)
Re:An Introduction to Crystal by tutfbhuf on Monday February 22, 2021 @04:44PM (#26231075)
Yup, I'll consider that.
Re:An Introduction to Crystal by phillipcarter on Sunday February 21, 2021 @09:00PM (#26219843)
> I would like to have something similar for Python.

Depending on the application, F# is a fantastic alternative to Python if you want some succinct code (with advanced types too) and fast runtime performance.

Re:An Introduction to Crystal by dunefox on Sunday February 21, 2021 @07:10PM (#26218757)
> I would like to have something similar for Python.

For anything 'scientific' there is Julia (with PyCall and RCall).

Re:An Introduction to Crystal by eigenspace on Sunday February 21, 2021 @08:12PM (#26219380)
Julia is not just for scientific computing, though a lot of it's ecosystem is built up for that. It's a general purpose language.

That said, it's a completely different language from Python, so the comparison to Ruby/Crystal is not very apt.

Re:An Introduction to Crystal by sidkshatriya on Sunday February 21, 2021 @04:24PM (#26217365)
I’ve heard the compiler is very slow. Is it? Go has a crazy fast compiler.
Re:An Introduction to Crystal by Jenz on Sunday February 21, 2021 @04:56PM (#26217642)
This is true, Crystal does compile pretty slowly, but this is the cost of its great static type system. The balance between Crystals expressiveness and performance is truly wonderful and a joy to program with
Re:An Introduction to Crystal by ranit on Sunday February 21, 2021 @04:44PM (#26217550)
GP meant Go run-time speed, not its compiler’s.
Re:An Introduction to Crystal by forde on Sunday February 21, 2021 @04:29PM (#26217403)
Yeah crystal is an awesome language
Re:An Introduction to Crystal by komuher on Sunday February 21, 2021 @04:24PM (#26217363)
nim-lang
Re:An Introduction to Crystal by gregors on Sunday February 21, 2021 @07:26PM (#26218885)
I'm really quite enchanted with Crystal. There are some amazing projects written in it including

an alternate youtube frontend https://github.com/iv-org/invidious

and an OS written in Crystal https://github.com/ffwff/lilith

Re:An Introduction to Crystal by yeskia on Sunday February 21, 2021 @04:57PM (#26217652)
I've played with Crystal a number of times and love it. It ticks a lot of the boxes for what I want in a language.

However, there seemed to be some confusion about whether the language could continue with inferred types or whether you'd need to annotate yourself - and what that would mean for compile speeds. I'm hoping those concerns can be resolved

Re:An Introduction to Crystal by klelatti on Sunday February 21, 2021 @04:28PM (#26217400)
Having written a Ruby (not Rails) app that would benefit from Crystal's speed and typechecking (and made a start on a conversion) I worry that the language won't find a niche that ensures its long term survival. Is there any area where Crystal is likely to provide a compelling solution when compared to other languages?
Re:An Introduction to Crystal by jiofih on Sunday February 21, 2021 @06:57PM (#26218639)
It’s niche is being a high level typed language with extremely nice syntax, while having speed that competes with Rust/Go and others. The best thing that can happen is for it to get its own life away from Ruby.
Re:An Introduction to Crystal by klelatti on Sunday February 21, 2021 @08:03PM (#26219289)
Just to clarify I meant niche as in use / market. I agree on the characteristics - where does it 'win' though vs Go / Rust which are already well established. I don't see any movement from those communities to even try Crystal.
Re:An Introduction to Crystal by chillfox on Sunday February 21, 2021 @08:37PM (#26219644)
Well, it wins for those of us who dislike Go/Rust syntax. Crystal is much easier to read/write than Go/Rust (Yes, I know that the majority of programmers like it the other way).
Re:An Introduction to Crystal by klelatti on Monday February 22, 2021 @08:18AM (#26224138)
I hope you're right as I much prefer ruby syntax too!

I just think that maybe rubyists overstate the attractions of the 'programmer friendly' nature of ruby a bit as outside of rails it's lost out vs Python for example. And Rails is popular because of the web app DSL that it provides (and so relies on Ruby Metaprogramming which crystal doesn't have).

Re:An Introduction to Crystal by chillfox on Monday February 22, 2021 @09:15AM (#26224754)
I use Ruby for work all the time and Crystal for hobby projects and I still haven’t used Rails or Ruby’s meta programming, but I have used Crystals macros.
Re:An Introduction to Crystal by m12k on Sunday February 21, 2021 @05:12PM (#26217785)
The absolute killer would be having a (ideally automatic) way to port existing Ruby applications to Crystal, and thus also tap into the existing ecosystem around Ruby. Though in order for that to really take off, they'd need to be able to port Rails too, which is probably quite tricky (considering how much metaprogramming Rails does for its "magic").
Re:An Introduction to Crystal by burlesona on Sunday February 21, 2021 @05:57PM (#26218213)
I think for this to have a realistic chance, you have to have some effort on the rails side to reduce the meta-programming. I doubt that’s going to happen.

It is certainly possible to port Ruby applications to Crystal without a total rewrite, but the addition of static types in and of itself means you may be surprised at how much fiddling is required to get the compiler to approve your code.

Re:An Introduction to Crystal by klelatti on Sunday February 21, 2021 @06:04PM (#26218266)
Having done some of this agree 100% with the "surprised at how much fiddling is required".

I think in practice that Crystal will have to carve out its own niche distinct from Ruby - and I'm not sure whether the Ruby like syntax is much of an advantage against competing languages.

Re:An Introduction to Crystal by chillfox on Sunday February 21, 2021 @08:41PM (#26219679)
It doesn't have to beat other languages, it just has to enable new domains for people who only like ruby like languages to be successful.
Re:An Introduction to Crystal by klelatti on Sunday February 21, 2021 @05:33PM (#26217989)
Absolutely and given the resources that firms spend on servers running Rails (GitHub, Shopify etc) I could see the effort being put into it - if it's possible. I suspect the metaprogramming issue is really tricky though.
Re:An Introduction to Crystal by bestinterest on Sunday February 21, 2021 @04:55PM (#26217632)
Crystal is a really nice language to me. If it had some large ecosystem behind it and wasn't boring I'd be able to use it to replace my other preferred boring languages of Java (strong engineering focus and long standing systems) and Ruby (beautiful to write and super productive).
Re:An Introduction to Crystal by kureikain on Monday February 22, 2021 @03:46AM (#26222223)
Crystal is a static type language but has really good type inference. You can go pretty far without writing a single line abouttype.

I made https://pix.fastloop.xyz entirely in Crystal: https://github.com/yeo/pix/tree/master/src