Turn this .Net C# class into Objective-C class

Discussion in 'iOS Programming' started by whitefang, Mar 16, 2009.

Thread Status:
Not open for further replies.
  1. whitefang macrumors 6502

    Joined:
    Mar 1, 2009
    #1
    Code:
    public class User
    {
           /* Local Variables */
           private string _firstName = "";
    
           /* Public Properties */
           public string FirstName { get { return _firstName; } set { _firstName = value; } }
    
          public User Login(string username, string password) {  return new User(); } //Method returns object
    
          public void JoinGroup(int id) {} //method
    
    
          public User() { } //constructor      
    
    }
    
    Look at how neat .NET syntax is.
    I looked at objective-c syntax to convert, it's like going back to Fortran. So unintuitive and horrible syntax.

    Using XCode is like going back to the dinosaur era. Visual Studio > XCode.
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Code:
    public class User
    {
           /* Local Variables */
           private string _firstName = "";
    
           /* Public Properties */
           public string FirstName { get { return _firstName; } set { _firstName = value; } }
    
          public User Login(string username, string password) {  return new User(); } //Method returns object
    
          public void JoinGroup(int id) {} //method
    
    
          public User() { } //constructor      
    
    }
    

    Nice flamebait post.

    It is a matter of opinion. It looks no more or no less neat than your average Objective-C program.

    If you spend the time learning it, you will see that it is actually pretty intuitive. Expecting all languages to look exactly like C will severely hamper you if you ever want / need to use a different language.

    Objective-C is still sufficiently C like in it's syntax as to be pretty easy for a C programmer to pick up in a very short amount of time.

    I find the opposite. But it really comes down to familiarity, the more you use something the more you get used to it. Once you have figured out Xcode + Interface Builder you will find that is probably the best RAD IDE combination available (certainly out of the ones I have used on Windows and Linux).
     
  3. ethana macrumors 6502a

    Joined:
    Jul 17, 2008
    Location:
    Seattle, WA
    #3
    You have a lot to learn. I've been a .NET developer for years before I moved to the iPhone for development and Objective-C is actually pretty simple.

    Stop complaining and start learning. You'll get farther that way. There are a million iPhone and Objective-C 2.0 books on Amazon now.

    Ethan
     
  4. whitefang thread starter macrumors 6502

    Joined:
    Mar 1, 2009
    #4

    Where's automated properties? Where's anonymous methods? Where's lambada expressions? Where's intellisense? Where's reflection? Where's proper collection classes? Where's proper GC?
     
  5. admanimal macrumors 68040

    Joined:
    Apr 22, 2005
    #5
    If you've already decided that .Net is so much better than Objective-C, what are you doing in an iPhone Programming forum?
     
  6. Encryptic macrumors member

    Joined:
    Jul 27, 2008
    #6
    I don't know what you're going for, if it's just that you want to start a fight, or need attention.

    All languages (and in your case you're also bringing up run-time environments) have their positive notes and negative notes.

    If you take a few moments and objectively look at the features of C# .Net on the Compact Framework, you will find that it's more comparable to that of the iPhone SDK.

    Notes: Automated properties? Objective-C has awesome properties... look up @property + @synthisize

    GC? Automated Garbage collection can make some developers lazy...

    IntelliSense? Type some code and hit Escape... you'll get the same type of menu you're used to...
     
  7. CarlosH macrumors member

    Joined:
    Apr 9, 2008
    Location:
    San Francisco, CA
    #7
    If you are going to debate something, at least have a good knowledge of both sides.
     
  8. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #8
    Garbage collection is not available on the iPhone for obvious reasons (it slows it down) but it is available on Mac OS X.

    Intellisence is built into Xcode and has been for at least the last 3 years or so.

    Properties are available in Objective-C.

    Reflection is available in Objective-C.

    As for the rest, it is not essential as shown by the sheer number of languages that get on fine without it.
     
  9. admanimal macrumors 68040

    Joined:
    Apr 22, 2005
    #9
    He's got a good point with this one though...Objective-C doesn't have the syntax to support any sort of dance, let alone a sexy Brazilian one like the lambada.
     
  10. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #10
    And .NET does? Maybe the Macarena... ;)
     
  11. ethana macrumors 6502a

    Joined:
    Jul 17, 2008
    Location:
    Seattle, WA
    #11
    Dude, you need to read up more on Objective-C 2.0 before you start to get in a debate or dismiss it. 2.0 does have Garbage Collection, just not on the iPhone because of speed and memory reasons. Garbage Collection is on the Mac (and who knows, with 3.0 SDK preview tomorrow, they might turn on GC).

    If you would just study a bit before coming on here and complaining, you would know simple things like this.

    Quit wasting your time on pointless posts and go study. Or is this your twisted way to get answers out of your questions about the language?
     
  12. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #12
    And where there's a business opportunity and a Turing equivalent language, a competent programmer will be able to take advantage of whatever tools are available, whether they include his favorite buzzwords, or different ones. (I've met several software millionaires who programmed directly in hex op codes.) Thanks for staying out of the game and reducing our competition.

    imho.
     
  13. fenrus110 macrumors regular

    Joined:
    Mar 24, 2008
    #13
    while I agree Objective C isn't the most prettiest, I do have to say that the code completion in XCode is fantastic.

    But regardless, you'll always suck as a programmer if you can't adapt to a new language. Programming is never about the language, it's about the principles and problem solving.

    Why don't you give us an example of how to code a multi touch game in ASP.NET?
     
  14. Nermal Moderator

    Nermal

    Staff Member

    Joined:
    Dec 7, 2002
    Location:
    New Zealand
    #15
    That's hardly a fair request when ASP.NET and the iPhone SDK are for completely different purposes.

    I believe that it's possible to compile C# to ARM assembly using Mono (I think that the Unity game engine does this) so C# is still an option if the original poster prefers it.
     
  15. whitefang thread starter macrumors 6502

    Joined:
    Mar 1, 2009
    #16
    Why do I have to press the 'esc' key to get intellisense? In visual studio, I get intellisense as you type.

    Also, debugging large objective-c code is very difficult because the syntax is so horrible. And programming in all hex op-codes is the equivalent of writing critical enterprise applications using notepad/textedit.

    Why doesn't the IPhone SDK support other more "enterprise" languages like Java/.NET.
     
  16. jnic macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #17
    Xcode > Preferences > Code Sense > Automatically Suggest

    No, it's difficult because you have to do your own memory management. If you can't cope without GC then iPhone development is not for you.

    Perhaps you should read up on how OS kernels are speed-optimized in tight loops. They're about as "critical enterprise" as it gets.

    Because GC isn't much use on devices with a small memory footprint. For the sake of speed you want something low-level; Objective-C is essentially C with Smalltalk message-passing, which makes it fast.
     
  17. caveman_uk Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #18
    In the end if you want to write iPhone apps you're using C/C++/Objective C and Xcode or nothing. If you don't like it then basically tough sh*t - Apple aren't going to change it just for you.
     
  18. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #19
    Since when have C / C++ ceased to be enterprise languages? Last time I checked just about every major operating system was written in either C or C++ which is what Objective-C is really (it is a proper super set of C).
     
  19. tacoman667 macrumors regular

    Joined:
    Mar 27, 2008
    #20
    I am primarily a .NET developer in a Microsoft Shop. I have been in the iPhone developer program since it was 2.0 beta (I got lucky and was accepted). This was the first time I ever experienced programming on a Mac using ObjC and Xcode.

    It is certainly different. Windows and OSX are 2 entirely different beasts with similar user interfaces. However, as with all languages, each language is built to serve a purpose. ObjC is a subset of C with SmallTalk added in order to make programming in a UNIX environment manageable. .NET is/was written in C++ primarily and are just libraries that do most of the work for you. Don't get me wrong, I love .NET and the languages that interact with it, but you are comparing apples to oranges here. .NET does not work or work well in Mac OS and ObjectiveC does not work well in Windows OS.

    If you have a problem with it, do not criticize the languages, the original creators had entirely different ideas of what hey wanted to accomplish in their language of choice.
     
  20. Luke Redpath macrumors 6502a

    Joined:
    Nov 9, 2007
    Location:
    Colchester, UK
    #21
    Not sure why people are bothering to respond to obvious flamebait from somebody only interested in trolling. Its quite clear from the OP's posts that they've neither used Obj-C or XCode enough to know the features available.

    The only genuine omission mentioned in this thread that I'd love to see in Obj-C is lambdas or some kind of closures, but thats the Rubyist in me talking (and there is a possibility that Obj-C 3 might get closures...nice).
     
Thread Status:
Not open for further replies.

Share This Page