Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What's the difference between various programming language and compilers?

Status
Not open for further replies.

mahaju

Full Member level 2
Joined
Mar 17, 2007
Messages
125
Helped
7
Reputation
14
Reaction score
2
Trophy points
1,298
Activity points
2,252
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.
 

A better compiler is simply the one that produces the better code,, in terms of the performance, size, and so on.

The compiler has to be designed accordingly to the microarchitecture of the CPU. Suppose you have a 4 way super scalar microprocessor and you can only issue 1 branch instruction at a time, you don't want to put 2 branch instructions within 2, 3 instructions vicinity since there is a high chance that
the 2nd branch instruction breaks the instruction issuance and hit the performance.
You may want to put some instructions in a delay slot. you may want to keep the load instructions and the one that has dependency to that load away each other, so that when load misses the cache, the following instruction doesn't get stuck in the reservation station for a long time... There are so many restriction in CPU that the compiler has to take care of to get the best performance.
The compiler makes quite a difference in performance. In fact, it is pretty common to have a hidden option in compiler only for the benchmark.
 
Last edited:

Programming languages are made to make life easy for programmer. As technology expands and grows the human needs also increase. so when R&D people put their thinking cap to achieve the requirement and check the availablity of resources they get many solution of achieving it. Some may need addition of more concepts and more features to existing resource. So they invent new programming languages, but their base is a common language.

Ya coming to compilers, Compilers and cross compilers are designed for specific applications. Turbo C and its variant are called compiler for normal application, where as cross compilers are used for embedded applications.
Each cross compilers are designed for a specific language, and it has its own limitation.
Good or bad compilers are decided on the basis of how they support programming features. suppose a new concept / feature is added in programming language, the old compiler need to be upgraded for that or else they will not support it. so when i compile my program it gives errors. the same program compiled on same compiler with different version or differnt compilers may compile as the feature may be incorporated.

he easiness of using the compiler, the IDE in it. Allowed user configuration and compiler optimization decides goog , bad, or worst compilers.
 

This is a very big question with many aspects to it.
Everything already said applies and also note there are
a number of different ways a compiler "compiles".

Some do indeed compile to machine code. Others compile down to
a code known as P code. Others may be "compilers" that can also
work as interpreters and compile to different forms such as Threaded Interpretive Compilers (TIL's - Forth being the most well known)

Some compilers compile to an intermediate level for which you need
to add a standard "runtime module" that performs the rest of the compilation at run time.

And some compilers can have assembly language ability built in.

Unfortunately a great many languages are pretty pointless (java for example) that offer nothing new whilst simply providing alternative syntax just to add
to the fragmentation of the programming world and to give commercial
leverage to to creators. They tend to be "fashion" driven.

There are of course a host of different "standards" to which one compiler
might be written to adhere to for specific purposes. A compiler
for engineering or "failsafe" applications for example may be required to
comply with specific standards for safety or other reasons.

And others are designed to produce specifically bug free code or at least
make it a good deal easier to do so.

Some compilers are called "optimising" compilers.
Any decent compiler these days will have optimisation options built in.

Optimisation can mean a lot of different things which is why programmers
are given the "option" to configer the optimisations they want:
Such as whether a variable is kept (for efficiency) in a processor register
or whether it is stored in system ram (which relates to your question about "volatile" to some extent. Under different circumstances
one option may be better than the other.

As lostinxlation said - there are also various ways to program a specific branch
or task with many processors to make the best use of a specific architecture.

Compilers are quite a fascinating field if you're into that sort of thing. :smile:


jack
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top