Tuesday, March 24, 2009

Is Reia an object oriented language Joe Armstrong could actually like?

Short answer: no! Long answer: he might hate it less than the others.

Erlang creator Joe Armstrong is no fan of OOP. He says it sucks! Oof! As someone who is building an object oriented language on a platform pioneered by Joe, I feel I'm at least obligated to respond to his concerns. Due to its strong Erlang influences Reia's object system ends up working a lot different than most other OOP languages so in some ways this does address some of his concerns.

Let's look at them:

Objection 1: Data structure and functions should not be bound together

So first, a confession: Reia's "builtin" types (which I'll get to later) are guilty of this. So -1 on my Joe score.

However, Reia's objects are more than just data structures. This is certainly a complaint about OOP which holds for most languages: "object" is really a fancy word for "a big chunk of state" and sending an object a "message" is really some more high falloting verbeage for "making a function call". In this regard OOP ends up seeming pretty imperative: it's just a big fancy facade for calling functions which probe and mutate state.

Similar concerns were noted by Clojure author Rich Hickey in his article On State and Identity. He notes that in most languages objects don't have real identities beyond their state and that OOP at its core is very much an imperative affair.

In Reia, all objects are Erlang processes and operate concurrently. Each object has a life of it's own... it's not just some lifeless chunk of data sitting somewhere in RAM, completely at the mercy of whatever modifications some random thread may throw at it.

Calling a method is more than just a function call. It uses messages... not goofy metaphorical messages but real, first-class messages. Presently Reia's objects are built on gen_server, so invoking a method on an object performs an RPC on the remote object.

Self-ascribed OOP creator Alan Kay is practically obsessed with messages. He once wrote: "I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful)." What he began with messages in Smalltalk would eventually be boiled down to function calls in most successor OOP languages (with C++ being perhaps the most infamous example).

Reia does not follow in this tradition, but maintains a very message-centric view of OOP which is more akin to what Alan Kay originally had in mind. I've also read that Alan Kay has claimed that not making objects concurrent was one of his greatest mistakes, although I don't have a specific citation on that one (if someone knows please leave me a comment).

Erlang vis-a-vis the actor model and its outgrowth from Smalltalk certainly embodies similar concepts.

Objection 2: Everything has to be an object

Well, this is an easy one to answer: everything doesn't have to be an object! I'm sure any Rubyist readers are groaning on that one. Pretty much every language I see coming out of other Rubyists follows this paradigm. Reia doesn't.

Reia has three fundamental types of entities: builtins, processes, and objects. Objects can be thought of as a type of process, but all objects respond to a common base set of messages. Reia's objects can thus address a particular concern of Rich Hickey's about actor-based systems:
"You can't observe anything without its cooperation/coordination - making ad-hoc reporting or analysis impossible, instead forcing every actor to participate in each protocol."
Reia implements an inheritance system, which means that you can group the protocols that you want a given set of objects to respond to together into superclasses. All objects will, at the very minimum, respond to the set of methods defined in the Object superclass.

You can certainly do the same in Erlang by placing common functionality into a "superclass" module. Reia just gives it first-class syntax and does some of the thunking a bit more automatically.

Reia also provides processes, which are for all intents and purposes identical to Erlang processes. For some reason many OO purists have messaged me asking if this is necessary and suggesting I rip it out. Reia does provide asynchronous features as part of its object system... it has (or rather, will have) equivalents for gen_server:cast and gen_server:reply. Given this, they argue, who needs processes?

I think these people don't understand that gen_server is not a one-size-fits-all solution. Since I'm building a language on top of Erlang it would be silly not to expose the full power of its messaging system and try to force everything into gen_server-shaped boxes. Reia goes the opposite route and provides processes which are virtually identical to Erlang. Reia even has the same "!" syntax for sending messages, and it works on objects as well as processes.

Reia's builtin types are made out of plain old immutable Erlang terms. They are not objects themselves. With a little bit less "throw objects at the problem" they can serve to represent all kinds of things. My hope would be programmers use builtins more and objects less than they would in a typical OOP language.

Objection 3: In an OOPL data type definitions are spread out all over the place

Guilty as charged... take another point off my Joe score. Next!

Objection 4: Objects have private state

Also guilty. However, I hope Reia gets some bonus points in this regard for the way it implements its private state. Behind the scenes Reia's representation of "instance variables" is a pure functional one. The compiled form has the "instance variable" state (represented as a dict) enter a method (now a function) as an argument. The state is versioned throughout the compiled form, so wherever there is potential for change it's bound to a new label. When the method completes the final state is returned.

Because this state is represented in a pure functional form behind the scenes it means Reia retains some of the benefits it brings in Erlang. For example: private state is transactional, as the object's true state isn't actually updated until method dispatch has completed, in the same way a gen_server's state isn't updated until one of the handle callbacks has returned with the new state.

It also means the scope of private state is limited. Any cases I've encountered (such as lambdas) where I cannot implement state modifications in a simple, pure functional form I've avoided it. Lambdas are able to access the private state (which they close over at the time they're declared) but they are not allowed to modify it.

This approach has been more complex than alternatives like just giving the process dictionary a first class syntax. I could've done that. However, compiling to a pure functional form really helped me see the corner cases where the state was trying to creep into strange scopes. The current implementation has precise semantics about state flow and works in a way not too far distant from how an Erlang programmer would actually write it.

What's the point?

I think that question is pretty much the sentiment of Joe's article. Is OO actually useful? Given certain technical drawbacks (i.e. side effects) introduced by hidden state it becomes more difficult to make the same statements about a Reia object that you could about an Erlang gen_server (and destructive assignment doesn't help things). Is there actually some value objects bring to the table?

The merits of objects aren't technical, in my opinion. I think they're a good model for certain types of people to conceptualize problems. Lots of people really like them. Joe tried it and said it felt "wrong" but for many it does feel "right" in some way.

Fortunately, for the people who think it feels "wrong" there's this great language called Erlang you can use...

What does Joe Armstrong actually think about Reia?

I saw Joe Armstrong was asked about Reia in an Erlang Inside interview, here's what he had to say:
"I haven’t tried it - I don’t like mutable anything"
D'oh! Oh well. I'm afraid you won't be seeing a single-assignment Reia. I'll save that for another post, though.

70 comments:

  1. How about Reia - any thoughts about this language? It has mutable variables, among other things…

    JA: I haven’t tried it - I don’t like mutable anything

    http://www.planeterlang.org/en/planet/article/Erlang_Inside_Interviews_Joe_Armstrong/

    Ooops :)

    ReplyDelete
  2. While developing with Reia i felt i don't miss OOP at all.
    Everything i did can be re-made with pure module syntax using Hash as data.

    ReplyDelete
  3. Since I was the one who made that Alan Kay claim in the first place, I should probably follow up on that … I think it might have been somewhere inside this talk from Intel Research Berkeley's Programming Systems Seminar Series, titled Could Computing be simpler than it seems to be? (The STEPS Project towards the Reinvention of Computing). It's basically a progress report about the STEPS project by Alan Kay himself (the project is partially sponsored by Intel, IIRC).

    However, I'm not sure that this video is where I heard it. I'll keep looking.

    ReplyDelete
  4. The more pertinent question is whether Louis Armstrong would like it.

    ReplyDelete
  5. Hopefully I'll get around to hacking with Reia shortly. Erlang's vm is the dogs bollocks.

    ReplyDelete
  6. Tony, since you brought up Rich Hickey's essay on state, do you have any thoughts on the effects of 2-message blocking reads and the serialization of reads and writes on same-process efficiency and protocol design?

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Tony/Joerg,

    "I've also read that Alan Kay has claimed that not making objects concurrent was one of his greatest mistakes, although I don't have a specific citation on that one (if someone knows please leave me a comment)."

    According to Alan Kay, the key is messaging – not classes or objects. He regrets not implementing messaging in Smalltalk/Squeak as he intended. This is what he had to say about objects and messaging:

    Smalltalk is not only NOT its syntax or the class
    library, it is not even about classes. I'm sorry that I long ago coined the
    term "objects" for this topic because it gets many people to focus on the
    lesser idea.

    The big idea is "messaging" -- that is what the kernal of Smalltalk/Squeak
    is all about (and it's something that was never quite completed in our
    Xerox PARC phase).

    Read the complete email here:
    http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-October/017019.html
    Regards,
    Vijay Kandy

    P.S: The previous comment had some HTML formatting problems so, I deleted it.

    ReplyDelete
  9. Good and Interesting... thanks for sharing your views...


    Java Training in chennai

    ReplyDelete
  10. Hey, joe armstrong would like. MaxCure is one of best orthopedic hospitals in Hyderabad.

    ReplyDelete
  11. Interesting one. Keep up good work.
    At Queen's NRI Hospitals - Vishakapatnam Providing 360 degrees treatment for Heart Care .

    ReplyDelete
  12. Good article. Interesting. We are here to help all who are suffering from cancer diseases with
    Best Medicine for Cancers. Click on for Good Natural Remedy for Cancers.

    Thanks!!!

    ReplyDelete
  13. My rather long internet look up has at the end of the day been compensated with pleasant insight to talk about with my family and friends.

    java training in bangalore

    ReplyDelete
  14. This is a comprehensive and helpful list, about Health Care. Orthopedic Surgeon in Hyderabad

    ReplyDelete
  15. I really likes the way you articulate and express your point. Nice job java training in patna

    Tally courses in patna



    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.

    machine learning course fees in chennai
    machine learning training center in chennai
    machine learning with python course in chennai
    machine learning course in chennai

    ReplyDelete
  18. I am amzaed by the way you have explained things in this post. This post is quite interesting and i am looking forward to read more of your posts.
    redmi service center near me
    mi service center
    redmi service center
    xiaomi service centre chennai

    ReplyDelete
  19. مؤسسة مكافحة النمل الابيض بالدمام تقدم لكم بعض المميزات المخصصة بمبيد بايفلكس :
    يُعد مبيد بايفلكس هو المبيد الافضل لإبادة النمل الابيض وهذا لأنه متدني السمية للأشخاص .شركة مكافحة حشرات بسكاكا
    شركة رش مبيدات بسكاكا
    المبيدات الحشرية الكيميائية
    افضل شركة مكافحة حشرات

    ReplyDelete
  20. I Got Job in my dream company with decent 12 Lacks Per Annum salary, I have learned this world most demanding course out there in the current IT Market from the big data training in bangalore Providers who helped me a lot to achieve my dreams comes true. Really worth trying Freelance seo expert in bangalore

    ReplyDelete
  21. This post was very interesting and informative. thanks a lot for sharing such great article.best gynecologist doctors in guntur

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete
  23. It's invigorating to discover such unique substance in an in any case duplicate feline world. Much obliged to you to such an extent.
    SAP training in Kolkata
    Best SAP training in Kolkata
    SAP training institute in Kolkata

    ReplyDelete
  24. If people that form articles considered making staggering material like you, more perusers would scrutinize their substance.
    SAP training in Mumbai
    Data Science training in Mumbai
    Best data science training in Mumbai

    ReplyDelete
  25. Never enough about knowledge
    hoyajackpot
    poker88
    hoyajackpot
    Education is very good and many knowledge

    ReplyDelete
  26. I very Exciting for each and every visit of your site...Thanks for such a interesting Articles about Education,Big Thumbs up for your Efforts.
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete
  27. حامد همایون
    I very Exciting for each and every visit of your site...Thanks for such a interesting Articles about Education,Big Thumbs up for your Efforts.
    بهنام بانی

    ReplyDelete
  28. Play online casino at 928bet ​​website, new members receive a 50% bonus immediately. Live casino system is very good.

    ReplyDelete
  29. These techniques can fix the HP Envy 4500 Error Code oxc4eb827f for you: power resetting, impairing the firewall, or utilizing the printer investigator.

    ReplyDelete
  30. The way you have explained is very good. keep posting also check Best Hospitals in Aurangabad

    ReplyDelete
  31. Marketing and Communications are on great demand. If you want to get your dream job in this field, then come to Talentedge. It provides you with the best source to find marketing and communication courses. Visit here for details

    ReplyDelete
  32. Semarang sekarang memiliki simbol tujuan rekreasi baru. Semenjak trending akhir 2019 lalu, Dusun Semilir Ecopark semakin ramai didatangi oleh kami. Tempat rekreasi ini ada di Kecamatan Ngempe dan Kecamatan Bawen, Kabupaten Semarang, Jawa Tengah. https://jelajah-indonesia.net/ Kekhasan bangunan yang lain dibandingkan rekreasi lain yang pantas untuk didatangi waktu berlibur datang.

    Bangunan di sini berupa stupa Candi Borobudur yang memiliki 2 lantai. Lantai pertama adalah pusat oleh-olehan, sewaktu-waktu lantai ke-2 adalah tempat makan. Tidak itu saja, Dusun Semilir mengangkat ide perdesaan yang asri.

    ReplyDelete
  33. You can live a happy and fulfilled life in Chandigarh and still feel the beauty and charm of Chandigarh. Escort Must Hire Chandigarh will help you do just that. It will be a memorable and unforgettable experience.
    ESCG News Of Independent escorts In Chandigarh

    ReplyDelete
  34. If you are having a tough time dealing with your academic tasks, don’t overthink. Just go ahead and hire an expert who suits your requirement. You can find professionals offering their services at affordable charges easily. So, money will never act as a barrier to the academic online assignment help you need. Try it for once and then decide how it worked for you.

    ReplyDelete
  35. Haldiram Franchise is a well-established sweet and savory brand and becoming a franchisee of Haldiram would be a golden opportunity for all those who are interested to start a Haldiram franchise in India. The brand Haldiram is popular in more than 23 countries apart from India.

    haldiram franchise

    dabur franchise

    ReplyDelete
  36. Thanks for sharing this nice blog!I have go through all the content of this blog.This is really helpful and informative for me and all the readers.We are offering an online Dissertation Data Analysis Help at a cheap price.

    ReplyDelete
  37. Really this article is truly one of the best in article history and am a collector of old "items" and sometimes read new items if i find them interesting which is one that I found quite fascinating and should be part of my collection. Very good work!
    Data Scientist Course in Gurgaon

    ReplyDelete
  38. If you are a student and you have no time to prepare for your online exam. then don't get panic and no need to go anywhere just click Online exam help in uk. we will provide you with the best quality exam help buy now this service at an affordable price.

    ReplyDelete
  39. Pinoy station by Pinoyflix is a free stage where you can see free TV projects without a doubt.

    ReplyDelete
  40. C and C# are two most prominent languages from the ages and everyone is confused that which one is best and for that I have written the article which will clear your mind in selecting the best from these two languages so it must read article for you if you are beginner and looking for starting the career into these languages.Click here and check out the article of difference between C and C#

    ReplyDelete
  41. Why on body told me about this blog before? I rellay love your posts. Thank you. Such amazing information. I am Jennifer, I like go shopping at crystal stores near me with my friends at weekend.

    ReplyDelete
  42. Sense of Beauty by Cecilie Mikkelsen ble startet opp i mars 2019 da jeg hadde studert estetisk injeksjonssykepleie på Amabilis academy. I noen år har jeg arbeidet i klinikk som
    Visit here :- LingaDore

    ReplyDelete
  43. RAYNA INDUSTRIES incorporated in the year 2013 and ISO 9001:2008 Certified organization is a pioneer in the field of LED based Lighting Systems and has been engaged in manufacturing and exporting of LED based Lighting Systems. Click here :-100w flood light

    ReplyDelete
  44. Founded in 2018, Adventure Mania is one of the most trusted travel partner in India. It has around 4.8 rating on google (as of June 2022). We cater to all type of travel enthusiast across the globe.
    Visit here :- rajasthan trip package

    ReplyDelete
  45. I am Mohua, the food blogger. Cooking is my passion. I love learning new recipes and experiment them to make a new and unique dishes. I believe if you have a tasty food, your mood will be good.
    I have learnt many old recipes from my mother and grandmother and have given those recipes a modern touch. Anything we do by our heart always gives a positive result.
    Now a days I am looking forward to many new recipes from food articles, and recipe books of my grandmother. I have also found many new tricks and techniques by which you can prepare delicious recipes very easily. Here I am going to share all the things I have learnt. Hope you all will also enjoy this technique of cooking those recipes. Come again and again to learn more unique techniques and recipes.

    Visit here curd calories 1 cup

    ReplyDelete
  46. I really likes the way you articulate and express your point

    click here :- tourist visa

    ReplyDelete
  47. thank you for this useful informations amd i found something is interesting here. plz visit here :- car rental in coimbatore

    ReplyDelete
  48. I find the information in this post to be very valuable. If you need help with your dissertation, dissertation expert are available to help. Thanks to their suggestions and assistance, your dissertation will be of a standard that beyond your expectations. I would definitely advise you to use their services if you wish to succeed academically as a student.

    ReplyDelete
  49. This comment has been removed by the author.

    ReplyDelete

  50. Hii
    Thank you for this excellent post. I always appreciate high-quality content, and your post is truly superb. The ideas presented are fantastic, and the content provides valuable information in various forms.Here is sharing some Python Certification Training journey information may be its helpful to you.
    Python Certification Training

    ReplyDelete
  51. When it comes to garage door repair in Howard County, trust the experts at Howard county garage door repair. We are a locally owned and operated company with years of experience serving the community. Our technicians are highly trained and certified, and we only use high-quality parts and materials for all our repairs.

    We understand that a malfunctioning garage door can be a major inconvenience, which is why we offer prompt and reliable service to get your door back on track as quickly as possible. Don't let a broken garage door disrupt your daily routine - contact us today for all your garage door repair needs.

    ReplyDelete
  52. The team at Marketing management assignment help truly understands the complexities of the subject matter. Their in-depth knowledge and practical insights helped me gain a better understanding of marketing management concepts, which I could apply to future projects and in my professional career.

    ReplyDelete

  53. Reia’s unique approach, influenced by Erlang, offers an alternative to traditional object-oriented programming (OOP), potentially addressing Joe Armstrong's concerns. Just as Reia simplifies complex programming concepts, seeking cheap assignment help can help students break down difficult topics into more manageable, understandable parts.

    ReplyDelete
  54. Trusted Law Assignment help offering reliable, high-quality, and plagiarism-free academic content for students tackling challenging legal topics.

    ReplyDelete
  55. Expert-crafted Law Assignment Help ensuring academic success with original, accurate, and thoroughly researched solutions tailored for students.

    ReplyDelete
  56. Comprehensive Assignment Help Ireland provides expert-written, plagiarism-free, and well-structured content to meet students’ academic requirements effectively.

    ReplyDelete
  57. Reia, while embracing object-oriented principles, introduces some unique concepts that may appeal to those who appreciate Erlang's strengths, such as its focus on concurrency and fault tolerance. Unlike traditional OOP languages, Reia offers a flexible approach that could potentially resonate with Armstrong's emphasis on simplicity, scalability, and reliability in distributed systems.
    abogado tráfico dinwiddie va
    abogado transito brunswick va

    ReplyDelete