If somebody has to start learning to program, where should he/she start? Should he start to write procedure-oriented programs or jump to OOP?
The best thing you can do is to get a handle on all the paradigms. I'd suggest the following order:
- Simple procedural programming: just getting basic sequential programming techniques down.
- Structured programming: Top-Down design, Abstract Data Types, Modules.
- Functional Programming: Working without side-effects, functions as first-class objects
- Object-Oriented Programming: Abstraction, Polymorphism
- Very low-level programming, i.e. assembly language: working with the hardware, number of registers, cache, memory, SIMD instructions, optimization, and generally an appreciation of how much easier compilers and interpreters make our jobs.
- Multiparadigm-programming: Combine all of the above using the best tool for the job when appropriate
And then you can try some more esoteric styles, such as Logic Programming (Prolog), and Concurrent Programming (Communicating Synchronous Processes, OCCAM).
You can several steps in one language (Python would cover most of the bases), though it's probably better to do 3 in a relatively strict functional language (I'd suggest Lisp), and 4 in a relatively strict OO language (Java, C#). You don't have to go extremely deep in any of the languages, just do a Code Kata or two in each to get a feeling for the paradigms.
Having all (or just several) of them under your belt will make you a more versatile programmer, even if you never really go deep into one specific paradigm again.
I think what you begin with isn't really important. What is important is that you know both, and fail with both.
Because you will fail. Learn from it.
All xOP are here to solve problems devellopers encounter when coding, or maintaining software. The bigger the software is, the more important it is. You can learn OOP, or POP, but at the end, you'll not understand what it is good for unless you exprience problem you have not following those methodologies.
POP, OOP and others are not just coding techniques. This is a way to think about your code. New way to think are devellopped to solve problems devellopper had with previous way to think about what they do.
Acquiring that require time, way more than learning simple techniques.
Anyway, I'll advise you to start with POP. Because at the end, you cannot do something without it. If you do OOP, you'll have clases, methods, but with methods, you'll find plein old procedural programming.
POP and OOP are not think that should be thinked at instruction level. At this point, you are doing procedural, even if you do OOP, fucntionnal, or whatverer. But doing only POP, you'll encounter problems when your software grows. OOP, functionnals, and others way of thinking your software as a whole will help you to handle the incrasing complexity of the code.
Note that thos can be achieved in pure procedural, but kinda hard, and not the way broadly used in industry.
I think that before you start doing oop programming you should have a basic understanding of programming as it used to be done. It's important for a programmer to know why he/she is using oop and i think the fastest way to understand this is by starting without, begin with the basics of memory manipulation and math.
There's no reason to start programming in a procedural manner. Neither coding closer to the computer nor re-enacting the history of programming will help you find a good entry point to programming.
When you first learn, how to drive, you won't do it in a steam engine, although it's historically correct and will help you actually see on what basic principles engines are based.
First learn how to do it, gather some intuition and then push forward for an ever deeper understanding.
I'd say go for learning both. If you don't know how to program yet, close your eyes and choose Python as your first language. It allows you to put in your procedural concepts while still being object oriented. Even using standard Python libraries/types will give you a feel of OOP and you will excel in the Science and Art of Programming. Then once you get the feel of the language itself, go for OO concepts.
Once you have the concepts right, you can give C++ or even Java a shot. But as a complete beginner, I'd recommend Python first.
OOP, Procedural programming, etc are just different ways to model and solve problems, and you should definitely have both under your belt.
PS: the second person in the above answer refers directly to the third person in your question :)
I would reccomend OOP first, here's why:
You want to start off with OOP. The reason is that this is primarily what is used in the real word, and you it's always easier to learn a concept like that as a first language, instead of a second one. I always hear people saying they don't understand the concept of OOP, theses are usually POP programmers that are transitioning to OOP. My first language was Java, which is an OOP programming language, and I never had a problem understanding the concept, because I didn't know anything else.
OOP can do everything POP can do
The other thing is that you can always use an OOP language as a POP if you want to. for example, in java, you don't have to use more than one class if you don't want to, and it becomes fairly easy to understand what POP is like (OOP has all of the features of a POP language, but it is more dynamic and reusable, but if you don't want to, you don't necessarily have to take advantage of those features) the same should apply with something like C++ vs C
There are many ways to Rome, but one approach that strikes me as logical is to follow the evolution of programming languages and paradigms. So you'd start out with a close-to-the-metal imperative language (probably C). Then you'd build from there, discovering abstractions that people have invented to make managing complex code easier. So:
- Structured, but avoiding global state
- Functional or OOP
- OOP or Functional
- ad libitum: Logic Programming, Aspect-oriented, Data-driven, Metaprogramming
And of course, taking the best of each in real-world programming situations.
At the bare minimum, I think a decent programmer should have had some exposure to at least one language in each of the following groups:
- C++, Java, C#, Objective-C, ...
- Lisp, Haskell, ML, Scheme, Clojure, F#, ...
- brainfuck, malbolge, befunge, intercal, ...
(I'm serious about that last category: while you won't do any serious programming in any of them, looking into them definitely gives insights into the way computers and the human mind work)
This question is a bit like asking men if they think being circumcised is better than not being circumcised - there seems to be a remarkable correlation between whether or not they are circumcised and whether or not they think it's better. Of course, once you've been circumcised it's hard to go back. ;-)
As someone who first learned procedural programming, I (and quite a few of my peers) initially struggled at first with OOP. Having spoken to people whose first experience with programming was OOP, it seems they found it a much more natural way of working. This may be because they weren't trying to make it fit with their pre-existing procedural approach, trying to impose it, if you will. Or it may just be that they were smarter than me and my friends (very likely).