What is paradigm?

What is paradigm?

Is there any more important than another?

Is

The same thing as design pattern ?

Is it the same as language?

Author: Maniero, 2016-07-20

2 answers

What is paradigm?

According to Wikipedia :

Paradigm (from The Late Latin paradigm, from the Greek παράδειγμα, derived from παραδείκνυμι "show, present, confront") is a concept of the sciences and epistemology (the theory of knowledge) that defines a typical example or model of something. It is the representation of a pattern to be followed. It is a philosophical assumption, matrix, that is, a theory, a knowledge that originates the study of a field Scientific; a scientific realization with methods and values that are conceived as a model; an initial reference as a model basis for studies and research.

In more specific entry on programming :

The notion of programming paradigms is a way of classifying programming languages according to the style of computer programming. Features of various programming languages determine which paradigms they belong to; such as as a result, some languages fall into just one paradigm, while others fall into multiple paradigms. Some paradigms are primarily concerned with implications for the language's execution model, such as allowing side effects, or whether the sequence of operations is defined by the execution model. Other paradigms are primarily concerned with the way code is organized, such as grouping code into units, along with the state that is modified by the code. However, others are primarily concerned with syntax and grammar style.

If you have to sum it up in one sentence: it's just a style of how to write code. It is the way the text (code) will look in general lines.

Some people prefer to talk about the paradigm more broadly and not just the code, that's the style of the solution as a whole.

In general there are some "rules" that determine what may or may not have in the code indicating whether it it is from one paradigm or another. Some things are forbidden, some are mandatory.

Of course the rule is free, but I see some people taking a subset of the rules of the paradigm and saying that something was written according to that paradigm. It's probably a mistake. Even because some paradigms are subsets of others, then you give a name to one thing when in fact it is another.

It is common for people to want their code to be from the fashion, even if he doesn't even go near that.

Is there any more important than another?

You can't say that. There are some more popular ones (technically or by marketing).

Some people consider that There are only three or four paradigms . They determine this through a vector with two characteristics that the code can have.

" but I saw a huge list in the Wikipedia article." Yes, there are several other secondary ones that can be combined with these main ones. But do not lose sight of that they are secondary, even if some of them are more famous. Fame has nothing to do with effective use. Some consider it an abuse to call them a paradigm.

Languages can execute or evaluate, focus on the mechanism or consequence.

  • When executes and focuses on the mechanism you have the paradigm imperative. It is fired the most used, for better or for worse its use is overwhelming. In practice most programmers have never experienced anything outside of it. The vast majority of languages are based on it. All strongly mainstream .

  • When evaluates and focuses on the mechanism you have the paradigm functional. It has an expressive niche that uses it, but that's it (at least in its pure form, although they say that there is no viable language in fact purely functional). It is very common to pick up parts from him to supplement the imperative. Lisp, ML, Haskell , are examples.

  • When evaluates and focuses on the consequence you have the logical paradigm. Its use is extremely restricted and the vast majority of programmers have never seen a code in it. The rise of artificial intelligence could slightly increase its use, but it is not happening. Prolog is the most classic.

  • When executes and focuses on the consequence you have the paradigm of goals. In practice it is not used anywhere, so some disregard it.

Paradigm

Other paradigms basically cannot exist without these being at the base. So the others are orthogonal and these are not among them (although you can mix some elements, but not the whole paradigm).

There are say that there is only the imperative and the declarative. I can accept that definition.

There is a definition that the language can only have one paradigm, the rest are features extras. It makes sense. And then it is better to define only the main ones, if trying to define all possible combinations turns crazy.

OOP

" but I hear so much from object orientation, isn't it important?". No. He's useful. For some problems, it is a highly desirable choice. Other times a paradigm similar, or a combination of other paradigms, is more suitable.

Even in so-called purely object-oriented languages (I'm talking about Smalltalk, nor Java, Ruby and things like that that it can be laughable to use the words "Oo" and "pure" along with their names) in the background the base paradigm is imperative with strong influence of object-oriented. True, the imperative tries to be hidden, but it is still there.

Its importance is more in the head of the people (although most do not even understand what the paradigm means and how to use it, not least because there are controversies about what it is in fact) than in the ability to define something useful for the code. It is useful in very specific points. At the risk of the answer getting dated, he is the Trump of the schedule. Everyone talks about him, few understand him. Many support it, few need it most of the time. He is useful, but not for protagonism.

If you are one of those who consider that the secondary are not even paradigms, so OO is not a paradigm: p

Secondary paradigms

Some pass scraping as a paradigm. If you think it's only a paradigm if it can exist independently then maybe none of these are actually paradigms.

Most of them refer to code Organization (generally Data Structures) or a specific mechanism, so it can only be applied in part of the code. This is why the expression is often used "oriented to".

I've talked about the most famous.

Meta programming is used in some languages and tends to be used more and more to give flexibility and expressiveness to code, when problems are increasingly complex and find good solutions. One part of this is the reflection . The generic programming is another that is a subset of this. The language orientation is probably a superset.

Um important mechanism is the event . Another, in some problems, is the agent .

Another very interesting mechanism gaining a bit of popularity is the Aspect-Oriented .

It is common to have specific points to facilitate parallelism and concurrency .

Is increasingly used that of contract . Not everyone considers it a paradigm, but if it is not, most secondary ones are not.

Some languages adopt some very specific mechanism. Even the genetic paradigm exists.

People should know more about the modular paradigm (more information). In a sense it is a superset of OOP.

Anyway, just to name a few.

Some consider that there are no paradigms . I disagree.

Diagram showing the main paradigms:

Programming paradigms

Is the same thing as design pattern?

Is not the same thing. A project pattern is something more specific, solves something more contained, and has a more concrete example of how to implement a solution to the problem. It's more for a feedback.

Often a design pattern is implemented in the language transparently, helping to achieve a goal of a paradigm.

If the solution involves a level above abstraction of the problem it will most likely be called architectural pattern.

Is it the same as language?

Are more specific techniques, usually within a paradigm. It is common to apply only to a specific language. Let's say you're in a middle ground between the design pattern and the paradigm.

 43
Author: Maniero, 2020-06-11 14:45:34

What is paradigm?

In programming, a paradigm is a way of thinking about problems and developing solutions. A given programming language is said to support a given paradigm.

When solving a problem, the programmer develops a mental model of the problem. The set of concepts he uses to understand the problem and structure its solution is what we call a paradigm.

For example, if it adopts the A-orientation paradigm objects, will think of the problem as a set of objects that have state in the form of variables and expose behavior through methods. However, if instead it employs the functional paradigm, it will adopt a more mathematical model, modeling the problem as a series of functions that can be composed.

In the same way: if he prefers to tell the computer exactly what to do, then he is thinking imperatively. Whether it is better to specify the facts about the problem to be solved and let the computer work without specifying how, then it is solving the problem declaratively.

These paradigms come to fruition when it comes to coding the solution of the problem in a programming language. It is at this time that the differences between them become more evident, even among those that support the same paradigm.

Java is a classic example of a language that supports object orientation, but there are languages like Smalltalk that take this paradigm to places that Java simply cannot reach. It is possible to use object orientation in C, but at great cost: what in Java is implicit in the language itself, as inheritance between classes, has to be explicitly encoded in C.

You can select data in a database imperatively. In fact, the database operates in this way. Even so it's more practical to simply say what data you want using SQL and let it figure out the that you have to do alone. From time to time, the software does this inefficiently and this becomes a problem; this is the time to think imperatively, since considering as the database is running the query will allow to find out the cause of the inefficiency.

Is there any more important than another?

Alone, it is difficult to say objectively. Each of them had a unique impact on the way programmers thought. It is said that it is not worth it's worth learning a programming language that does not change your way of thinking about the problems it solves.

When the question is asked along with a description of the problem to which the paradigm will be applied, the question becomes clearer.

Is

The same thing as design pattern?

Design Patterns are architectural patterns, ways of organizing language elements to generate specific effects such as " ensuring that only a single instance of a class exists".

A different paradigm can make these patterns unnecessary by offering alternative ways to solve the problem that do not present the flaws that the design pattern tries to mitigate.

Is it the same as language?

Languages exist in the context of a programming language. They refer to recurrent patterns of use of the language by programmers.

It can be said that idiomatic code is one that exploits language to the fullest, and by this is clearer and more succinct than supposed non-idiomatic code.

For example, in Ruby, the following code is idiomatic:

[1, 2, 3, 4, 5].select &:even?

Is equivalent to the following code:

[1, 2, 3, 4, 5].select { |n| n.even? }

The first example is generally preferred among experienced Ruby programmers for dispensing with the use of keys and the variable n.

To understand non-idiomatic code, it is enough to understand objects, methods and blocks; simple and basic parts of the Ruby language. Code idiomatic requires much more knowledge from the programmer:

  • meaning of the operator & and its relation to the blocks
  • method to_proc
    • language protocol for transforming objects into blocks
  • symbols
    • Symbol#to_proc and its functioning

Endowed with this knowledge, a Ruby Programmer may discover that it is possible to combine the unary operator & with a symbol. Or & converts using to_proc and it passes its argument as a block in the call of a method, while a symbol can be implicitly converted to a block in the default :sym => proc { |x| x.sym }. A language is born.

 16
Author: Matheus Moreira, 2018-02-23 03:42:59