Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
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.
 

mobilehaathi

macrumors G3
Aug 19, 2008
9,368
6,352
The Anthropocene
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.

You've never dynamically allocated an array or used a function pointer in a general algorithm?
 

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
You've never dynamically allocated an array or used a function pointer in a general algorithm?
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.
 

AppSwage

macrumors newbie
Jan 18, 2015
29
0
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.
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,560
6,059
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.
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.