Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Programming Apple

Objective-C Comes of Age 437

New submitter IdleThoughts writes "Sometimes it takes a long time to spark a revolution. Long the ugly duckling of programming languages, iOS' Objective-C passed C# in the 'TIOBE Programming Community Index this month and seems on a trajectory to overtake C++ in the next few. It was invented in the early 1980s by Brad Cox and Tom Love, with the idea of creating 'Software Integrated Circuits' and heavily influenced by Smalltalk — yet another legacy from Xerox PARC, along with desktop GUIs, ethernet and laser printers. It was adopted early on by Steve Jobs' NeXTStep, the grand-daddy of all that is now OS X. It had to wait, however, for the mobile device revolution to have its day, being ideally suited to the limited resources on portable devices. It's still being actively developed by Apple and others, sporting the new automatic reference counting and static analysis in the Clang compiler. It turns out it has supported dynamic patching of code in applications all along. What more surprises does this venerable language have up its sleeve?"
This discussion has been archived. No new comments can be posted.

Objective-C Comes of Age

Comments Filter:
  • New features (Score:5, Informative)

    by bonch ( 38532 ) * on Friday May 11, 2012 @01:43PM (#39969463)

    What more surprises does this venerable language have up its sleeve?

    Clang recently added literal syntax for collections and boxed numbers:

    // Old way.
    NSArray *array = [NSArray arrayWithObjects:@"one", @"two", @"three", nil];
    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
                                                @"bar", @"foo",
                                                @"post", @"first",
                                                nil];
    NSNumber *num = [NSNumber numberWithInteger:42]; // New way.
    NSArray *array = @[ @"one", @"two", @"three" ];
    NSDictionary *dict = @{
                                                  @"foo" : @"bar",
                                                  @"first": @"post"
                                                };
    NSNumber *num = @42;

    Properties will also be synthesized by default, so you won't have to write @synthesize statements anymore, and corresponding ivars will be synthesized with an underscore prefixed name.

    Objective-C is interesting to follow because it's a language that was once considered totally niche and almost completely irrelevant, but the frameworks were beloved by developers, and the language's keepers kept at it long enough for the world to see how useful the language is. It also has historical significance as the tools used for creation of the original WorldWideWeb program as well as the development of Doom and Quake. John Romero wrote [rome.ro] about he and Carmack simultaneously editing the same map in DoomEd thanks to distributed objects.

    It's still verbose and Smalltalk-ish, but the language as a whole has improved drastically since the transition to Clang. According to the mailing list, Apple has more engineers allocated to the language than ever before, and a lot of it has to do with the move away from GCC.

    I hear that GCC is working toward being easier to modify, so the competition from Clang has been good for everybody, and it's all open source.

    • "Clang recently added literal syntax for collections and boxed numbers"

      Oh thank your deity. Long overdue IMHO.

    • by Yold ( 473518 )

      It's still too verbose

      Fixed that for you. For the uninitiated, trimming a string is as simple as

      NSString *s = [stringToTrim stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet]];

      The way the language functions is beautiful, but they seriously need to get rid of stuff like this.

      • Why? Anyone can look at that line and understand exactly what it does without any knowledge of the APIs (although those of us that are familiar with them will suspect that you probably meant +whitespaceAndNewlineCharacterSet). It's more to type, but given that even vim with the clang plugin can autocomplete from a couple of characters that's not really an issue. Most code spends a lot more time being read than being written, and Objective-C is very easy to read.
  • Yes but (Score:2, Insightful)

    by Anonymous Coward

    Its recent success has obviously been tied to one gigantic hit platform, for which it is the only natively supported PL.

    • by perpenso ( 1613749 ) on Friday May 11, 2012 @02:35PM (#39970541)

      Its recent success has obviously been tied to one gigantic hit platform, for which it is the only natively supported PL.

      To be clear, objective-c is only required for iOS user interface code. An iOS developer is free to use c/c++ elsewhere, free to use posix rather than iOS for many operating system services, etc.

    • Re:Yes but (Score:4, Informative)

      by beelsebob ( 529313 ) on Friday May 11, 2012 @02:43PM (#39970679)

      Uhh, C, C++ and Javascript are all supported on iOS... notably, one of those is below Obj-C on the list, and another is looking like it'll soon fall below obj-c.

  • Fine language in many ways but I call 'Boo' on the method syntax.

    • I'm not doing anything in Objective-C but I actually like the method name syntax. Code becomes much easier to read and hardly any harder to write if written in a somewhat modern IDE with code completion.

      • by Jackmon ( 170028 )

        Here's my problem with it:

                -(void) what: (int) kind of: (int) bullshit isThis;

        IMO, that is very difficult to read. And try doing a multi-file search for calls to it.

        IDEs can overcome the search problem, but the readability problem remains.

    • Re:Method Syntax (Score:4, Interesting)

      by spongman ( 182339 ) on Friday May 11, 2012 @03:22PM (#39971323)

      agreed. when i look at obj-c code it feels like someone's pushing hot pins into my eyes.

      seriously.

      why have (c-style) syntax for declaring and accessing variables and functions, and a completely different syntax for declaring and accessing bound methods?

      it makes no sense. it doesn't add anything semantically to the language. it adds another syntax construct just for the sake of it. completely unnecessary.

      and why are properties accessed using c-style syntax, and not methods?

      • Re:Method Syntax (Score:4, Informative)

        by Cinder6 ( 894572 ) on Friday May 11, 2012 @03:45PM (#39971665)

        Objective-C is a strict superset of C. Anything it adds over C has its own special syntax and notation, possibly to help reduce confusion. Properties didn't always use dot-notation--you used to have to do [object ivar] in order to access a member variable, and [object setIvar:ivar] to change it. The (relatively new) dot-notation and @property syntax is just shorthand for this functionality, and a welcome thing (though you can still use the old style).

        Objective-C used to have a lot of irritating things about it, but I think the language has really improved over the past couple years. Properties, auto-synthesizing, automatic garbage collection, fast enumeration, etc. have all made the language much better. Once I got past the odd messaging syntax, I really came to like it, and I have to wonder how much recent experience some of these vocal haters have with the language.

  • by aaaaaaargh! ( 1150173 ) on Friday May 11, 2012 @01:53PM (#39969691)

    Look, I understand that people who use their tools daily want to advertise them and it's a goosd thing if you like what you're using, but let's face it: Objective-C is just another unsafe, hopelessly outdated extension of C as C++. It's great to get things done and sucks less than C++, but it's not in any way a modern language nor is it based on a great language design.

    Before people start flaming me, please consider that programming languages are tools and you choose the right tool for the right purpose and platform, and the availability of libraries is often more important than the language itself. There is no doubt that Objective-C has its place and is useful, just don't try to sell it as the latest great new thingy. Even Apple's own old Dylan was a more interesting and innovative as a language than Objective-C.

    My 2 cents. Now let the language flamewars commence.

    • by Maury Markowitz ( 452832 ) on Friday May 11, 2012 @02:07PM (#39969935) Homepage

      "Even Apple's own old Dylan was a more interesting and innovative as a language than Objective-C."

      Agreed. I loved the multi-interface stuff. Why doesn't anyone else pick that up? It would be particularly easy to implement in Bundles. But...

      "the availability of libraries is often more important than the language itself"

      Bingo. Lets be honest, is any native library set even *remotely* as good as Cocoa out of the box? With the exception of Delphi I've fiddled with them all, and the answer is a resounding "no!". All you have to do is compare the basic text editing widget across libraries and you can draw your own conclusions.

      • by Arker ( 91948 )

        MMM Delphi.

        Now that brings back memories. Objective Pascal with Borland libraries. I hated high level languages back in those days, until I met Delphi.

        Borland is long gone, it would be cool if there were a free software clone out there to use though. It might even inspire me to try programming again sometime.

    • Look, I understand that people who use their tools daily want to advertise them and it's a good thing if you like what you're using, but let's face it: C is just another unsafe, hopelessly outdated extension of assembly. It's great to get things done and sucks less than fortran, but it's not in any way a modern language nor is it based on a great language design.

    • by maccodemonkey ( 1438585 ) on Friday May 11, 2012 @02:22PM (#39970263)

      Before people start flaming me, please consider that programming languages are tools and you choose the right tool for the right purpose and platform, and the availability of libraries is often more important than the language itself.

      Not only does Objective C have an extremely rich set of libraries from both Apple and the community (UIKit and Foundation are arguably the best mobile development APIs out there), but Objective C is compatible with all C and C++ libraries.

      So I'm not exactly sure what the point is. I suppose if you have to use a C library one could say "Well see, you have to use C anyway!". But at least for me, the important part is while I'm using C, I'm still encapsulating that code in Obj-C.

      • My main point was basically yours, but in contrast to you I didn't really get my message across without waking up a bunch of programming language trolls. Wrong choice of words I guess. :-/

    • by SuperKendall ( 25149 ) on Friday May 11, 2012 @02:23PM (#39970287)

      Objective-C is just another unsafe, hopelessly outdated extension of C as C++.

      Why do you claim it is "unsafe"? Almost all work done in Objective-C is very "safe", by any measure - mostly you are never using C arrays or the like. Just because they are there does not make the language inherently "unsafe" if that's not how real people use the language.

      consider that programming languages are tools and you choose the right tool for the right purpose and platform, and the availability of libraries is often more important than the language itself.

      Objective-C currently has some of the most advanced libraries for any platform. It already had great string support and other strong frameworks even before iOS, but with iOS and the Mac taking off the framework support for really advanced animations, database work, networking, etc. as good as or better than any other platform. I came from a Java world and am missing nothing for libraries... not to mention a really good set of open source libraries that offer other abilities in addition to the core frameworks.

      In fact, I would go so far as to say the range and quality of design of the frameworks are THE reason to use Objective-C.

      People like you just look at when Objective-C was developed and think because of its age it cannot be "modern". What you don't realize is that Objective-C was developing over all that time, just in a fairly parallel path to other languages - I like to refer to it as a "Steampunk" language. It is modern but just not quite the same as other things you are used to, coming from an alternate reality.

      You're going to have to come up with real reasons for Objective-C not being "modern", most of which are probably quite out of date by now. Before we can flame you, there need to be specifics which we can skewer...

      • Re: (Score:3, Insightful)

        by Anonymous Coward

        Why do you claim it is "unsafe"? Almost all work done in Objective-C is very "safe", by any measure - mostly you are never using C arrays or the like. Just because they are there does not make the language inherently "unsafe" if that's not how real people use the language.

        There is a common consensus in the CS community that pointers as opposed to references, pointer arithmetics, direct type conversion ("memory overlays") etc. are unsafe, and a language that makes it easy to use them is "inherently unsafe". (That doesn't have anything to do with actual programming practise. Obviously, you can write "safe" programs in any language, even in machine code, as long as you're very careful.) As a comparison, take Ada, Eifel, Java, Haskell -- these are all much safer.

        As for "modern"

        • by SuperKendall ( 25149 ) on Friday May 11, 2012 @03:35PM (#39971505)

          There is a common consensus in the CS community that pointers as opposed to references, pointer arithmetics, direct type conversion ("memory overlays") etc. are unsafe

          In ObjectiveC we are really using objects more as references than as pointers.

          Basically you come off here as just being afraid of something because you've been told it's scary, not because you've seen real issues.

          As a comparison, take Ada, Eifel, Java, Haskell -- these are all much safer.

          Exactly my point, As I said, I was a Java programmer (for almost a decade) - Objective-C is not really less safe at this point in practice. I say that in terms of stability and in terms of memory use (since you still do not say what you mean by "safe" and the world offers many perils).

          As for "modern": Perhaps you haven't seen any modern programming languages yet?

          Snark alert. As I said, I used Java for a LONG time. Before that I knew better languages still, Scheme and other things... Perhaps you have not worked with enough different languages to know what is really "safe" and what is not.

          Because otherwise you should know what I mean.

          I don't automatically agree with snobs.

          Relatively modern features are e.g. automatic type inference, automatic parallelism, contracts, a concurrent garbage collector -- things like that.

          You're still using a garbage collector? Do you watch that operate while gnawing on woolly mammoth bones or what? ARC is a far superior approach as it involves no overhead.

          As for contracts... you really don't know Objective-C at all, do you?

          You just come off as some ancient CS grad-school twat totally removed from real world programming. I've worked on large systems for multi-national corporations, and now on mobile applications used by millions of people. I don't automatically assume anything anymore, as experience I have found teaches you a lot more than mere theory or some summary of a language you have read on a blog.

          Don't judge any language until you've tried to solve real problems with it.

      • Why do you claim it is "unsafe"?

        He may be using unsafe in the same way as Microsoft. See this [microsoft.com].

        From that page:
        ... code that makes low-level API calls, uses pointer arithmetic, or carries out some other unsavory operation, has to be placed inside blocks marked with the unsafe keyword.

        Heh, "unsavory". Personally, I think pointer arithmetic is delicious!

      • Why do you claim it is "unsafe"? Almost all work done in Objective-C is very "safe", by any measure

        Objective C, at least as used on iOS, is not a safe language. I don't see how anyone with serious programming experience could believe that.

        Here are some things about it that are unsafe. Firstly, it's not garbage collected (on the phone). Manual memory management has a long history of resulting in memory corruptions, leaks, and even security vulnerabilities. Yes, on MacOS X there is GC available, so Apple clea

        • Objective C, at least as used on iOS, is not a safe language. I don't see how anyone with serious programming experience could believe that.

          Some people with experience know better.

          Here are some things about it that are unsafe. Firstly, it's not garbage collected (on the phone).

          No, it uses ARC, which is superior, since there is no run time overhead.

          Manual memory management has a long history of resulting in memory corruptions, leaks, and even security vulnerabilities.

          Even under the old regime memory managem

    • Assembly.

      The "modern" Kolibri OS is written in assembly and fits on a floppy. Assembly is the way to go. Just kidding. WHAT do you recommend as a modern language we should all learn?

  • TIOBE Index (Score:5, Insightful)

    by PCM2 ( 4486 ) on Friday May 11, 2012 @02:02PM (#39969835) Homepage

    Seems like every few weeks someone writes another story about the amazing "trends" in the TIOBE Index. As far as I can see, the real trend is: Languages go up in popularity, they go down, they move around, one month it's the First! Time! Ever! that a language has made the list, the next month it's gone again, and C, C++, and Java are always at the top (in varying order). Such variable results suggest that TIOBE's sampling method isn't all that reliable or accurate to begin with, but I think we all have a pretty good idea what languages people are really using and for what.

    • Thanks for giving clarity. If we went by popularity, we'd all be listening to Rihanna or Gotye (both hit #1) or watching FOX (#1 on cable, #2 on broadcast) or reading Alex Jones infowars.com (routinely 1 or 2 in the webnews index). Popularity is interesting to note but doesn't mean much otherwise.

  • Don't you mean the "daddy" of OS X? I thought OS X *is* the Next OS but overlaid with the Mac desktop.

    Also why is it called iOS Objective C? Is objective-C only available through Apple?

    • by Arker ( 91948 ) on Friday May 11, 2012 @02:30PM (#39970431) Homepage

      OSX is NOT the NeXT OS with the Mac GUI. That would be much better.

      In fact it can be claimed to be a lineal descendent of NeXT, but it's been greatly modified, and the new UI is a regression from either the Mac or NeXT GUIs.

      Also iOS - Obj C is obviously referring to the proprietary dialect of ObjC used in Apple mobie devices. (Nothing to do with Cisco iOS either, why cant they think of their own names for this stuff?) There are other dialects, notably the GCC version, which is much more widely applicable.

      • >>>the new UI is a regression from either the Mac or NeXT GUIs.

        So you're saying OS X GUI is actually inferior to the Classic OS 9, or the old NeXT computer's GUI? Interesting. I jumped from OS 8 to OS 10.2 and didn't really notice any major differences in the desktop (except the new tab bar at the bottom). Maybe I just didn't use it enough. Why do you think OS 10 is inferior?

    • by dan325 ( 1221648 )

      Not entirely limited to Apple:

      http://www.gnustep.org/ [gnustep.org]

    • Objective-C is not exclusive to Apple platforms, they just happen to be one of it's most prominent supporters. As a matter of fact the GNU project has actually for long time been a supporter of the language due to its use in GCC and through the Gnustep project.

  • ObjC sucks (Score:5, Informative)

    by dbrueck ( 1872018 ) on Friday May 11, 2012 @02:26PM (#39970365)

    I dev in ObjC on iOS almost every day, and the language sucks. I think it sucks less than C++, but I'm not sure that says much. The Xcode IDE (which also sucks) and the bolted-on features help, but overall the language hasn't aged as well as plain old C - i.e. while coding in it, you are constantly reminded that it is not a modern programming language. Anytime a language gets in your way, it's a bad thing, and that happens an awful lot with ObjC.

    (And before the flames start: yes, I fully recognize that nobody is forcing me to dev for the iOS platform, it's a choice I've made because I make gobs of money off of it. But that doesn't make ObjC suck any less, it just makes me willing to tolerate the suck and grumble about it on /.)

    • I dev in ObjC on iOS almost every day, and the language sucks.

      Please give examples why.

  • Surprise (Score:5, Funny)

    by StikyPad ( 445176 ) on Friday May 11, 2012 @02:29PM (#39970409) Homepage

    What more surprises does this venerable language have up its sleeve?

    Theres only one way to find out, and it involves wading through extraordinarily long, unintuitive, and overly verbose object, property, and method names until, Surprise!, you find yet another feature of limited utility.

  • by Anonymous Coward on Friday May 11, 2012 @02:30PM (#39970435)

    When I evaluate a language the first thing I do is look at a random block of code and say to myself is this what I really want to be writing?

    When I look at lisp all I see is endless streams of ()()())))) and my brain instantly reboots in a violent seizure.

    jquery would be a decent system if only I could get over the rediculous hackish syntax needed to workaround underlying JS environment.

    ASP and close neighbors were always a turnoff due to the weird escape sequences you needed to plaster absoultely everywhere more recently razor cleaned that up somewhat.

    Objective c has too many perlish @ symbols and a rediculous number of [] [][][ ][][][] [] contraptions all over the place. I know this sounds and is shallow but when I look at code I really need to see the code not have to look under layers of syntatic nonsense existing only for convenience or compatibility/interop purposes.

    Give me a capable clean language not hacks upon hacks.

    Given enough time any language can be made useful... this does not mean I would ever willingly choose to use it. I'm instantly wary of languages with only one killer app (iphone) unless it is heavily domain specific.

  • by gestalt_n_pepper ( 991155 ) on Friday May 11, 2012 @02:39PM (#39970615)

    I mean, that's the simple explanation. If Apple wasn't having a resurgence, would anyone be paying attention to Ojective-C?

  • What is the percentage of software projects being developed for Mac OS X? iOS, on the other hand, currently dominates the smarthphone market and development on this platform is mainly done in Objective-C, which explains the statistics. But it's a "dynamic" situation, as we are all aware.
  • by sl4shd0rk ( 755837 ) on Friday May 11, 2012 @03:13PM (#39971175)

    Tiobe's data is an indicator of how active internet based discussions on each programming language. Even Tiobe says it themselves:

    "What programming languages are hot in the Internet discussions? "

    and

    " Observe that the TIOBE index is not about the best programming language or the language in which most lines of code have been written." (http://www.tiobe.com/content/paperinfo/tpci/index.html)

    All the graph on that link above shows is there's been an increase in the amount of discussion on Objective C. You can say it's due to an increase in adoption, or you could say it's due to people being absolutely fitful with learning it. There's no way to tell what the data means. You may as well google " sucks" and count the results.

    I think the author/submitter is being very hopeful in the way they have construed the data.

What is research but a blind date with knowledge? -- Will Harvey

Working...