57

I need to reconcile these 2 facts:

  1. I don't feel comfortable working on Linux;
  2. I need to develop software for Linux.

Some background: I have a 10+ years of programming experience on Windows (almost exclusively C/C++, but some .NET as well), I was a user of FreeBSD at home for about 3 years or so (then had to go back to Windows), and I've never had much luck with Linux. And now I have to develop software for Linux. I need a plan.

On Windows, you can get away with just knowing a programming language, an API you're coding against, your IDE (VisualStudio) and some very basic tools for troubleshooting (Depends, ProcessExplorer, DebugView, WinDbg). Everything else comes naturally.

On Linux, it's a very different story. How the hell would I know what DLL (sorry, Shared Object) would load, if I link to it from Firefox plugin? What's the Linux equivalent of inserting __asm int 3/DebugBreak() in the source and running the program, and then letting the OS call a debugger? Why the hell release builds use something, called appLoader, while debug builds work somehow different? Worst of all: how to provision Linux development environment?

So, taking into account that hatred is usually associated with not knowing enough, what would you recommend? I'm ok with Emacs and GCC. I need to educate myself as a Linux admin/user, and I need to learn proper troubleshooting tools (strace is cool, btw), equivalents to the ones I mentioned above.

Do I need to do Linux from Scratch? Or do I need to just read some books (I've read "UNIX programming environment" by Kernighan and "Advanced Programming..." by Stevens, but I need to learn something more practical)? Or do I need to have some Linux distro on my home computer?

gnat
  • 21,442
  • 29
  • 112
  • 288
rincewind
  • 547
  • 1
  • 6
  • 4
  • 73
    I feel same about Windows –  Apr 07 '11 at 06:32
  • 15
    Considered getting a another job you are more comfortable with? –  Apr 07 '11 at 06:54
  • 3
    On Unices `man` is your friend. I would `man nm` and `man ld` as a starting point. – dietbuddha Apr 07 '11 at 07:35
  • How is this constructive? – ChrisF Apr 07 '11 at 09:06
  • 1
    start using windows ;) – jmj Apr 07 '11 at 09:42
  • FYI some Linux distros have run-from-DVD or run-from-USB images ready to go. I tried Ubuntu the other day and it booted from DVD faster than the Windows partition on the hard drive (due to Windows' update-a-go-go on boot) – JBRWilkinson Jul 08 '12 at 09:37
  • If you have not been sentenced by a court to use Linux, don't. Not every developer must love every environment. It is OK to hate it. It is not OK to work on something you hate to that extent your message shows. – NoChance Jul 19 '12 at 09:43
  • 1
    "Everything else comes naturally"? Of course it comes naturally, you've been doing it for 10 years. Linux isn't worse, its *different*. And now that you're 10 years older, your brain doesn't learn new things as easy as it used to, and all those things which are different become something you have to unlearn. Approaching the entire thing with "Linux sucks" is going to make your life miserable. – JesperE Apr 26 '13 at 10:53
  • This question fails the requirements of being to the point, having a clear answer, and not soliciting endless debate and opinion. – Andres F. Apr 26 '13 at 13:09

16 Answers16

62

You might find the article Dynamic Linking in Linux and Windows interesting which explains how each OS does dynamic linking. The article Shared Library Search Paths explains how the libraries are found. Also Static, Shared Dynamic and Loadable Linux Libraries is very good. A nice thing about Linux libraries is that they have better support for versioning and having several versions of a library around than Windows (AFAIK, I don't do Windows). See Library Interface Versioning in Solaris and Linux for that. These articles should really get you covered with libraries.

The GDB is very mighty, a good introduction is probably RMS's gdb Tutorial. You might want to read up on conditional breakpoints. For equivalents to __asm(int 3) see the question Set breakpoint in C or C++ code programmatically for gdb on Linux.

The book Advanced Unix Programming from Marc Rochkind is a must-read, IMHO. Has lots of examples and covers all POSIX/SUS topics in a very well explained way. It's the best book about this topic I've read so far.

But to make your life easier I actually recommend to use a highlevel API that abstracts stuff for you, like Qt. Also makes writing cross-platform a lot easier.

Doing Linux From Scratch helps you get an understanding on how a Linux system is composed, but I think it doesn't much improve your knowledge about it from a developers point of view. It does make you more comfortable with Linux though, as you learn what parts are there in a Linux environment (and partly also why). A Linux won't be a big blackbox to you after working through Linux From Scratch.

DarkDust
  • 612
  • 4
  • 12
  • Sure, on 32bit system this interrupt will break into the debugger, _if the process is already being debugged_. That's this if I'm asking about. Windows allows to attach debugger _after_ the trap happened. Under some scenarios, this is extremely convenient. And thanks for the links! – rincewind Apr 07 '11 at 16:44
  • 6
    Great answer! Note, for the gdb tutorial, RMS is "Ryan M. Schmidt" not "Richard M. Stallman." (an important note since Stallman was the original author of GDB) – entropo Apr 07 '11 at 17:42
  • Windows had Side-by-Side (http://msdn.microsoft.com/en-us/library/ms229072(v=vs.80).aspx) library loading supported for around 12 years now. So you're rather wrong with regards to versioning. – Claus Jørgensen Jul 08 '12 at 18:59
16

If you like strace, don't forget ltrace: the equivalent for library calls.
Also, yes, I recommend Linux From Scratch. It's a good exercise in working out the core elements of the OS and how they fit together.
For a modern, complete system programming reference treatment, I'd recommend picking up The Linux Programming Interface.

Paul R
  • 706
  • 4
  • 14
entropo
  • 301
  • 1
  • 3
12

The Mac OS X is like a Mercedes; it's the prettiest and cleanest but it costs a lot. Windows is like a Toyota; it will get you there and back.

Linux is like a hot rod; It's for people to dig into and take apart and put back together again. Linux is not for someone who just wants to use the computer; it's for people who love computers. People who don't love computers should stay away from it.

The stuff you learned in Windows won't translate very well, no. But you get to see the internals and watch the engine run.

Try to take Linux as a new toy, that you can play with and crawl into and see what's going on. Things that are easy in Windows are harder in Linux; things that are impossible in Windows are possible in Linux.

If you love computers you can love Linux; if you don't love computers why are you programming at all?

Andy Canfield
  • 2,083
  • 12
  • 10
  • 13
    +1, for "_Things that are easy in Windows are harder in Linux; things that are impossible in Windows are possible in Linux_". I'd add "_Whereas Windows pushes pre-digested food in your mouth, with Linux you have the possibility to cook and the reward for this is that you get to eat what you like_"... Of course, whether it's edible or not depends a lot on how good a chef you are... – Alain Pannetier Apr 07 '11 at 08:36
  • Mind naming a couple of things that are "impossible in Windows" and "possible in Linux" (besides removing a locked file)? – SK-logic Apr 07 '11 at 09:44
  • 1
    Hm, recompile the kernel with your custom settings ? Develop an "installable file system" without paying big bucks for the license ? – Alain Pannetier Apr 07 '11 at 10:07
  • 14
    @Andy: *"Windows is like a Toyota"*. Toyota has much better quality than Windows. – Reinstate Monica - Goodbye SE Apr 07 '11 at 10:15
  • 2
    @Alain Pannetier, these are not technical differences. Surely if you've got Windows sources you can recompile your own kernel too. – SK-logic Apr 07 '11 at 10:25
  • 4
    @SK-logic, Precisely. Without engaging into yet another religious war, please consider the following. For mere strategic and financial reasons, MS target the largest audience possible. Technical stuff that computer aware users would like to be able to control are buried away out of sight so that the Joneses don't run into problems. You end up with red tape everywhere DEP, GPO, "Trusted installer", private or hidden APIs, "self repairing boot", etc. Geeks don't fix Windows, they just opt out. Linux does not have the same hegemonic goal; it's done by users for users. That's the whole point. – Alain Pannetier Apr 07 '11 at 10:52
  • 3
    @SK-logic - "if you've got Windows sources"... :-) – Rory Alsop Apr 07 '11 at 10:53
  • 1
    Windows is more of a Fix Or Repair Daily (FORD), IME. – user21007 Apr 07 '11 at 11:34
  • 1
    I'm a programmer and I definitely don't love computers. I love logic. – Eric Wilson Apr 07 '11 at 12:36
  • Neal Stephenson's OS analogy is ... station wagon : windows, free tanks : linux, batmobile : BeOS. See: ["In the Beginning Was the Command Line"](http://artlung.com/smorgasborg/C_R_Y_P_T_O_N_O_M_I_C_O_N.shtml) Stephenson switched to OS X after it was released, so batmobile can probably be transposed to OS X. – entropo Apr 07 '11 at 17:54
  • 2
    -1 for OSX - Mercedes comparison. If you can compare OSX to cars, it would be Pellandini – vartec Apr 08 '11 at 09:59
  • 3
    "Mind naming a couple of things that are "impossible in Windows" and "possible in Linux" - I found a bug in a Linux system script and fixed it. I have found bugs in Windows but never been able to fix them. Suppose you have an ISO (CD) image in a disk file; I can mount that as a drive in Linux; can you do that in Windows? And remember that nearly everything in Linux is free, and nearly everything in Windows requires an expensive proprietary application. – Andy Canfield Apr 15 '11 at 06:30
  • 2
    -1 I down voted this answer because it is not about the question but the good old OS flame. I myself use Windows 7 and found it quite decent. I also tried linux some years ago but I found it hard erto get my job done - I was paid for doing my tasks and not for hacking around in my machine :-) – Lorand Kedves Jul 07 '12 at 21:06
  • 1
    Continue: I am a programmer, I do love computers but I consider configuring my environment a waste of time. I think you can love cars and be a good driver even if you don't deal with the engine at all (yet of course you must know it well, but perhaps as a driver and not as an engineer). I bet F1 pilots don't touch the engine either. These are different jobs for different skills, yet we can all love this thing - differently. Cheers! – Lorand Kedves Jul 07 '12 at 21:22
  • Does this mean that drivers of mercedes can be compared to users of macs? They say a lot of the same things about the two... – Drake Clarris Jul 19 '12 at 13:17
  • @Andy I can (and very frequently do) mount an ISO file as a drive in Windows. – Jon Bentley Jan 16 '13 at 18:53
  • Not a good answer. In particular both Windows and Linux are Turning complete and therefore either one can solve any problem capable of being solved by any computer. Each OS has strong and weak points for different application domains. If you can program one, you can program the other. Just approach the new to you OS with a 'beginner's mind' and you'll be fine. – Jim In Texas Apr 25 '13 at 04:12
  • One other thought. I develop for Windows, Linux, and OS-X at work from time to time. The Windows file manager is a Maybach. The OS-X finder is a Yugo. Dolphin and every other Linux file manager I've used are rusty old Kmart bicycles. – Jim In Texas Apr 25 '13 at 18:20
  • @JimInTexas if you're using a file manager in linux/osx you're doing it wrong. Terminal FTW. – MrFox Apr 26 '13 at 13:04
  • 1
    I find this answer is outdated: nowadays a well-configured Ubuntu (or pick your alternative desktop-oriented distro) is ready for pop & mom to use it for daily tasks such as browsing the net, reading email, watching movies and listening to music. – Andres F. Apr 26 '13 at 13:12
  • @MrFox - If you're using terminal in Linux you're doing it wrong. Hollerith cards FTW. – Jim In Texas Apr 27 '13 at 13:42
9

How about you develop on Mono with Monodevelop? This would get you started quite easily by re-using your experience in .NET.

Johann Blais
  • 339
  • 2
  • 7
  • I tried this recently - some differences to Visual Studio, of course, but I was up and running in an evening. It's a great migration path. – JBRWilkinson Jul 21 '12 at 18:39
7

It's daunting when you look at it from the outset (just like if you were a Linux developer being tasked with doing some Windows development). I would tackle this one problem at a time.

  • First get your environment setup (compiler, IDE - yes they exist, Netbeans/Eclipse etc.)
  • Next get the higher level apis installed (boost/Qt etc.)
  • Start slowly, if there is an immediate problem to solve, get the code compiling (or start writing from scratch etc.) Like you would tackle any development project, get the stuff you know working first (i.e. things that don't need OS specific interaction), and then when you hit a snag - search, I'm sure someone out there has come across the same problem before and have resolved it..

Most importantly, leave all your subjective opinions at the door. And no, you don't need to be a guru to develop in Linux, I know enough to get around, and not everything - but I'm comfortable with that...

Nim
  • 1,363
  • 1
  • 11
  • 17
  • 1
    +1 Nim: StackExchange has an awesome amount of prior information here. I am most comfortable in flavours of Unix, but currently working in Windows development environment and searching SE has answered almost all my queries in a very short space of time. – Rory Alsop Apr 07 '11 at 10:55
6

I think you answered your question in the question:

"On Windows, you can get away with just knowing a programming language, an API you're coding against, your IDE (VisualStudio) and some very basic tools for troubleshooting (Depends, ProcessExplorer, DebugView, WinDbg). Everything else comes naturally."

Gues what, on Linux you can get away with just knowing a programming language, an API (or a couple), your IDE (Eclipse or NetBeans, even Geany, Emacs, or vim, if you like) and some basic tools for troubleshooting (gdb, tracing tools, lint, htop, ps).

You have a lot of knowledge invested in the Windows programming ecosystem. Much of that is (hopefully) abstract knowledge (what's a compiler, a debugger, a shared library, a process, a thread? What do they do?) that will tranlate easily, once you get up to speed on the different tools. Some is domain specific (What DLL is linked when I add X to a project?), but even moving from one class of language to another within Windows would require some new learning.

Install Ubuntu or Fedora in a VM, read some C++ Hello World in Eclipse or NetBeans tutorials, and some debugging in Eclipse/NetBeans tutorials, and let your brain's natural ability to adapt take over. It'll translate ideas for you if you relax and just put it to work.

Justin
  • 51
  • 1
  • 1
6

The success or failure of many thing in life comes down to our attitude, looking for positives and keeping your mind focused on the positives will do more to adide you as you start down this new interesting adventure.

How long did it take you to become proficient in working in a windows environment. You might say it was easy you just started. But you had a few years of working with windows before that. How long had you been using windows before you wrote your fist program. It was 8 years for me, all though I have now been using Linux almost exclusively for 5 years. I am now more proficient in Linux then in windows. You should give your self at least that much time to become familiar with a new system.

Start off with the list of application that you can't live with out in windows and look for alternatives in the *nix world. http://alternativeto.net/ and the Wikipedia further reading sections can be helpful here.

Here is a list of alternative software that could prove to be very useful. Here are some alternitives to the things you mentioned.

Other useful resources in moving from one system to another

About becoming a better power user or admin user have a look at these resources

It also sounds like it has been a while since you have looked at the *nix world. I would recommend some of the new distros releases from fedora, suse, debian, or my prefered work station Ubuntu.

You can now probably get away with not know the internals of the system and just the basics as in windows. I would not just try to get away with the minimum. If you see Linux as a tool that actually assists you in your development and not merly an operating system in which you develop it would be helpful.

Linux From Scratch will be much more important if you are specifically developing for Linux is a very specific and technical sense. I.E. you want to develop for the kernel, or port you program on to a super computer running Linux. It would be very useful never the less. I think you could probably leave that for a few months while you just try to get going in Ubuntu. Ubuntu will be as close to the things just work world of mac and windows.

nelaaro
  • 172
  • 1
  • 10
3

I learned Unix in general by reading the man pages. You should at least skim them. Yes, I mean all of them. The method I use it to cd into the man page directories, and attack them one section at a time.

I use this:

for i in *; do f=`basename $i .gz`; man `basename $f .1` ; done

...replacing the .1 with the number of the section you are reading, .2, .3, etc. Hit ctrl-Z ctrl-C to get out of the loop. You mileage might vary if your linux distro stores things differently, i.e. not as cmdname.1.gz.

Just go through the descriptions, and more if it's something interesting. Sections 1, 2 and 3 are the most important for a programmer. 1 covers general user commands, which include your compilation tools, and various forensics utilities. 2 is system calls, and 3 is library calls.

Hack Saw
  • 274
  • 1
  • 5
  • 2
    I'd suggest to fire up `xman` as a more “friendly” interface. Select a section, click the man page, read it. Rinse, repeat. – ΤΖΩΤΖΙΟΥ Jul 08 '12 at 20:56
  • I'd forgotten about such things. The state of documentation in free OS land is less than ideal, and I found the tools often made it worse, so I stopped using them. I can only assume they've gotten a little better? – Hack Saw Jul 11 '12 at 19:52
3

Do not force yourself into doing something you do not like. Use Windows as your development environment, write a portable code, cross-compile it for Linux, and only test it occasionally in a VM.

SK-logic
  • 8,497
  • 4
  • 25
  • 37
2

I'm not sure it works for platforms but for programming languages, I've found it helpful to think about how I got familiar and comfortable with the ones I'm good at and try to replay those experiences and activities for the what I'm trying to learn.

Perhaps something on those lines?

Generally speaking though, my interest and confidence with GNU/Linux has come by it being much more tinkerable (and requiring of tinkering in the early days) than Windows. I needed to mess with a lot of stuff to get things working and that helped me learn a lot of stuff. Things are much better now but all those hours helped.

Noufal Ibrahim
  • 311
  • 1
  • 4
2

I was one of two tasked with something similar, but different. I work in a K-12 school district, and the business system (HR, financials, etc...) is migrating from an HP3000/TurboImage db to a Linux/MS SQL platform. I'm comfortable with the MS SQL side. But not the Linux side. The two of us are on the admin side, not the programming side. The programming is done outside - 3rd party business app for K-12 orgs.

I took a 5 weekend Intro to Linux (Redhat) class on weekends - was done mostly in command line mode - and it was worth the time for me as a quick jumpstart into the Linux way of doing things. Obviously YMMV depending on class/teacher.

You mentioned 'Worst of all: how to provision Linux development environment?'? Since you're very familiar with Windows already, I would strongly suggest you get a copy of vmWare Workstation. With that you can keep Windows as your workstation, and install Linux as guest systems - delete, rinse and repeat as needed. When you get a good setup, I believe you can snapshot it, but I can't say for sure which versions are capable of the snapshotting aspect. And if you go in the vmWare Workstation route to enable multiple development setups - bump up the memory, definitely.

I also don't mind recommending using CentOS as the Linux OS for the guests. From what I understand, it's like RedHat without the branding and/or sales pitch and/or support costs. I'm not familiar with the other Linux flavors, so can't give input on those.

Greg

1

Consider this: you once didn't know anything about Windows, but you learned it and over time became comfortable with it.

Then MS changed whatever programming system you were comfortable with to .NET and you no longer knew anything about DLLS, COM, and whatever, you had to learn things like assemblies, GAC, app domains. You learned those ok.

So why are you now worried about doing the same with Linux?

There are loads of 'get you started' tutorials on the web for all kinds of programming environments. Now you say GCC so I'm going to assume C++ development. Get yourself Eclipse, install the CDT (c dev tools) on top of your Eclipse platform (Eclipse is a multi-purpose IDE, you can use it for C++, PHP, Java, whatever - but you need to install the tooling for your language as you wouldn't really want it all pre-installed like VS and take 3 days to install :) )

There are easy-to-use tutorials all over the web. IBM has one here that is quite comprehensive.

Debugging tools... eclipse has it embedded (tutorial), but you can find plenty of tools like the ones you mentioned, just search around the web and you'll find lots of options. It will take you a little while to figure out how to read a core dump (as opposed to a windows userdump for example) but you'll get there.

It might also be worthwhile starting a blog with your experiences, not only will it allow you to remind yourself of what you've done (eg setting up eclipse how you like it, you'll forget when you need to do it again in a year's time) but it'll help others in your situation.

gbjbaanb
  • 48,354
  • 6
  • 102
  • 172
1

I like both platforms and for all the differences in the user interface and the dev eco-system, I find them more similar than different under cover. In fact, for most Windows concepts you can find an equivalent Linux ones just by searching the Internet.

Having said that, I strongly suggest learning how to do things the "Unix way". Use command line rather than buggy GUI front-ends (I am talking mostly about gdb here); don't look for an IDE, and learn how to use a set of specialised tools instead. Pick a good editor (pointing to vim) and learn it well. Read how make works even if you don't plan to become an expert. Maybe you even get to like Linux. It is geek-friendly and fun to play with.

Nemanja Trifunovic
  • 6,815
  • 1
  • 26
  • 34
0

I don't think you need to do Linux from Scratch. If I were you I would go for Ubuntu. It is more comfortable, and being based on debian, there is plenty of technical material available.

If you do want more of a head-first dive into Linux, Gentoo is a good option. It requires you to read quite a lot about configuration and kernels, but it also gives you quite a functional system to work in af

0

Google "The art of Unix programming" and read it. IMO, your main difficulty is the different philosophy, and that book is excellent reading for this.

It also introduces you to some non-obvious but technically very important differences between *n*x and Windows systems - these being key to understanding why doing things another way makes sense on Linux.

  • 1
    ... and it also presents you with a lot of tools and techniques to use on Linux. –  Jul 19 '12 at 04:06
0

The first question I'd ask is what is it that you want to develop? If it's a gui-based application then that can be different from having to write something like a kernel extension.

In the case of a gui app, I find the easiest method is to use Qt, which has its own development environment (Qt-Creator) and being cross-platform, allows you to learn just one API that can be used for Windows / Linux / OSX and even mobile development. Like visual studio in Windows, or XCode in OSX, you can create and layout windows and items from a graphical editor and the API is very easy to pick up with loads of sample applications.

If you need to get more low-level, then once you know your way around linux on the command line, know how to traverse directories, manipulate files, understand permissions etc., then either start reading how to compile a simple program with gcc, how to link files and run the executable and then how to debug with gdb.

Alternatively, if that seems a little daunting, you could download Eclipse or another IDE, but you'll probably become much more comfortable with Linux in the long term, if you put the time and effort into the command line first.

TheDarkKnight
  • 486
  • 3
  • 6