Java or C? Which is better?

Discussion in 'Mac Programming' started by pchipchip, Jun 10, 2012.


Java or C?

  1. Java

    22 vote(s)
  2. C

    41 vote(s)
Thread Status:
Not open for further replies.
  1. pchipchip macrumors regular

    Sep 7, 2011
    So I am thinking of taking an online course for either Java or C npbut I can't decide cpwhich one would be moe useful. I am eventually going to learn with Objective C, but I heard that is harder to learn as a first language. So out of Java and C which has the most uses, what are they, and which is easier as a sort of gateway language for learning others?
  2. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    C if Objective-C is next. Both are good, you should eventually learn both. I'm not going to vote because you should eventually know some of each.

  3. ender land macrumors 6502a

    Oct 26, 2010
    Hard to say, I guess. Depends on a million factors.
  4. grapes911 Moderator emeritus


    Jul 28, 2003
    Citizens Bank Park
    If you learn the concepts of object-oriented programming, then any OOP langage is relativity easy to pick up. Java or C, I don't think it matters. Concepts are more important than APIs and syntax.
  5. pmau macrumors 65816

    Nov 9, 2010
    C might be a little hard to learn programming concepts.
    Java is a great learning langauge for OOP.

    Some other interpreted languages like Ruby, Python or Perl might give you other ideas what to do or learn.

    Languages are designed for a purpose, there's really no better or worse.
    It mostly depends on what you are aiming for.

    I prefer compiled languages that result in machine code, but of course Java is used widely in enterprise environments where cross-platform ailability is more important than special features.

    Keep an open mind and don't dismiss other peoples choices for tools to solve their problems.
  6. talmy macrumors 601


    Oct 26, 2009
    C provides a good background in programming basics. It's been called a glorified Assembler. Java provides a great introduction to Object Oriented Programming. I use both, C for embedded programming (microcontrollers) and Java for everything else I can use it for. Consider also: Objective-C if you are interested only in Mac Programming is the obvious choice. C++ might be a good compromise choice, especially when combined with Qt.
  7. wrldwzrd89 macrumors G5


    Jun 6, 2003
    Solon, OH
    I'm a die-hard Java fan... but that does not mean that I eschew C. I have used it in the past - the biggest problem with it is that it's not as newbie-friendly as it could be. This is why I throw my support behind D as a C alternative - all the power of C, all the user-friendliness and object-oriented flexibility of Java in one language.
  8. ArtOfWarfare macrumors G3


    Nov 26, 2007

    Obj-C is just an extension of C, so any C code can be mixed in with Obj-C. If your goal is ultimately Obj-C, you'll need to learn C sooner or later if you want a comprehensive knowledge of Obj-C... May as well just learn it now.
  9. Mac_Max macrumors 6502

    Mar 8, 2004
    It likely doesn't matter. Find out which instructor is better and decide based on that. Java uses C style Syntax, just like C++, C#, Java, Objective C, Javascript, and many others. Your introductory programming class is almost always the same when dealing with strongly typed, statically linked languages (you'll understand what that means later) and most of the concepts in an Into to CS/Programming class are universal amongst all languages and computers.

    You'll learn:

    What types are, i.e. int, char, float.

    Arrays and possibly other containers.

    A little bit about references (pointers in C & ref type v.s. value type in Java).

    File IO... because everyone loves writing to text files.

    How to create functions.

    All of that is pretty much the same basic idea in C, Java, C++, etc. Your second programming course is where things will diverge.

    If your class is pushed harder than your average intro to CS class (or does everything from a 10,000 ft overview) you might end up doing Object Oriented Programming and GUI (simple) programming in the Java class.

    I can't really speak for what I more advanced C class will do for you since I started with Java, skipped the basic intro to C course, and went directly into mid to upper level C++ & C# classes in school (and read and experimented A LOT at home). My guess would be learning how to do more with pointers like pointer arithmetic and building custom data structures.
  10. balamw Moderator


    Staff Member

    Aug 16, 2005
    New England
    Only you can tell if Objective C is harder to learn as a first language. Kochan's fine book doesn't think so, and Hillegass' book thinks that ~70 pages of C is enough to give you the basics.

    If your goal is Objective-C I still suggest, try Kochan first, fall-back to Hillegass and then and only then, switch to C if that isn't working for you.

  11. Sydde macrumors 68020


    Aug 17, 2009
    It is kind of like comparing grapefruits and pomegranates. C is useful for a broad range of work, though going from Objective-C to procedural C can be a little disorienting if the former is what you cut your teeth on. Objective-C is essential if you want to write for iOS, but Java is what you need for Android. From what I have seen, the verbosity of Objective-C makes code a little easier to understand compared to Java, so maybe Java is the best place to start, since it might be a harder climb, making Cocoa more downhill.

    I would say, if at all possible, try to learn both at the same time.
  12. throAU macrumors 603


    Feb 13, 2012
    Perth, Western Australia
    Even though I hate the language, i voted for Java.

    Why? Because it is more general purpose and cross platform. You can do webserver code with it. You can build apps with it. You can build applets with it. Whilst yes, technically you can do web server side stuff with C, security is a very difficult thing to get right.

    Also, you are somewhat protected from needing to learn the ins and outs of memory management and pointers.
  13. Daveoc64 macrumors 601

    Jan 16, 2008
    Bristol, UK
    Might as well ask which religion is the best next!

    Java for me though!
  14. Sydde macrumors 68020


    Aug 17, 2009
    You mean, like, go over to a bike forum and start a discussion on helmets?
  15. larswik macrumors 68000

    Sep 8, 2006
    If you are just starting out I would start with C. Both Java and Objective are built from C.

    You can figure out the tools pretty easy. The hard part is knowing how to use them to solve problems. I could put a tool chest in front of you and you know what wrench are and what they do. But you have to use those tools to put together a car engine. That is the part that takes time getting use to IMO.
  16. tomozj macrumors newbie

    Jan 29, 2004
    In the last year I've learnt both Java and am learning C now, and I'm glad of the order I did it in. Java will teach you important OOP concepts (remember C isn't object oriented!) and improve your general programming skills. Java is much easier to work with and debug compared to C, where I'm finding it extremely hard. You don't want to be spending a long time to find a really small bug when you're learning to program.

    Don't stress too much about learning a lot of C before diving in. I coded an app and published to the app store before learning either Java or C just from searching the web and from my experience with web scripting languages. In hindsight, I struggled because I didn't know programming concepts (such as OOP), not because I didn't know C specifically.

    Get Eclipse (Java IDE, works on most platforms) and go from there. The IDE will help you write code (autocompletion, giving you errors and warnings as you write code) and will make debugging your code really easy. Good luck!
  17. surma884 macrumors regular

    Feb 21, 2011
    In C there is something called a "pointer". In C you also have to allocate and deallocate memory yourself (memory management). Java does that for you and you also don't have pointers. I like C and Java both. You should learn both. Also you should learn on your own first and then take the online course. That way it will be easier.

    Once you learn C and Java you will learn the syntax and be able to program in C#, C++, and any C based syntax language.
  18. Setmose macrumors regular

    Nov 7, 2007
    Jerusalem, Israel
    Real Men Program in C

    Are you kidding? Java is for GUI wimps. There's a reason that operating systems are written in C and C++. :apple:
  19. hchung macrumors 6502a

    Oct 2, 2008
    Like Mac_Max said above, the quality of instructor at a school will likely matter more than your choice of language.

    If you're planning on working hard at it and becoming a good developer, start with C. You're better off knowing how the computer interprets your code.
    Once you're accustomed to how the computer works, then build on top of that by adding objects.

    If you're planning on being last decade's equivalent of a web "programmer", then go dive right into Java as a start.

    Note: I'm not saying Java's bad. I'm saying, if you don't have an idea of what you're actually telling the CPU to do, you'll always be second rate.

    If you've learned Java (or VB or any scripting language), feel comfortable with it, and looking to decide what to do next, then do yourself a favor and go back to learn C. If you become comfortable with C, you'll be a better engineer even if you don't have to use it.
  20. ytk macrumors regular

    Jul 8, 2010
    That's like saying all of the trustworthiness of a used-car salesman.

    To the OP: Learn Ruby. You'll get much better with it much more quickly, you'll be able to use it for far more than C or Java (particularly on the Mac), and most importantly, you'll actually enjoy using it way more than C or Java. And when you get the basics down in Ruby, you can go off and learn other languages. And as you learn the "features" of other languages, your reaction will likely be something along the lines of, "Oh, I get it. That's just the hard way of doing something that's straightforward in Ruby!"

    That said, there's a value to learning C, in that there's a value in knowing how to take apart an engine and put it back together. But you're best off learning how to drive before you tackle that task, and guess what—C makes you build the car before you can actually start driving. Java's a bit better, in that it's more like assembling a car from a kit, but the downside to that is that you're still just following directions because "that's the way it's done", but you won't have a clue why it's done that way for a very long time, if ever.

    Ruby, on the other hand, puts you in the driver's seat from the get-go. And as you learn the language, you'll realize you have way more control over the car than you knew at first, and you've actually learned way more in the process than you would have with C or Java.
  21. wrldwzrd89 macrumors G5


    Jun 6, 2003
    Solon, OH
    Thanks, I'll have to add Ruby to my list of languages to learn then ;)
  22. ytk macrumors regular

    Jul 8, 2010
    Do yourself a favor and move it to the top of the list. ;)

    Seriously, you'll never want to write
    for(int i=0; i<30; i++) {
    /* Does this execute 29, 30, or 31 times? */
    once you get used to just writing
    30.times do
    In fact, Ruby has no ++ or -- operators, and I've never missed them (+= still works). That may seem insignificant, but it actually says a lot about the way Ruby handles control structures. Having used a variety of languages over the years, starting with BASIC and going through C, C++, Perl, Objective-C, and Java (with a couple of other more obscure ones thrown in here and there), I can honestly say that Ruby is the one language that fundamentally changed the way I think about programming more than any other.

    As I've said above, C has its uses, and having at least a working understanding of it is a must for any serious programmer. For that matter, if you want to write software for the Mac, it pays to at least be able to understand Objective-C (although you can write full-fledged Cocoa applications on the Mac in Ruby, with probably 95% or more of the functionality of Objective-C available to you and the addition of all of the cool Ruby features). But I'd gladly toss all of the rest of the languages I've learned in the dustbin and never touch them again in favor of Ruby.

    Sorry if I sound like a raving Ruby fanatic, but I'm just trying to convey how truly awesome this language is. Granted, I'm largely a hobbyist programmer (although I do a fair amount of programming in my job, it's not a part of my job—it's mostly automation of tasks that would otherwise have to be done manually). But after four years of using Ruby, I still regularly have "Oh, cool!" moments when using it, and I can't say that about any of the other languages I've ever used.
  23. Kenndac macrumors 6502


    Jun 28, 2003
    Easy — 30. 0-based math isn't hard.

    Anyway. If you're moving to Objective-C, C is best. It's a lot harder than Java especially at the beginning, and isn't object oriented like Java, but Objective-C is a strict superset of C and you'll be using C stuff all the time in it.
  24. sigma8 macrumors regular

    Feb 2, 2005
    I'd start with C. And I mean plain old C. If you're truly a learner, it makes sense to focus on syntax and basic concepts first--without all the OO stuff. I would almost say C, Java, then Objective-C. And actually, you could probably do better to replace Java with Ruby. The problem with Java, is that it's a very heavy language. It's very secure and goes to lengths to improve maintainability largely by increasing verbosity and process. Those would help you a lot if you were writing an enterprise level accounting module, but I think it would only slow and obscure your learning of concepts.

    Plus, both Java and Objective-C get stuff done largely through frameworks, which each have their own learning curves. C and Ruby (without Rails) aren't quite as framework-focused. If you're goal is to end up in Obj-C only, it would save some sanity and unlearning if you skipped Java's framework and OO peculiarities and just focused on Objective C. Consider that learning Java practically requires you to learn Eclipse, it's ubiquitous and substantial IDE. That knowledge will be mostly thrown out the door when you have to learn Xcode.

    Totally huge "on the other hand": if you want to position yourself to do both iOS and Android development, you really need to learn Java. So if there is a well taught course, I'd take it. Java is certainly worth learning, but mostly on its own merits. I wouldn't rate it highly as a starter language.
  25. splitpea macrumors 6502a

    Oct 21, 2009
    Among the starlings
    They're both better for different things. For instance, it's easier to build cross-platform software in Java, but for embedded device firmware you get far better performance from C.

    In terms of learning, C (and I really mean C, not C++ or Objective-C) as a comparatively low-level language will require you to learn a lot about how your computer interprets programs, what primitive data types are represented and how they're processed, how memory is managed and what a pointer really is, etc.

    All of that will serve you well when you work in higher level languages, from Java to Objective-C to scripting languages like Javascript or PHP.

    All that low-level stuff can mean it's more challenging to learn, though, as in addition to learning to debug basic control-flow logic (conditionals, loops, function calls), you'll also have to juggle memory management and data types.

    Honestly, I'd recommend learning procedural control flow first with a dynamically-typed scripting language that handles your memory management for you (Javascript, PHP, Python, Ruby, etc).

    After that, C to understand the underlying fundamentals (or even a toy assembler if you want to dig deeper); then an object-oriented language (whether that's Java, Objective-C, or going back to Ruby or Python) to learn OOP. Functional programming is another paradigm worth learning for the heck of it (Lisp is the ultimate functional language, but it's also one of the most common techniques used in Javascript, among others).
Thread Status:
Not open for further replies.

Share This Page