Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 17 Apr 2014, 08:10
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Difference among programming languages
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [6 Posts]  
Author Message
mahaju


Joined: 11 Oct 2010
Posts: 493
Location: between the keyboard and the chair

PostPosted: Tue 14 Dec 2010, 21:27    Post subject:  Difference among programming languages
Subject description: Whats the difference between all the programming languages and compilers?
 

Hi
What is the main difference between all the programming languages and compilers anyway? I mean, the only thing the computer understands is machine code, and they all convert high level text into machine level code. Still, each language looks and feels much different than the other (eg, C and BASIC)

Similarly, what does it mean by one compiler being better (or worse) than the other, or more (or less) suited for a particular application? I am not trying to talk about languages and compilers designed for different operating systems (Windows/Linux) or different types of computers (PC/Mobile). I am talking about compilers and languages for the same platform. For example, I can write a C program (hello World for example) and compile in Turbo C or gcc and get the same results (at least I think they are the same, I know there should be some difference even if I haven't noticed it, but that's why I am posting this question).

So what's the difference?

PS: Could you please tell me in brief about various types of compiler optimizations, what they are, what they are good for and not good for and how the C volatile keyword is related to it?

Thanks in advance.
Back to top
View user's profile Send private message 
RetroTechGuy


Joined: 15 Dec 2009
Posts: 2634
Location: USA

PostPosted: Wed 15 Dec 2010, 00:21    Post subject: Re: Difference among programming languages
Subject description: Whats the difference between all the programming languages and compilers?
 

mahaju wrote:
Hi
What is the main difference between all the programming languages and compilers anyway? I mean, the only thing the computer understands is machine code, and they all convert high level text into machine level code. Still, each language looks and feels much different than the other (eg, C and BASIC)


Compilers compile "human readable" code into machine language. The language itself defines the grammar and vocabulary required for the compiler to convert the "human readable" language into machine language (though with C, "human readable" is a strange concept... Laughing )

C looks nothing like Basic. Basic looks more like Fortran than C.

Which language do you know? What do you want to do with it?

FWIW, a friend of mine recommends learning python or perl, rather than some of the older languages.

Re C: http://linux.die.net/man/1/gcc

_________________
Wellminded Search
Add swapfile
Back to top
View user's profile Send private message 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Wed 15 Dec 2010, 16:36    Post subject:  

Using two different C compilers, the resulting executables should both generate a program that performs the same task. However the means by which it performs the task may be slightly different due to different methods of optimization and such. There is not a 1-to-1 conversion between C and whatever instruction set a particular processor supports, so different compilers are going to do the conversion in different ways.

I can't say much regarding specific optimizations.

Different languages being suited for different tasks has to do with... being suited for different tasks. Writing code to perform certain actions is just much cleaner with some types of syntax and feature sets than with others. Bash is great for the type of system scripting it is used for, what with its easy capturing, piping, and redirecting of inputs and outputs. However, it would be horrible at the types of stuff that Javascript is used for (traversing the DOM, attaching interesting functions to HTML elements, etc.). Bash's array support is somewhat cumbersome to use, and it has basically no easy way to deal with hierarchical structures (besides the filesystem tree anyway).

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
Cust0dian


Joined: 22 Oct 2010
Posts: 28
Location: Russian Federation, St. Petersburg

PostPosted: Wed 15 Dec 2010, 21:13    Post subject:  

Hi, mahaju.

About compilers ― no big difference for same language (GCC\C and Ch), it's more about specifications of a particular compiler.

Compilers for different languages produces different output code. Why is that? As already told, different languages ― different tasks. But for some reasons, for example code written in functional language is simpler to optimize by compiler. But this ones are so called "academic" languages, because mostly used for science purposes.

About compiler optimization ― there are a lot of optimization techniques. Most significant are loop optimization (a lot of programs spend most of their work-time in loops) and hardware dependent optimization (for a particular processor), but last one is quite useless if not compiling program for yourself only. And don't forget ― any optimization mostly is a choice between speed and size.

Loop can be optimized in different ways... If not all, most of following optimizations can be done by the programmer in native source. As for modern compilers:
​​ ​ • Code, that changes nothing in the loop must be out of the loop.
​​ ​ • Two loops adjacent loops can be forked in one (with only one iterator).
​​ ​ • Forcing cache use for loops that are not intend to use it, but will have more performance in such way.
​ ​ • If first iteration(s) is(are) problematic, split them in different loop
​ ​ • Body of loop can be repeated for a number of times, so there will be less checks and switches (more memory consumption for better speed)

But really, most powerful optimization is math, logic (algorithm and design perfection) and experience (right choice when optimization must occur and which technique to use).
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4133

PostPosted: Wed 15 Dec 2010, 23:01    Post subject:  

see pet packaging in my signature for optimization flags for the key size optimizing flags... or the documentation of your compiler for others - most optimizations that decrease size also improve speed but not vice versa -Os will increase speed and decrease size while -O3 will typically increase size and _sometimes_ increase speed ... when code gets too large it takes longer to load but more importantly it can cause cache issues that slow things down -- graphite (enabled by cloog and ppl) _should_ help to minimize this in gcc (still does not seem stable though)

different compilers do make a difference - tcc gcc and llvm/clang implement different optimizations ... versions even make a difference

the C library you choose to base on makes a bigger difference than people realize - contrary to popular belief, the size difference is not limited to the compiled size of the respective shared library. It even affects the size of code compiled against its headers, because it uses the internal structures. (it is fairly common for a static linked dietlibc binary to even be smaller than a glibc binary that is dynamically linked)
The same can be said for C++, but the effects are even greater due to the object containerization.

some c libraries: glibc, eglibc, uclibc, bsdlibc, dietlibc, newlibc
some c++ libraries: libstdc++(gcc), libc++(llvm/apple), stdcxx(apache), uclibc++(uclibc) , embeddedstl(dietlibc) (there are a lot of other standard template libraries around)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: Thu 16 Dec 2010, 04:31    Post subject:  

There is a woefully out of date explanation and list of Puppy languages here:
http://puppylinux.org/wikka/ProgrammingLanguages

Maybe someone will have the inclination to update . . . Smile

_________________
Puppy WIKI
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [6 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0852s ][ Queries: 12 (0.0236s) ][ GZIP on ]