1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Which programing language should I learn first?

  1. Nov 29, 2010 #1
    I'm interested in learning how to program, however there so many ones (C++,Python,Java) and IDK which one is the best one to learn for beginners.

    Suggestions? Also would it be good to get a book or find a guide online?
  2. jcsd
  3. Nov 29, 2010 #2
    I know this is off topic, but that username of yours is from Rurouni Kenshin right?
  4. Nov 29, 2010 #3


    User Avatar
    Science Advisor

    I'd recommend starting with Python and then going for C++ additionally.

    C++ is well suited to build and manage (i) medium sized to large programs (>100k lines of code. Most of both Windows and large Windows programs are written in C++) and (ii) to build programs which are as fast as they can (if you know what you are doing). It is also by far the most complicated programming language practically used and takes many years to master. Python[1], on the other hand, is bad at both (i) and (ii), but good for everything else. It is simple to learn, very powerful, and has "batteries included", meaning, it comes with lots of tools and packages for doing stuff you might want to do.

    Being good at (only) Python will already allow you to do an immense number of programming tasks you might stumble across, say, data analysis, text processing, graphics, all kinds of scripting, so it is a more useful skill to have than knowing only C++.

    [1] Actually: Currently existing Python implementations, but there are few reasons to believe this will ever change.
  5. Nov 29, 2010 #4


    User Avatar
    Science Advisor

    This might not be the answer you're expecting but it depends on how much understanding you want to get and what kind of programs you intend to write.

    If you only want to do mathematical simulations then you might be better off learning the language that comes with industry standard programs. Things like Mathematica, Maple, and MATLAB for applied math and things like R and SAS for statistics.

    If you want to work you're way to writing production quality code again it depends. To get to this stage you need to understand why the languages that are out there are there. If you look at particular paradigms of certain languages or even run-time environments (like Java and .NET) you'll notice certain patterns that have emerged that take coding to a new level.

    If you are serious about learning programming, I would learn a little bit about assembly programming. You don't have to necessarily program in it, but become aware about how programs go from high level language (like C,C++,Java,Python etc) to something like you would see in assembler. Once you get a basic idea of what happens in assembler not only will you understand what is actually going on, it will help you when you are debugging those hard to find bugs.

    I'll give you my take on pros/cons of learning a few different languages as your first

    1) QBASIC (Procedural not VB series)

    QBASIC or QuickBasic is a runtime environment created by Microsoft that interprets, compiles and runs QBASIC code. You can get the free compiler and editor (it compiles code but doesn't interpret code like the original QBASIC did) which works on any version of windows (and maybe linux).


    The syntax is pretty easy to deal with
    Easy to get simple programs up and running (ie disk access, user input, simple drawing commands)

    Allows programmer to use variables that are not explicitly defined
    No real "pointer" capability

    A note for the above two cons:
    1) The reason this is bad is because this sort of coding leads to bugs: You might say use a variable in different ways and if it is not declared then it doesn't have a type and if you use the variable in the wrong way you might get a crash and it may end up being hard to find the bug if you have some code doing things it wasn't intended to because the program was not told that a variable should be an integer or something else.

    2) Although pointers can be considered an "advanced" topic, they are essential to programming. When you learn about pointers, you will be able to understand how stuff really works and it will help you pick up assembly programming a lot quicker. Some people might say that I'm wrong in suggesting for someone to learn assembler language early on, but it does have the advantage of giving the student a little extra understanding of how everything simply "comes together and works".

    2) C++


    Good paradigms to learn early for beginner (OOP structures, templates, operator overloading, interfaces, other OOP features (eg. polymorphism))
    As close to assembly as you can get without being an assembly language
    Used quite a lot in industry
    Allows you to pass callbacks to functions (Can't do this QBASIC ignoring CALL ABSOLUTE which is not supported in QB64)

    Very demanding on beginners

    There are a lot more features of C++, but as the con says, it is something that is very demanding on beginners. On one hand you have the task of learning a procedural language (most procedural languages have more or less the same basic features) and on top of that you have to learn about object oriented paradigms and templates as well as worry about variable declaration, memory management, pointer management and so on.

    One suggestion that you could do is to first learn the language C and then when you are comfortable with the procedural aspect, to then get a C++ compiler and IDE (Integrated Development Environment like say MS Visual Studio) and then learn the "C++ specific parts". In a standard C++ compiler, C code should compile with no problems, so the transition should go ok in that respect.

    3) Java

    In some respects a lot like C++ without the memory management or need for pointers, so easier for beginners

    Not good when you want your own "standalone binary"

    The one thing you should know about Java is that it is actually a virtual machine. When you have a language like C++, what happens is that you have a compiler that turns the code you write into binary code that the computer can understand. As long as you supply the executable and the appropriate data to any computer it will run on any operating system that supports that code.

    The above means that if I compiled a program for Windows, it won't normally run on linux unless you have an emulator that emulates the windows environment on linux.

    With Java it is not compiled into the form that is done when you compile C++. It is compiled to an "inbetween" state which the virtual machine runs.

    The Java VM has been written for many different operating environments like Windows, Linux, different Unix environments and even for mobile computing environments and embedded devices.

    The good thing is that once you write the java code it should work on all target environments or in the case that it doesn't, it should be easy to make it work on another target environment.

    The bad thing is that you need the Java Runtime Environment to run any Java code, so you are depending on Java.

    Another related consequence is speed. The Java Runtime has to act like a CPU: It has to fetch instructions and then turn those into instructions that the CPU can understand: this is slower than compiling the code to the "CPU language" and running it directly.

    .NET is in a way similar to Java in that it is compiled into "intermediate code" which the .NET compiler compiles code into.

    The last first language suggestion I will give is assembler

    4) Assembler

    Once you learn this, you should understanding everything about procedural programming
    You will more than likely become highly skilled in debugging
    You will understand how computers actually work

    Not a gentle introduction to programming
    Easier to get confused especially when things go wrong (This is debatable)

    When I talk about assembly, I am talking about the lowest level of code just higher than the actual binary code that the CPU can read. In assembly you will write with instructions and you can have labels and data like you do in high level programs (like for example arrays and strings), but the difference is the relation between the instructions and the code: for assembler most instructions map straight to an instruction byte whereas a statement like "int a = 100" will require the compiler to make space for it somewhere (on the stack, register or a heap).

    In assembly programming everything is precise down to every instruction and it can be hard to keep track of things, but if you stick it out, you'll become very very skilled in procedural programming.

    If you have any other questions, I'll try to answer them
  6. Nov 29, 2010 #5


    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    I agree with cgk. Learn python first and then go for C++.

    If you know these two languages, then I'd consider you a pretty good programmer already...
  7. Nov 29, 2010 #6
    C++ is a timesink. Only devote yourself to it after you're moderately good at another language, and know for certain that C++ is a necessity for the kinds of things that you want to build.
  8. Nov 29, 2010 #7
    Very good post chiro, I agree with a lot of it. Just as a condensed piece of confirmation, I think I would go for a language like Java. It's really easy and similar to C and C++ but it's easier because you don't worry about things that you won't really understand if you try to learn it now. Once you get accustomed to thinking about how computers really work and how languages really work in relation to the hardware and things like that, you'll be ready to tackle things like garbage collection (in Java, at least), memory management, all the technical stuff. Python may be a good language to learn too, but I've only got limited experience with.

    See the great thing about languages is that they're all usually pretty similar in structure (they kind of have to be really). Once you learn a language or two, you can tackle anything. I'd say learn a real programming language first because once you do, Mathematica and MATLAB are just syntax weirdness to deal with for the guys who don't know programming. MATLAB's better about this, Mathematica is weird but becomes intuitive somewhat over time. I'd say Mathematica is the best at symbolic manipulations and expressions but for everything else, use MATLAB (or C/FORTRAN if you're worried about speed).
  9. Nov 29, 2010 #8
    If you learn C first, in a Linux environment, you will not regret it in the end. However, this is a long, difficult road. Start small, learning about Linux, then go to programming, maybe get a book like The Art of Unix Programming.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Which programing language should I learn first?