Hacker News new | ask | show | jobs
by brudgers 3394 days ago
Some random internet remarks:

0. This looks like the why in 'why are there new languages?'

1. Objects are a place based abstraction that provides the ability to distinguish between 'this' and 'that' in the same way that two identically optioned BMW 325i's may be distinguished, e.g. mine and yours.

2. Immutability is a value based abstraction in which two identically optioned BMW's are fungible (e.g. mine and yours while they are sitting on the dealer's lot awaiting sale).

3. The simplest object like data structure is a hash/hash map/hash table. An immutable hash table can probably provide all of the semantics you describe.

4. There are lots of languages with immutable hash tables.

5. Ruby is one of them and:

   a. Ruby uses the . syntax.
   b. Everything in Ruby is an object.
   c. To a first approximation, any object in Ruby
      may have any of its methods over-ridden/shadowed/redefined
   d. The Ruby ecosystem supports writing new embedded languages,
      e.g. Rails.
   c. The downside is that, historically,
      a first class Windows experience has
      not been a priority of the Ruby community.
My random advice is to not get hung up on the dot syntax until it is clear that the semantics actually do what you want and therefore to mock up the semantics using hash-tables in a language that expects them to be immutable such as Clojure...hash-tables are more or less why Clojure does not have an object system.

Good luck.

1 comments

1. I get the difference you're talking about between an instance (identity based) and a value. My question is exactly about a value based oop language, more like 'Value Oriented Programming Language' with modelling and patterns similar to oop languages. C# has struct types, so does many languages which have mechanisms to disallow state mutation but they are all optional. You can pretty much do oop modelling with them all.

2. On Ruby, is it possible to have functions on hashtables, just like methods on objects? Is it possible to define a Person hashtable and a Car hashtable and type system pick up the difference? It would be a hack to code like that if idiomatic Ruby code is not built around hashtables.

3. I see your point not to get hung up on dot syntax, my question was out of curiosity. I do like object modelling and wished if I could continue with a paradigm I'm so familiar with without its warts (side effects).