Re:Ask HN: Any OOP language which enforces / encourages puri...
by nawfalhasan on Monday March 06, 2017 @10:36PM
(#13808088)
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).
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:
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.