Live data from Hacker News

Ruby vs. Crystal Performance

ptimofeev.com

121–130 of 151 posts

Re: Ruby vs. Crystal Performance

#121
post #108

Earlier quoted context omitted.

I wrote Rails professionally for a few years back when that was THE de-facto tech for greenfield projects and new startups. At the time, I really enjoyed it, but I'd never written a modern-feeling typed/gradually typed language yet (C#, which I found really verbose and ugly, a lot of pre-ES6 JS and Ruby, some Lua + Python). I would never voluntarily write it again. Ruby/Rails completely falls apart in larger projects…

Another issue with writing rails is the "bug in production that would've been caught at compile" issue lots of people have. There's been multiple instances early in my career when I missed a nil guard somewhere that broke months later because someone else used the method and sent it a nil. Types are super useful because they also work as on-demand accessible documentation, and the compiler helps you figure out well i…

I mean, the answer is just, more tests. If you choose a dynamic language over a compiled one, then you've in essence chosen to eliminate type definitions in code and replace them with type verifications in tests. Of course, if you switch to a typed language that doesn't have nil types, that doesn't help...

Re: Ruby vs. Crystal Performance

#122

Earlier quoted context omitted.

Sorbet ? So you can't write maintainable dynamic code without basically making it static is what you're saying.

When you have +100,000 LOC written over many years by people with varying degrees of experience and familiarity with the language, Ruby/Rails becomes unmanageably difficult a lot faster than other languages. It isn't the only one though. Not that you can't have a great, large Rails codebase but the "guardrails" are a lot less present than in some languages and it can be harder to try to clean up the mess once it's ha…

Hmmm well in the current fad of breaking out everything into a "micro" service how often do you deal with 100K LOCs? Also, typed code will reach 100K locs way faster than dynamic.

Re: Ruby vs. Crystal Performance

#123

Earlier quoted context omitted.

Lots of people are sure their stack provides an amazing experience, for example I don't get why you would choose node over rails. As for the performance: looks good for js, but quite a memory hog or am I missing something?

If all you are doing is writing API then you already don't need 50% of what Rails provides. If you are not into ORMs then you don't really need anything Rails provides at all.

Sure, if you don't need Rails than you don't need Rails I agree

Re: Ruby vs. Crystal Performance

#124
post #34

I really liked Crystal some years ago, even used in a prototype. Soon I realized that despite its cute syntax and good performance, coming from Elm, I would prefer a simpler language with type safety, good error messages and very fast compile time. Maybe in the next years I'll experiment again, especially due to Lucky web framework.

May I ask what language you decided to move to instead?

In my current job I use Node/Koa with Js, and I am not happy with it. Every side project that I start I use Elixir, and I plan working with it next year, or maybe with Clojure. It's not exactly what I was looking for, but while I can't find one that matches the criteria in the next years, these are pleasant options for me.

Re: Ruby vs. Crystal Performance

#125
post #100

Earlier quoted context omitted.

you obviously did not do metaprogramming in Ruby. Try it and you will never look at the "metaprogramming" capabilities of other languages in the same way. no offence to JS, but JS and a proper programming language are not even the same species.

For real metaprogramming try Clojure. It's another world entirely.

Lisps are far more natural at metaprogramming; Clojure is the most most popular Lisp at the moment.

Re: Ruby vs. Crystal Performance

#126

Earlier quoted context omitted.

>> and are also semantically very close >Sorry I super disagree with this. They look similar. Dig into it just below the surface? Start to model it formally? Not at all. I think you're missing the point. If 90% of Ruby code works in Crystal unmodified (even if it's because the standard library had to be rewritten from scratch), then the programmer experience may well be quite similar, regardless of how fundamentally…

> If 90% of Ruby code works in Crystal unmodified False, premise, since it's not the case at first place. 90% of your Ruby code will absolutely not work in Crystal unmodified.

> 90% of your Ruby code will absolutely not work in Crystal unmodified.

Don't nail me on exact 90%, but for me it does. Nothing rails related though. Good example: https://news.ycombinator.com/item?id=23437035

However, I agree that the fundamentals/underlyings are very different. It's far from being like a python 2 to 3 migration.

Re: Ruby vs. Crystal Performance

#127

Coming at Crystal from a Go and PHP development background, here are my thoughts: - The syntax is lovely. No, really. - I hate waiting for it to compile, especially compared to Go's compile time. - It's really young yet, and the ecosystem is just getting started.

> - The syntax is lovely. No, really.

Matter of taste; I find it horrible, just as I find Ruby syntax horrible. And I do not care about syntax too much generally (among my production langs are k and clojure) but I find this an eye sore; don’t know why but it is what it is.

Edit: aaah downvotes for an opinion :) Anyway, background; I maintained a huge Rails codebase for years; it was pretty much the worst thing I ever did (in 30 years of production coding) and that was pretty much down because how much I don't like the syntax. That doesn't happen often.

Re: Ruby vs. Crystal Performance

#128

Earlier quoted context omitted.

This is the reason why I have to keep IntelliJ Idea Ultimate/RubyMine laying around. I don't have the greatest laptop, and run a lot of containers, so Jetbrains IDE's are generally a no-go for me and I stick to VS Code, but trying to develop Ruby/Rails without a Jetbrains IDE Is crippling. I think ctrl+click definition jump does work in Crystal and it has a decent language server.

That's good to keep in mind, I strictly write code in vim but if I have to pick up ruby again I'll give those IDEs a shot. I really like the sales pitch of rails, but as someone that almost exclusively writes in modern, compiled languages, it's really tough to adjust to ruby and be productive with it.

The crystal language client can attach to one of the vim language server implementations just fine and make the same functionality available

Re: Ruby vs. Crystal Performance

#129
post #37

If `brew install crystal` is taking more than an hour to complete, in my case it was because llvm is a dependency and for some reason it was trying to compile it from source. If you manually install a precompiled llvm (you can do `brew install llvm` with some flags) it should skip that step during the crystal installation.

I installed crystal almost instantly with ASDF. Just:

    asdf plugin-add crystal https://github.com/asdf-community/asdf-crystal.git
    asdf global crystal 0.34.0 

It was painless. Other languages I've installed with ASDF must have had the same dependencies.

Re: Ruby vs. Crystal Performance

#130
I sort of felt compelled to post this. An OS written in Crystal. [1] Which got quite a bit of discussion last time it was on HN [2] .

I know this may sounds strange but I would not be surprised once Crystal reached 1.0 there will be a Ruby implementation written in Crystal.

[1] https://github.com/ffwff/lilith [2] https://news.ycombinator.com/item?id=21860713

Post reply on HN