views:

1978

answers:

20

I recently moved from the Microsoft world (Windows XP) to a virtual machine and I am now using Ubuntu Linux.

I would like to learn to program in this environment, but I need guidence as to any book that outlines the basics. I am also not sure which language to start in (Java, Python, Perl).

What is the best place for me to begin?

+8  A: 

Start with C. Use the Bible.

http://www.amazon.com/Programming-Language-Prentice-Hall-Software/dp/0131103628

BobbyShaftoe
The link appears to be broken.
Shrivara
It was working three days ago...
yjerem
Found it in pdf format after a bit of searching: http://compscgug.googlepages.com/kandr.pdf
yjerem
^ Someone please remove this comment above me (and mine when its done)
Ólafur Waage
+2  A: 

One of the great things about Linux is that there's a compiler or interpreter for just about any language, and many distros have them installed by default.

You can program in Java, Python, or Perl on Linux. They're great languages to start with, but programming in Java, Python, et al. on Linux is not fundamentally different that programming in these languages on Windows. You won't see a dramatic difference until you start programming in a language like C, and start doing systems programming. However, writing in Java or Python is perfectly fine -- especially if you don't know any of those languages yet (or don't know them inside and out).

mipadi
+5  A: 

What problems are you trying to solve by writing software? The environment you work in (mostly) irrelevant to the actual problem you are trying to solve, unless that problem is something in the environment itself.

Or do you just want to learn to program, and don't have a specific problem to solve (yet)? In that case, I'd suggest picking a small problem, to give yourself some direction. You will learn as you solve a problem!

pkaeding
A: 

What programming language(s) did you use on windows? I would suggest working with something higher level like python, ruby, etc. if you are used to VB, and C/C++ if you're more confident with things like Java/C#.

semmons99
+7  A: 

Programming in Unix (Linux offers a very similar environment) is a lot more than programming in a particular language. It's a mindset of using effectively the many tools, libraries, and languages that are available on a typical system. I suggest to start by reading Kernighan Pike's classic book The Unix Programming Environment. It is also important to understand Unix's philosophy. Eric Raymond's book The Art of Unix Programming is another book I'd recommend. Whatever you do, don't shy away from the command-line. This is where the power of Unix lies.

Diomidis Spinellis
For anyone who is interested, The Art of Unix Programming is available online here: http://catb.org/esr/writings/taoup/html/
Bruce Alderman
yes...don't reinvent the circle :)
dotjoe
+1 for not shying away from the command line. Neal Stephenson's "In the Beginning was the Command Line" ( http://cryptonomicon.com/beginning.html ) provides enjoyable literary support for this view.
mas
A: 

In my opinion is pointless to start with a very low-level language. Start with C++ and try to create something you need, or you'll get bored quite soon; moreover C++ will turn handy soon or later. And maybe take a look to the make basics, just to build comfortably.

tunnuz
How is it pointless? The vast majority of programs written on Linux are written in C++.
BobbyShaftoe
Not true. Ignoring the fact that that statement is hard to quantify and measure, most Linux programs are written in straight C. C != C++.
Adam Rosenfield
That's what I'm saying. Learn C++ instead of C.
tunnuz
tommaso, are you stupid?
@Adam Rosenfield, I meant C not C++. My answer above, which keeps getting voted down, says to learn C. I just accidentally wrote C++. So, I guess I should say again, why is it pointless when the vast majority of programs on Linux are written in C.
BobbyShaftoe
A: 

I'd recommend you start with building toy LAMP Web applications. onlamp.com is a reasonable starting place. What this does is, rather than focusing you in on "I'm going to learn this programming language", brings you into the integrative, whole-system process of making products that deliver some kind of functionality to an actual user on the Web.

chaos
+5  A: 

It seems that you are going to be spending a lot of time in Linux. I would therefore recommend you learn some of the following:

  • bash (very useful for small automation and admin projects)
  • python or perl for more complex programming (perl is really good for manipulating large text files easilly)
  • C or c++ you should know from your Windows days :)
  • I can also recommend Beginning Linux Programming 0174d7c0e81060f29a04da793438efec

For bash and perl any of the O'Reilly books will help a lot.

Francois Wolmarans
the book you linked is great i read it cover to cover
Matt Joiner
+3  A: 

Spare yourself the trouble of C++/Java for the moment and get familiar with shell and another scripting language. Shell is a must for understanding how Linux works, and Perl/Python/Ruby will keep you in for more interesting tasks.

When you're comfortable with the shell, you can venture into C++ (familiarize yourself with Makefiles and one of emcas/vi first) or Java (Java has a wonderful dev environment that's likely to work out of the box).

Arkadiy
+3  A: 

A good book is Advanced Programming in the Unix Environment. If you're not new to programming (ie. if you've done C / C++ programming under Win32) but you are new to Linux, this will give you a leg-up on writing apps.

For script programming, I often turn to O'Reilly's cookbooks:

Finally, for a big rant on Unix programming culture, check out The Art of Unix Programming.

Congrats on the decision to branch out from Windows XP development! If your experience with Linux is anything like mine, you will probably find that programming becomes much more fun.

Parappa
+17  A: 

I recommend you peruse the advice in Eric Raymond's How to Become a Hacker and compare it with the recommendations you read here as you are deciding.

If you have C/C++ experience, I recommend you start with that language in UNIX. Get ahold of a UNIX/Linux systems calls book to teach you what all is available in the operating system libraries. Spend a year becoming familiar with them. Write some applications to do UNIXy things, such as processing an arbitrary number of lines of input as a filter, redirecting input and output, forking and exec'ing processes, etc.

If you haven't done C or C++, then I recommend you start with Perl. Get ahold of O'Reilly's Learning Perl and go through that; then read the online perldoc documentation for Perl, one document at a time; execute the command perldoc perl to get a list of perldoc documents to read. Build some UNIXy things in Perl, as above.

Regardless of where you start, also spend that first year becoming familiar with what you need to know to use your shell (bash) effectively in an interactive context, and also how to use a good, traditional, programmer's-oriented editor like vim or emacs. As part of learning to get around the shell, learn to read man pages.

After the first year, I'd add a language a year or so and work toward getting a good grasp of it. You want to cover Perl, C, C++, Java, Python, shell scripting, and if you want to go for true programmer enlightenment you want Scheme or Lisp [this isn't for UNIX mastery, though].

What follows is my subjective opinion (more subjective than above, that is):

  • Depending on your experience, you could probably combine C and C++ in a single year. C++ can also probably be dispensed with if you learn Java. With Java and C experience, you could pick up C++ quickly later if you need it.
  • You probably only need one of Perl or Python. Again, with one you can probably easily pick up the other. I am biased in favor of Perl (a not unreasonable bias, IMO :) ). You can find informative debates about which is "best" elsewhere on SO.
  • If you learn Perl or Python, you probably don't need a full year of shell scripting experience. Just enough to learn how to automate simple tasks in the shell, to read scripts you encounter, and to learn why you should always use a dynamic "scripting" language like Perl or Python instead of shell scripting.
  • Learn to compile open source software packages from source code, including your own Perl (or Python). Learn to install in non-standard locations.
  • Look up the Linux From Scratch HOWTO and work through it at least once.
  • For real UNIX mastery, get a Linux kernel internals book and play with the kernel.
  • For real programming mastery, learn Scheme or Lisp. I'm sadly not there, yet, although I did both in college, years ago.
  • Learn to use the CPAN (which will require Perl).
  • I do not recommend TCL as a language, but O'Reilly's Learning Expect by Don Libes really contributed a lot to my understanding of the UNIX way, as well as containing a lot of random miscellaneous pieces of UNIX information I didn't see anywhere else. (Expect is a TCL-based language.)
skiphoppy
+4  A: 

I started this as a comment on the original question, but decided to post a more complete answer...

Your question is too broad to elicit a reasonable answer. You need to refine the question and describe what exactly you mean by "learn to program on Linux".

For example, most linux disributions now come pre-loaded with C/C++, Java, Perl, (probably) PHP as well as at least one database (Postgress or MySQL).

So what do you you want to create with these programs? Web sites? Utilities? Modify the Kernel? Write an email program? Until you define your goals, it's hard to even suggest the "most optimal" language to use and learn.

If you really don't know, I'd suggest you grab a good book (Java, C, Perl, PHP), learn the VI editor and then go through the book's exercises.

Cheers,

-Richard

Huntrods
Hehe, bonus point for the "Learn the VI editor" comment at the end. ;-)
Claes Mogren
A: 

I've also recently started development in Linux land. Coming from a Windows background, here's the path I took:

  • Find and learn a text editor with syntax highlighting. I went with emacs.
  • Figure out the command line compiler for your language of choice.
  • Start coding.

apt-cache search "thing" and sudo apt-get install thing" got me a long way towards filling in the blanks.

If you're looking for a language to learn, I'd recommend C++. The C++ Programming Language by Bjarne Stroustrup has tons of exercises that will keep you busy for years.

Gabriel Isenberg
A: 

You may want to try http://www.advancedlinuxprogramming.com/

It's concise and includes samples.

A: 

This Slashdot question has some good answers regarding programming languages:

What Programming Language For Linux Development?

My suggestions are that if you're a .net C# programmer, why not try using Mono and MonoDevelop? You'll feel right at home. But as people asked above, depends on what kind of programming you want to do.

Another tip that I have recently played around with is PyGTK. I used it to make some simple GUI applications and found it really easy to work with and there are plenty of good tutorials on the net.

Claes Mogren
A: 

It is possible to approach Linux at different levels of abstraction. In many respects a Linux desktop such as Ubuntu is similar to a Mac.

For example do you want to write desktop applications? You may only need to learn GNOME or KDE, and the language/framework of your choice (Mono may be a good choice if you know .NET). It's possible to write apps in scripting environments also. And of course the beauty of Linux is you can go look at the source of anything you see on your desktop and reuse parts of it. Which language? Up to you. Whichever is what you know already, or closest to what you know already.

If you want to write web applications, frameworks like rails work much the same on Linux as they do on a Mac, and not that much differently than they do on windows.

You may not need to learn the 'Unix' aspects at all, but it does help. You will probably benefit from learning the default shell environment (usually bash - equivalent to the command line on Windows - and the same as bash on windows :-)...and learning some scripting ability would be useful. There are tons to choose from - bash itself, perl, python, ruby, etc etc. There is not really a 'wrong' choice here (though perl comes close. ahem. :-)

Similarly you don't need to know C or C++ at all, but it helps.

One thing you will probably find unavoidable ultimately is to learn some amount of Linux system administration. However you can do most of that through the GUI these days.

Good luck

frankodwyer
A: 

The Art of Unix Programming (by Eric Steven Raymond) tells you a lot about the philosophy behind Unix (Linux considered a variant). Particularly why certain things are done in ways that may seem unfamiliar to people with no prior Unix experiences.

The good thing about this book as compared to more technical ones is that it does not try to tell you a lot of details, such as how to use each and every system call in Unix, but rather delivers the Tao in a way that common folks can appreciate (the book was said originally titled The Tao of Unix Programming). On the other hand, it does give a lot of references for further reading if you become really interested in the details.

Best part: It's free. Just google it.

PolyThinker
A: 

Questions similar to this have been asked on Stackoverflow Here, Here and probably in several of the postings that a Search on 'Linux and Programming' turns up. You might want to take a look at the fan-out in the answers to these questions for some good resources on Linux programming.

ConcernedOfTunbridgeWells
A: 

Quite frankly, most programming language are platform agnostic. If you already know how to program in some language (say X) on windows, you can get a similar IDE to compile/run X on Linux too. Then I would suggest when you get your code up and running, slowly wean yourself from the IDE and start using the powerful command line to get the things done.. one baby step at a time. This involves:

  • Finding the editor that fits your style. Emacs and Vi are the most popular.. but use whatever you are comfortable with. You will slowly gravitate towards the one of those eventually (if you stay on Linux long enough).
  • Finding a compiler/interpreter. This is a no brainer most of the time. Most modern distros are supplied with compilers/interpreters that you would need. You can learn about their options when you need them.. dont have to learn them all at once.
  • Getting a good debugger for your code.
  • Learning to use a profiler.
  • Learning about toolkits. Eg Qt or GTK for gui development.
  • If you need to get into system programming, start with a book on system calls... if not don't worry about it too much.

PS: if you don't know how to program in any language, just pick up a good book on programming. What language you want to use, is a matter of personal choice.

Sridhar Iyer
A: 

Try setting up Gentoo Linux. I gained most of my experience and appreciation of linux after having to compile this entire operating system from scratch. It's not too hard as long as you have another computer with the instructions on the screen and have the mental capacity to follow them.

It also helps that all applications you install are built from source so it's easy to poke around and see how everything works.

Ryu
Did it teach you to program in linux?
Joe Philllips
He didn't ask how to be taught programming in linux. He asked how to get started. I was already in college for programming when I installed gentoo. Having easy access to all the source and seeing how everything was built from scratch was a great start for programming on linux.
Ryu