PDA

View Full Version : How to teach myself a new programming language



Heliomance
2013-10-21, 06:41 AM
As the title says, I'd like to learn a new programming language. I want to do this for several reasons - out of interest, to give me something productive to do with my time, and to look good on job applications. I'm reasonably competent - though by no means expert - with Python already, and I think I understand the logic of how high level scripting languages work.

Due to my third reason above, I'd like to learn something likely to be useful out in the wide world of work. I'm currently tossing up between C and Java, but other suggestions will be considered.

So, my questions are thus: what language do you suggest I learn, and where can I find the resources necessary to teach myself, preferably for free?

valadil
2013-10-21, 08:00 AM
Personally I find it really hard to sit down and learn a language. I can read the book and understand it, but nothing sticks unless I actually work with the language. For that reason I find it easier to pick a project first and then learn a language that's suitable for the project.

Sooooo... what sort of projects are you interested in working on?

Heliomance
2013-10-21, 08:42 AM
I don't, particularly. As I say, I want to occupy my time and make myself more employable. One assumes that any instruction resource worth its salt would have practical exercises to work through, as it's well known that the best way to learn is by doing.

gooddragon1
2013-10-21, 08:57 AM
I'm thinking java. I'm currently learning at a pace that makes that movie about the speedy snail seem plausible due to laziness. The reason I suggest java though is because I see it a bit more often (the thing that asks me to update it). As for a project... well you can make a game out of it (http://www.runescape.com/title.ws)... though probably not that big :/. You can also maybe make other stuff but nothing comes to mind.

I've done C++ a long time ago and it can be used to make a tic-tac-toe game from what I understand. As in:

-|-|-
-----
-|-|-
-----
-|-|-

And printing out the whole screen with each change. It was annoyingly difficult to code.

factotum
2013-10-21, 10:10 AM
It has to be said, the language itself isn't as important these days as whatever user interface library you end up using--for instance, .NET programming is considerably different to Gtk+ regardless of the language used. Other than that I can't offer much advice, it's been more than a decade that I've been out of the "coal face" as far as programming goes (more's the pity).

Drumbum42
2013-10-21, 10:35 AM
I'd say C, C++, or Java. All of those are pretty popular and useful languages. C is rather primitive compared to Python, so Java may be more comfortable then C. On the other hand, if you don't mind learning something really different, C is great because it's a lower level programming language (That that can be debated) and will show some diverse coding experience on a resume.

Both Java and C will help you pick up C++ quickly if you ever need to, so I'd skip C++ unless you have a need for it. Personally I'm a Java programmer, but I've been known to do C/C++ from time to time, and C always feels like a grind. I don't know if that means I should stay away from it, or just put more time into it, you can take that as you will.

Castaras
2013-10-21, 10:50 AM
Find something you could put the language to use to make, look up syntax, start making, refer to documentation and stack overflow, make thing that looks interesting.

Seeing as you already know one language, it'll be a bit easier to learn a second.

Heliomance
2013-10-21, 10:54 AM
I'd prefer to learn it in a more orderly fashion than haphazardly finding out what I need to make a particular thing work. Does anyone know any good "teach yourself" resources?

Drumbum42
2013-10-21, 03:10 PM
I'd prefer to learn it in a more orderly fashion than haphazardly finding out what I need to make a particular thing work. Does anyone know any good "teach yourself" resources?

Well, I've picked up most of my stuff from High School/College courses or talking to a friend for a couple of hours to get the basics and experiment from there. But the few times that that has not been a viable option, I've gone to the library/book store and picked up a book. Not a "How to program X" book, but the 500lb "Complete Everything" by "Official Company."

I could be old school, but I really like to have my programming source book, in REAL book format. If you buy it in a store it will set you back $40-60, but I found "Java SE7 by Oracle" and it was a good read. (As software development books go) It helped me understand some of the less then obvious "Why X does Y" stuff that my professors in college skipped over. I just sat down in front of my computer, read the book, found something cool/new, tried it out on my computer, then kept reading.

Now I can't suggest a good C book, but I'm sure they're out there. (There's probably several people here who could recommend one.)

kyoryu
2013-10-21, 04:23 PM
C# or Java.

I wouldn't really recommend diving into C or C++ until you've got a little more experience under your belt.

Neftren
2013-10-21, 08:08 PM
Sooooo... what sort of projects are you interested in working on?

This is the most important question you (Heliomance) need to answer. Are you interested in scientific computing? Are you interested in front-end web development, or would you prefer working on backends? Game programming? Commercial software programming?

Remember, a programming language is just a tool. Pick the right language for the right job.


I don't, particularly. As I say, I want to occupy my time and make myself more employable. One assumes that any instruction resource worth its salt would have practical exercises to work through, as it's well known that the best way to learn is by doing.

This really depends on the metric, and where you're looking to be employed. Java is probably the most popular enterprise-level language right now. C is extremely valuable as a fundamental language -- I personally feel everyone should be familiar with C programming. There's also C++ which is very related to C.

If you're already familiar with one programming language, it's not particularly difficult to switch (within the same class of languages). Switching from Python to C/C++ and Java will be easier than switching from Python to a functional programming language (as opposed to an imperative language).


I'm thinking java. I'm currently learning at a pace that makes that movie about the speedy snail seem plausible due to laziness. The reason I suggest java though is because I see it a bit more often (the thing that asks me to update it). As for a project... well you can make a game out of it (http://www.runescape.com/title.ws)... though probably not that big :/. You can also maybe make other stuff but nothing comes to mind.

There aren't many 3D game engines written in Java unfortunately. Or perhaps fortunately. Java is a great ecosystem for writing business applications, but for invoking graphics routines, you pretty much have no strong options, unlike OpenGL and DirectX, which have strong C/C++ bindings.

As for your Tic-Tac-Toe example, my initial (probably naive) thought would be to call the bash `clear` function (using exec) after every move to clear the screen before redrawing the board.


I'd say C, C++, or Java. All of those are pretty popular and useful languages. C is rather primitive compared to Python, so Java may be more comfortable then C. On the other hand, if you don't mind learning something really different, C is great because it's a lower level programming language (That that can be debated) and will show some diverse coding experience on a resume.

C isn't particularly primitive compared to Python (keep in mind mainstream Python is written in C). You just have to do a bit more of the legwork to get where you need to go. Unless I misunderstood what you meant by primitive.


C# or Java.

I wouldn't really recommend diving into C or C++ until you've got a little more experience under your belt.

As I noted earlier, I think everyone (even novice programmers) should start with C. Understanding the fundamentals of lower level programming languages helps make informed decisions about use cases in the higher level languages. It also helps you appreciate features of higher level languages much more. For instance:


for i in some_list:
# Do Something


~~~~~~~~~~~~~


for (unsigned int i = 0; i < some_max; i++)
{
// Do Something
}


I haven't even touched iterators in this example.

Balain
2013-10-21, 08:52 PM
Java seems to be the most popular language to learn right now.

Talking with my friends, they were looking for interns last summer, and my friends were shocked that none of them knew anything about HTML and CSS.

Aurenthal
2013-10-21, 09:07 PM
I have tried to learn (several times) some programming languages through the internet, but my laziness has beaten me to the ground everytime. Still, I would recommend you take a look at http://code.org/. I really don't know if it's a good source, or a bad one... but it's something!

Eulalios
2013-10-21, 09:16 PM
I'd prefer to learn it in a more orderly fashion than haphazardly finding out what I need to make a particular thing work. Does anyone know any good "teach yourself" resources?

You're being pointed at the very best teach-yourself resource. Go find a project you want to build. Bestest: find something half-baked on sourceforge, and fix it.

valadil
2013-10-21, 09:55 PM
I don't, particularly. As I say, I want to occupy my time and make myself more employable. One assumes that any instruction resource worth its salt would have practical exercises to work through, as it's well known that the best way to learn is by doing.

Exercises are pretty limited in scope. They'll teach you how to do a for loop, then ask you to write a for loop. It's a different environment than having all of the language open to you and having to pick the right parts of it.

I have a question and I hope you don't take it the wrong way. If you don't want to do a personal programming project, why do you want someone to employ you as a programmer? Try this stuff out and see if it makes you happy.

Okay, here's a less negative question. If you want to be employable, why not pick an open source project and contribute to it? This is a great way to build up reputation that transfers on to your resume. Find some open source software you like, learn the language it uses, and then start working on some bugs from their issue tracker. You also get the benefit of learning to work in a team using source control, vital skills which most classes ignore.

factotum
2013-10-22, 01:33 AM
There aren't many 3D game engines written in Java unfortunately. Or perhaps fortunately. Java is a great ecosystem for writing business applications, but for invoking graphics routines, you pretty much have no strong options, unlike OpenGL and DirectX, which have strong C/C++ bindings.

You realise Minecraft is written in Java, right? I believe it makes use of this:

http://lwjgl.org/

Finlam
2013-10-22, 06:38 AM
I'd prefer to learn it in a more orderly fashion than haphazardly finding out what I need to make a particular thing work. Does anyone know any good "teach yourself" resources?

For online (web) programming i.e. HTML/CSS, Javascript, PHP, etc... check W3Schools (http://www.w3schools.com/). It's a site that features great tutorials that are really hard to beat.

For Python (the best programming language), Ruby, JQuery, Javascript, or PHP, check CodeAcademy (http://www.codecademy.com/). This is a great resource that walks you through programming exercises, checks your work, and provides you with solutions as well as discussion threads for the exercises. If you are learning any of those languages, I highly recommend this site.

For almost any language, there's also TutorialsPoint (http://www.tutorialspoint.com/). I cannot emphasize this enough: this site is fantastic, but not in the usual way. There are phenomenal examples of nearly every function, method, and programming concept for each language on the site. I've never followed their tutorials all the way through i.e. one after the other, but any time that I had a question on something that was stumping me in a program, I would search TutorialsPoint and read their explanations and their awesome examples. This site could be used as your only site to learn a language, but I think it works best as an aide.

The best part, is that each of these sites is free. Completely, no strings attached free. Also, when you start programming and you run into a question, feel free to post it on the appropriate Reddit subforum i.e. http://www.reddit.com/r/learnpython or http://www.reddit.com/r/learnjava, the posters there are incredibly helpful and will answer and explain any question until you feel you have a good understanding of it.

I only mention this because the only way to learn a programming language (or anything in life) is to do it. Pick a language, and start coding. CodeAcademy is really good for that. Ask questions as you go. Start your own project, even if it's as simple as making 'Pong'.

---------
On learning languages: Some people will tell you that you need to learn this or that language first, and there's a lot of arguments for and against each.

If you were going to do this professionally, you would have to start with either C or C++, no exception. Programmers who do not start with those (or assembly), end up having to learn what a pointer is, and usually become mediocre programmers at best. If you are doing this as a hobby, you can probably skip that.

If you want to do something lightweight and easy, that doesn't go on the web, then you have either Python, Ruby, or Java. Java has the advantage that any program you write can be run on pretty much any computer (since everyone has Java and bytecode is nifty), but Ruby and Python will have the advantage of being MUCH, MUCH easier to learn. I would recommend Python because it has a large community of programmers who will gladly answer any question. With Ruby, the community tends to be dominated by people who use 'Ruby on Rails', which is not really good for a beginner.

Finally, if you want to put something on the web, then you're stuck with learning both HTML/CSS and Javascript. It may help to learn PHP as well, but it seems to be less necessary nowadays.

Hope that helps!

[EDIT]
Also, Factotem, Minecraft took 8 years to develop. It is a game that proves you can have money making games in Java and you can have single processor games that make money, but it is the exception and not a rule.

Heliomance
2013-10-22, 08:42 AM
Python's out because I already know it :P

I'm leaning towards C from your explanation. I'd like to learn to code properly. I'll have a look at TutorialsPoint, thanks!

factotum
2013-10-22, 08:53 AM
Also, Factotem, Minecraft took 8 years to develop.

Er, no it didn't--the first alpha release of Minecraft was in May 2009, and it can't have started much earlier than that because Notch has gone on record as saying that Infiniminer was an inspiration for the game, and that game came out a couple of months earlier. The actual first full release (e.g. not alpha or beta) of Minecraft was in November 2011, so around two and a half years of development to get to that point--doesn't seem that excessive to me, especially since the game was a one-man project for much of its early life.

The fact is, when you're dealing with any sort of 3D, it almost invariably takes *much* longer to render the final scene than it does to process it beforehand, which means the language used is almost entirely irrelevant--it's the game library that does the heavy lifting. There are exceptions, obviously, but there's no point in saying that you *have* to use C or C++ to write games when this is demonstrably not true.

[EDIT] If you're going to learn C, bear in mind that's it's barely one step removed from assembly language--it's very low level indeed. If you're used to having lots of high-level abstractions to help you out, prepare for a bit of a culture shock! :smallwink:

Heliomance
2013-10-22, 09:02 AM
I know, I dabbled in C for my final year project at uni. I've got the absolute basics of it already, but I'd like to learn more.

Neftren
2013-10-22, 11:23 AM
You realise Minecraft is written in Java, right? I believe it makes use of this:

http://lwjgl.org/

Yes, and practically no other commercial (3D) games are written in Java. I'm not saying it can't be done, but the infrastructure for developing games overwhelmingly points developers towards C/C++/C# rather than Java. Quite frankly, I'm amazed Minecraft runs so poorly considering how basic its graphics are. Adding basic lighting to the game (GLSL shaders) brings my computer to its knees.


The fact is, when you're dealing with any sort of 3D, it almost invariably takes *much* longer to render the final scene than it does to process it beforehand, which means the language used is almost entirely irrelevant--it's the game library that does the heavy lifting. There are exceptions, obviously, but there's no point in saying that you *have* to use C or C++ to write games when this is demonstrably not true.

I was very careful to avoid bringing up language performance earlier as a reason for why Java isn't used more frequently.

Again, the reason C/C++ is among the most popular is two-fold. 1) History -- most game engine programmers started out as C or C++ programmers. The interoperability between the two languages is excellent (to the point where one can compile in the other with few issues).

2) Infrastructure. Quite simply, the bindings for game engines and graphics frameworks are much more advanced for C/C++/C# rather than Java. Oracle has poured millions into Java as a business application language, not as a game development language.


[EDIT] If you're going to learn C, bear in mind that's it's barely one step removed from assembly language--it's very low level indeed. If you're used to having lots of high-level abstractions to help you out, prepare for a bit of a culture shock! :smallwink:

I still don't get where this is coming from. x86 looks nothing like C, and it's not exactly "one step removed from assembly language." Are you thinking of FORTRAN? C is powerful, and has a certain paradigm to it. That doesn't make it any harder to read or learn if you know another language... unlike Assembly. :smallfurious:

Grinner
2013-10-22, 12:02 PM
I know, I dabbled in C for my final year project at uni. I've got the absolute basics of it already, but I'd like to learn more.

C is an odd language. It's difficult to use, very fussy (though less so than Python), and makes strings a pain in the ass. But once you get past that, it can do some very cool things rather elegantly.

factotum
2013-10-22, 04:13 PM
Quite frankly, I'm amazed Minecraft runs so poorly considering how basic its graphics are.
.
.
.
I still don't get where this is coming from. x86 looks nothing like C, and it's not exactly "one step removed from assembly language." Are you thinking of FORTRAN?

I'm amazed at how *well* Minecraft runs considering how complex its graphics are! The sheer number of polygons that the graphics card has to deal with in a typical Minecraft scene is enormous--yes, everything is made of cubes, but there are a heck of a lot of them. Also, they can't use the usual trickery that 3D artists use to make a scene look more complex than it really is with judicious use of textures, shading, and lighting, because the scene is created by the player and they have to allow for any combination of stuff to appear.

And no, I'm not thinking of FORTRAN--that would be hard, considering I've never coded in it. The fact is, the basic C language syntax is incredibly simple--everything that does anything useful in a C program is actually part of a library and therefore technically not part of the base language; heck, the language doesn't even have support for strings, if you look closely enough! It really shouldn't come as a surprise that C is like that, considering it was originally intended as a way to write operating system kernels in a portable way.

Errata
2013-10-22, 04:27 PM
If you're looking to improve your resume, broaden your experience, and you already know Python, then C/C++ is the way to go. Python and C/C++ will both prove useful in particular situations in real life, but they are somewhat at different ends of the spectrum. The situations where you'll use one in real life will be rather different than the other. Java falls somewhere in between the two of those. So it may be useful as a stepping stone from one to the other, but ultimately knowing both ends of the spectrum will be a more useful goal to set for yourself.

C++ is mostly a superset from C (though there are a few minor differences), but if you learn C++ you basically know C, so I'd treat them as a single language rather than two. My advice would be not to go overboard with the C++ for no reason though. While you'll want to know the C++ stuff, when you use C++ you'll often be in situations where performance is relevant, and it's hard to keep track of that if you bury it under layers and layers of abstractions with complex STL type code. Use C++ language features rather than more basic C where it's genuinely helpful and clarifies your code, but don't use it gratuitously.

One of the key difference is going to be pointers. C coding is all about pointers, which you don't really have in Python or most other scripting language. Becoming intimately familiar with them will help you to be able to quickly pick up a variety of languages, and it's a very important computer science concept that you need to be an expert programmer. Your computer is using pointers all the time under the hood. If you don't understand them then you don't understand what's really happening and it limits your ability to understand important data structures and algorithms.

I don't have a lot of advice for how to pick up a language, but always have projects that you're working on, rather than just trying to read a textbook straight through. Start with simple examples, that you can actually get working in a short amount of time, not huge overwhelming things where you don't know where to start. Work your way up to bigger projects as your knowledge grows.

My company is always looking to hire strong C++ programmers. Each year it becomes slightly more difficult as more universities are teaching other languages, like Python. Python is good if you want to work at a dot-com company, but there are still lots of rewarding jobs out there that aren't web based and where you'll need a slightly different skill set.