Live data from Hacker News

Compiling Ruby to machine language

patshaughnessy.net

21–30 of 56 posts

Re: Compiling Ruby to machine language

#21
post #11
post #5

IIRC MacRuby used to compile to native code on OSX using LLVM, and was supposed to support native OSX APIs and Objective-C frameworks. It always seemed like a neat idea, and a slick integration, but I guess Apple moved to Swift instead. I'll have to pick up a copy of this "Ruby Under a Microscope" book when the new version comes out. I've always liked Ruby, I just haven't had much chance to use it.

Typical. I may get absolutely destroyed for this, but being professionally proficient in a ton of languages, including Ruby and the ones I mention below, and the ones I'm about to mention: This sounds like Microsoft when they moved from VB6 to VB.Net. At least they have a good thing going with C# though. VB6 was quite an interesting beast. You could do basically everything that you could do in languages like C/C++, b…

VB6 deserves the huge popularity it had, but the reason wasn't because of the language design, rather, its (extremely) rapid GUI application development. It was actually a two-edged sword - it facilitated writing spaghetti code.

> You could do basically everything that you could do in languages like C/C++

As long as there is some form of memory access, any language can do basically everything that one can do in C/C++, but this doesn't make much sense.

Re: Compiling Ruby to machine language

#22
post #11

Earlier quoted context omitted.

Typical. I may get absolutely destroyed for this, but being professionally proficient in a ton of languages, including Ruby and the ones I mention below, and the ones I'm about to mention: This sounds like Microsoft when they moved from VB6 to VB.Net. At least they have a good thing going with C# though. VB6 was quite an interesting beast. You could do basically everything that you could do in languages like C/C++, b…

What about something like Shoes[1]? I have played with it a little, just to make a simple UI to run some scripts I can run fine in a shell myself, but less-technical people may be too scared to fire up Terminal.app in order to do the same... 1: http://shoesrb.com/

Shoes was very limited, and could only be used for extremely simple applications.

Re: Compiling Ruby to machine language

#23
post #11

Earlier quoted context omitted.

Typical. I may get absolutely destroyed for this, but being professionally proficient in a ton of languages, including Ruby and the ones I mention below, and the ones I'm about to mention: This sounds like Microsoft when they moved from VB6 to VB.Net. At least they have a good thing going with C# though. VB6 was quite an interesting beast. You could do basically everything that you could do in languages like C/C++, b…

VB6 deserves the huge popularity it had, but the reason wasn't because of the language design, rather, its (extremely) rapid GUI application development. It was actually a two-edged sword - it facilitated writing spaghetti code. > You could do basically everything that you could do in languages like C/C++ As long as there is some form of memory access, any language can do basically everything that one can do in C/C++…

> As long as there is some form of memory access, any language can do basically everything that one can do in C/C++, but this doesn't make much sense.

No VB6 had really easy COM integration which let you tap into a lot of Windows system components. The same code in C++ often required hundreds of lines of scaffolding, and I'm not exaggerating

Re: Compiling Ruby to machine language

#24
post #5

IIRC MacRuby used to compile to native code on OSX using LLVM, and was supposed to support native OSX APIs and Objective-C frameworks. It always seemed like a neat idea, and a slick integration, but I guess Apple moved to Swift instead. I'll have to pick up a copy of this "Ruby Under a Microscope" book when the new version comes out. I've always liked Ruby, I just haven't had much chance to use it.

AFAIK, you can still use Objective-C and create apps for macOS, iOS, and iPadOS? The APIs previously used may not be available anymore.

Re: Compiling Ruby to machine language

#25
Making dynamically typed, single threaded languages faster via JIT usually comes at the cost of a significant increase in memory consumption which for businesses smaller than Shopify is a much more significant factor.

Re: Compiling Ruby to machine language

#26

How fast is Ruby, lately? I haven't used it in about 10 years

> How fast is Ruby, lately?

I did recent testing that showed it to be faster than Python but slower than Lua: Lua, Ruby and Python ran my benchmark in 12, 18 and 25 seconds respectively.

This was measured using the latest versions of each language (5.4, 3.4 and 3.13), using only the interpreters, no JITs.

> I haven't used it in about 10 years

It looks like the relative performance of the three languages hasn't changed much since I did a similar benchmark with Ruby 2.0, about that long ago.

Re: Compiling Ruby to machine language

#28
post #26

How fast is Ruby, lately? I haven't used it in about 10 years

> How fast is Ruby, lately? I did recent testing that showed it to be faster than Python but slower than Lua: Lua, Ruby and Python ran my benchmark in 12, 18 and 25 seconds respectively. This was measured using the latest versions of each language (5.4, 3.4 and 3.13), using only the interpreters, no JITs. > I haven't used it in about 10 years It looks like the relative performance of the three languages hasn't change…

luajit likely still smokes it then

Re: Compiling Ruby to machine language

#29
post #26

Earlier quoted context omitted.

> How fast is Ruby, lately? I did recent testing that showed it to be faster than Python but slower than Lua: Lua, Ruby and Python ran my benchmark in 12, 18 and 25 seconds respectively. This was measured using the latest versions of each language (5.4, 3.4 and 3.13), using only the interpreters, no JITs. > I haven't used it in about 10 years It looks like the relative performance of the three languages hasn't change…

luajit likely still smokes it then

Yeah, LuaJIT and PyPy run it in about 2 seconds. I haven't tried a Ruby JIT though.

Re: Compiling Ruby to machine language

#30

How fast is Ruby, lately? I haven't used it in about 10 years

If you want to compare it against other languages you could look at The Computer Language Benchmarks Game [1], which is an ongoing comparison of various programs written in various popular languages. You should always take all these benchmarks with a pinch of salt though since they are never truly apples-to-apples. That said, Ruby seems to measure slightly faster than Python and Lua, slightly slower than PHP, and maybe 1 order of magnitude slower than Node.js, just to compare it with other similar languages.

Compared to itself from 10 years ago I think it's made great progress. Can't put a number to it but I wouldn't be surprised if it's 2x or 3x faster, especially with the "new" JIT (YJIT) enabled. The JIT comes with a memory usage penalty though. You can see some benchmarks over time (although not going back as far as 10 years) at https://speed.ruby-lang.org

1: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Post reply on HN