Hacker News new | ask | show | jobs
by divtiwari 1946 days ago
I'm currently learning Ruby as I plan to implement the 'Building Git' book by James Coglan. Ruby has lot many features/syntactic sugar and a weird OO model. Makes me feel quite uncomfortable. Also, no good IDE except RubyMine.
2 comments

The OO model is very clean. Pretty much Smalltalk's model. Wanna see weird OO, look at JS or even Python (both were not OO in first version).

IDE's will never be really good for Ruby (or any dynamically typed language), as it can only infer so much from the code. Type hints in the new Ruby version will maybe change this, but it is an addon so it may take a while to materialize.

Ruby is --to me-- a dynamically typed language with very clean OO, expressive syntax, and as much FP goodness as possible without sacrificing it's OO essence.

There is a language that has --in my view-- similar fundamentals, except that it is strict/strongly typed. This language is Kotlin: very clean OO, expressive syntax, and as much FP goodness as possible without sacrificing it's OO essence. IntelliJ is a great IDE for Kotlin and IDEs for Kotlin can actually deliver (due to the static typing). And yes, Kotlin is null-safe (no reason to carry this mistake around in static typed langs any further).

Oh and the syntactic sugar in Ruby is called cocaine. :)

> JS or even Python (both were not OO in first version)

This isn't true for Python. Quoting Guido: "classes were added late during Python’s first year of development at CWI, though well before the first public release" [0].

I don't think it's true for JS either - the first versions didn't have classes, but I believe they already had prototype-based OO.

[0] http://python-history.blogspot.com/2009/02/adding-support-fo...

I dont consider prototypes-based OO a real OO.

I thought Python had classes in the first release but not to be used by library/application makers. But I was probably mistaken. Thanks for setting that straight.

What I think is rather unidiomatic in OO langs is Pythons "function/methods" like `len(x)` which is implemented as `__length__()`. This is just weird/unintuitive/unidiomatic OO... I do not know what Guido was on when he thought this was a good idea.

> I dont consider prototypes-based OO a real OO.

Fair enough - in some ways it’s like half-way to an OO system. Yes, it’s theoretically elegant to have everything be an object and not to have classes. However in the vast majority of cases it seems prototype-based OO is only used as a foundation upon which to build a class system.

> What I think is rather unidiomatic in OO langs is Pythons "function/methods" like `len(x)` which is implemented as `__length__()`.

AFAIK the reason for the double-underscore method for `len` is to avoid it accidentally working for, say, a Rectangle class that exposes `length` and `width`.

Could you elaborate on the "weird OO model"? Is it the thing with eigenclasses?