Friday, September 9, 2016

Best Book to Learn Java for C and C++ Programmer?

In the last 2 decade many Java programmers started programming with C and C++ but the situation is changed now, you have more choices e.g. you can choose Python or you can even start with Java. It seems Academia is preferring Python in USA and Java in India, but there are still many programmers who know C and C++ and wants to learn Java for one or other reasons. I often receive emails from my readers about book recommendation and recently a couple of them asked me to suggest best Java books for C and C++ programmer. I can relate those beginners to myself because I have also gone through the same phase but those days the university text books are our only source to learn new thing. We didn't have broadband and unlimited access to Internet and eBooks was not popular at that time but things have changed. The good thing is now I know a couple of really good books which can help to utilize most of his C and C++ knowledge to learn Java e.g. Core Java Volume 1 - Fundamentals by Cay S. Horstmann which provides comparative analysis with C++ time to time.

For example, if you have worked in C++ for a couple of years then you are already familiar with the Template feature you will find that it's quite similar to Generic in Java, but, not exactly same. If you read Core Java by Cay S. Horstmann you will learn Generics by utilizing your previous experience on C++ Template feature because this book will tell you which feature of Generics is similar to templates in C++ and where they are different.

This is just one example, there are many features in Java which has the origin in C++ but implemented slightly differently e.g. multiple inheritance is available in both C++ and Java but it's not exactly same. Java's support of multiple inheritance is more granular than C++, you have multiple inheritance of type, and in Java 8 some level of behavior but not exactly same as C++.

Another example is the concept of pass by value and pass by reference in Java which is slightly different from C++. In C++ term everything in Java is pass by value because you have no pointer so you cannot pass the address of a variable like you do using & operator in C++, but when you pass objects to a method, a copy of the reference (handler to the object) is passed around. Which any modification on the same reference will be visible outside the method as well, much like it does in case you do pass by reference in C++.

There are plenty of such examples when it comes learning Java after learning C and C++ and that's where I think a book like Core Java by Cay S. Horstmann helps a lot.

Other good books to Learn Java for experienced C++ programmer

As an experienced C++ developer, I expect you to know about OOP concept, design patterns, SOLID design principles, multi-threading and how to write code to implement any algorithm, how to use different data structures and using various collection classes from BOOST and C++ STL library. When you start learning Java, you will find all these features are available and more or less in same form e.g. Java's collection framework contains many of Collection classes from BOOST library.

You will also find that OOP concept and design patterns are exactly same, Polymorphism is not very different, you can both overload and override methods. All you would like to learn is what different feature in Java does, how different they are from C++ and how to do things in a right way in Java. So basically a refresher course of these essential concepts in Java language will help you a lot and that's why I suggest following books for experienced C++ developer learning Java for work :

Head First Design Patterns By Kathy Sierra
A refresher course in OOP design patterns where implementation and examples are in Java. This will quickly help you to start writing intermediate level of code in Java using your existing knowledge of these things in C++.

Java: A beginners guide by Herbert Schildt
The best part of this book is that it is updated with latest Java version which is Java 8. If you are new to Java world, I suggest you to start using Java 8 right from beginning because of its designed for modern system and allows you to better leverage capability of multicore CPU and modern hardware.

Once you know Java and start feeling comfortable with syntax, API, and their usage. You can start reading books mostly recommended to intermediate Java programmers e.g. Effective Java, Java Concurrency in Practice, Java Generics and Collections and books about Java NIO. Combined with your experience in C++ and knowledge of application development, you will learn a lot more in quick time.

That's all about some of the good Java books for C and C++ programmers who wants to learn Java programming. As a C, C++ Developer your Java journey is likely to be smooth and some of you might appreciate the lack of pointers as it makes your code much more readable than what it was in C++, but many experienced C++ Dev might complain because of lack of power due to no pointers.

In short, If you are coming from C and C++ background to Java and want to learn Java language and API in quick time and with decent level of detail then you would probably benefit more from a book like Core Java Volume 1 - Fundamentals by Cay S. Horstmann and Core Java Volume 2 - Advanced Features, who provides comparative analysis with C++ time to time.
Best Book to Learn Java for C, C++ Programmer?

Further Learning
Complete Java Masterclass
Java Fundamentals: The Java Language
Java In-Depth: Become a Complete Java Engineer!

If you love books, you may like to explore these articles as well:
  • 5 Books to Learn Data Structure and Algorithms in Java (list)
  • 6 Books to Master Coding in Java (list)
  • 5 Books to Learn Java Performance tuning and Garbage collection (list)
  • 2 Good book to prepare for Oracle Java Certifications (list)
  • 5 Books for preparing Programming/Coding Interviews (list)
  • 10 Books Every Programmer Should Read (list)
  • 3 Books to Learn and Master Eclipse IDE for Java developers (list)

All the best with your Java journey, you can let me know if you come across any hurdle in your Java learning and we can solve it together.

No comments :

Post a Comment