Live data from Hacker News

Ruby vs. Crystal Performance

ptimofeev.com

91–100 of 151 posts

Re: Ruby vs. Crystal Performance

#91
post #90

> If you recall Crystal is a statically typed language but you can omit explicit type restriction and the compiler will try to infer the type of variable. In our code Crystal uses the Int32 type for the n variable which has the maximum value of 2,147,483,647 but the 47th number is higher. In this case we need to specify the type of n. We can use Unsigned Int 64. Both Ruby and Python use arbitrary-precision integers t…

Haskell has arbitrary precision.

JavaScript has fixed precision.

Re: Ruby vs. Crystal Performance

#92

Earlier quoted context omitted.

> Care to explain more? Having been using Ruby for about 8 years and Crystal for about 4, they actually have an extremely similar syntax and are also semantically very close. To the point where many Ruby scripts are completely valid Crystal, or at the very least require only a few changes. It doesn't have Kernel#eval. It doesn't have Kernel#send. It doesn't have Kernel#binding. It doesn't has Proc#binding. It doesn't…

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

Re: Ruby vs. Crystal Performance

#93

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?

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.

Re: Ruby vs. Crystal Performance

#94

Crystal and Ruby do not even remotely have the same semantics. They look similar but the similarity is extremely superficial. The extra semantics that Ruby has have a massive impact on performance, for even the most optimising implementations. This is not a reasonable comparison if you do not consider the 'slick as Ruby' part. No runtime metaprogramming! The entire Ruby ecosystem is built on runtime metaprogramming!…

Metaprogramming doesn't need to have a performance impact. VM languages like Java, C#, and JS allow you do define and modify code at runtime JS you can redefine anything, Java support is pretty good, C# better support is coming with generators

Java and C# essentially let you dynamically load/JIT code (not to be confused to the JIT-to-native virtual machine implementation they often run on); JavaScript is much closer to Ruby in that sense. It also gets really slow if you try to do any of those things extensively.

Re: Ruby vs. Crystal Performance

#95

Earlier quoted context omitted.

Agreed. Crystal looks like it has many positive characteristics, but having similar syntax has nothing to do with having similar semantics. Without constructs like missing_method, you cannot run practically any of the Ruby ecosystem libraries, including everything involving Rails. Java and C also share a similar syntax, but that does not make that you can easily swap one for the other.

To be clear, crystal does have method_missing.

Crystal’s has something with the same name but like almost everything it has completely different semantics. You can’t use it for the same things.

Re: Ruby vs. Crystal Performance

#96
post #63

Earlier quoted context omitted.

Ruby's "metaprogramming" is something Java, C# and JS don't do well -- dynamically redefining things during runtime. Everything in Ruby, including literals and operators, can be redefined during runtime, because everything is an object, and every message passed to any object can be redirected, filtered, transformed ad hoc. It's not just classes can be modified. Specific objects can be modified. Well-crafted Ruby code…

Why did you have to move on?

I didnt have to move on. I chose to. I had learned what I wanted from Ruby, and I started to realize that the problems I was facing was leading me to reimplement some of the things that OTP already offered. I was getting more interested in concurrent, resilient systems. It came about the time when it converged with my interest in permaculture (which is also about resilient, regenerative systems).

Re: Ruby vs. Crystal Performance

#97
post #65

Earlier quoted context omitted.

However, JS does not treat everything as an object as pervasively as Ruby does. A JS object and a JS integer are two different abstract data types. A Ruby number literal "1" is treated as an object of the Integer class. There are no separate abstract data type other than an object. All operators for an Integer can be overriden (in runtime), or perhaps, a specific object's methods can be overridden. Now granted, the r…

A JS integer is actually an instance of the "Number" object, you can to a small degree alter fundamental behavior even with primitive types

I stand corrected.

Re: Ruby vs. Crystal Performance

#98
post #61

Earlier quoted context omitted.

Yeah how fast is that compiler? If it's just another compiled language (rather than the kind of wicked fast compiled language like Go), my enthusiasm will be dampened...

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?

I often switch between feature branches, when working on more than one project in a repo with multiple related modules. If there's a change near the top of that dependency graph, I'm forced to not exactly rebuild from scratch, but still to rebuild quite a lot.

Re: Ruby vs. Crystal Performance

#99
post #90

> If you recall Crystal is a statically typed language but you can omit explicit type restriction and the compiler will try to infer the type of variable. In our code Crystal uses the Int32 type for the n variable which has the maximum value of 2,147,483,647 but the 47th number is higher. In this case we need to specify the type of n. We can use Unsigned Int 64. Both Ruby and Python use arbitrary-precision integers t…

Haskell has arbitrary precision. JavaScript has fixed precision.

Well, they both have both. More or less. Haskell has Integer for arbitrary and int for fixed precision integers, for example. JavaScript has arbitrary precision integers (via BigInt), and fixed precision floats.

Re: Ruby vs. Crystal Performance

#100

Earlier quoted context omitted.

Metaprogramming doesn't need to have a performance impact. VM languages like Java, C#, and JS allow you do define and modify code at runtime JS you can redefine anything, Java support is pretty good, C# better support is coming with generators

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.
Post reply on HN