Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

View Poll Results: Java or C?
Java 22 34.92%
C 41 65.08%
Voters: 63. You may not vote on this poll

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old Jun 10, 2012, 04:31 PM   #1
pchipchip
macrumors regular
 
Join Date: Sep 2011
Java or C? Which is better?

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?
pchipchip is offline   0
Old Jun 10, 2012, 05:07 PM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: 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.

-Lee
lee1210 is offline   2
Old Jun 10, 2012, 05:13 PM   #3
ender land
macrumors 6502a
 
Join Date: Oct 2010
Hard to say, I guess. Depends on a million factors.
ender land is offline   0
Old Jun 10, 2012, 05:20 PM   #4
grapes911
Demi-God (Moderator emeritus)
 
grapes911's Avatar
 
Join Date: Jul 2003
Location: 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.
__________________
grapes911 is offline   0
Old Jun 10, 2012, 05:25 PM   #5
pmau
macrumors 6502a
 
Join Date: Nov 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.
pmau is offline   3
Old Jun 10, 2012, 05:27 PM   #6
talmy
macrumors 68040
 
talmy's Avatar
 
Join Date: Oct 2009
Location: Oregon
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.
__________________
27" i7 iMac, 15" MacBook Pro, Mac mini with Mavericks Server, 5 other Macs and an unused Apple TV.
talmy is offline   0
Old Jun 10, 2012, 05:28 PM   #7
wrldwzrd89
macrumors G4
 
wrldwzrd89's Avatar
 
Join Date: Jun 2003
Location: 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.
__________________
iMac Intel (Rev H, 27"), 1TB HDD, 16GB RAM, 10.8.4
wrldwzrd89 is offline   0
Old Jun 10, 2012, 07:59 PM   #8
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
C

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.
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   2
Old Jun 10, 2012, 08:11 PM   #9
Mac_Max
macrumors 6502
 
Join Date: Mar 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.
Mac_Max is offline   2
Old Jun 10, 2012, 08:15 PM   #10
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Quote:
Originally Posted by pchipchip View Post
I am eventually going to learn with Objective C, but I heard that is harder to learn as a first language.
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.

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   4
Old Jun 10, 2012, 09:06 PM   #11
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 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.
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0
Old Jun 10, 2012, 09:43 PM   #12
throAU
macrumors 68030
 
Join Date: Feb 2012
Location: 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.
__________________
MBP (early 2011) - Core i7 2720 2.2ghz, Hires Glossy, 16GB, Seagate Momentus XT 750GB
Mac Mini (mid 2007) - Core2 Duo 1.8, 2gb, 320gb 7200 rpm
iPhone 4S, iPad 4, iPad Mini, HTC One (eval)
throAU is offline   3
Old Jun 10, 2012, 10:36 PM   #13
Daveoc64
macrumors 601
 
Join Date: Jan 2008
Location: Bristol, UK
Might as well ask which religion is the best next!

Java for me though!
__________________
Nexus 5 32GB Black (Three UK) | Nexus 7 (2012) | Kindle Paperwhite (2013)
iPhone 4 32GB
White MacBook (Late 2007)
Windows 8.1 | iCloud, Dropbox, Spotify Premium
Daveoc64 is offline   1
Old Jun 10, 2012, 11:24 PM   #14
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
Quote:
Originally Posted by Daveoc64 View Post
Might as well ask which religion is the best next!
You mean, like, go over to a bike forum and start a discussion on helmets?
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0
Old Jun 10, 2012, 11:36 PM   #15
larswik
macrumors 65816
 
Join Date: Sep 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.
__________________
I know more than yesterday.
Lars
larswik is offline   0
Old Jun 11, 2012, 02:21 PM   #16
tomozj
macrumors newbie
 
Join Date: Jan 2004
Location: UK
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!
tomozj is offline   1
Old Jun 12, 2012, 09:35 AM   #17
surma884
macrumors regular
 
Join Date: Feb 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.
surma884 is offline   0
Old Jun 12, 2012, 12:11 PM   #18
Setmose
macrumors regular
 
Join Date: Nov 2007
Location: 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++.
Setmose is offline   -3
Old Jun 12, 2012, 02:15 PM   #19
hchung
macrumors 6502a
 
Join Date: Oct 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.
hchung is offline   -2
Old Jun 12, 2012, 03:50 PM   #20
ytk
macrumors regular
 
Join Date: Jul 2010
Quote:
Originally Posted by wrldwzrd89 View Post
all the user-friendliness… of Java
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.
ytk is offline   -3
Old Jun 12, 2012, 04:42 PM   #21
wrldwzrd89
macrumors G4
 
wrldwzrd89's Avatar
 
Join Date: Jun 2003
Location: Solon, OH
Quote:
Originally Posted by ytk View Post
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.
Thanks, I'll have to add Ruby to my list of languages to learn then
__________________
iMac Intel (Rev H, 27"), 1TB HDD, 16GB RAM, 10.8.4
wrldwzrd89 is offline   0
Old Jun 12, 2012, 07:31 PM   #22
ytk
macrumors regular
 
Join Date: Jul 2010
Quote:
Originally Posted by wrldwzrd89 View Post
Thanks, I'll have to add Ruby to my list of languages to learn then
Do yourself a favor and move it to the top of the list.

Seriously, you'll never want to write
Code:
for(int i=0; i<30; i++) {
...
}
/* Does this execute 29, 30, or 31 times? */
once you get used to just writing
Code:
30.times do
...
end
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.
ytk is offline   -2
Old Jun 12, 2012, 11:36 PM   #23
Kenndac
macrumors regular
 
Join Date: Jun 2003
Quote:
Originally Posted by ytk View Post
Code:
for(int i=0; i<30; i++) {
...
}
/* Does this execute 29, 30, or 31 times? */
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.
Kenndac is offline   4
Old Jun 13, 2012, 11:47 AM   #24
sigma8
macrumors regular
 
Join Date: Feb 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.
sigma8 is offline   1
Old Jun 13, 2012, 12:22 PM   #25
splitpea
macrumors 6502a
 
Join Date: Oct 2009
Location: 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).
__________________
What's the point of a sig showing the system I owned in 2006?
splitpea is offline   1

Closed Thread
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Tags
java

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Some apps prompt to install Java 6 even when Java 7 is installed MacMan988 OS X Mavericks (10.9) 1 Apr 18, 2014 07:56 AM
Java 6 or Java 7 for OSX Mavericks for your Macbook Pro? Starfyre MacBook Pro 3 Dec 22, 2013 03:49 PM
Java 6.x security risk (?) vs Java 7.x and broken apps w/ v7.x installs? mgiamo Mac Basics and Help 1 Dec 15, 2013 03:48 PM
Chrome on OS X -- Java plugin / Java 7 vs Java 6 Issue booyahbooyah Mac Applications and Mac App Store 4 May 31, 2013 09:13 AM
Installed Java 7.07 but doesn't show up in Java preferences? -mattias- OS X 10.8 Mountain Lion 21 Aug 31, 2012 04:49 PM

Forum Jump

All times are GMT -5. The time now is 04:17 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC