Table of contents
- 0.1 1) Procedural programming
- 0.2 Advantages of procedural programming:
- 0.3 Disadvantages of procedural programming:
- 0.4 2)Functional Programming
- 0.5 Advantages of functional programming:
- 0.6 Disadvantages of functional programming:
- 0.7 3) Object-oriented Programming
- 0.8 Disadvantages of OOP:
- 0.9 4) Scripting
- 0.10 Advantages of scripting:
- 0.11 Disadvantages of scripting:
- 0.12 Conclusion
- 1 Don’t miss amazing tips!
Developers are always looking for the next new thing, here are the different types of programming every programmer should know about. There are plenty of programming languages out there that make developers more productive, but not all of them deserve your attention. It’s easy to get caught up in the hype and start learning a poorly-designed language that doesn’t suit your needs, so before you start exploring new languages outside your comfort zone, watch this video first! We’re going to cover 4 types of programming every programmer should embrace: procedural programming, functional programming, object-oriented programming, and scripting.
1) Procedural programming
With procedural programming, the order of execution is determined by the order of statements in a program. This type of programming style is common in languages such as C and Java. Procedural programming can be difficult to debug and find bugs because the order of statements is unpredictable. Design patterns such as decorators, or factory methods can help make procedural code more flexible and easier to work with.
Advantages of procedural programming:
– Easy to learn and use
– Reliable, simple, and efficient
– Fairly powerful
Disadvantages of procedural programming:
Can be difficult to understand at times. It’s easy to get lost in the details. Technical debt is a very real thing when dealing with procedural code. When debugging procedural code, you lose a lot of context from what is going on in the program at any one time. It can be difficult to determine if there are slowdowns or other problems when debugging procedural code. In a large system, the order of statements could change from run-to-run which makes debugging even more difficult.
With functional programming, functions are treated like first-class citizens, which means that functions can be passed around similar to how you would pass around primitive data types such as strings or numbers. The difference with functional programming is that functions don’t contain any state, which means they’re easier to test and more reliable. Functional programming languages such as Haskell and Clojure are gaining popularity in the financial sector because they’re highly reliable and are easily testable.
Advantages of functional programming:
Production code is easier to test – because functions don’t contain state, it’s easy to test functions in isolation.
Code is highly reliable – the absence of side effects makes functional code very reliable. It’s difficult to write faulty code with this paradigm.
Easy to scale – functional programs are easily parallelized and distributed across multiple CPUs, GPUs, or other computing resources.
Disadvantages of functional programming:
Shared mutable state must be avoided at all costs. The state can be shared between threads or processes but it should always be handled with care because it’s a common source of bugs (race conditions) and security vulnerabilities (SQL injection).
3) Object-oriented Programming
With object-oriented programming, objects come to life. Think of an object as a real-world item. For example, a dog can be represented by an object in software. We can create methods that represent actions such as “bark” or “sleep”. Each time we call a method on the dog object, it will carry out the action we specified.
Objects have an identity. They have a set of properties and can respond to messages in a predictable way.
Code is more flexible. It’s easier to change how an object works without having to change how other objects interact with it.
Hierarchical code makes maintenance of large systems easier – if you decide to refactor your code, it’s much easier to do so if the code is well organized. If the system becomes too complex, you can simply split it up into smaller subsystems of code by using inheritance or other design patterns such as the Model-View-Controller pattern.
Disadvantages of OOP:
Object-oriented programming is difficult to master. Learning how to use design patterns effectively, and to organize your code properly can take years of practice. You must also know how to properly model your system to make good use of object-oriented features.
For example, if you were writing an application for a dog training school, you might create an “animal” class that has a method called “train”. The train method can be called repeatedly on a dog in order to teach it new tricks. The animal class would need to know how many times the dog has been trained before so it could determine what command was being given at any time.
Scripting languages are very simple. Their primary use is to do simple things quickly without any additional overhead. Similar to how you would open a text editor and write a quick script for your favourite game or program, scripting is designed for very specific tasks such as reconfiguring a web server or making a quick backup of files on your hard drive. This type of programming needs to be written in plain text and does not have many features commonly found in compiled languages such as debugging support and garbage collection.
Advantages of scripting:
Easier to get started writing code – you don’t need to install anything when using a scripting language. Most of them are bundled with the OS, so they’re very easy to get started writing code.
Less dependencies – scripts don’t necessarily need helper programs to be installed on a machine to run. This can save time when troubleshooting problems.
Disadvantages of scripting:
Very few modern languages are designed to be used as scripting languages. This means that most of them don’t have any debugging or logging support built-in. You might be able to use the command line or third-party programs for this, but it can make things much more difficult than simply using a compiled language with these functions built-in. You also lose some consistency because these functions may be implemented differently from one language to another.
Scripts are easier to break – when a script is run, it must be executed in its entirety. If you run two scripts at the same time on the same machine, they might try to write to the same file. Even if you make use of file locking or other techniques, scripts are often harder to coordinate and fail faster when you do run them concurrently. Most web frameworks designed for larger applications aren’t designed for high concurrency, which means that your scripts will also slow down these larger apps.
Selecting the right language for a project is often based on the general environment in which it will be used. If you plan to use the code in multiple places, you might need a language that supports multiple programming paradigms.
This means that you’ll end up with more code to maintain, but it will also make your life much easier if the language does indeed support all of these paradigms.
Selecting a programming paradigm that supports all of these features guarantees you’ll have everything you need, and just like using any other good tool in your toolkit, this will make development much more efficient and ultimately more productive.
You might be interested in free websites to practice programming.