Object-oriented vs. …what, exactly?

The first thing I learned about Ruby was that it is an “object-oriented” programming language. That meant nothing to me. I wanted to know: what is an object-oriented language and what does a non-objected-oriented language look like? Let’s find out.

  1. Object-oriented languages
    Objects are variables that contain information. For example, I am an object, “me”, of type person with name “Torie” and hair color “brown”. The object “me” contains the information of what my name is and what color my hair is. In an object-oriented language, functions (or methods) are used on these objects, and these objects are what contain the data the functions use. These functions are designed specifically for certain objects. So an object “carries” with it both data and functions. In other words, functions, methods, etc. are oriented around these objects.
    Examples: Ruby, C++, VBA, Python


  2. Procedural languages
    Procedural languages, also known as “top-down” languages, are more intuitive than object-oriented ones to those unfamiliar with programming. Rather than having data and functions bundled within objects, variables stand on their own – i.e. data is not stored in objects, but in separate variables. Using the previous example, instead of having one object variable, “me”, you would need one variable for my name and a separate variable for my hair color. These languages can be thought of as step-by-step instructions for the computer.
    Examples: C, Fortran, BASIC


  3. Functional languages
    This third type of programming language has allegedly gained popularity recently. Functional languages are based on one basic principle: there is no assignment. When you create something in the memory of your computer, that’s it. It’s not going to (or supposed to) change – i.e. it’s immutable. As someone who’s never used a functional language, this is very hard for me to conceptualize. This link has a great example. What makes this type of language so cool is that it has the power to speed up programs by making use of multiple cores, because there is no assignment. For an explanation of how this works, I refer you again to the previous link. Functional languages are also considered to be less “buggy” – at least that’s the hope.
    Examples: Haskell, Scala, Erlang, Clojure

Sources/related reading: Stack overflow, UIC notes, The Pragmatic Bookshelf, Creative Clojure, Geek Sublime

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s