
InfraRuby 3.7 – Compiler and runtime for statically-typed Ruby - MrBra
http://infraruby.com/blog/infraruby-3-7-released
======
vidarh
"Statically-typed Ruby" that isn't actually Ruby, but a subset of Ruby[1] +
mandatory type annotations. A rather misleading title.

E.g. here's an example [2], with stuff like this:

    
    
            ## java.lang.String -> void
    	def set_title(title)
    		@title_view.setText(title)
    		return
    	end
    

I kinda doubt this will take off with most Ruby users. Though being able to
use something quite close to Ruby to write native Android apps is somewhat
appealing even with extra pain (RubyMotion seems nicer to me, but the compiler
only runs on OS X).

[1] "The runtime implements selected methods from core classes" [long list
omitted]

[2]
[http://webcache.googleusercontent.com/search?q=cache:sUdn7y_...](http://webcache.googleusercontent.com/search?q=cache:sUdn7y_lf8gJ:infraruby.com/examples/wiktionary+&cd=1&hl=en&ct=clnk&gl=uk)

~~~
duaneb
RubyMotion is terrible: it's expensive, closed, and is basically objective-c
meets ruby syntax.

This is at least running on a JVM, which gives you a buttload of tooling.

~~~
fleitz
That's what I love most about the JVM, lots of tools to solve problems that
don't exist on other platforms.

~~~
coldtea
If we remove the snark and keep the reality:

Those problems do exist on all platforms and the tooling elsewhere is usually
not as good.

~~~
fleitz
Never had a GC pause in objc

~~~
coldtea
Apples to oranges.

How about any of the major GC languages?

How about the great debugger tooling Java has. Had that in ObjC? How about
performance and threading related tooling? How about refactoring tooling?

------
fuzzythinker
How does this compare to Crystal[1]? Crystal is very clear that it compiles to
native [2].

Tried to figure out what InfraRuby compiles to, but no avail. Is it to JVM?

[1] [http://crystal-lang.org](http://crystal-lang.org)

[2] Very impressive result actually. It only performs ~3x slower on a basic
Monte Carlo Tree Search compared to Nim, which itself is ~c speed.

~~~
infraruby
> How does this compare to Crystal?

You can use InfraRuby code with a Ruby interpreter:
[http://infraruby.com/blog/why-infraruby](http://infraruby.com/blog/why-
infraruby)

> Tried to figure out what InfraRuby compiles to, but no avail.

Sorry, that should be made clearer...

> Is it to JVM?

Yes! ruby.Object extends java.lang.Object:
[http://infraruby.com/reference/Object](http://infraruby.com/reference/Object)

------
Demagog
If you want Ruby-like syntax with static typing and almost no type annotation
then Crystal is good for you. Sadly no windows binary available

------
overload119
Cached version, as the site is having trouble loading for me.

[http://webcache.googleusercontent.com/search?q=cache:7UYpJjG...](http://webcache.googleusercontent.com/search?q=cache:7UYpJjGdULsJ:infraruby.com/blog/infraruby-3-7-released+&cd=2&hl=en&ct=clnk&gl=ca)

------
stripeless
Heh good luck get any of the Ruby "code" that community cares about like Rails
to run on this - it is 99% magic, and DHH likes magik too much to want
typing...

~~~
fleitz
It's more like context...

Rails has a lot of context which allows developers to rapidly specify what
they want to happen in the context of web apps.

Rails is like asking someone to get milk, rails maps a route, obeys the laws
of the road while getting there, pays for it, and returns with milk.

In other frameworks you explicitly have to tell it every little detail of how
to get milk, usually culminating in the IMammalianFactoryMilkFactory pattern.

------
ankurpatel
Finally a solution that can makes Rails more competitive

~~~
vidarh
If you can find anyone willing to port Rails to a statically typed subset that
requires adding type annotations and also porting every single gem it depends
on....

~~~
MrBra
Well that is a starting point. It would be even harder without it so better
having it that not. Also do you have any alternatives?

Maybe for a start, making a statically typed Sinatra rather than Rails would
be a more affordable task.

But anyway I'm not sure this is the right direction for Ruby as I think that
more radical and different changes are needed to extract the full potential
out of it.

Anyway if Infrared proves to be a nice and quick alternative solution that
will let us gain back some lost terrain in those situations where Ruby was
discarded because of performance, then I more then welcome it, hoping that a
some point the efforts put in it will somehow also be useful to Ruby MRI (or
whatever the Ruby reference implementation will be at that time) improvement..

~~~
vidarh
> Also do you have any alternatives?

Yes: Not doing it.

> in those situations where Ruby was discarded because of performance

In most cases where Ruby gets discarded because of performance, it's a red
herring. Most of Ruby's main uses are in areas where you can generally make
things IO bound fairly easily.

For my part, I don't believe Ruby needs static typing to get far more
performant. I'm working on a Ruby compiler, and while it's far from usable,
from looking at MRI in particular it's worth noting that MRI implements pretty
much nothing of the last 30 years or so of dynamic language optimizations.

Look towards JRuby today, and especially the Truffle backend, for indications
of where Ruby optimizations can be going without sacrificing what makes the
language attractive in the process.

That's not to say there aren't warts that makes it harder than necessary, but
you can get very far with far less impact on the language than taking away
dynamic typing.

~~~
MrBra
Wow, then you do have an alternative! Hope to hear something more about it
soon!

