# Type inference in ruby

**URL:** <https://rubytalk.org/t/type-inference-in-ruby/15673>\
**Category:** ruby-talk\
**Created:** [8 January 2005 19:35 UTC](https://rubytalk.org/t/type-inference-in-ruby/15673 "2005-01-08T19:35:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![E\_S](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/32.png) [@E\_S](https://rubytalk.org/u/E_S)\
**Post date:** [8 January 2005 19:35 UTC](https://rubytalk.org/t/type-inference-in-ruby/15673/1 "2005-01-08T19:35:08Z")

</div>

> Lähettäjä: Eric Anderson \<eric@afaik.us\>  
> Aihe: Re: Type inference in ruby
> 
> Trevor Andrade wrote:  
> \> I was wondering whether it would be possible to have a type inference system  
> \> in ruby. My question was asked before
> 
> I am sure it is possible to implement but I think most people end up  
> wondering why do it? If you want a typed system (strong or weak) there  
> are plenty of languages that support it natively. For me that is one of  
> the reasons I left those other languages. For me a type system has too  
> much coding overhead without much benefit. The two advantages are:
> 
> \* Catches type errors  
> \* Possibly better optimizations
> 
> To answer the first advantage Ruby encourages Unit testing. Unit testing  
> it 10 times better than type checking because it can not only check for  
> valid types but also check for logic errors. So why spend the overhead  
> of a type system when unit testing is better.
> 
> The second advantage again isn't an issue for me. Ruby is fast enough.  
> If I need it faster I can profile the code to find bottlenecks. If I  
> need it even faster I can recode the bottlenecks in C. Again, the  
> overhead of a type system is not worth even the possibility of better  
> optimizations.

A TI system could be implemented as a separate library to be run  
on some code rather than as a part of that code, as an additional  
testing facility.

That being said, I think it may be too much trouble for little gain.

> Just my two cents,
> 
> Eric

E
