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 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.
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.)
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 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 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 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 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).
8s to compile a hello world is "reasonable"? Am I missing something?
One of its main competitors hasn't exactly been up to Turbo Pascal levels with their own compiliation performance.
I would like to have something similar for Python.
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
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
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.
For anything 'scientific' there is Julia (with PyCall and RCall).
That said, it's a completely different language from Python, so the comparison to Ruby/Crystal is not very apt.
an alternate youtube frontend https://github.com/iv-org/invidious
and an OS written in Crystal https://github.com/ffwff/lilith
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
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).
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.
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.
I made https://pix.fastloop.xyz entirely in Crystal: https://github.com/yeo/pix/tree/master/src