Register to reply

Which programing language should I learn first?

by battousai
Tags: language, learn, programing
Share this thread:
battousai
#1
Nov29-10, 12:31 AM
P: 84
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?
Phys.Org News Partner Science news on Phys.org
New type of solar concentrator desn't block the view
Researchers demonstrate ultra low-field nuclear magnetic resonance using Earth's magnetic field
Asian inventions dominate energy storage systems
flyingpig
#2
Nov29-10, 01:01 AM
P: 2,568
I know this is off topic, but that username of yours is from Rurouni Kenshin right?
cgk
#3
Nov29-10, 01:11 AM
P: 423
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.

chiro
#4
Nov29-10, 01:40 AM
P: 4,573
Which programing language should I learn first?

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).

Pro's:

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

Con's
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++

Pro's:

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)

Con's
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

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

Con's
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

Pros
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

Cons
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
micromass
#5
Nov29-10, 09:26 AM
Mentor
micromass's Avatar
P: 18,213
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...
G037H3
#6
Nov29-10, 09:44 AM
P: 326
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.
hadsed
#7
Nov29-10, 10:07 AM
P: 492
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).
unixunited
#8
Nov29-10, 11:22 PM
P: 10
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.


Register to reply

Related Discussions
Learn a language General Engineering 1
What programing language should i learn? Programming & Computer Science 15
What is the best way to learn Windows programing? Programming & Computer Science 5
Need help programing in assembly language Programming & Computer Science 1
What language should i learn Academic Guidance 22