ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How easy is it to program for other platforms from another? For instance, could I write Windows programs in Linux or BSD Unix? How about for MAC OS X? Could I write a Linux program in BSD Unix, or vice versa?
You could start by reading an article on wikipedia about cross-platform programming here. Basically, it will heavily depend what kind of programs you are doing, what language you are using and things like this.
It is actually really easy to program for windows/bsd/linux from one of the others.. they all provide ide's and text editors inside which you may write code. But you mean generating executable's, thats another story.
One thing to consider is your interest in programming, do you wish to learn? You may find an OS like linux will be not only fun to learn, but it will tend to push you towards doing new things with your computer, possibly due to the generally different culture of its users. It tends to be more of a "how to" culture than windows, a world where people tend to pay for (or steal) software to do certain things rather than harness the power of free software, although thats not always the case.
All that to say, linux & the bsd's tend to be more programmer oriented. Its worth taking the plunge.
Specifically about programming, most programs you will begin to write will not be "in bsd" or "in linux," but will be aware of their own data and interaction with the user. The program interacts with the os through "system calls," basically handling stuff like user input, output to screen, writing to the disks and using the network. In C, printf() will work in a program on bsd, windows, whatever, as long as the stdio.h library is implemented. So the idea is that the library implements the printf() function differently on different platforms, but it is called the same way whether its a windows or unix console app. However not all libraries are implemented on all platforms. Allegro is a game programming library that is very portable (C, C++). Compiling is another issue, a cross compiler will have to be set up properly to generate code for the other platform.
Lisp, python, and java are examples of languages that don't need to be compiled to "native binary"--this is to make their use more universal. There are lots of good tutorials on these languages. Another consideration is web programming, a la the idea of programs interacting with the user over the internet. You can get exactly the same web interface on different os's, while running the program itself on the platform you want.
I can sort of see how you could write the code for another platform, but how would you test it. Even if you could compile it with a cross compiler (please tell me more about these), how would you test and debug it?
As far as languages, I am more interested in the traditional languages like C/C++, ADA, Assembly, etc. I don't think I would like to use Lisp (I don't like EMACS) or JAVA, which has never impressed me and at times annoyed me from a user standpoint.
My experience in programming is limited. I learned Pascal via TurboPascal 7 in high school and a class in Visual Basic in college, which didn't teach me anything but how to fumble through a very sloppy program - oh, and I wrote the 'hello, world' program in C. But I am eager to learn much more! I am already familiar with Linux and a little bit with BSD Unix. I was raised with Windows so I know that OS. I am fairly knowledgable in networking and know how to build a computer from scratch (and repair them, too). But I feel incomplete and lacking without programming skills.
When I have to write a cross-platform app that has to work with Windows, or requires a GUI, I use the QT toolkit. QT is a cross-platform C++ library (there are bindings so you can use other languages with it as well). QT handles networking, file i/o, gui stuff, ect. so you don't have to deal with writing special code for Windows vs. strict POSIX OS's.
If I'm writing a non-gui app that doesn't need to run on Windows (which is usually the case for me) then I just use the normal unix-c stuff.
As far as testing is concerned, with QT you can test on any platform it supports, but ultimately you will probably want to do final testing on all platforms you intend your program to run on.
JMJ, the higher-level language you use, the easier it will be to go cross-platform, but the less direct control you'll typically have over your hardware and operating system.
Sounds like you want to learn more C. C is most often used for writing drivers and low-level libraries used by other programs.
If you're interested in networking, you might check out W. Richard Steven's books about TCP/IP. Also look into what POSIX means.
Note that C, networking drivers, and POSIX, are some typical staples for hardcore cross-platform unix hacking.
I don't think I would like to use Lisp (I don't like EMACS)...
Lisp doesn't have anything to do with Emacs except that Emacs is written in Lisp. That's a one-way association, there. Many people write Lisp in an editor other than Emacs; you could use Vim or jEdit or any other text editor. And actually, that one-way association is verly loose at the user level, because you can use a lot of Emacs' features without understanding an ounce of Lisp code. But to automatically dismiss Lisp because you don't like Emacs -- well, that's like saying I don't want to learn C because I don't like Windows.
I can sort of see how you could write the code for another platform, but how would you test it.
You could use virtualization to test your binaries inside the host operating system, eg. vmware server. On linux you can run windows and bsd guest os's for example. Pearpc allows you to run os x. But it would still be worth it to test it out on the os running on real hardware eventually, I believe most virtualization softwares give you a somewhat generic hardware profile, eg. the os may *think* its using a 3com network card when the real hardware is different. Some bugs may only expose themselves with certain hardware and drivers. If you decide to code in higher level languages than C it may be less of an issue.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.