so here is what i think a compiler is;
a compiler is a computer program that is created for the purpose of translating a text file following a specific syntax of a programming language (E.g C, Java, etc) into something a computer is able to interpret usually for the purpose of creating an executable set of commands that the computer will be able to perform.
while an IDE or an Integrated Development Environment is a sort of text editing program created for the purpose of aiding a person in writing codes, usually having features that regular text editors lack such as snippets and color-coded words.
now that that's out of the way, i am going to write the next thing in the assignment; which is a tutorial of how to install a compiler and an IDE in a specific OS.
The OS i'm using is OSX 10.11 (el Capitan)
in my case, i am going to use Apple's default; XCode as a compiler and IDE.
but since Xcode is going to be a bit to complicated and overpacked, i would also install a simple text editor with added features to speed my coding process up; i would also install text wrangler as my IDE
the first thing you'd want to do is to open up the Appstore and download the latest version of Xcode (which, luckily, as of the el capitan release, is free of charge)
(mine says update because i've already downloaded the file, it's around 3.8 GB)
After you've downloaded and installed Xcode, you can just open it up and use it as an IDE, you can compile it right there in the program, but Xcode is an IDE created specifically for the development of Apple related softwares such as iPhone applications, and Mac Applications, which is why i recommend downloading an IDE and use Xcode just as a compiler.
now the IDE i am going to recommend is Text wrangler, which is basically a more awesome text editor, you can download it the same way you downloaded Xcode which is by going into the appstore and searching up textwrangler (which is also free).
after you've downloaded text wrangler you can open it up and start typing codes;
Here's how it looks like.
The next thing on my assignment is to write a simple program with an input and an output. And i'm going to do that here in Text wrangler as a demonstration. first thing you'd want to do is safe the file with the extension of ".C" so that text wrangler knows it's handling a C file, so save it as yourfile.c
i always name mine "test" and then i'd give it a more permanent name later, this is a bad habit because it would create chaos in a larger project where multiple classes reference and inherit one another. i only do this when it's only for practice or if i wanted to test something out.
here's a code i wrote in C;
#include <stdio.h>
int main(){
char name[20];
printf ("hello and welcome to will's name sayer, what's your name?");
scanf ("%s", name);
printf ("hello, %s", name);
}
and here's how it looked like in text wrangler;
now save that file and open up your terminal window
First type in cd yourfilesdirectory, in my case, i saved mine in my desktop so i'll just write
"cd desktop" and then press enter, it'll look like this;
after that you should type in gcc -o fileoutputname yourfilename.c, in my case, since i want the output to be named "dude" and my code is called test.c, i'll type in "gcc -o dude test.c" and hit enter;
the computer then will start the compilation process, which may take a few seconds. If all goes well you should get no error and it'll look like this;
once that's done, close your terminal window and open the chosen directory and you should see a unix executable has been created with the name you just chose;
double click that executable and another terminal window will show up
and we're done!!!!












No comments:
Post a Comment