Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

  (email not shown publicly)

I work for MessageLabs [] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Sunday September 08, 2002
11:05 AM


[ #7603 ]

This week I'm trying to learn objective C. It's quite a nice language, with reference counted garbage collection (albeit manual reference counting), and fairly loose typing (compared to C++ or Java that is).

The syntax is rather strange though. I think that's the most offputting thing about the language. To call a method on an object, it looks something like:

[myobject method]

But then if there's a parameter to go into the method, it has a colon in it:

[myobject doSomethingWith:anotherobj]

It's also got some named parameters stuff, so you can have:

[foo insertObject:bar atIndex:5]

Note that the first parameter is bar, but it's almost not a named parameter. This is interesting because I use this kind of call style in Perl a lot, where I'd do:

$self->method($param, %options);

Which seems to be pretty much the same thing, except Objective-C has it built into the language, and comes with parameter checking.

Anyway, I'll post more as I code up more interesting things.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Smalltalk:

    anArray insert: anObject at: 5

    Objectionable C:

    [array insertObject: object at: 5]

    Quite cute really. Makes it a lot easier to use simple type suggesting variable names 'cos they're not having to do double duty to describe what they're for as well as what they are.
    • I don't understand your final point about variable names. Could you expand on it?

      Someone once suggested to me it was nice that Obj-C was nice because it showed you very clearly what parts were method calls, and what parts were just regular C code. I'm not sold on that yet, as I don't really have a problem with that in other languages. But my mind is open on it, and the OS X tools are nice enough that it won't sway me either way.
      • Consider a Smalltalk method declaration

        OrderedCollection at: anInteger put: anObject

        The method selector tells you what each argument is for, the parameter name tells you what it is. Actually, good Smalltalk style is to only use type suggesting variable names for method argument names. The method body that I lifted the above from, for instance, continues:

          | index |
          index := anInteger asInteger.

        | index | is Smalltalk for my $index. Note that there's an assumption in the implementation that th

  • You may be interested in looking at his wiki on RubyGarden.