Why is Bash used in the Command Line for OSX [closed] - c

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
According to Wikipedia, Mac OSX was written primarily in C (which makes sense because it is a UNIX like OS). Additional languages used were C++ and Objective-C. If this is the case, why do I have to use BASH to communicate with the OS on the Command Line? Why is BASH used in the command line in an OS that was written in C? Are there any reasons why C is not used, as this is the primary language used to create the OS.

The same could be said of Unix, Linux, etc. There's nothing special about OS X in your question.
Bash is interpreted. C is compiled. An interpreted language is required for something that can be typed live and run.
You really want to fat finger a regular expression and blow out your
hard drive because you messed up your array bounds checking? (Which is surprisingly easy to do in bash nonetheless.)
As for why bash and not csh, or heck, Python or Ruby, that's getting more historical and / or opinion based. Even if I were knowledgeable on this, that would be out of scope here.

Related

How does C access files? [closed]

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 11 months ago.
Improve this question
everyone! I'm learning how to access files in C but, I wonder how my program(or C) access files(drive sectors)? I'm searching the Internet for answers but they don't have some proper explanation on how C(or my program), loads drive sectors to memory. Please give me some clarity, and thanks in advance.
C programs use functions of the kernel or a device driver to access hardware. A computing platform (Windows, Linux, OSX, etc) that supports C provides an implementation of the C standard library for programmers. This library contains system specific implementations of functions for accessing files, like fopen. The systems implementation of the standard library is most often just a wrapper around their specific system calls. For example on Windows, the C standard library is going to end up calling these functions: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/

Language choice for GameBoy Advance Homebrew Development [closed]

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
I was reading a ton of tutorials and wanted to get into GBA Homebrew
Now, should i use C or assembly? I already know a bit of C, but asm wouldnt be difficult to me, and i was interested in learning it anyways.
So, which one?
C is easier to develope, specially complex and long programs, and it will take you way less time than making it in assembly, plus you can write assembly in c. Assembly on the other hand can get you better performance if done correctly and it's more flexible.
So I would say go ahead with C
The general rule for the asm vs C no matter what platform (that has both choices) is to use C and only if you really have to use asm for performance or other reasons use asm...

Application written in perl script and c language , which executes quick and why? [closed]

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 converting code written in perl to C language but before proceeding I would like to know the performance difference between perl execution and c language execution.
It depends entirely on what you are doing. Raw performance of an interpreted language like Perl isn't as good as C, but if you are accessing files, pulling information out of a database, or other things which aren't purely part of the language itself you'll find the performance difference is negligible and the benefit of an interpreted language is much easier maintainability.

Good output for first language [closed]

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 9 years ago.
Improve this question
I have built a compiler for my new programming language. It works perfectly. I am onto the last part. I need to put it into a runnable format (an executable). I was looking at the mach-o format (I am runnning on osx), but it is not well documented and I am not that advanced. So my question is:
What is a good output for my first compiler?
P.S. I would really like to be able to run my program in terminal
I would suggest you to use TAC as an output of your compiler. TAC is a context free language, which means it can easily be converted to assembly by a simple script. It is widely used by compilers to optimize the intermediate code, before it is translated to a processor specific assembly language and being optimized to the corresponding processor architecture.
If I'm not wrong, there are several types of TAC code, and you will need to find which one suits you better. I remember having used it as an output of my compiler in the compiler course of my graduation, because I could then run a python script which would translate it into x86 assembly

How do computers interpret programming languages? [closed]

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.

Resources