{"id":1643,"date":"2020-11-28T14:22:40","date_gmt":"2020-11-28T20:22:40","guid":{"rendered":"https:\/\/www.pensemosweb.com\/?p=1643"},"modified":"2024-03-22T12:34:14","modified_gmt":"2024-03-22T18:34:14","slug":"paradigma-programacion-javascript","status":"publish","type":"post","link":"https:\/\/pensemosweb.com\/en\/paradigma-programacion-javascript\/","title":{"rendered":"JavaScript programming paradigm"},"content":{"rendered":"<h2 class=\"wp-block-heading\">What is a programming paradigm?<\/h2>\n\n\n\n<p>The model or map of how we see the real world, that is a paradigm, it is a way of seeing and doing things. Following this logic, a programming paradigm is nothing more than a way of viewing and creating programming code.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Paradigms are powerful because they create the glasses or lenses through which we see the world.<\/p>\n<cite><a href=\"https:\/\/amzn.to\/2JivEJR\" target=\"_blank\" rel=\"noreferrer noopener sponsored nofollow\">Stephen R. Covey<\/a><\/cite><\/blockquote>\n\n\n\n<p>There are three main programming paradigms used today and in JavaScript they have always existed since its first version.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Structured programming paradigm<\/li>\n\n\n\n<li>Object-oriented<\/li>\n\n\n\n<li>Functional<\/li>\n<\/ul>\n\n\n\n<p>Now, if we stick to the phrase of <a rel=\"noreferrer noopener sponsored nofollow\" href=\"https:\/\/amzn.to\/2JivEJR\" target=\"_blank\">Stephen R. Covey,<\/a> that paradigms create the lenses through which we see the world. Let&#039;s imagine that the three previous paradigms, each, are a pair of glasses that we put on when programming and that we can change those glasses according to our visual needs (for programming or problem solving).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Structured programming paradigm<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Origin<\/h3>\n\n\n\n<p>In 1954 the FORTRAN programming language appeared, then in 1958 ALGOL and in 1959 COBOL. Time after <strong>Edsger Wybe Dijkstra<\/strong> in <strong>1968<\/strong> discover the structured programming paradigm, we say \u201cdiscover\u201d because they didn&#039;t actually invent it. Although this programming paradigm was formalized some time after the appearance of these programming languages, it was possible to do structured programming in them.<\/p>\n\n\n\n<p><strong>Dijkstra<\/strong> He recognized that programming was difficult, and programmers don&#039;t do it very well, which I totally agree with. A program of any complexity has many details for the human brain. In fact, the <a href=\"https:\/\/amzn.to\/3q8QrQG\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Neuroscience tells us that the focused mind <\/a>It can only work with four pieces of data at a time, at most. For this reason, if one small detail is neglected, we create programs that seem to work well, but fail in ways you never imagine.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Evidence<\/h4>\n\n\n\n<p><strong>Dijkstra&#039;s solution was to use tests<\/strong>, only these tests used a lot of mathematics, which was quite difficult to implement. During his research he found that certain uses of GOTO made it difficult to decompose a large program into smaller pieces, it could not be applied <a href=\"https:\/\/pensemosweb.com\/en\/introduccion-desarrollo-guiado-especificacion-tdd\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u201cdivide and conquer\u201d, necessary to create reasonable evidence.<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sequence, selection and iteration<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/pensemosweb.com\/wp-content\/uploads\/2020\/11\/patron-programacio\u0301n-estructurada.png\" alt=\"Patrones de la programaci\u00f3n estructurada\"\/><figcaption class=\"wp-element-caption\">Patterns of structured programming<\/figcaption><\/figure>\n\n\n\n<p><strong>B\u00f6hm and Jacopini<\/strong> They proved two years earlier that all programs can be built by just three structures: <strong>sequence, selection and iteration<\/strong>. Dijkstra already knew these three structures and discovered that these are the ones necessary <strong>to make any part of the program tested<\/strong>. <strong>This is where the structured programming paradigm is formalized.<\/strong><\/p>\n\n\n\n<p>Edsger tells us that it is bad practice to use <code>GOTO<\/code> and suggests better using the following control structures:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If, then, else (selection)<\/li>\n\n\n\n<li>do, while, until (iteration or repetition)<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Decomposition of small units easy to test<\/h4>\n\n\n\n<p>Nowadays most programming languages use structured programming, JavaScript uses this type of programming. The simplest example is if conditions.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"const EDAD_MINIMA = 18;if (edad &gt;= EDAD_MINIMA) {\t\/\/ hacer algo porque es mayor que 18} else {\t\/\/ Hacer otra cosa en caso contraio}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> EDAD_MINIMA <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">18<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">if<\/span><span style=\"color: #BABED8\"> (edad <\/span><span style=\"color: #89DDFF\">&gt;=<\/span><span style=\"color: #BABED8\"> EDAD_MINIMA) <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">\t<\/span><span style=\"color: #464B5D; font-style: italic\">\/\/ hacer algo porque es mayor que 18<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">}<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF; font-style: italic\">else<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">\t<\/span><span style=\"color: #464B5D; font-style: italic\">\/\/ Hacer otra cosa en caso contraio<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>And if we isolate it in a function, we have a decomposition of functionalities or units that can be tested more easily. In the next section we will see the importance of having a completely probable unit<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"const EDAD_MINIMA = 18;function esMayorEdad(edad) {  if (edad &gt;= EDAD_MINIMA) {     return true;  } else {     return false;  }}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> EDAD_MINIMA <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">18<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">functions<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">esMayorEdad<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8; font-style: italic\">edad<\/span><span style=\"color: #89DDFF\">)<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">  <\/span><span style=\"color: #89DDFF; font-style: italic\">if<\/span><span style=\"color: #F07178\"> (<\/span><span style=\"color: #BABED8\">edad<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">&gt;=<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8\">EDAD_MINIMA<\/span><span style=\"color: #F07178\">) <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">     <\/span><span style=\"color: #89DDFF; font-style: italic\">return<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #FF9CAC\">true<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">  <\/span><span style=\"color: #89DDFF\">}<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF; font-style: italic\">else<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">     <\/span><span style=\"color: #89DDFF; font-style: italic\">return<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #FF9CAC\">false<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">  <\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>With this condition we have direct control of what can happen if the age is greater than or equal to <code>18<\/code>, and also in the event that the age is younger.<\/p>\n\n\n\n<p>Let&#039;s not be so strict either, surely the GOTO ruling has its merits and perhaps it was very efficient in some cases, but I think that to avoid misuses that probably caused disasters, <strong>Dijkstra<\/strong> recommended to stop using GOTO.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Test, divide and conquer<\/h3>\n\n\n\n<p>Structured programming allows us to apply the \u201cdivide and conquer\u201d philosophy, because we <a href=\"https:\/\/pensemosweb.com\/en\/introduccion-desarrollo-guiado-especificacion-tdd\/\" target=\"_blank\" rel=\"noreferrer noopener\">allows you to create small unit tests<\/a>, until the entire program is covered. The mathematical solution of <strong>Wybe Dijkstra<\/strong> It was never built, precisely because of its difficulty in implementation. And unfortunately today there are still programmers who do not believe that formal tests are useful for <strong>create<\/strong> high quality software.<\/p>\n\n\n\n<p>And I say <strong>create, <\/strong>because verify correct operation after <strong>create, <\/strong>is nothing more than a <strong>simple measurement<\/strong> and the opportunity to reduce time and money is lost.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Scientific method, experiments and impiricism<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/11\/metodo-cientifico-experimentos-pruebas.jpg\" alt=\"M\u00e9todo cient\u00edfico, experimentos y pruebas\" class=\"wp-image-1925\"\/><figcaption class=\"wp-element-caption\">Scientific method, experiments and tests, by ThisIsEngineering Raeng on unsplash<\/figcaption><\/figure>\n\n\n\n<p>The good news is that the mathematical method is not the only way to verify our code, we also have the scientific method. Which cannot prove that things are absolutely correct from a mathematical point of view. What we can do is create experiments and obtain enough results to verify that our theories work. Since our theories work on these experiments, then we conclude that they are \u201ccorrect\u201d enough for our validation purposes.<\/p>\n\n\n\n<p>If the theory is easily validated as false, then it is time to modify or change it. This is the scientific method and this is how tests are currently done:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>First we establish our theory (write the test), then we build the experiments (write production code) and finally we verify (run the test) and repeat this cycle until we have enough evidence.<\/p>\n<\/blockquote>\n\n\n\n<p><a href=\"https:\/\/pensemosweb.com\/en\/introduccion-desarrollo-guiado-especificacion-tdd\/\"><strong>Doesn&#039;t this sound like a current agile practice called TDD?<\/strong><\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Tests show the presence, not the absence, of defects<\/h4>\n\n\n\n<p><strong>Edsger Wybe Dijkstra <\/strong>said \u201cTesting shows the presence, not the absence, of defects.\u201d That is, a program can be proven wrong by testing, but it cannot be proven correct. All we can do with our tests is validate that our program works well enough for our goals. But we can never be one hundred percent sure of the absence of defects.<\/p>\n\n\n\n<p>If we can never be one hundred percent sure that our code is correct, even with its tests, what makes us think that without tests we deliver a program with sufficient validity to affirm that no negligence is consciously committed?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">direct control<\/h3>\n\n\n\n<p><strong style=\"font-style: italic;\">l<\/strong><strong>to<\/strong><strong style=\"font-style: italic;\"> structured programming teaches us about direct control<\/strong>, that is, controlling the sequential flow of operations through the control structures, without neglecting the recommendation of <strong>Wybe Dijkstra<\/strong> about <strong>GOTO<\/strong>. This recommendation also applies to statements that drastically change the normal flow of operations, for example a <strong><code>break<\/code> <\/strong>within a cycle <code><strong>for<\/strong><\/code> nested, that <strong><code>break<\/code> <\/strong>It breaks direct control because it abruptly complicates the understanding of the algorithm. Let&#039;s not be purists either, there will surely be cases where you need these sentences, but in the first instance, try to avoid them.<\/p>\n\n\n\n<p>In conclusion, the structured programming paradigm teaches us:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>The direct, clear and explicit control of what a piece of code does<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Object-oriented programming paradigm<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Arised from functions?<\/h3>\n\n\n\n<p>The object-oriented programming paradigm was discovered in <strong>1966 <\/strong>by <strong>Ole Johan Dahl and Kristen Nygaard<\/strong> when they were developing simula 67. Two years before structured programming and its adoption by the programming community was some time later. In 1967 it was launched <strong>Simulates 67<\/strong>, <em><strong>Simulates<\/strong><\/em> It was the first object-oriented programming language, it basically added classes and objects to ALGOL, initially Simula was going to be a kind of extension of ALGOL.<\/p>\n\n\n\n<p>During the development of Simula, it was observed that the execution of an ALGOL function requires certain data, which could be moved to a tree structure. This tree structure is a Heap. <\/p>\n\n\n\n<p>The heap allowed you to declare local variables of the function that can exist even after the function returns a value.<a href=\"https:\/\/pensemosweb.com\/en\/funciones-node-js-javascript-realmente-importante\/#Closures_o_cierres\" target=\"_blank\" rel=\"noreferrer noopener\"> <strong>Doesn&#039;t this last sound like what closure is in JavaScript?<\/strong><\/a><\/p>\n\n\n\n<p>The parent function becomes a constructor, the local variables become the properties, and the child (nested) functions become its methods. In fact, this pattern is still widely used by Javascript to create modules and use functional inheritance. <strong>This also describes how classes work in Javascript<\/strong>, behind are functions.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Spread of polymorphism<\/h4>\n\n\n\n<p>All this helped a lot to implement polymorphism in object-oriented programming languages. Ole Johan Dahl and Kristen Nygaard invented the notation:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"objeto.funcion(parametro)\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">object<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">function<\/span><span style=\"color: #BABED8\">(parametro)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The execution of <code><strong>function<\/strong><\/code> that belongs to <code><strong>object<\/strong><\/code>, but more importantly, we pass a message through parameters from the first part of the code to the second part located in a different object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Molecular biology and message passing<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/pensemosweb.com\/wp-content\/uploads\/2020\/11\/paso-mensajes-celulas-poo.jpg\" alt=\"Paso de mensajes entre c\u00e9lulas\"\/><figcaption class=\"wp-element-caption\">Passing messages between cells, <em>Image modified from \u201c<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"http:\/\/cnx.org\/contents\/185cbf87-c72e-48f5-b51e-f14f21b5eabd@9.87:46\/Signaling-Molecules-and-Cellul\">Signaling molecules and cellular receptors: Figure 1<\/a>,\u201d by OpenStax College, Biology (<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"http:\/\/creativecommons.org\/licenses\/by\/3.0\/\">CC BY 3.0<\/a>).<\/em><\/figcaption><\/figure>\n\n\n\n<p>Some time later it was created <strong>Smalltalk<\/strong>, a much more sophisticated and modern object-oriented programming language, in charge of this project was <strong>Alan Kay<\/strong>. This person is credited with the formal definition of object-oriented programming. <\/p>\n\n\n\n<p>The main influence on Alan Kay&#039;s object-oriented programming was biology, he has a degree in biology. Although it is obvious that it was influenced by Simula, the influence of LISP (functional programming language) is not so obvious.<\/p>\n\n\n\n<p>From the beginning he thought of objects as interconnected cells in a network, from which they could communicate through messages.<\/p>\n\n\n\n<p>Alan Kay commented:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>I&#039;m sorry I coined the term a long time ago. <strong>Objects<\/strong> for programming because it made people focus on the least important part. The big idea is \u201c<strong>Sending messages<\/strong>&#8220;.<\/p>\n<cite>Alan Kay<\/cite><\/blockquote>\n\n\n\n<p>My English is bad so you can check the original text <a href=\"http:\/\/wiki.c2.com\/?AlanKayOnMessaging\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Better object composition over class inheritance<\/h3>\n\n\n\n<p><strong>Smalltalk<\/strong> It also allowed the creation of <strong>Self<\/strong>, created at Xerox Parc and later migrated to Sun Microsystems Labs. It is said that <strong>Self <\/strong>It is an evolution of smalltalk.<\/p>\n\n\n\n<p>In this programming language the idea of <strong>prototypes<\/strong>, eliminating the use of classes to create objects, this language uses the objects themselves to allow one object to reuse the functionalities of another.<\/p>\n\n\n\n<p><strong>Self <\/strong>It is a fast language and is generally known for its great performance, <strong>self<\/strong> It did a good job on garbage collection systems and also used a virtual machine to manage its execution and memory.<\/p>\n\n\n\n<p>The virtual machine <strong>Java HotSpot <\/strong>It could be created thanks to Self. <strong>Lars Bak<\/strong> one of Self&#039;s latest contributors, he was in charge of creating the V8 Javascript engine. Due to the influence of Self we have today the engine of <strong>JavaScript<\/strong> <strong>V8<\/strong>, which uses it <strong>node.js, mongoDB and<\/strong> <strong>Google Chrome<\/strong> internally.<\/p>\n\n\n\n<p>Self followed one of the book&#039;s recommendations <strong>Design Patterns: Elements of Reusable Object-Oriented Software<\/strong>, long before it came out, published this recommendation:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Better composition of objects to class inheritance.<\/p>\n<cite>Design Patterns: Elements of Reusable Object-Oriented Software<\/cite><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p>Currently Javascript uses prototypes for code reuse, you could say that it uses composition, instead of inheritance. Let&#039;s look at an example:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"const persona = {    saludar () {      return 'Hola'    }};\/\/ se crea un programador con el prototipo igual al objeto personaconst programador = Object.create(persona);programador.programar  = () =&gt; 'if true';const saludo = programador.saludar();const codigo = programador.programar();console.log(saludo); \/\/ 'Hola'console.log(codigo); \/\/ 'if true'\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> person <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    <\/span><span style=\"color: #F07178\">greet<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">()<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">      <\/span><span style=\"color: #89DDFF; font-style: italic\">return<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Hola<\/span><span style=\"color: #89DDFF\">&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">    <\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">};<\/span><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">\/\/ se crea un programador con el prototipo igual al objeto persona<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> programmer <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> object<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">create<\/span><span style=\"color: #BABED8\">(persona)<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">programmer<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">programar<\/span><span style=\"color: #BABED8\">  <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">()<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C792EA\">=&gt;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">if true<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> saludo <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> programmer<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">greet<\/span><span style=\"color: #BABED8\">()<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> codigo <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> programmer<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">programar<\/span><span style=\"color: #BABED8\">()<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">console<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">log<\/span><span style=\"color: #BABED8\">(saludo)<\/span><span style=\"color: #89DDFF\">;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #464B5D; font-style: italic\">\/\/ &#39;Hola&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">console<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">log<\/span><span style=\"color: #BABED8\">(codigo)<\/span><span style=\"color: #89DDFF\">;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #464B5D; font-style: italic\">\/\/ &#39;if true&#39;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The object <code>programmer<\/code> It is based on the prototype of `person`. It doesn&#039;t inherit, it just directly reuses the functionality of `person`.<\/p>\n\n\n\n<p>JavaScript emerged shortly after JAVA, in the same year. JavaScript took influences from <strong>Self<\/strong>, and in turn <strong>Self <\/strong>was influenced by <strong>smalltalk<\/strong>.<\/p>\n\n\n\n<p>The syntax of current classes in Javascript is nothing more than a facade, well a little more accurately they are an evolution of the constructor functions, but internally, their basis are functions and prototypes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Communication with message passing<\/h3>\n\n\n\n<p>As we already saw, the origin of object-oriented programming has its origins in functions, and the main idea has always been communication between objects through message passing. We can say that <strong>Object-oriented programming tells us<em> of message passing as a key piece for the communication of objects<\/em>,<\/strong> for example, when a method of one object invokes the method of another.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"objeto.funcion(parametro);\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">object<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">function<\/span><span style=\"color: #BABED8\">(parametro)<\/span><span style=\"color: #89DDFF\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>In conclusion, the object-oriented programming paradigm teaches us:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Message passing for communication between objects<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Functional programming paradigm<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">lambda calculation<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/11\/sintaxis-calculo-lambda-programacion-funcional.jpg\" alt=\"\" class=\"wp-image-1930\"\/><figcaption class=\"wp-element-caption\">Image taken from https:\/\/www.slideshare.net\/FASTPresentations\/introduction-to-lambda-calculus-using-smalltalk-by-facundo-javier-gelatti<\/figcaption><\/figure>\n\n\n\n<p>Functional programming is the oldest programming paradigm, in fact its discovery was long before computer programming, it was discovered in <strong>1936 <\/strong>by <strong>Alonzo Church<\/strong>, when I invented the <strong>lambda calculus<\/strong>, based on the same problem to be solved by your student <strong>Alan Turing<\/strong>.<\/p>\n\n\n\n<p>As a curious fact, the symbol of the lambda calculus is:<\/p>\n\n\n\n<p class=\"has-huge-font-size\"><strong>\u03bb<\/strong><\/p>\n\n\n\n<p>The first language based on functional programming was <strong>LISP<\/strong>, created by <strong>John McCarthy<\/strong>. As we saw previously, Alan Kay also took influence from LISP to create Smalltalk, with this we can see that the programming paradigms can be united and their relationship between them arises from the idea of how to solve problems more efficiently, they are not fighting, nor Separated, they seek the same goal and somehow evolve together.<\/p>\n\n\n\n<p><strong>The basis of the lambda calculus is immutability<\/strong>,<strong> <\/strong>We will review this concept later.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Similarities with OO and structured paradigms<\/h3>\n\n\n\n<p>As we saw in the structured programming paradigm, we can decompose our programs into smaller units called procedures or functions. Since functional programming is the oldest paradigm, we can say that the structured programming paradigm also relies on functional programming.<\/p>\n\n\n\n<p>Now, if we analyze the notation a little <code><strong>object.function(x)<\/strong><\/code> that we saw in the object-oriented programming paradigm section, is not very different from <code><strong>function(object, parameters)<\/strong><\/code>, these two lines below are the same, <strong>the fundamental idea is the passing of messages<\/strong>, as Alan Kay tells us.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"objeto.funcion(parametro);funcion(objeto, parametro);\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">object<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">function<\/span><span style=\"color: #BABED8\">(parametro)<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #82AAFF\">function<\/span><span style=\"color: #BABED8\">(objeto<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> parametro)<\/span><span style=\"color: #89DDFF\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Smalltalk uses the <strong>\u201cThe Actor Model\u201d<\/strong>, which says that actors communicate with each other through messages.<\/p>\n\n\n\n<p>On the other hand we have <strong>LISP<\/strong>, which has a <strong>\u201cFunction dispatcher model\u201d<\/strong> What we currently call functional language, these models are identical, because what functions and methods do is send messages between actors.<\/p>\n\n\n\n<p>An example of this is when a function calls another function or when an object&#039;s method is invoked, what happens is that actors exist and they communicate with each other through messages.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Message passing again<\/h4>\n\n\n\n<p>So we can emphasize that the main idea of OOP is the sending of messages and that it is not very different from functional programming, in fact according to what we already established in the previous sections, OOP was born from a functional base. And here it is important to highlight what he said <strong>Alan Kay Co-creator of SmallTalk<\/strong>:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>I&#039;m sorry I coined the term a long time ago. <strong>Objects<\/strong> for programming because it made people focus on the least important part. The big idea is \u201c<strong>Sending messages<\/strong>&#8220;.<\/p>\n<cite>Alan Kay<\/cite><\/blockquote>\n\n\n\n<p>From the communication models between Smalltalk and LISP messages, it was created <strong>scheme<\/strong>.<\/p>\n\n\n\n<p><strong>scheme<\/strong> has the goodness to use <strong>tail recursion <\/strong>and <strong>closure<\/strong> to obtain a functional language, <strong>closure<\/strong> allows access to the variables of an external function even when it has already returned a value. This is the same principle that gave rise to object-oriented programming by <strong>Ole Johan Dahl and Kristen Nygaard<\/strong>. <strong>Do you remember the closure question in Javascript?<\/strong><\/p>\n\n\n\n<p>Javascript uses closure a lot in its functional programming paradigm. JavaScript took influences from <strong>scheme<\/strong>, at the same time  <strong>scheme<\/strong> was influenced by <strong>LISP<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">No side effects<\/h3>\n\n\n\n<p>The basis of the lambda calculus is immutability, therefore, l<strong>Immutability is also the basis of the functional programming paradigm<\/strong>.<\/p>\n\n\n\n<p>We as functional programmers must follow this principle and limit object mutations as much as possible to avoid side effects.<\/p>\n\n\n\n<p>I repeat, the main idea of functional programming is immutability, which allows you to create your programs with fewer errors by not producing side effects that are difficult to control.<\/p>\n\n\n\n<p>As an example, suppose we have an object <code>person<\/code> and we want to \u201cchange\u201d the name, the most obvious thing would be to modify the name property directly, but what happens if that object is used elsewhere and the name is expected to be \u201cJaime\u201d, that is why instead of changing the name property , we only create a new person object with a different name, without modifying the original.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function cambiarNombre(nombre, persona) {  return {    nombre: nombre,    edad: persona.edad  }}const jaime = { nombre: 'Jaime', edad: 30 };const juan = cambiarNombre('Juan', jaime);console.log(jaime); \/\/ { nombre: 'Jaime', edad: 30 }console.log(juan); \/\/ { nombre: 'Juan', edad: 30 }\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C792EA\">functions<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">cambiarNombre<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8; font-style: italic\">name<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #BABED8; font-style: italic\">person<\/span><span style=\"color: #89DDFF\">)<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">  <\/span><span style=\"color: #89DDFF; font-style: italic\">return<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">    name<\/span><span style=\"color: #89DDFF\">:<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8\">name<\/span><span style=\"color: #89DDFF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">    edad<\/span><span style=\"color: #89DDFF\">:<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8\">person<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #BABED8\">edad<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F07178\">  <\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> James <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F07178\">name<\/span><span style=\"color: #89DDFF\">:<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Jaime<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F07178\">edad<\/span><span style=\"color: #89DDFF\">:<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">30<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">};<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> juan <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">cambiarNombre<\/span><span style=\"color: #BABED8\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Juan<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> jaime)<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">console<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">log<\/span><span style=\"color: #BABED8\">(jaime)<\/span><span style=\"color: #89DDFF\">;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #464B5D; font-style: italic\">\/\/ { nombre: &#39;Jaime&#39;, edad: 30 }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">console<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">log<\/span><span style=\"color: #BABED8\">(juan)<\/span><span style=\"color: #89DDFF\">;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #464B5D; font-style: italic\">\/\/ { nombre: &#39;Juan&#39;, edad: 30 }<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Here you will find more details about the fundamental principles of functional programming:<\/p>\n\n\n\n<p><a href=\"https:\/\/pensemosweb.com\/en\/introduccion-programacion-funcional\/\">Introduction to functional programming<\/a><\/p>\n\n\n\n<p>Finally, the functional programming paradigm teaches us:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>No side effects, for clear expression and less prone to errors<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>It is important to note that if the three programming paradigms were implemented between 1958 with LISP (functional programming) and Simula (object-oriented programming) in 1966, and the discovery of the structured programming paradigm in 1968, in only a period of 10 For years there has been innovation in programming paradigms, and new paradigms have not really emerged, unless they are based on these three main ones.<\/p>\n\n\n\n<p>Right now more than 60 years have passed, which tells us the importance and firmness they have despite the time that has passed.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Functional programming paradigm (1958, already implemented in a programming language for computers, remember that it was discovered in 1936)<\/li>\n\n\n\n<li>Object Oriented (1966)<\/li>\n\n\n\n<li>Structured (1968)<\/li>\n<\/ul>\n\n\n\n<p>The implementation of these three paradigms from the beginning within JavaScript has made this programming language the global success it is today. And it proves to us the value of combining paradigms when writing our programs.<\/p>\n\n\n\n<p>JavaScript is a multi-paradigm programming language, so you can combine the paradigms to create much more efficient and expressive code using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The direct, clear and explicit control of what a piece of code does<\/li>\n\n\n\n<li>Message passing for communication between objects<\/li>\n\n\n\n<li>No side effects, for clear expression and less prone to errors<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"referencias\">References<\/h3>\n\n\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Structured_programming\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/en.wikipedia.org\/wiki\/Structured_programming<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Structured_program_theorem\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/en.wikipedia.org\/wiki\/Structured_program_theorem<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=JxAXlJEmNMghttp:\/\/wiki.c2.com\/?AlanKayOnMessaginghttps:\/\/www.youtube.com\/watch?v=yvx4ObDBGZs\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">http:\/\/wiki.c2.com\/?AlanKayOnMessaging<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.slideshare.net\/FASTPresentations\/introduction-to-lambda-calculus-using-smalltalk-by-facundo-javier-gelatti\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/www.slideshare.net\/FASTPresentations\/introduction-to-lambda-calculus-using-smalltalk-by-facundo-javier-gelatti<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.amazon.com.mx\/Clean-Architecture-Craftsmans-Software-Structure\/dp\/0134494164\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Clean architecture book<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>The model or map of how we see the real world, that is a paradigm, it is a way of seeing and doing things. Following this logic, a programming paradigm is nothing more than a way of viewing and creating programming code.<\/p>","protected":false},"author":2,"featured_media":3725,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[21,28,30,33],"tags":[39,54],"class_list":["post-1643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-agilidad","category-javascript","category-node-js","category-intermedio","tag-agilidad","tag-javascript"],"_links":{"self":[{"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/posts\/1643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/comments?post=1643"}],"version-history":[{"count":2,"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/posts\/1643\/revisions"}],"predecessor-version":[{"id":3776,"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/posts\/1643\/revisions\/3776"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/media\/3725"}],"wp:attachment":[{"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/media?parent=1643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/categories?post=1643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pensemosweb.com\/en\/wp-json\/wp\/v2\/tags?post=1643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}