Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-24-2011, 07:15 PM   PM User | #1
Nightshade_II
New to the CF scene

 
Join Date: Jul 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Nightshade_II is an unknown quantity at this point
Question Just a few general programming concept questions that Google couldn't answer.

I'll preface this by saying it's okay to laugh if what I'm asking is a bunch of elementary stuff. None of it is syntax related, just trying to get a better grasp on certain concepts before I really get into the nitty gritty of learning a language.

I figured using a hive mind of good programmers was the best way to go.

So my questions are this:

1. Why is one language better than another? For example, people might say C+ is better for visuals than Java. But why is that true? What makes goes into making them different?

2. I've heard reference to Coding languages being used as "Glue" acting as a overall construct, within which are aspects written in other languages. How does that work? How can a program start reading in a different language for a portion of it's processes?
Nightshade_II is offline   Reply With Quote
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,650
Thanks: 4
Thanked 2,451 Times in 2,420 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)
Old 07-25-2011, 02:59 AM   PM User | #3
Nightshade_II
New to the CF scene

 
Join Date: Jul 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Nightshade_II is an unknown quantity at this point
That's definitely very, very helpful. You're exactly the kind of person I was hoping would answer.

However, your explanation raises a few new questions

1. You mention the terms higher/lower level. How one programming language operates on a lower level? Does that mean in a manner closer to what the machine ultimately understands?

2. I understand JAVA is platform independent, but (In stuff like C) do things need to be recoded on different OS's?

3. Why can a langauge have the ability to generate a GUI while others don't?
Nightshade_II is offline   Reply With Quote
Old 07-25-2011, 03:23 AM   PM User | #4
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Quote:
Originally Posted by Nightshade_II View Post
1. You mention the terms higher/lower level. How one programming language operates on a lower level? Does that mean in a manner closer to what the machine ultimately understands?
Yes that is correct.

Quote:
Originally Posted by Nightshade_II View Post
2. I understand JAVA is platform independent, but (In stuff like C) do things need to be recoded on different OS's?
It depends on what you are writing, a lot of code doesn't need to change. You just need to recompile the code on the different target (OS and/or architecture).

In some areas like GUIs if you write for the OS' native implementation then yes you would need to recode a lot to move say a Windows GUI to run on X11. However there are a number of GUI libraries you can use such as Gtk+, Qt and wxWidgets that will alleviate that problem.

Quote:
Originally Posted by Nightshade_II View Post
3. Why can a langauge have the ability to generate a GUI while others don't?
The GUI limitation isn't really because of the language, in terms of syntax, it is just limited to whatever APIs are exposed to it. And some languages don't have the support for GUIs because there isn't a lot of point. For example PHP is targeted for developing web applications where creating desktop like GUIs isn't needed.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 07-25-2011, 04:30 AM   PM User | #5
Nightshade_II
New to the CF scene

 
Join Date: Jul 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Nightshade_II is an unknown quantity at this point
Quote:
Originally Posted by oracleguy View Post
Yes that is correct.



It depends on what you are writing, a lot of code doesn't need to change. You just need to recompile the code on the different target (OS and/or architecture).

In some areas like GUIs if you write for the OS' native implementation then yes you would need to recode a lot to move say a Windows GUI to run on X11. However there are a number of GUI libraries you can use such as Gtk+, Qt and wxWidgets that will alleviate that problem.



The GUI limitation isn't really because of the language, in terms of syntax, it is just limited to whatever APIs are exposed to it. And some languages don't have the support for GUIs because there isn't a lot of point. For example PHP is targeted for developing web applications where creating desktop like GUIs isn't needed.
Right. Once again, very helpful. Now when you mention API's. Those are libraries right? A library is premade set of tools? So if an object is a tool, than a Library is the shed?
Nightshade_II is offline   Reply With Quote
Old 07-25-2011, 05:08 AM   PM User | #6
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Yeah by APIs I meant libraries. Your analogy is more or less accurate. A library is a collection of code for a specific purpose.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 07-25-2011, 05:37 AM   PM User | #7
Nightshade_II
New to the CF scene

 
Join Date: Jul 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Nightshade_II is an unknown quantity at this point
A collection of code that is written in the respective language, right? I was reading on some site about multiple languages accessing the same API's and couldn't quite grasp who that was possible.


And just to clarify, code syntax is the same across all OS's then? It's just that some poor blokes at the Language developer has to get knee deep in a computer and create a compiler that can take then code and turn it into machine code for that OS?
Nightshade_II is offline   Reply With Quote
Old 07-25-2011, 10:53 PM   PM User | #8
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Quote:
Originally Posted by Nightshade_II View Post
A collection of code that is written in the respective language, right? I was reading on some site about multiple languages accessing the same API's and couldn't quite grasp who that was possible.
Not necessarily. For example you can use a C library in a C++ application. PHP extensions are written in C but you would use the resulting library with PHP. Lua can use libraries written in C.

Quote:
Originally Posted by Nightshade_II View Post
And just to clarify, code syntax is the same across all OS's then? It's just that some poor blokes at the Language developer has to get knee deep in a computer and create a compiler that can take then code and turn it into machine code for that OS?
Yes, the syntax of say C is the same regardless of the OS. The differences aren't always limited to the compiler but the syntax is always the same.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Reply

Bookmarks

Tags
c++, newbie, questions, simple

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:32 AM.


Advertisement
Log in to turn off these ads.