Live data from Hacker News

Ruby vs. Crystal Performance

ptimofeev.com

141–150 of 151 posts

Re: Ruby vs. Crystal Performance

#141
post #61

Earlier quoted context omitted.

If it has reasonable incremental compilation, it can take a few seconds to compile. With good code structure, I see large Java projects compile small changes in seconds, even though compiling Java used to be a hog. You don't often rebuild from scratch during development, do you?

Often I do because that's what CI does. This is pretty normal. But the point is having a different view of what compilation means in the developer's workflow as a language designer. Having the engineer have to think about how to organize the code for the compiler is bad design unless that organization is built into the compiler. The compiler should reject programs that are not organized for optimal compilation. And t…

However you frame it, compile times are going to be longer the more static guarantees you need to check, and the longer the more dependencies a particular code change affects.

Making your code low-coupling if equally beneficial for the compiler and for the human to reason about the code. Hence modularization, limiting the visibility of parts, etc.

OTOH there are situations when you have to have a common interface which is used across the board. Imagine Java's `List` or `CharSequence`. If you touch it, you have to recompile all the innumerable uses of it. So the more pervasive the dependency is, the smaller and simpler and more fine-grained it should be. Java's `List` does not do a hugely good job in the compactness department; it's pretty stable, though. You want the same trait from your most foundational interfaces.

Re: Ruby vs. Crystal Performance

#142
post #114

Earlier quoted context omitted.

Right now I'm at the very same situation. Yes, it is frustrating. This is why things close to the top of the dependency graph should be small, well-tested, and rarely need changes. But when you still need to troubleshoot them, there's no way around recompiling a lot of stuff if you want these static guarantees :(

Bad language design, IMO. The language shouldn't make the writers in it worry about how to organize the code to speed up the compiler.

In my case it's not even a language proper; I was using JavaScript which gives you near-zero static guarantees.

I was fixing an issue in one common library; properly testing changes required rebuilding and restarting a number of containers. Unit tests only tell you so much; you need proper integration tests to see how certain things interact.

If I were used a statically typechecked language (e.g. TypeScript), I could have eliminated 50%, or maybe 75% of the testing, because the compiler would check things for me before runtime. It would be drastically faster to localize and fix the bug even if the compilation increased build times 10x.

Re: Ruby vs. Crystal Performance

#143

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…

I don't like rails either but I like ruby syntax. You're sure you don't like ruby and not rails?

You got downvoted for not liking something "just because". (I didn't downvote.)

Re: Ruby vs. Crystal Performance

#145

Earlier quoted context omitted.

> - 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…

I don't like rails either but I like ruby syntax. You're sure you don't like ruby and not rails? You got downvoted for not liking something "just because". (I didn't downvote.)

Is that not a matter of taste means? I even say I do not know why; I just break out in hives when I open a ruby file. When I open up a file to start programming, I have to have some feeling of ‘let’s do it’; I have that with most languages but with ruby I just think ‘crap this is ugly’. Not sure how to explain that; it is more like trying to explain why I prefer Klee over Rembrandt. I guess some people can but I cannot put that into words.

Re: Ruby vs. Crystal Performance

#146

Earlier quoted context omitted.

I don't like rails either but I like ruby syntax. You're sure you don't like ruby and not rails? You got downvoted for not liking something "just because". (I didn't downvote.)

Is that not a matter of taste means? I even say I do not know why; I just break out in hives when I open a ruby file. When I open up a file to start programming, I have to have some feeling of ‘let’s do it’; I have that with most languages but with ruby I just think ‘crap this is ugly’. Not sure how to explain that; it is more like trying to explain why I prefer Klee over Rembrandt. I guess some people can but I cann…

I share the same feeling when opening up rails project because of their own weird rules and files being all over the place. I don't feel that when writing a single ruby file and feel elegant.

Re: Ruby vs. Crystal Performance

#147

Earlier quoted context omitted.

We recently finished our first node backend (typescript) and I have to say it was an amazing experience. The npm ecosystem definitely attracts its fair share of undesirables, but I struggle to see why JS full stack isn’t the default for 99% of people.

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?

I'm not expert in Ruby, but I'd say there's definitely a few wins in typescript (types, performance, async). But the biggest wins have nothing to do with language differences, but rather not having to worry about that because you're using one language. If teams are large and split between api and frontend, then perhaps less of an issue. But if you're doing anything fullstack, to be able to use one language, everywhere with mostly the same ecosystem...well it's kind of what Java wanted to be.

And I say this coming from a python/django background. And ORM is one big thing that Rails/Django definitely are clear leaders in.

Re: Ruby vs. Crystal Performance

#148

Neat seeing crystal on here. I built my startup using crystal and now I write crystal full time. I’m still only using a single dedicated server with a SQLite database.

I'm really curious why you picked Crystal for your startup :) Currently I'm evaluating different stacks and so far Crystal and Elixir are the ones that stand out the most. Did you evaluate other languages and frameworks before settling on Crystal? What has been your biggest pain points so far with the language / ecosystem? Would love to hear more :)

Yeah i evaluated elixir, node.js, ruby, and ocaml.

Pain points with crystal have mostly been about one of the couple packages i depend on have a breaking change. It was common for crystal to deprecate an API which makes its way to a dependency. Its less common now in the last few months. Maybe I'm just not using the lock file correctly?

There is a little verbosity when parsing user input, like JSON or query parameters, but I've embraced writing bigger schemas or logic for validating input and its made the software better.

BUT, one thing that has been absolutely important was a static compiler. I remember using node or ruby and how many bugs i would catch later in prod after refactoring. Crystal helps big there, as would elixir since its functional but its not statically typed.

Elixir scales but I'm not a huge company yet. I want raw speed right now for the few customers i have. Elixir was a close second.

Crystal compiles slower than most languages, but (except for my website) I just use it as an API server and everything else is a Preact app so I spend most time on the Preact/Webpack stack.

Re: Ruby vs. Crystal Performance

#149

Earlier quoted context omitted.

Is that not a matter of taste means? I even say I do not know why; I just break out in hives when I open a ruby file. When I open up a file to start programming, I have to have some feeling of ‘let’s do it’; I have that with most languages but with ruby I just think ‘crap this is ugly’. Not sure how to explain that; it is more like trying to explain why I prefer Klee over Rembrandt. I guess some people can but I cann…

I share the same feeling when opening up rails project because of their own weird rules and files being all over the place. I don't feel that when writing a single ruby file and feel elegant.

I don't know...

http://www.rosettacode.org/wiki/Mutual_recursion#Ruby

I find almost every other implementation better on the eyes; picolisp, pari/gp, nim and some others I would call elegant; the Ruby version looks like overly noisy and fairly ugly to me. Not so much (but still) the function defs, but p (Array.new(20) {|n| F(n) }) I find pretty nasty for some reason (again, not sure why).

Randomly picked example.

Re: Ruby vs. Crystal Performance

#150

Earlier quoted context omitted.

Here you go: https://spider-gazelle.net/

Does it also have a massive community and thousands of libraries(rubygems) for almost every possible thing you can possibly think of?

It's a significantly younger language than Ruby, so no, the ecosystem is not as diverse (yet). It is quite populated though - for a taste you can browse at sites like https://crystalshards.xyz/ or https://shards.info/.
Post reply on HN