Jump to content



Photo

Getting started FAQ


  • Please log in to reply
68 replies to this topic

#61 vhane

vhane

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 15-August 04

Posted 22 January 2014 - 02:48

Obj-C has various keywords that don't begin with @ and break compatibility with C codes that use the names. There is no reason why they couldn't have done that with all of the keywords.

 

I'm struggling to come up with a code example. It seems to me that you couldn't call Obj-C a strict superset of C if that were the case.

 

 

 

Seems to me they just did it to differentiate various compiler directives from other types of keywords.

 

I think we're getting closer. And why were these implemented as compiler directives instead of built into the language?




#62 +snaphat (Myles Landwehr)

snaphat (Myles Landwehr)

    Electrical & Computer Engineer

  • Tech Issues Solved: 29
  • Joined: 23-August 05
  • OS: Win/Lin/Bsd/Osx
  • Phone: dumb phone

Posted 22 January 2014 - 03:06

I'm struggling to come up with a code example. It seems to me that you couldn't call Obj-C a strict superset of C if that were the case.

Easy: id, inout, nil, byref, byval (there are others, i don't know off the top of my head). It's not a strict superset, everyone just says that because it is almost true. Who cares if you end up having to change c code names in an unlikely scenario anyway? It's really a silly thing to worry about in most cases.

 

I added nasty address space keywords (__global, __local, etc.) in a compiler at one point on a project I was on because "nice" keywords conflicted with some library code we were using. Eventually, my colleague was like "stop using those keywords no-one likes them because they look horrible and we aren't going to have many issues anyway because we will never be reusing much existing code". He was right, so we switched to global, local, etc. proper and just modified the library code we had instead. At the end of the day, how many people are compiling existing C libraries using obj-c? And how many libraries would have issue with keywords? Probably not much in either case.

 

I think we're getting closer. And why were these implemented as compiler directives instead of built into the language?

Well they are built into the language: they are just compiler directives that are part of the language, right?



#63 vhane

vhane

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 15-August 04

Posted 22 January 2014 - 03:31

I see. Would it be more fair to say that it's the fact that Obj-C is implemented as a thin layer on top of C that informs the way it looks then?



#64 +snaphat (Myles Landwehr)

snaphat (Myles Landwehr)

    Electrical & Computer Engineer

  • Tech Issues Solved: 29
  • Joined: 23-August 05
  • OS: Win/Lin/Bsd/Osx
  • Phone: dumb phone

Posted 22 January 2014 - 03:43

I see. Would it be more fair to say that it's the fact that Obj-C is implemented as a thin layer on top of C that informs the way it looks then?

It's is possible. Maybe the compiler directives are straightforward to do transforms or something. Along those lines, I just searched for a second and someone said the obj-c language extensions were initially implemented using the C preprocessor. Perhaps at the time they were simpler and doable using that.

 

Disclaimer: I do not know if that information is correct.



#65 vhane

vhane

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 15-August 04

Posted 22 January 2014 - 04:11

It's is possible. Maybe the compiler directives are straightforward to do transforms or something. Along those lines, I just searched for a second and someone said the obj-c language extensions were initially implemented using the C preprocessor. Perhaps at the time they were simpler and doable using that.

 

Disclaimer: I do not know if that information is correct.

 

Yeah, I was just reading the same thing, and have just stumbled upon eero, a dialect of Obj-C which also supports drop in C and C++ code. So it seems that it's really the initial implementation of Obj-C that informs the way it looks. It kind of just grew from there.

 

This conversation has gotten me interested to dig deeper. Sorry for going way off-topic though!



#66 +snaphat (Myles Landwehr)

snaphat (Myles Landwehr)

    Electrical & Computer Engineer

  • Tech Issues Solved: 29
  • Joined: 23-August 05
  • OS: Win/Lin/Bsd/Osx
  • Phone: dumb phone

Posted 22 January 2014 - 04:17

Yeah, I was just reading the same thing, and have just stumbled upon eero, a dialect of Obj-C which also supports drop in C and C++ code. So it seems that it's really the initial implementation of Obj-C that informs the way it looks. It kind of just grew from there.

 

This conversation has gotten me interested to dig deeper. Sorry for going way off-topic though!

That's a sad reason to keep it like it is though. I guess it is too late now. eero does look much better in comparison.



#67 OP Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 24 January 2014 - 16:23

I don't really understand this argument: C++ is nearly a superset of C and didn't end up with "ugliness" if you are referring to the syntax. What exactly is inherently there that would force such a thing?

Oh, I intensely disagree with that. C++ wouldn't have headers, for once, if it wasn't for compatibility with C. It also wouldn't have two almost identical keywords for creating a class (struct/class), and many such strange things.



#68 +snaphat (Myles Landwehr)

snaphat (Myles Landwehr)

    Electrical & Computer Engineer

  • Tech Issues Solved: 29
  • Joined: 23-August 05
  • OS: Win/Lin/Bsd/Osx
  • Phone: dumb phone

Posted 24 January 2014 - 19:22

Oh, I intensely disagree with that. C++ wouldn't have headers, for once, if it wasn't for compatibility with C. It also wouldn't have two almost identical keywords for creating a class (struct/class), and many such strange things.

I was contrasting C++ to Obj-C to show that being a superset to C doesn't force the ugly (hard to read) syntax of Obj-C, so what is there to disagree with? It appears to me that you are making a side argument that C++ is ugly itself because it inherited headers and quirks from C. Sure it inherited those things, but that's neither here nor there w.r.t. what I was said regarding Obj-C syntax, and it's a matter of opinion whether the quirks make the language ugly. To be perfectly honest, someone could argue that the syntax of Obj-C isn't ugly (hard to read) (note: I would never do this myself), but that doesn't change my point, that it being a superset of C doesn't force the language to have the additional syntax that it added that many people consider ugly.



#69 OP Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 24 January 2014 - 21:39

(...) but that doesn't change my point, that it being a superset of C doesn't force the language to have the additional syntax that it added that many people consider ugly.

I wasn't really following your discussion, sorry.