Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-18-2009, 06:41 PM   #1
LQ Newbie
Registered: Aug 2009
Posts: 18

Rep: Reputation: 0
A Newb wondering about programming in multiple languages

Well I have been interested in programming for a while, and just found out about Linux and Unix. I started out with Java, but now I know I bunch: Flash, C++, C and others. I was working on a mac so I made a few flash games then started to work on iPhone games. I was board one day and I found out about Unix and I thought that would be something else to try.

So in an attempt to learn about Unix I have been reading different articles about it, and have heard of using different languages in one program. The article I was reading didn't give any examples, and it assumed the reader has programmed Unix before.

So how do you write programs in multiple languages, which languages would you use, and why would you want to do that?

Thanks for the help,
Old 08-18-2009, 07:27 PM   #2
Senior Member
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
You just write your modules in the appropriate language, compile with the gcc toolset, and link it all together. Sometimes you have to do certain things in the code or in the compile or link options to make it work but it is always do-able.

Why do it? Sometimes you want to talk to a library that is written in a certain language, and using a module written in that language to talk to it is easier. Sometimes what you want to do is convenient in one language and harder in another language. Sometimes you are taking existing code from one language and want to use it in a program that you are writing in another language, without rewriting that module. All kinds of reasons why.

I routinely mix C and C++ modules, and sometimes I even throw in some fortran.
Old 08-18-2009, 07:33 PM   #3
Senior Member
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Originally Posted by kcaz View Post
So how do you write programs in multiple languages, which languages would you use, and why would you want to do that?
You might want to start your game using Python and the pygame library. You might find that you need to speed up a portion of your game, so you might write a Python extension module in C. You might want to customize Python, so you might write a Python extension module in C++ to get access to templates and the STL.
Old 08-19-2009, 12:16 AM   #4
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,706
Blog Entries: 4

Rep: Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030
Always try to program new stuff in the "highest-level" programming language available to you. For example, if you can possibly get away with doing the whole thing (say...) in Python, then you should by all means do that.

Here's why: even a single line of code in one of those languages will invoke very large amounts of well-tested low level code written by some of the smartest minds around. That code has been extensively tested, and execution-wise it is sure to be "more than fast enough for your purposes." The time that you're trying to save here is, your time.

If for some reason you found that things were "just not fast enough," then you should run a profiler on the code to determine where and why this is so. Your first response then should be, "find a better algorithm."

Certainly, programs can be written in a multitude of languages. But, especially at today's processor speeds and system capacities, the most urgent objectives are your speed and efficiency in developing a robust application.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Languages where did it came from SBN Programming 14 11-05-2007 08:20 PM
'commercial' use of programming languages?!? suicideducky Programming 4 05-04-2007 03:34 AM
What programming languages do you know? ugoff General 24 12-13-2004 07:01 PM
How many programming languages do you know? MikeZila Programming 4 07-25-2004 02:26 PM
new to programming and linux wondering a few things... kato678 Programming 4 05-30-2002 08:10 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:24 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration