- #1
pairofstrings
- 411
- 7
If we write better compiler does it mean that programming language is getting better?
Ivan92 said:All a compiler does is check the code for syntax.
pairofstrings said:If we write better compiler does it mean that programming language is getting better?
As mentioned above, one or more people create some type of document describing the language. A document describing a programming language and a compiler or interpreter for that programming language could be developed somewhat concurrently, but I don't know if this actually occurred for any specific programming language.pairofstrings said:How programming languages are created?
As mentioned above, it depends on what you mean by "better". The language isn't changed by the compiler, but part of the choice of which programming language is best for a particular computer and program may depend on the quality of the compilers and the corresponding size or speed of the code generated by the compilers that are available for that particular computer.pairofstrings said:If we write better compiler does it mean that programming language is getting better?
A single program may be able to compile two similar programming languages, but this would be unusual. Some compilers are able to produce more than one type of machine code, for example, Visual Studio can produce 32 bit or 64 bit code. Going back to the 1960's, Cobol has an "environment division" which includes a source computer (the computer the program is compiled on) and an object computer (the computer the program is to be run on), but I'm not sure how many actual implementations supported multiple computers.pairofstrings said:Question 1:
My understanding is that we need to have two different compilers which can understands the instructions of language 1 and 2. Am I right? I mean we cannot have same compiler compiling instructions of both Java and C,or instructions of different operating systems.
The issue here is that the C compliler will include machine code to call main(), and also all of the code required for printf(). It will end up being much larger than the minimal machine code required to read two numbers from memory, add them, and and store the result in memory.pairofstrings said:Question 2, 3:
If we have 'C' language code like this:
# include <stdio.h>
main(){
c = a + b;
printf(c);
}
This can get tricky. An initial version of a compiler will have to be written in some other language, perhaps machine level language like assembly, or perhaps some other high level programming language, or a working compiler for one machine is modififed to produce code for another machine, or an emulator on the other machine is created and used to emulate the machine the compiler current works on. Once the initial version of a compiler is working, then the compiler may be re-written and updated in it's own language.pairofstrings said:Question 3, 4:
How to program/make a compiler?
pairofstrings said:Question 2:
If we have 'C' language code like this:
# include <stdio.h>
main(){
c = a + b;
printf(c);
}
When above code is compiled it might look like this(not familiar with machine language):
11111000 stdio.h
110011()
10101010 01 10
001100(01)
Is it an object code or machine code? I think of it as an object code because machine code has to be only 0's and 1's. There shouldn't be any stdio.h in the code. True?
pairofstrings said:Question 3:
If you see above main() statement when it is compiled it got converted into 1111100. Similarly, the other statements also got converted into 0's and 1's.
And every time I compile the same statements in our above 'C' program we will get the exact object code( in other languages exact intermediate code). Right?
Ok now, that means compiler has to know that the statements should be represented by a particular binary numbers only. In this case, the main() statement is represented as 11111000. That means the compiler has to remember which statement has to be converted to what binary numbers.
That means if we are able to make/program a compiler then we are able to create a new programming language. Or make changes(adding new features, as Chiro said) to existing ones. Is it right? That is my understanding. Help please.
MisterX said:It's not as if statements translate into binary numbers with typical implementations of a high level language such as C. It's considerably more complicated than that.
rcgldr said:The issue here is that the C compliler will include machine code to call main(), and also all of the code required for printf().
pairofstrings said:I agree that translation could be more complicated. But by your first sentence do you mean that the compilers are made using 'C' language?
rcgldr said:The issue here is that the C compliler will include machine code to call main(), and also all of the code required for printf().
It wasn't clear to me if the original poster was asking about object modules which include external links to be resolved by the linker, or was asking about executables, which would include library code (or overlay handlers). The compiler would at least need to generate the code required to call printf().MisterX said:This is implementation specific, but in many cases, the entire code for printf is not included by the compiler.
How was the initial gcc compiler created? You'd need an existing C compiler in order to compile C code. I mentioned this above, that this is either done by cross compiling from another machine, or by creating the initial version of a compiler in a language already supported by the target machine.MisterX said:No, that't not what I meant. But, I'm sure compilers have been made using the C language, such as gcc which was "written primarily in C".
rcgldr said:How was the initial gcc compiler created? You'd need an existing C compiler in order to compile C code. I mentioned this above, that this is either done by cross compiling from another machine, or by creating the initial version of a compiler in a language already supported by the target machine.
As a modern example of a cross compiler, note that ARM processors are often embedded into the chips that go into consumer devices and computer peripherals:pairofstrings said:cross compilers
Boot - for a PC, this is done in the BIOS which is stored in some type of prom. For some early mini and micro computers, the boot strap program had to be manually entered via toggle switches on the front panel. One clever idea used in the ancient Monrobot mini computer was like a music box, except the pins on the drum were used to toggle switches to enter the bootstrap program (in this case to read and then run a program from paper tape). Wiki article:pairofstrings said:bootstrapping
pairofstrings said:Can anyone suggest me some books which could help me grab this subject? I have a book on compilers. I have this book- Compilers: Principles, Techniques, and Tools.
I want a book which could explain me how compilers after converting source code to machine code interacts with the hardware in a computer, like a microprocessor for example.
pairofstrings said:Can anyone suggest me some books which could help me grab this subject? I have a book on compilers. I have this book- Compilers: Principles, Techniques, and Tools.
I want a book which could explain me how compilers after converting source code to machine code interacts with the hardware in a computer, like a microprocessor for example.
pairofstrings said:I want a book which could explain me how compilers after converting source code to machine code interacts with the hardware in a computer, like a microprocessor for example.
pairofstrings said:Hi.
- Suppose that I have created a software and I am assuming that it will run only on one particular platform. What do I have to do if I want to make it run on different platforms as well?
Do I have to change the hardware or the compiler or the programming language or should I make changes to the existing software code?
2. Suppose I have created a software and I know that it is not working as good as it is working on other platforms. What changes should I make? Should I change the hardware or the compiler or the programming language or should I make changes to the existing software code?
- Also when I have some restrictions like I should use only the given hardware and make the program work for different platforms. What should I do then?
- I am restricted to use only so-and-so compiler and not the other one and should make the software work everywhere.
- I am restricted to use only this particular language and not other one and should make the software work everywhere.
- Also when I have some restrictions like I should use only the given hardware and make the program work with same performance. What should I do then?
- I am restricted to use only so-and-so compiler and not the other one and should make the software work with same performance.
- I am restricted to use only this particular language and not other one and should make the software work with same performance.
chiro said:The difference between platforms will be the byte code outputted. If the platform is different, chances are the output is going to be different. Remember the code is represented as a sequence of bits in memory and depending on the platform, the data will be treated differently for each platform.
If your platform changes, you have to change the output to a format that the new platform will be able to read and use.
If the architecture is significantly different in how it runs code, then that is also another issue. In this case you will probably have to implement major changes to the compiler, or you could use bootstrapping to create a compiler that converts one format to another.
Have a look at machine code by doing a google search.
Bootstrapping is probably a good idea to investigate.
Usually what happens is someone creates a language (like C/C++) and then if its useful it becomes standardized. The standardization creates rules that implementations must follow and compilers are created for the different platforms adhering to those rules.
The idea is that a compiler is created for each platform, but it works exactly the same way for each platform. Each implementation is adapted for that particular architecture and the output is generated for that particular architecture.
So in terms of language, it helps if it becomes standardized first where the intended behaviour of the program is thoroughly examined and specific rules are drafted that help establish all of the specifics that are required to create a decent standard.
It might help you if you look at some of the standards (ISO standards) for things like C++, and documents relating to .NET and Java.
pairofstrings said:I thought when I compile a C/C++ program using a C/C++ compiler, I get a '.obj' file which contains the 'object-code' and when this object code is added with header files, consequently,(I think 'linker' will be used here to generate an executable file, which links 'object-code' and header-files)
When I compile C/C++ programs using C/C++ compilers I am getting a 'object-code'.
When I compile Java programs using java compilers I am getting a 'byte-code'.
Will I get object-code or byte-code when I compile, say a Lisp program?
An instruction set, or instruction set architecture (ISA), is the part of the computer architecture related to programming, including the native data types, instructions, registers, addressing modes, memory architecture, interrupt and exception handling, and external I/O. An ISA includes a specification of the set of opcodes (machine language), and the native commands implemented by a particular processor.
Instruction set architecture is distinguished from the microarchitecture, which is the set of processor design techniques used to implement the instruction set. Computers with different microarchitectures can share a common instruction set. For example, the Intel Pentium and the AMD Athlon implement nearly identical versions of the x86 instruction set, but have radically different internal designs.
Some virtual machines that support bytecode for Smalltalk, the Java virtual machine, and Microsoft's Common Langauge Runtime virtual machine as their ISA implement it by translating the bytecode for commonly used code paths into native machine code, and executing less-frequently-used code paths by interpretation; Transmeta implemented the x86 instruction set atop VLIW processors in the same fashion.
jtbell said:My understanding is that Lisp is usually interpreted, not compiled.
This is a hallmark of interpreted languages - translate a section of code, execute, and repeat.AlephZero said:It's not an "either/or" situation. Efficient list-processing implementations often do compilation "on the fly" - i.e each "statement" in the code is compiled the first time you try to execute it, rather than compling everything up front.
AlephZero said:That preserves the ability to for the program to operate on itself (in simple terms, Lisp programs can rewrite their own source code when they are running) but the compiler can optimise the code when it is compiled. For example list-processing compilers often transform recursion into iteration - recursion is often the most efficient way to describe an algorithm in the source code, but iteration is the most efficient way to run it on a conventional computer.
Programming languages are designed and created by a team of computer scientists, software engineers, and linguists. They first identify the purpose and target audience of the language, then create a set of rules and syntax to define how the language will function. This is followed by writing a compiler or interpreter, which translates the code into machine-readable instructions.
The process of developing a programming language involves several stages, including conceptualization, design, implementation, and testing. During the conceptualization stage, the purpose and features of the language are defined. In the design stage, the syntax and rules of the language are created. Implementation involves writing the compiler or interpreter, and testing ensures that the language functions as intended.
The time it takes to create a programming language can vary greatly depending on the complexity and goals of the language. It can take anywhere from several months to several years to fully develop a programming language. Additionally, the process of refining and updating the language may continue even after it is released to the public.
The key factors that influence the design of a programming language include the purpose of the language, its target audience, the existing programming languages and their features, and the desired level of complexity. Additionally, the availability of resources and the potential for future updates also play a role in the design process.
Technically, anyone can create a programming language. However, it requires a deep understanding of computer science and programming concepts, as well as strong skills in software development. It also takes a significant amount of time, effort, and resources to create a functional and useful programming language.