On Fri, 1 Jan 2010, Adrian Kuhn wrote:
> Levente Uzonyi <le...@...> writes:
>
>>> Personally, I would love to have a #gsub:with: on String. It is short and
>>> uses established vocabulary.
>>
>> Please no, smalltalk is not awk or ruby and noone should expect that
>> these cryptic function names are well known. Message names should be
>> as descriptive as possible, this enables understanding the code without
>> documentation. Short message names have no advantage, we are not in the
>> 80's.
>
> I dare to disagree :)
>
> Growing a language *and* compressing it.
>
> There is two directions for natural growth of a language. Composing complex
> expressions from simple ones (see Guy Steele's classic OOPSLA keynote) *and*
> shortening the name of often the most common operations. The latter is clearly
> something that should happen overtime as an evolutionary process and not up
> front. Akira Tanaka refers to this as the "huffman coding" of API design. I
Why didn't it happen to smalltalk? I guess because the language tries to
mimic natural languages. Btw I can't come up with a language that changed
it's core library function names to shorter ones.
> have written about that on my blog [1].
I read your blog post and I think that your suggestions are not generally
useful. In smalltalk where you can print, inspect and explore any object
Object >> #p is not really useful. Logging to Transcript is a bad
practice anyway.
Object >> #h instead of #halt? You must be kidding. Saving 3 letters when
you have code completion?
List = OrderedCollection? List new ===> an OrderedCollection() ?
Which is more readable?
List new << 'Lorem' << 'ipsum' << 'dolor'
vs
{ 'Lorem'. 'ipsum'. 'dolor' }
'Expected <1p> but got <2p> (using <3s>)' e: value e: expected e: symbol
vs
'Expected <1p> but got <2p> (using <3s>)' expandMacrosWithArguments: {
value. expected. symbol }
'Regex are aaaaaaaaaawesome!' =~ 'a*wesome'r
vs
'Regex are aaaaaaaaaawesome!' matchesRegex: 'a*wesome'
(Most of the time I use #format: instead of #expandMacros* and never
seen any code using #expandMacros* that wasn't written by me, your code
is the first. Possibly because it has no documentation/examples.)
>
> So method names should initially be as descriptive as possible, but often used
> method names should get a short alias. In 80 when Smalltalk was fresh,
> #copyReplaceAll:with: was a revolutionary short "huffman encoding" for like 20
> lines of C (or worse) code. Smalltalk was visionary in using long method names
#copyReplaceAll:with: is just a library method, a C library could have a
similar function, but C libraries can't be explored like smalltalk
libraries. In C you have to look up the docs or google a bit to find a
function that fits your needs. In smalltalk you can browse the class
hierarchy or in squeak/pharo you can use the MethodFinder besides the docs
and the internet.
> in the 80ies, but to each anti-thesis there is a synthesis. Today we are 30
> years later, and "gsub" has established itself as a generally known name for
> replacing all occurrences of a pattern in a string. IMHO it has evolved from
People familiar with awk or ruby will know what gsub does but others won't.
Levente
> what once used to be a cryptic function name to a proper programming term of
> its own.
>
> We can think of other mebbe more Smalltalkesque huffman codings also, eg
>
> 'foobarqux' at: 'bar' put: 'XYZ'.
>
> with a double dispatch on the parameter of the #at: keyword, this would even
> open up the API of String for unlimited extensions by clients without
> cluttering it with dozens of new messages. So you could use integers, strings,
> regeces, et cetera...
>
> Well, just brainstorming :)
>
> --AA
>
>
> [1]: http://www.iam.unibe.ch/~akuhn/blog/2009/one-letter-method-names/
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project