Language gripes

Discussion in 'iOS Programming' started by moonman239, Jan 24, 2015.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    This thread is mainly for us programmers to talk about the various things we don't like about Objective-C and/or Swift. The nice thing about Swift is that Apple seems to have taken a page or two from the scripting playbook.

    OK, on with the griping:
    First, what's wrong with using a + sign for concatenation? Can't the compiler be trained to treat
    Code:
    NSString *string1 = string2 + string3
    as
    Code:
    NSString *string = [string2 stringByAppendingString:string3
    (Note: Swift does use the + operator for concatenation)
    Second, what's so great about pointers? In C++, the only thing you use them for is to create a new variable that is different only in name from an old variable; if x=2 and p=x, and p is a pointer, and we have access to both variables, and p's value is untouched after the part where p is set to x, then we can choose to get either one's value.
     
  2. mobilehaathi macrumors G3

    mobilehaathi

    Joined:
    Aug 19, 2008
    Location:
    The Anthropocene
    #2
    You've never dynamically allocated an array or used a function pointer in a general algorithm?
     
  3. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #3
    1) If, by "dynamically," you mean "in runtime," and you're talking about Objective_c, then yes. Otherwise, no.
    2) No.

    The point is, I think Objective-C pointers do nothing other than cause confusion as to when they're supposed to be used. in C++, variables don't need to be declared as pointers to their own memory; for quite a few situations (or so it seems), one can afford to forego declaring a pointer.
     
  4. AppSwage macrumors newbie

    Joined:
    Jan 18, 2015
    #4
    I would just make the observation that Objective C can only exist because of Xcode. Can you imagine trying to code something in Objective C using a standard editor? If I want to do something on the server side with Python I can easily bring up Notepad. The thought of such a thing with Objective C makes you go running for the Scotch. Excessive ornamentation in the extreme. Swift does seem an attempt to become more Pythonic.
     
  5. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    Objective C has the worlds longest method names. A lot of them I bet you'll never be able to guess without looking it up in the docs, too. A lot of the time I accidentally reinvent the wheel because there's something already included, but it was given such a retarded name, or placed in a pointless subclass, that I don't find out about it until after the fact.

    Also, regarding pointers, I feel like theres some details you're missing on memory management in C, C++, and Obj-C.
     
  6. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #6
    The great thing about pointers is that Obj C is a strict superset of standard C, so a massive ton of C code (libraries, special functions, ported unix stuff) can be used, as is, in any Obj C app. And the C standard includes pointers.

    C is very close to a high level portable assembly language (needed for writing low level OS kernels and drivers, etc.), and assembly language needs to access anything in memory with knowing its type name or anything. Thus pointers are the C type for a raw memory address.

    That's great if you really want to know what your code is really doing to each bit of memory state, without someone else's translation layer hiding stuff from you.
     

Share This Page