Coffeehouse Post

Single Post Permalink

View Thread: is managed code faster than native?
  • User profile image

    evildictait​or wrote


    Because all primitive types duck-type to each other by default. An int is a double is a string is an array is an object.

    Nope. If you are only using weakly typed languages you will have a very distorted view.

    irb(main):001:0> x = 5

    => 5

    irb(main):002:0> x.length

    NoMethodError: undefined method `length' for 5:Fixnum from (irb):2 from /usr/bin/irb:12:in `'

    irb(main):003:0> x = "Foo"

    => "Foo"

    irb(main):004:0> x.length

    => 3