What Should be Your First Programming Language ?

What Should be Your First Programming Language ?

Java or C++

What should be my first programming language?

If you're reading this article, I'm pretty sure you must have asked this question to yourself. In this article i'll try to answer this question.

Well there's No straight forward answer to this question. We need to know context of this question. It totally depends upon your needs.

I'm assuming you are a student of B-tech./B.C.A/B.Sc.(i.t).

For getting a job you need to have Good command on DSA(Data Structure and Algorithms). For Learning DSA Their is a Tie between 2 languages:-

1- JAVA

2- C++

(Python Nowdays is becoming popular but i'll recommend you should not start with python because python has pre-built libraries and python is smart language it detects many things which might be compulsory for you to learn & Python comes under category of easy language and it is said that you should not learn easy things first because learning easy things first might cause you difficulties in long run. After learning python it is not compulsory that you'll understand JAVA and C++ concepts but after learning JAVA & C++ i'm 100% sure that you'll learn every concept of python)

(Let me clarify it doesn't meant that other languages are not good. They are good but as a beginner these two languages are recommended because they don't have pre-built libraries which eases your tasks. By learning any of these languages you'll learn every concept by implementing it.)

  • Now Question arises which one shall I choose between JAVA and C++. If you've learnt C/C++ in school and you have basic knowledge of syntax of C++ you should go with C++ because it'll save your time for learning syntax.

C++

If You know basic functioning of C++ (if-else,loops,functions). than you should immediately start DSA in C++ & if we compare C++ with JAVA, C++ is pretty difficult to learn so if you learnt difficult language in starting than you won't face problem in shifting to another languages.

Let's look at some benefits of C++:-

  1. Very Fast language :- Because C++ doesn't have that much predefined libraries so it is very fast in nature.

  2. Puts Less load on processor:-it is very light in nature its Good for your processor if you're compiling in your local machine.

  3. Its best for C.P:- As you've seen that it is fast and consumes less memory so for competitive programming i'll recommend you C++. its just best language.

  4. Short syntax:- you've to type less words as compared to Java in C++ which makes it better choice over Java for C.P. as it will save your time in writing syntax..

  5. It has some other benefits (you need little knowledge of DSA to understand):-

    • C++ supports operator overloading (ad hoc polymorphism) it means we can perform computation on objects.
    • C++ supports multiple inheritance.
    • C++ use pointers. So, directly we can do system level programming.

So, you have seen benefits of C++, Lets see the other side of coin:-

  • If you're seeking DevOps or remote works than you should not use it because doing projects in C++ is very difficult.
  • C++ is very Complex if we are using it in large high-level program.
  • For a particular operating system or platform, the library set has usually chosen that locks.
  • When C++ used for web applications program gets complex and difficult to debug.
  • C++ can't support garbage collection so you'll face problems of data leaks very frequently.

- Let's have a look at JAVA Now

  • If you are complete beginner, JAVA must be your choice because when we compare JAVA with C++ JAVA is easy to learn and even if you don't have any idea what you have to do what are your interests than java will be best for you because after learning java you can pivot to any tech stack like you can learn :-

  • Android Development

  • Back-End of web pages
  • Competitive Programming etc.

  • Though I'm not saying by only learning java you'll learn all these stuff you have to learn them too but you'll save time in switching language.

Benefits of JAVA:-

1. Simple

Java is a simple programming language since it is easy to learn and easy to understand. Its syntax is based on C++, and it uses automatic garbage collection; therefore, we don't need to remove the unreferenced objects from memory. Java has also removed the features like explicit pointers, operator overloading, etc., making it easy to read and write.

2. Object-Oriented

Java uses an object-oriented paradigm, which makes it more practical. Everything in Java is an object which takes care of both data and behavior. Java uses object-oriented concepts like object, class, inheritance, encapsulation, polymorphism, and abstraction.

3. Secured

Java is a secured programming language because it doesn't use Explicit pointers. Also, Java programs run inside the virtual machine sandbox. JRE also provides a classloader, which is used to load the class into JVM dynamically. It separates the class packages of the local file system from the ones that are being imported from the network.

4. Robust

Java is a robust programming language since it uses strong memory management. We can also handle exceptions through the Java code. Also, we can use type checking to make our code more secure. It doesn't provide explicit pointers so that the programmer cannot access the memory directly from the code.

5. Platform independent

Java code can run on multiple platforms directly, I.e., we need not compile it every time. It is right once, runs anywhere language (WORA) which can be converted into byte code at the compile time. The byte code is a platform-independent code that can run on multiple platforms.

6. Multi-Threaded

Java uses a multi-threaded environment in which a bigger task can be converted into various threads and run separately. The main advantage of multi-threading is that we need not provide memory to every running thread.

Disadvantages of JAVA:-

1. Performance

Java needs to be interpreted during runtime, which allows it to run on every operating system, but it also makes it perform slower than the languages like C and C++. On the other hand, the C++ program needs to be compiled on each operating system, directly to binary and therefore runs faster.

2. Memory consumption

Java program consumes more memory since it runs on top of Java virtual machine.

3. Cost

Java programming language is a bit costly due to its higher processing and memory requirements. We need better hardware to run the Java program.

4. Less machine interactive

Java lacks when it comes to interacting directly with machines, making it less viable for the software that needs to run quickly and run directly with the machine, as explicit pointers are also missing in Java.

5. Garbage collection

Java provides automatic garbage collection that cannot be controlled by the programmer. It doesn't provide the methods like delete() and free() to free the memory.

At the end i'll say pick any of the above language because you have to switch to other languages no. of times in your life. But if you have honestly learnt any of above language you won't find any difficulty in switching languages. I'll say you just need to start with anything but what important is JUST STARTING because:-

"It is our attitude at the beginning of a difficult task which, more than anything else, will affect its successful outcome "

~William James