LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 08-18-2009, 05:41 PM   #1
kcaz
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,
Kcaz
 
Old 08-18-2009, 06:27 PM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
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, 06:33 PM   #3
David1357
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
Quote:
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-18-2009, 11:16 PM   #4
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,381

Rep: Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109
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.
 
  


Reply


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 07:20 PM
'commercial' use of programming languages?!? suicideducky Programming 4 05-04-2007 02:34 AM
What programming languages do you know? ugoff General 24 12-13-2004 06:01 PM
How many programming languages do you know? MikeZila Programming 4 07-25-2004 01:26 PM
new to programming and linux wondering a few things... kato678 Programming 4 05-30-2002 07:10 AM


All times are GMT -5. The time now is 11:37 AM.

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