COP 3330 Object Oriented Programming
Sarah Sheehan
3829980
July 15th, 2018
Object Oriented programming is a programming model that is designed with objects (which can be comprised of data structures, variables, and functions) and data in mind over actions and logic. Objects are seen as things the programmer wants to manipulate and describe such as people (describe by name, address, etc.), to dogs (described by name, breed, color, etc.), to houses (described by size, rooms, etc.).
In object oriented programming, all of the actions come from sending messages between objects (Stefik & Bobrow 1985). Message sending specifics the operation that the object will perform. These objects use methods in order to perform such operations. A method is a chunk of code with a unique name that can be invoked by calling the name of the method in order to perform a certain action with data, return a value, etc. Methods are important in any programming language model because they allow the programmer to condense their code by only writing the method once but being able to call it as much as they want without having to repeat the same code over and over again. Objects are designed to interact with one another in order to produce the information needed.
The most popular object oriented programming languages are class-based where objects are combinations of state and behavior. State is representative of the attributes of objects called instance variables (ex. Human have states: name, age, height, etc.) and behavior is representative of tasks the methods will call (ex. Humans have behaviors: talking, walking, working, etc.).
Object oriented programming has three basic principles: encapsulation, abstraction, and inheritance. Encapsulation is used for information hiding via access modifiers in object oriented programming. Abstraction is used to increase efficiency and hide data from the programmer, except the most relevant data, to be able to reduce the complexity of an object. In object oriented programming, inheritances allows classes to inherit state and behavior from other classes.
One of the most popular programming languages in use, not just object oriented, is Java. Java programming language was created by James Gosling, Mike Sheridan and Patrick Naughton in 1991. It was designed with C/C++ syntax in mind so programmers would find the language familiar thanks to Gosling. Java 1.0 was released in 1996 under Sun Microsystems (which was acquired by Oracle). Java’s “Write Once, Run Anywhere” promised easy support of Java programs on multiple platforms so programs would not have to be recompiled or rewritten when going from platform to platform. Sun Microsystem was acquired by Oracle in 2009/2010 and has had four major updates to the program since then. Oracle claims they are the “steward of Java technology with relentless commitment to fostering a community of participation and transparency” (Samoylov 2018).
The creation of Java had five goals: 1) it must have familiarity through simplicity and object orientation, 2) it must have security, 3) it must be portable, 4) it must have a high performance rate, and 5) it must be dynamic. Since the creation of Java 1.0, 9 other major development version of Java have been released with the latest being Java SE 10 released March 20th 2018.
Java is commonly used on web and application servers. Java is the easiest to use for these type of servers because of its “write once, run anywhere” promise. Java Platform Micro Edition (Java ME) allows mobile applications for iPhones, Androids, etc. to be created for all Java supporting devices. Software Development Kits (SDK) allows programmers to use Java to script their applications across different mobile operation systems such as Android or iOS. The Java Graphical User Interface (GUI) uses Abstract Windowing Toolkit (AWT), Swing and JavaFX to allows for creation of desktop applications that users can access and interact with easily. Java is also used in embedded systems such as TV’s and SIM cards. Oracle claims that 100% of Blu-ray disc players use Java embedded programming and 97% of enterprise computers run on Java Enterprise Edition (Java EE).
Another popular object oriented programming language, is Python. Python was first released in 1991, when Java was just starting to be created, by Guido van Rossum. The main design philosophy behind Python is readability of code so the code is clear, on large and small scales. Python has only had two new versions since its release in 1991, Python 2.0 released in October of 2000 and Python 3.0 released in December of 2008. Python 3 is not backwards-compatible to its previous versions and many features have been backported to versions 2.6 and 2.7.
Python was created to be a successor to ABC, another programming language that is imperative general-purpose based. Python was created to be capable of exception handling (being able to respond to exception during computing that change the normal flow of execution). Python also is not just an object oriented language. Python supports many programming paradigms which also include imperative, functional and procedural.
There are many features of Python that make it a good first language. Python uses whitespace indentation instead of brackets like a lot of other languages in order to organize the code. “The basic structures are simple, clean and well-designed which allow students to focus on the primary skills of algorithmic thinking” (Zelle). Many concepts displayed in Python are easily carried over when learning other object oriented languages like Java and C++.
Python has many of the same real world applications as Java such as web development, desktop GUIs, and software development. Mozilla, PBS, NASA and Reddit all use Python for their websites. A lot online multiplayer games use Python as well.
Java and Python are both object oriented based programming languages that have similarities and differences, as expected.
Both Java and Python, for memory management use garbage collection and have large libraries, standard and external. Both languages can be written in an imperative style as well. But other than that, the similarities are very small.
In the example below, both programs declare the class Animal using “class Animal” syntax. Both codes also use dog.saySomething() in their code in order call the method that is wanted.
The inheritance syntax in Java and Python are very different though. In Java, the keyword used to inherit a class is extends, while in Python, just parentheses and the class name are used next to the class that wants to inherit the other class.
In this example I found online of two different examples of Java and Python, it shows initializing an integer variable to 0, changing the type to a string, and checking to see if it is empty. There is also source code printing integers one through nine out in both Java and Python.
They major differences in the programming languages come to the organization. In Java, and many other languages, curly brackets are used to separate statements and organize the section of code. But with Python, more of a list type view is used with indentation. In Python, for a for statement like the one above, a colon is used, then an indented print statement to execute within the for statement.
Commands are different within each language as well. In Python, commands are more simple such as the print statement that is simply just “print *variable*” where in Java, “System.out.println(*variable*);” is needed.
There are more differences than just the physical language itself. Python is faster to learn, has more compact code and is proven to have 5-10 times more programmer productivity. There are cons to Python versus Java though. Python runs slower than Java and does not compile easily across multiple platforms. It’s hard to distribute software written in Python because it is not “write once, run anywhere” like Java is.
Overall, object oriented programming is very beneficial to the field of computer science and information technology. Object oriented programming allows for easier organization of code and there are multiple languages that are object oriented. Java and Python are two examples of widely used object oriented programming languages and even though they have similar uses, the syntax are completely different and both languages have pros and cons to them. The different object oriented languages all serve different purposes and can be used in many ways and will continue to develop through extensive uses and practices.