Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm interested to know how programming languages are interpreted by machines. I was looking at some language comparison/benchmarks and noticed that some programming languages are written in the C programming language while others were written in others. For example Ruby and JVM (although not a language) are written in C. But why did the people who wrote Ruby or JVM write it in C? Couldn't they write it in a way like C, which , I guess, wasn't written in another language. :-) Was it just because not to reinvent the wheel or is C the god of machines?
One has to write them in something. They could be written directly in machine language (actual processor instructions) but that would be very cumbersome - and not portable. So another - preferably standard, portable and ubiquitous - language (like C) is a much better option.
C (and C++, FORTRAN, etc) is compiled directly to machine code, while Ruby and Java are compiled to bytecode which is interpreted by a virtual machine, which is like a software platform on top of the hardware.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I was looking around bored for stuff to do, then I stumbled across a guide on making your own simple C & Assembly command line operating system.
Im just wondering, is it just major operating system that use things like C or can an operating system be created in other languages, like android with java.
The lowest level of an operating system is the kernel, it runs on the CPU, so the languages used can't depend on virtual machines or interpreters. Compilers create machine code from the language, and generally package the output in modules with well defined formats. Those modules can be used to create libraries, applications, or an operating system kernel. You need a language that lets you specify the module contents with a fair amount of control, a language like C is fairly easy, a language like C++ makes it much harder, so is not used for the low level of an operating system.
At the lowest level, you need complete control over the output, because it has to match the hardware, not a module format, so you use assembly language for that.
Above the kernel, there's a lot of stuff that uses higher level interfaces, so doesn't need to be a specific binary module, and can use an interpreter or virtual machine. Those levels can be in Java like Android is.
The original MacOS was written in a version of Pascal. Some IBM mainframe OSes used PL/1. Those are no longer popular, but both compiled into modules like C does.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Why everything low-level is written in C?
I mean kernel code, drivers, Run-time libraries, compilers, embedded systems s/w are mainly written in C/C++.
Why not use Fortran, COBOL, Pascal or even Java/C# or some other third-generation programming language that produces machine-independent code but also gives you the freedom to do low-level ,tweaks and optimizations.
My question is why developers and companies ended up using mostly C for these purposes.
Edit: Most of you here talk about performance. So, is the reason that there is no other general-purpose low-level language faster than C?
A few points:
Pascal is not low level language but there are kernels and even whole OS written in it.
You would not want to have a OS written in Java\C# because it will be darn slow.
C is probably not the best language. It has many cavities, and improvements like D or C++ have been tried. The only "problem" is inertia, C is still popular because C is the most widely used programming language (weather you like it or not). There is a plethora of kernels\OS\libraries\books\course with this language. It would take decades to replace it. And it seems that despite its cavities, there is very little will to completely replace it.
Java (and all JVM-based languages) and C#/F# run inside "virtual machines". That means the applications written in these languages cannot use hardware resourses directly, they are contained weithin a "sandbox". It helps portability ("runs everywhere where a VM is implemented") but can hurt performance (and does).
Some would say that the type of mind capable of writing low-level stuff can only be forged by years of damage caused by using C :-)
On a more serious note, the whole purpose of C was as a systems programming language and, as such, it mostly keeps out of your way. Other languages have different purposes: COBOL is really for transactional/business stuff, C# is for applications running under MS Windows, LISP is for people who have love counting parentheses, and so on. They can be used for other things but I wouldn't write an operating system in COBOL.
Or an accounting package in assembler.
Or anything in Pascal :-)
C allows you unfettered access to the lowest levels without having to concern yourself with things like garbage collection which may adversely affect your code in ways you can't foresee.
Because, comparatively, C and C++ are low level programming languages. Some people still write in Assembler. I hope no one still writes in machine code. Anyway,
Why not use Java, C#, COBOL, Pascal or some other third-generation programming language that produces machine-independent code but also gives you the freedom to do low-level tweaks and optimizations?
Those languages are classified as high level languages. They provide a level of machine abstraction that is beneficial for programming, but not useful for low level bare metal development. Also, relevant might be Why Pascal is Not My Favorite Programming Language by BWK.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I was reading "Operating Systems Design and Implementation" by Andrew S. Tanenbaum. It has Source code of MINIX when approaching the back of the book. I know C programming and have also studied the subject of Operating Systems, but still I was not able to understand the source code. Very few lines were such which could be understood.
I found many new libraries included over there. These libraries are not taught the syllabus of my university. Also, when asked teachers of this, even they don't understand the code. So, where can whole C programming be learnt, with all of its libraries? Because university doesn't go in depths.
In a nut shell, how can we learn C programming or any other programming language to such a depth, that by just looking at any code, one can tell what is the code gonna do.
I used to refer to a book a long time ago by Plauger...you may find it useful if you implement your own versions and then compare OR just study them. Ref: http://www.amazon.com/The-Standard-Library-P-J-Plauger/dp/0131315099
You need not learn all libraries. You have to learn how to use libraries. All libraries are presented as object files in the our c source. So you will not find any code for libraries. Learn how to use the libraries and make your task done.Here is a reference manual for standard c library. You can go through it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to work through Jack Crenshaw's excellent compiler programming tutorial "Let's Build a Compiler" and have bumped into two hurdles. First the code is written in Pascal, a great language for which I have both respect and fondness from a brief exposure to it in the mid 1980s, but which I have not touched since. I currently program mostly in C.
The other hurdle is that the generated assembler is for the Motorola 68000 line of processors. While I may be able to find a translator for it, it would be preferable if I could generate Intel x86 assembler (either Intel or AT&T style).
I can work through the code on Linux, Mac OsX or Windows 7, if it makes anything easier. I have access to all of the named operating systems.
I do not feel fully qualified to do the transcription myself. Has anybody worked this out already, or do you have other suggestions?
Any ideas, feedback or suggestions welcome.
You could run the generated code on a 68K emulator—several of the entries on that page are open-source.
It might be easier to target the JVM instead of a native processor. as for translating Pascal to C... it'shouldn't be that much of a hurdle really.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
do anyone know the history of programming language names? where they come from?
a,b,c, java, python, scheme, prolog, ada, fortran, algol, cobol, assembly, pascal, lisp, perl, haskell, php, javascript, c#, ruby, c++ and so on.
Often the name is inspired by a previous lagnuage (that's the case of C++, which derives from C, which in turn has been named after B ...), but more often language inventor just picked a name he was liking for some reason.
Maybe you could be interested in the genealogy of programming languages.
I would suggest searching Wikipedia :)
But for Python I can answer the question, it comes from "Monty Python", the entertainment/comedy group - not the animal. In Python examples often there are references to Monty Python like "SPAMSPAMSPAM" and "NI NI NI".