View Single Post
Old 07-24-2011, 08:23 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
These aren't stupid questions at all. They're questions that should be asked as they differentiate between programming (knowledge of how to perform tasks with programming code) and languages (the tools chosen to implement that knowledge). Its like determining that you wouldn't use a screw driver to hammer in a nail, and frankly elementary is what many programmers often lack. So your questions are more than valid.
  1. You choose a language most suited to the task at hand. C and C++ are 'better' for GUI implementations because you work with them at a much lower level than languages like Java. Java uses bytecode interpretation, so you write java code to implement the gui and allow the JRE to choose how it wants to implement it based on the system its running in. Pro to Java is that it should work the exact same on any system you run it on with the JRE without needing to modify the code, while C/C++ would require a specific build for the OS and architecture in use.
  2. Languages do not usually interpret other language's source code unless it was designed to do so (ie: PHP is interpreted by C). You can write straight C in a C++ compiler if you wanted to, but typically you would interact with another language in one of three ways. Either by linking a dll/so into the other code and calling it directly into the other language, creating a new process of the original application and provide it the input and capture output, or by passing data between two processes in a way they understand (such as XML). Java cannot compile C code, and PHP cannot talk to Ruby, but both are capable of doing so with alternate means including constructing new processes or simply passing data.

Choosing a language is all about the trade offs. What do you gain from choosing one language over another, and what do you sacrifice. Choosing C over Java provides you with a much faster application, but loses the ability for a direct cross platform application (specifically a GUI I'm thinking of). Choosing PHP in a web environment over C grants you much more rapid application development, at the cost of speed and low level control.
Knowing what to sacrifice for something else simply comes from experience; I wouldn't write something in C to develop a new website, unless it was on a direct extension to PHP code (which is interpreted in C btw). This is because I'm well aware of how many websites support PHP code for their development, and how few will allow a direct extension to the currently existing PHP engine.
Besides this, you must know the limitations of what a language is capable of doing; typical built PHP code cannot generate a GUI interface, Java and C are not capable of operator overloads, C is a procedural language, C# is object oriented, etc, etc.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Nightshade_II (07-25-2011)