Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C for Java Programmer? [duplicate]

Tags:

java

c++

c

Possible Duplicate:
Should I learn C before learning C++?

As a professional (Java) programmer and heavy Linux user I feel it's my responsibility to learn some C (even though I may never use it professionally), just to make me a better coder.

Two questions :

  1. Should I try C or C++ first - I realise they are different languages with some common ground. Is it useful to learn a bit of both, or just try one? I hear C++ is a bit of a nightmare behemoth of a language.

  2. What are the best resources (books, tutorials, practice programs, reference code) for a Java developer like myself.

Thanks

like image 428
lucas1000001 Avatar asked Aug 21 '10 18:08

lucas1000001


People also ask

Should I learn C after Java?

In order to become a good programmer in JAVA you should start from the language C because it is the most basic language and in order to understand the concepts of JAVA first you should learn C than C++ and after that go for JAVA.

What language is harder C or Java?

C is a procedural, low level, and compiled language. Java is an object-oriented, high level, and interpreted language. Java uses objects, while C uses functions. Java is easier to learn and use because it's high level, while C can do more and perform faster because it's closer to machine code.

How many times C is faster than Java?

Elapsed Time Based on these results, C is 2.34 times slower than Java and Python is 33.34 times slower than Java.

Is there any link between C and Java?

C is a middle-level language as it binds the bridges between machine-level and high-level languages. Java is a high-level language as the translation of Java code takes place into machine language, using a compiler or interpreter. C is only compiled and not interpreted. Java is both compiled and interpreted.


1 Answers

C is simple to learn, difficult to master. as a Java programmer the barrier will be memory and structure .. and undoing the damage Java may have done to the algorithm producing portions of your brain ;)

I would recommend getting familiar with the GCC toolchain on your Linux box, through tutorials on the Internet. Then read The C Programming Language, and a copy of Linux Application Development doesn't hurt. Also, on Linux glib will save you from reinventing the wheel ... but at least try to create your own linked-list, hashmap, graph and other API to learn. Pointer arithmetic, arrays and learning that elements such as structs are just named-offsets in a binary chunk are all important. Spend time with malloc and free and memcheck. With C, your tools and toolchain are very important and the IDE isn't necessarily your friend when learning.

I would pick C over C++ as C is a good foundation to get used to the memory management and pointer usage of C.

The best thing you can do is apply what you learn to a real project. But be prepared to bash your head against the wall allot in Valgrind and GDB. I have been programming C for years, and I am still no C monk.

I do agree that C is a great language, it shows up a bad programmer. But remember:

Any sufficiently complicated C program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

The moral of which is learn other languages too, rather than just C-derived ones! Consider some Lisp dialect, Erlang (which is cool at the moment), Haskell, etc. They will expand your horizons from the 2x2 cell of Java. Consider looking at SICP too.

like image 181
Aiden Bell Avatar answered Sep 22 '22 04:09

Aiden Bell