Every programming language I’m familiar with provides some kind of
syntax for literal values of “primitive” types like numbers,
characters, and strings. Many languages go further and allow you to
create literal values of more complex types, like arrays and hashes.
Of the three languages I use the most, C++98 is the most limited in
Smalltalk is also somewhat limited:
Ruby fares much better:
C++11’s new uniform initialization mechanism is much better than
Because of C++11’s explicit types, we can even go one step further.
It is possible to use uniform initialization to create temporary
objects to pass to a method or function:
Each of these languages provides different affordances for working
with simple collection and object types. These affordances impact the
kind of code you choose to write in those languages. Smalltalk’s
relatively verbose syntax drives different solutions than Ruby’s more
Which is better? I’m torn. I like the cleanliness of Ruby’s rich
affordances a lot. It results in cleaner-looking code. I haven’t
worked with C++11 much yet, but I expect I will like uniform
initialization a lot as I start to work with it more. Smalltalk’s
lack of affordances in this area sometimes frustrates me.
On the other hand, I think these affordances make it easier to fall
into the trap of
Smalltalk’s more verbose syntax drives me to look for solutions that
involve domain concepts rather than built-in basic types.