(a) drawRect(50, 50, 10, 21)
(b) aRect drawAtX: 50 andY: 50 width: 10 height: 21
(a) drawRect(50, 50, 10, 21)
(b) aRect drawAtX: 50 andY: 50 width: 10 height: 21
But having gone from c++ to Ruby to C++, I think the benefits of this expressiveness may not really be there.
This construction makes each line of the whole program that much longer, it asks that every functions arguments be meaningful outside the context of the function as well as within. Basically, this syntax may show you that certain calls are wrong but there are many other calls it won't prevent and it gives you larger amount of code to page through to find those other errors.
Remember, a good program wouldn't be using 10 as a function input except if there was some reason it's meaning was clear. And a rect would take two points rather than four ambiguous ints.
So what you can have is drawRect(Pt(screenLeft, screenTop), Pt(screenRight, screenBottom) if you want a rect covering the screen and you want expressiveness.
drawRectOrigin: 50@50 extent: 10@21.
drawRectOrigin: 50@50 corner: 60@71.
If you really wanted, on class Point you could define method ',' with parameter 'otherPoint' as follows... , otherPoint
^ Rectangle origin: self corner: otherPoint.
then you could do draw rectangles like this... drawRect: (50@50),(60@71).
drawRect: (screenLeft@screenTop),(screenRight@screenBottom). aRect.Draw(x:50, y:50, width:10, height:21);So with that (mis)feature, eliding commas would make a lot of code harder to reader.
Not really. Lisps get by without them and it doesn't have formal keyword parameters.
Foo(from n in range select n * n into: from n in range where n % 2 == 0 select n) aRect.Draw({x:50, y:50, width:10, height:21}) enumerateObjectsUsingBlock: aBlock
to Smalltalk's do: aBlock
or NSDictionary's objectForKey: aKey
to Smalltalk's at: aKeyI think the majority of Objective-C's verbose conventions are artifacts of the Frankenstein type system — for example, having two methods with the same selector but different signatures will cause any use of either method with an id type to emit warnings, and possibly to generate incorrect code if the types are not compatible. So in order to avoid these awkward situations, Objective-C prefers to be as explicit as possible about what it's getting and giving. (Case in point: The extra verbosity in the examples you gave is almost entirely caused by adding nouns.)
It's sort of weird to me that so much effort goes into making programming languages expressive, yet we cling to incredibly terse method names, sometimes too terse, and no labels on method inputs. So, if you don't know what some bit of code does, you have to figure out what the methods are doing and what arguments they are supposed to take.
I guess to me it's like if you had to do a dictionary lookup for every word you read and had minimal context to understand a words meaning in the context of the other words around it. At the very least you would cling to a dictionary if you wanted to get anything done.
I find it faster to read since I don't have to glance at API docs at the same time.