Saturday, June 5, 2010

Reia: Immutable objects at last!

When I started creating Reia, I was originally skeptical of the "everything is an object" concept seen in languages like Smalltalk and Ruby.  This was partially inspired by Erlang creator Joe Armstrong's hatred of object oriented programming.  However, the more I used Erlang and increasingly saw Erlang's solutions for state encapsulation like records and parameterized modules as increasingly inadequate, the more I looked to objects to provide a solution.

Moments ago I committed the remaining code needed to support instance variables within Reia's immutable objects.  You can view an example of Reia's immutable objects in action.  If you're familiar with Ruby, you'll hopefully have little trouble reading this code:

>> class Foo; def initialize(value); @value = value; end; def value; @value; end; end
=> Foo
>> obj = Foo(42)
=> #<Foo @value=42>
>> obj.value()
=> 42

One caveat: Reia uses Python-style class instantiation syntax, i.e. Foo(42).  Rubyists should read this as

So what are immutable objects, exactly?  They work much like the traditional objects you're used to using in Ruby.  Howevever, unlike Ruby, Reia is an immutable state language.  This means once you create an object, you cannot modify it.  The constructor method, which borrows the name "initialize" from Ruby, has the special ability to bind instance variables within a particular object, however once that initialize method completes and the object is created, no changes can be made.  If you want to modify the instance variables, you'll have to create a new object.

Reia will eventually support objects whose state is allowed to change.  These will take the form of concurrent objects, which is the original design goal I had in mind with Reia.  Mutable objects take the form of Erlang processes, and more specifically Erlang/OTP gen_servers, which do not share any state with other concurrent objects and communicate only with Erlang messages.  Going forward, my goal is to make all of the Reia built-in types into immutable objects, allowing user-defined immutable objects, and also allowing concurrent objects whose state can change (albeit in a purely functional manner).

If you've been following me so far, I hope you can sense how concurrency affects Reia's state management model:
  • Sequential objects have immutable instance variables
  • Concurrent objects will have mutable instance variables
This is similar to the state management compromise Rich Hickey chose in the Clojure language.  In Clojure, by default all state is immutable.  However, Clojure employs Software Transactional Memory for concurrency, and inside of Clojure's STM transactions (i.e. where concurrency enters the picture) state becomes mutable.

There's still a lot to be implemented in Reia's object model.  I intend to support polymorphism through simple class-based inheritance, and the code needed to support that is partially in place.  I'd like to support Ruby-style mix-ins.  Once these features are all in place, I intend to completely rewrite the core types, reimplementing them all as immutable objects.

All that said, if you're interested in Reia and would like to start hacking on it, Reia could really use a standard library of objects, and the requisite code is now in place to facilitate that.  I would encourage anyone with an interest in Reia to clone it on github and start implementing the standard library features you will like.  The standard library needs all sorts of things, particularly wrappers for things like files, sockets, ETS tables, and other things which are already provided by the Erlang standard library.

Don't worry too much about making mistakes.  Just send me a pull request and I'll incorporate your code, review it, and make changes where I see issues.  I'd like to prevent the standard library from snowballing into the monster the Ruby standard library is presently, so if you have a feature you'd like to see incorporated, ping me on it (through github is fine) and I'll let you know if I think it should be incorporated.

I'm actively trying to recruit the open source community to build Reia's standard library, so if you're interested, start hacking!


Knodi said...

amazing, cant wait to use it.

jbaker said...

I've tried to get it running on Windows several times, but to no avail. Great work though!

قمم التميز said...

شركة عزل اسطح
شركة كشف تسربات المياه بالرياض
خدمات عزل الاسطح من الخدمات التى فى حاجة الية فى المكان فاذا اراد ان تقوم باعمال العزل لاى اسطح فى المصانع – المنازل – الفلل ... وغيرها وتبحث عن افضل الخدمات التى تساعد فى الوصول الى افضل ما تتمنى ان ترى علية النتائج فعليك ان تتعاون مع شركة قمم التميز التى تحقق اعلى مستوى من العزل بالاعتماد على افضل المواد المخصصة فى القيام باعمال العزل والتى استطاعت ان تتاكد ان اعمال العزل التى تتم بالخيش المقطرن والسيلتون من افضل الخدمات المثالية المميزة التى تحقق اعلى مستوى من العزل دون ان يؤدى الى ظهور اى عيب فى اعمال العزل . كشف تسربات المياه
لا تكتفى شركة قمم التميز بالقيام باعمال العزل فى منطقة معينة بل تسعى الى الوصول الى اى مكان فى شرق الرياض – جنوب الرياض – غرب الرياض – وسط الرياض من اجل ان تحقق خدمات العزل لجميع عملاء الشركة الكرام . كشف تسربات المياه بالرياض
تهتم شركة عزل اسطح بالقيام باعمال العزل الحرارى من خلال الاعتماد على افضل الطرق المثالية وافضل الخدمات المميزة فى القيام باعمال العزل بالاضافة الى ان الشركة تهتم باعمال الكشف الدورى من فترة الى اخرى من اجل ان يتم التحقق ان اعمال العزل تمت كما هو مطلوب فى المكان . شركة كشف تسربات بالرياض
كشف تسربات المياه
كشف تسربات المياه شرق الرياض
تسربات المياه مشكلة تؤدى الى التعرض الى عدد من المشكلات الاخرى ، فالاهمال فى تسربات المياه يؤدى الى التعرض الى الكثير من المشكلات التى نحن فى غنى عنة فاذا تعرض الى التسربات وتعرضت الى ظهور عدد من المشكلات الاخرى مثل سقوط الدهانات والتعرض الى مشاكل الرطوبة فعليك ان تتواصل وتتعاقد مع شركة قمم التميز المخصصه فى اعمال الكشف عن تسربات المياه والتى تحقق افضل ما تتمنى ان ترى علية المكان من خلال القيام بالاتى :- كشف تسربات المياه غرب الرياض
1- الاهتمام باحدث الاجهزة المخصصة فى اعمال الكشف وبالاضافة الى التعرف على اساليب الكشف التى تتلائم مع مكان التسرب .
2- الاعتماد على العمالة المدربة الكاملة التى تحقق افضل مستوى من النتائج من خدمات التنظيف والكشف والاصلاح والتى تحقق افضل ما تتمنى ان ترى علية المكان .
3- الاهتمام بخدمات التنظيف بعد ان تتم اعمال الاصلاح .
كشف تسربات المياه غرب الرياض

اذا اراد ان تقوم باعمال الاصلاح والتخلص من التسربات المتواجدة فى المكان بالاضافة الى البحث عن الاسباب التى ادتت الى التعرض الى تلك المشكلة حتى لا تحدث مرة اخرى فعليك ان تتعاون مع شركة قمم التميز المتخصصة فى اعمال كشف تسربات المياه شمال الرياض
عن تسربات المياه والتخلص من مشاكل التسربات .

shina said...

cctv camera for home
Pestveda | Pest Control
Termite control
Surveillancekart | CCTV System
cctv installation services
best home security camera system

mariablack said...

Pc Optimization
Windows Installation
Data Recovery

shabnam praveen said...

Call girls in Kolkata
Call girls in Chandigarh
Call girls in Chandigarh
Call girls in Gurgaon
Call girls in Chandigarh
Call girls in Chandigarh

shabnam praveen said...

Call girls in Lucknow
Call girls in Guwahati
Call girls in Mumbai
Call girls in Jaipur
Call girls in Jaipur
Call girls in Jaipur
Call girls in Bangalore

anosh said...

شراء الاثاث المستعمل بالرياض
شراء الاثاث المستعمل بجدة
شراء الاثاث المستعمل بالمدينة المنورة ومعلومات عن تنظيف الاثاث
نخصص في شركتنا لبيع الاثاث المستعمل ارقام خاصة يمكنكم الاتصال بها وطلب اى نوع من انواع الاثاث التي تريدها ونحن نهتم بتوصيلها اليكم اينما كنتم ويفضل للحفاظ على اثاث منزلك تنظيفه بشكل مستمر والتنظيف يكون كامل وذلك لجعل المنزل مرتب ومنظم ونظيف من اى اتربه او اوساخ كما يمكنك صنع المنظفات فى منزلك لتوفر عليك المال والجهد لكى تحصل على منظف مناسب لك وذلك بوضع كوب من زيت الزيتون وكوب من عصير الليمون فى بخاخة مع رجهم جيدا ويتستخدميها فى رش الخليط فوق الاثاث مع مسحة بقماشة من القطن ويجب ان تلاحظى ان المنظفات التى تستخدم للزجاج لا تستخدم لتلميع الزجاج فكل نوع اثاث له المنظف الخاص به ويحتاج اثاث المنزل لكى يكون لامعا دائما الى تنظيفه يوميا وذلك باستخدام قماشة قطنية لتلميع الاثاث و جهاز شفط الاتربة
شراء الاثاث المستعمل بالرياض
شراء الاثاث المستعمل بالمدينة المنورة
كيف تمنع دخول الاتربة الى منزلك والتصاقها بالاثاث
لكى تقومى بمنع دخول اى تراب الى المنزل الذى قد يلتصق بالاثاث قومى بعمل هذة الخطوات وهى : -
شراء الاثاث المستعمل بجدة
1. قومى باستخدام قطعة من القماش مبللة وضعيها بعد الانتهاء من تنظيف المنزل فى الفتحات الخارجية لباب الشقة واخرى بين شيش الشبابيك والزجاج لكى تمنع دخول الاتربة لها
2. يجب ان تقومى بتنظيف المنزل وشبابيك المنزل جميعها نفتوحة وبعدها تقومى بغلقها جيدأ و غلق الستائر
3. يجب ان يكون للمنزل أخذية غير التى يتم استخدامها للخروج حتى لا يتم احضار الاتربة من الخارج للمنزل
اتصل الان شراء الاثاث المستعمل بجدة للمزيد من الاستفسار عن خدماتنا المميزة ليبيع وشراء الاثاث المستعمل

Juliana Kho said...

cara daftar sabung ayam s128
cbet judi online
login osg777

daftar joker123 slot online

lymacsau said...

Great post, thanks for sharing!

Hương Lâm với website chuyên cung cấp máy photocopy toshiba cũ và dòng máy máy photocopy ricoh cũ uy tín, giá rẻ nhất TP.HCM

dadyar said...

Maybe this site will also help you

Mirty Birds said...

Hey Thanks for Sharing here is my site Ganesh Gaitonde

Nannie Co Pam said...

IEEE Project Domain management in software engineering is distinct from traditional project deveopment in that software projects have a unique lifecycle process that requires multiple rounds of testing, updating, and faculty feedback. A IEEE Domain project Final Year Projects for CSE system development life cycle is essentially a phased project model that defines the organizational constraints of a large-scale systems project. The methods used in a IEEE DOmain Project systems development life cycle strategy Project Centers in Chennai For CSE provide clearly defined phases of work to plan, design, test, deploy, and maintain information systems.

This is enough for me. I want to write software that anyone can use, and virtually everyone who has an internet connected device with a screen can use apps written in JavaScript. JavaScript Training in Chennai JavaScript was used for little more than mouse hover animations and little calculations to make static websites feel more interactive. Let’s assume 90% of all websites using JavaScript use it in a trivial way. That still leaves 150 million substantial JavaScript Training in Chennai JavaScript applications.

Jatinbis said...

Got these Buzz Hippy

steve said...

تنظيف منازل بالدمام تنظيف منازل بالدمام
تنظيف منازل بالاحساء تنظيف منازل بالاحساء
تنظيف منازل بمكة تنظيف منازل بمكة
تنظيف منازل بجدة تنظيف منازل بجدة
تنظيف منازل بالمدينة المنورة تنظيف منازل بالمدينة المنورة

Susan said...

Im thankful for the blog article.Much thanks again. Really Great. Pikdo is an Instagram Online Viewer that you can easily browse users, location, followers, hashtags, popular contents, statistics and much more.

gyaan said...

Each of the women associated with our agency is strictly professional when it comes to rendering her services to her clients.Female Escorts in Aerocityhere at our escort agency make sure that their talents are such that they will never fall short of giving the best of services to their clients. Check our other Services...
Female Escorts in Aerocity
Female Escorts in Aerocity
Female Escorts in Aerocity
Female Escorts in Aerocity
Female Escorts in Aerocity

customized gifts for him said...

linen cushion covers uk
geometric pillow colorful
pillow of solid rock

niramay said...

IDNPlay DominoBet Domino99 AudiDomino said...

Dominobet raih kejayaan anda dengan tangan keberuntunganmu
Domino99 bermain melalui pc dan mobile dengan lancar tanpa kendala
AudiDomino IDNPlay uang asli, live time dan bertarung lawan pemain judi online asli lainnya

RobertDeLong said...

Looking for the Best LED Monitor Under 10000?
We at NiamIndia covers best gaming monitor under 10000 including the Buying Guide of the product.

Mom is Love said...


Priya Chakraborty said...

Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well.
FMWhatsApp APK

Jitendra said...

I am professional Gamer working for Foriza Horizon as a Senior Consultant. i love to play games on Tablet. Here is the Best Motherboard for i9 9900K for PC.

Jitendra said...

I am professional Gamer working for Foriza Horizon as a Senior Consultant. i love to Play Games on my PC. Here is my Blog How to Solve Netflix Error Code UI 800 3.

kate said...

Are you looking for the
Top Rated Bluetooth Headphones.
Top Rated Bluetooth Headphones under 300
After reviewing and testing multiple headphones we have curated a list of the 7 best bluetooth headphones under 300 that you should consider in 2020.Let’s look at the 7 best bluetooth headphones under 300.


I am an Interior Designer by Profession. I love to listen to music. Here is my Blog about

Best Affordable Audiophile Headphones.


I am an Interior Designer by Profession. I love to listen to music. Here is my Blog about

Best Affordable Audiophile Headphones.

Antonio said...
This comment has been removed by the author.
Antonio said...

This is amazing site for Gloves and Clothes.

Antonio said...

It is a website which offers 8 ball pool coins,

Antonio said...

You shared a very nice piece of information

Steven Salvatore said...

where is the wps pin on my hp printer WPS Pin stands for the “Wi-Fi Protected Setup”, it is a 8 digit number that is generated by HP printer for wireless connection with routers.

Insta Follower said...

Hi! I simply would like to give you a big thumbs up for the great info you have got here on this post. I will be returning to your website for more soon.

Visit on this: Buy Instagram Video Views

Unknown said...

Hi. Its Impressive. Instagram is Very Platform For Using.

Aerocity Service said...

Paharganj Escorts
Dwarka Escorts
Russian Escorts Noida
Russian Escorts Delhi
Karol Bagh escorts
Delhi Escorts Service
Escorts in Delhi
Call girls in Delhi
Delhi escort
Aerocity Escorts

Ana Watson said...

Thanks for sharing this post, it was very impressive and helpful. Waiting for your new post. Also checkout Nulls Clash.

Escorts Service Kolkata said...


Shahid Ali said...

Compress PDF
Compress MP4
Famous Converter