When the question “which language is better?” comes up, the obvious answer is “it depends.” Understandably, you want to make sure you’re investing your time and resources towards learning a language that you can thrive in and land one of the best tech jobs with. When choosing between Java vs C, you’re choosing between two of the oldest programming languages still in widespread, mainstream use.
Let’s discuss why the history of these two languages makes up an important part of computer science history in general, and which language is better to use under which circumstances.
C: A Beginning
- Speak to a career coach who is a student in a bootcamp
- Coaching sessions are free and always will be
C was developed in 1972 to use with the UNIX operating system, which at the time was being developed by Bell Labs. This was a crucial moment in computer science history as every operating system since then has its roots in UNIX (which itself was partially written in C). This means C is either present in or has influenced almost every piece of software used today.
C has also had an incredible influence on the languages that have followed it—including Java. While C is still used today for scripting and other behind the scene tasks, offshoots of the language like C++ or C# are now more widely used for apps and programs used by the general public.
Java: The Challenger
Java was developed by Sun Microsystems in the years between 1991 and 1995; originally to be embedded in digital televisions. Now it can run on a dizzyingly wide variety of platforms. According to Oracle, three billion devices currently have Java installed on them. The most widely seen platform for Java development is in Android devices, all of which use code written in Java language.
Java vs C: A Comparison
Java vs C: Object-Oriented vs Procedural
One fundamental difference between these two languages is that Java is an object-oriented programming language while C is a procedural language. What does this mean for you as a programmer? It’s a question of what paradigm each language uses to model working with a problem.
Java breaks the world down into objects: everything is modeled as a thing—an object—with certain qualities and capabilities. Objects are reusable and malleable, meaning you don’t have to continually reinvent the wheel when you’re writing. These objects then interact with one another in specific ways depending on their identities. A shape object, for example, won’t have a smell but it will have a color.
C, on the other hand, is a procedural language, meaning its paradigm is to take data and run them through different processes (or procedures) as the program runs; right down the code, sequentially. In other words, a procedural program will start at the top and work its way down. Although it might specify some re-routing to different points in the program, it’s still following the sequence as you specify it. You can almost think of it like a Choose Your Own Adventure book, following the directions depending on data. Sometimes it will go from top to bottom, sometimes it will loop back to the top, and so on.
Neither way of working is inherently better than the other. Rather, it’s a question of what makes sense for the problems you’re tackling and (perhaps more importantly) what makes more sense for you as you’re trying to solve a problem.
C vs Java: Low Level vs High Level
C is a low-level language. This means that your interaction with your computer while writing in C is closer to the machine code (the ones and zeros) that is at the lowest level of the machine. It’s still using syntax that you’ll recognize with English language commands, but it has less abstraction or distance from machine code.
Whereas Java is a high-level language: it has a syntax that’s a little more distant or abstracted from the machine instructions; so closer to human language. Think of the machine language as being at the bottom of a lake and our spoken/written language as being a boat on the surface of the water: Anything closer to how you normally speak is a high-level language.
Because they work closer to the actual machine code of the computer, lower-level languages are generally considered to be harder to read than higher-level ones. Another way to look at it is: A higher-level language is usually more human-readable but at the expense of obscuring a lot of the machinery and activity going on. A low-level language can be verbose and hard to follow initially, but you are privy to every machination.
Java vs C: Interpreted vs Compiled
There’s another very important point of difference that will get us into the guts of how computers read a program you write: Java is an interpreted language–using the Java Virtual Machine–while C is a compiled language.
Let’s break that down by looking at how we communicate with a computer. Whenever you write a program—no matter what language, high or low level—it’s always interpreted in some way by the processor. In other words, it has more steps of translation it has to go through to run your program. An interpreted program is like having a native speaker translate a text for you as you read it, whereas a compiled program is like having the full text sent to you already translated.
What does this mean for you as a programmer? Compiled languages have a reputation for being faster and more efficient than interpreted languages and allow for more lower level control, like memory management. As indicated by the name, they need to be compiled—the program has to be built by the compiler—before they can run. This means an extra step every time you make a change in your program.
Interpreted languages can run after any change without that extra step. Simply change what you want and run it. The trade-off comes with a slightly slower performance; although this is becoming less the case over time as interpreted languages are getting faster and faster.
C vs Java: Memory
One big task that C programmers have to manage themselves is memory management. When manipulating data in a C program, the developer needs to use calls like ‘malloc’ (memory allocation) and ‘free’ to outline whatever memory their program will need to use. Java uses something called a garbage collector to delete any objects that are no longer used. In other words, Java manages memory for you.
Think of it a bit like driving a manual transmission versus driving an automatic. If you don’t want to worry about switching gears and would rather just concentrate on driving, you’d get an automatic. But if you like the control that comes from managing shifting yourself (for example, in bad weather), you’re going to prefer a manual transmission. If this is your first language, Java might be a little more approachable in this respect.
Java vs C Speed: Which is Faster?
If it’s a question of concern about the speed between Java and C, it’s a bit hard to do an apples-to-apples comparison.
One thing that does edge C ahead is that it is possible to write code that is extremely barebones with little overhead. That’s because it is a lower-level language, meaning it doesn’t need the same syntactical baggage a higher-level language requires.
In short: it’s closer to machine code without the need to do a lot of translating down. Of course, this means if you’re writing at this level, you’re either going to have a) very stripped down, simpler programs (which will indeed run fast), or b) you’ll have to do a ton of extra writing to get all the extras a higher-level language already provides cheaply or free of charge.
Which Should You Learn First: Java or C?
Learning C is a little bit like learning Latin: you’ll have the basis for a lot of other programming languages, making it that much easier to learn them. C is used in a number of contexts for scripting and other lower-level tasks. Odds are good you’re not going to write the next Angry Birds with it, though (but with a lot of work, you technically could).
Java is going to be slightly more approachable given it’s a higher-level language than C. The tradeoff is that you might not fully understand everything that is happening in a program at the expense of brevity and speed of learning. Although, if you wanted to take a deeper dive into what Java is doing, the means are there.
Java programming is much more widespread in use with application programming and other public-facing programs. You’re probably going to see more job listings that explicitly call for Java programmers, but even those numbers are dropping. Still, Github lists Java as the third most popular language in its repositories, meaning people are actively using it. While C is listed at number 9 (note that C++ and C#—two very popular offshoots of C—are at 6 and 5 respectively.
If you’re approaching programming for the first time, you’d understandably want to start with one of the easiest programming languages. Neither C nor Java can truthfully be described as easy, but they’d both give you a rich introduction to some important programming concepts.
And the Winner Is…
If you’re looking to learn a computer language to further your skills, both Java and C are excellent candidates and would be great foundations for continuing to learn other languages.
Learning C will force you to learn more “under the hood” aspects of programming as you deal with lower-level workings of computer science and software development. Java is an excellent introduction to object-oriented programming, which is a very widely used programming paradigm.
Java vs C Summary
In short, C is a procedural, low level, compiled language. Java is an object oriented, high level, and interpreted language. Java is easier to learn, while C can do more and run faster.
Part of being a developer is being adaptive to change, so either of these languages would give you a solid background to learn and adapt to whatever coding challenges come your way.
Take a look at the offerings at Career Karma to see what languages are being taught at a bootcamp near you!