Vous êtes sur la page 1sur 8

An Analysis of Programming Languages & Their Syntax

by Eric Peralli

A report submitted in partial fulfillment of the requirements for ENC 3241 Technical Writing March 9, 2013

ABSTRACT The purpose of this report will be to introduce and explain the different programming languages and their applications. Also, syntax of different languages will be analyzed and explained so the reader will be able to get a feel for how different languages can be. This report will be split into five parts. The Introduction will explain the concepts of programming languages and what exactly programming can be used for. Section One/Topic One will start with the most common starting programming language, C. C is the language that, once applied and learned, can open most possibilities and careers in the Computer Science world. Section Two/Topic Two will focus on application programming interfaces (API). Discussing these interfaces will give a prelude to learning more advanced languages. Section Three/Topic Three will evaluate object oriented language and popular uses of said languages. Such examples will include the popular sandbox game Minecraft and the vastly successful video game, The Elder Scrolls: Skyrim. Section Four/Topic Four lastly explains iPhone and Android mobile apps, and how exactly one could go about creating them. Many people believe they could have the next Angry Birds if they learned to program apps. This last section will explain the process of going about learning said languages and being able to replicate Angry Birds, thereby introducing the amount of work required to build an app.

Keywords: C Programming Language, Objective-C, C++, Java, C Sharp, Data Structure, Abstract Data Types, Object-Oriented Programming, API

A programming language is an artificial language designed to commune with the internal architecture of a computer, primarily used to create programs that can control or manipulate the machine for the purpose of the user. When a program is created in a programming language, a compiler is then used to interpret the program from the source code that the user wrote, to object code, usually binary. Without programming languages, building a computer program becomes exponentially harder, as one would have to learn the object code that is native to the machine being used. Once a language has been developed, it can be applied to accomplishing all sort of things, such as managing the buttons on a calculator, or creating the most physics demanding game engine for a video game. There are literally thousands of programming languages being developed by individuals for use in their software and products, but most of these languages build off of already existing languages. This report will focus on the more popular and easily adaptable languages, such as C and Java.

C Programming Language
The C Programming Language is a general-purpose programming language that was developed between 1969 and 1973 by AT&T. Many languages, such as Java and C Sharp have borrowed structure and syntax rules from C, making C arguably the best place to begin learning for a novice Computer Programmer looking to enter the field. Syntax is an important aspect of computer languages, and varies greatly when looking at difference languages. Some of the syntax rules that apply to C are ending a statement with a semicolon, using brackets to separate

functions from the overall statement, and creating a prototype for a function in the header, before using said function.

/* Hello World program */ #include <stdio.h> int main() { printf("Hello World"); return 0; } Figure 1. Hello World Print Statement

Figure 1 is an example of a very simple program that prints a statement to the screen. We are going to be analyzing its syntax and explain what each line does. Line 1 starts with a slash and an asterisk, which tells the computer than everything inside the slash and asterisks are comments are should be ignored. Line 2 includes the main library that contains most of the primitive functions of C. Line 3 starts the main function, which doesnt end until the closing brackets are paired with the opening brackets. Line 4 uses a common function, printf, which prints everything inside in the parentheses to the main window. Line 5 returns a 0, which is needed to end an integer function (which is the int that preludes main). Finally the program closes on line 6 with the end brackets. This example is used as the basic program for Computer Science enthusiasts.

Application Programming Interface

Application Programming Interfaces are libraries that include blueprints for data structures, object classes, and certain variables. Basically, APIs are instructions and standards applied to access a software application, usually Web-based. APIs are sometimes related to a software library. The difference between the two is that APIs describe and prescribe the behavior of a function, while libraries are actual implementations of the rules. In object-oriented languages, an API usually includes a description of classes, which are constructs that are used to create instances. APIs are usually released to the general public so developers can design their products with access or powered by their services. An example of an API is Amazon.com, who released its API so web developers could more easily access their products informations. When using the API, third party apps and sites can use its Cart function, or their Buy It Now option, while also being able to check current prices

Object-Oriented Languages
Is a programming style that focuses on the concepts of objects. Objects have what are known as data field, which are the characteristics that are associated with the object, and procedures known as methods. Methods are procedures that define the behavior that is portrayed by the associated class. Object-Oriented languages are necessary so a programmer can program around an object with a visual aid, instead of having to program the code in a different language then compile and run the code in a testing area. Some of the more popular Object-Oriented program languages are Objective-C and Java. Popular programs made with C++ and Java, other Object-Oriented languages, are Minecraft and The Elder Scrolls: Skyrim. Each of these games required an immense amount of programs to have all the processes seamlessly work together, but

the basis around which these games were made could not have been programmed without object orientation.

// First program example #import <Foundation/Foundation.h> int main () { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog (@"Hello, World!"); [pool drain]; return 0; } Figure 2. Hello World Print Statement

Figure 2 is an example of the Hello World program we saw earlier now in Objective-C. We are going to look at the syntax and get a feel of how different this is from the example we saw earlier. Line one starts out with two slashes, telling the computer that it is a comment and it should be ignored. Line two imports the library that most main functions are in when dealing with Objective-C. Line three declares that the main function is starting, and will not end until a closing pair of brackets are found. Line four has to do with memory management and declares a pool of stacks. Line five call NSLog, which, along with the NSAutoreleasePool from above, is a function that tells NSLog to output the text Hello, World! to the screen. Line six, releases a pool down the stack into the runtime. Line seven returns a 0 which ends the main function, and finally line eight closes the brackets and ends it. As you can see, syntax varies in different ways when dealing with variations of the C language, but most still retain the familiar structure of ending with a semi colon and using brackets to open and close functions.

Mobile App Programming Languages

Now that weve looked as many different programming languages, one of the last topics to cover would be the development of mobile apps through the use of said languages. Programming mobile apps brings together all the concepts weve learned and applies them to a working project. For iPhone apps, the main language used would be Objective-C, but this is not all that is needed to make the next Angry Birds. Apple also uses a native application programming interface for the Mac OS X operating system called Cocoa. Cocoa allows for the implementation of animation, gesture recognition like finger swipers that everyone uses on their iPods and iPads, and many other iOS concepts. Once your API has been loaded, you have learned your programming language, and you have your million dollar idea, you are ready to start working on your app.

References Bolton, David. "What Is a Programming Language?" About.com C / C / C#. N.p., n.d. Web. 10 Mar. 2013. <http://cplus.about.com/od/introductiontoprogramming/p/programming.htm>.

Kay, Alan. "Dr. Alan Kaya on the Meaning of Object-Oriented Programming." Dr. Alan Kay on the Meaning of "Object-Oriented Programming" N.p., n.d. Web. 10 Mar. 2013. <http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en>.

Roos, Dave. "How to Leverage an API for Conferencing." HowStuffWorks. N.p., n.d. Web. 10 Mar. 2013. <http://money.howstuffworks.com/business-communications/how-to-leverage-anapi-for-conferencing1.htm>.