I've seen a number of question asking whether someone should learn procedural or OO first. But is this even possible? Can you learn OO programming without first having an understanding of procedural programming? Obviously, they can learn to program in an OO language like Java or Python first. But you can write Fortran in any language. My impression is that such beginning programmers write procedural code in an OO language at least at first.

But what do you think?

  • 1
    For non-pure OOP language such as PHP you cannot do that. – Shoe Dec 30 '11 at 0:34
  • 2
    "But you can write Fortran in any language" - I was under the impression you had to write Fortran in Fortran? – Kirk Broadhurst Dec 30 '11 at 1:10
  • @KirkBroadhurst I don't really get what he meant by that statement either. I thought he was talking about paradigms. Plus, does he mean write Fortran code, or write a Fortran compiler? – Bob Dec 30 '11 at 1:15
  • 1
    @KirkBroadhurst, codinghorror.com/blog/2005/04/… – Winston Ewert Dec 30 '11 at 1:30
  • 1
    Surely all code is procedural? OO programming supports grouping bits of procedural code for the purpose of extendability, DRY etc. OO programming requires procedural-style instantiation and usage of classes too? – Anonymous Dec 30 '11 at 9:28

If you're programming in a purely object-oriented language such as Eiffel, Smalltalk, or Ruby then you're probably going to be forced to learn object-oriented programming from the get-go (as it's effectively the cornerstone of the language) (also note that these languages often have support for other types of programming, such as functional, etc.).

Now, having said that, both object-oriented and procedural programming are ultimately derived from the imperative paradigm, effectively describing how the program is meant to accomplish its task. As such, you still use certain procedural ideas in your program.

In languages that are hybrids (and not fully object-oriented), such as Java, you will still see a lot of object-oriented programming (as it's very relevant in the programming field today, also, Java is routinely used to teach object-oriented concepts).

Bottom line: you don't need to spend years (or even months) learning the procedural paradigm to be capable of understanding the object-oriented paradigm. You can start learning the object-oriented paradigm from the get-go (and you'll doubtlessly pick up certain procedural concepts as you go).

|improve this answer|||||

OO is an extension of the procedural paradigm.

You can learn to program in OO without being able to code non-trivial-to-complex programs in procedural languages, but the theoretical bases behind procedural are inevitable.

You wouldn't know:

  • how to use globals effectively,
  • what static C variables are for,
  • what primitive types really are for and will always push to deal with the equivalent object types.

You would indulge in:

  • defining class variables,
  • throwing in redundant objects,
  • thinking hierarchically,
  • abusing inheritance,
  • denying that objects may cause overhead (performance-wise, but also on the organizational level)
|improve this answer|||||
  • C is not an OO language. – user41310 Dec 30 '11 at 17:14

What makes something object-oriented? You might produce a list of things that characterize the paradigm, here is a list derived from wikipedia:

  1. data abstraction
  2. encapsulation
  3. messaging
  4. modularity
  5. polymorphism
  6. inheritance

But no language forces to use these things. You can write procedural Java. Using the class keyword doesn't make your code OO. OO is really about the way you structure the design of your system. Many programs written in pure OO language are not structured in anything like an OO way. Many programs written in non-OO languages are structured in an OO way.

If you look at a beginner's code you'll see that do a terrible job of pretty much everything in that OO list. Their code will work, but it is not pretty. (I've written some pretty terrible stuff myself, and it stubbornly stays in production). They've grasped the basics, the procedural part, but they really haven't grasped OO programming.

Basically, you can't really grasp the idea of encapsulation until you've first grasped variables, loops, functions, etc. That's why I think you have to learn procedural before you can learn OO.

|improve this answer|||||

I don't recommend that you "try" OO without formal support (a good book, a helpful website, formal schooling, or a human mentor).

You can easily "try" Procedural without any help - the way you think about how to solve a problem will likely be in a step-wise fashion. This coencides well with procedural programming, so it flows more or less naturally from your thoughts on how to solve a given programming problem.

But "OO" is another animal, a very different way of organizing, abstracting and hiding the implementation of solution, and thus requires a different way of thinking about a problem. You might need some help/a mentor/a good book/formal training to get started in OO.

Setting aside all other concerns for a moment, and considering your question purely from a career-based perspective - If you want a job as a professional software developer you will have greater marketability if you possess OO skills.

If you only want to write code for fun, you can use whatever is easiest/more enjoyable for you.

If you want a career as a software developer, might as well bite the bullet and start with OO - and make sure to get that formal support that I mentioned!

|improve this answer|||||

Any program in the world is typically comprised of either or all of the following characteristics:

  1. A Logical Sequence (a decent algorithm)
  2. Selection Structures (if, switch)
  3. Repetition (Iteration or loops)

Any beginning programmer has to be good at the aforementioned aspects of programming before proceeding to more advanced stuff. It is always recommendable to write your own functions and procedures just in the beginning so that it speeds up logical approach towards solving problems. Once that is done, then you can study data structures! A class (which is the essential unit of OOP) itself is a data structure. Ever wondered why C is taught before C++? Reason is that if one knows the implementation and weakness/disadvantage of struct(record), it will be easier to comprehend and appreciate the importance of using classes.

Although it not a prerequisite to learn a procedural programming first before going into the aspects of OOP. But it is highly recommended to write your own procedures and functions, before one gets rather addicted to reuse pre-built libraries and methods of objects.

One important note here I would always advise for beginning programmers is to stay away from primitive procedural programming languages of the 50's and 60's like FORTRAN, Pascal, COBOL, BASIC, etc. The reason I said that because those languages are all application oriented.They were meant to be there to perform certain things in their respective areas. Secondly, their syntax is also very different from the modern powerful OOP languages of today.

It is always best to start from C or C++! Once you are comfortable in these languages, it won't take much time for you to learn languages like Java, C#, PHP, Drupal, Ruby, etc. These are all object oriented languages.

|improve this answer|||||

When I first started learning programming, I started with OOP. Procedural code was mentioned, and we all understood the concept, but we simply didn't care about exploring procedural further since we were using .Net and going to be learning OOP.

Personally, I think if I HAD learned Procedural first I would have had a hard time making the transition to OOP, but I find going from OOP to Procedural extremely easy.

|improve this answer|||||
  • The experience you had is exactly what I have highlighted in my answer. There is no harm in starting OOP right from the beginning but if you lack procedural programming skills then OOP would not benefit the way it should. – Maxood Dec 30 '11 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.