{"id":864,"date":"2010-10-14T08:25:40","date_gmt":"2010-10-14T12:25:40","guid":{"rendered":"http:\/\/www.elblender.com\/wordpress\/?p=864"},"modified":"2010-10-14T18:11:20","modified_gmt":"2010-10-14T22:11:20","slug":"introduction-to-concepts-of-programming-languages","status":"publish","type":"post","link":"http:\/\/blog.acarlstein.com\/?p=864","title":{"rendered":"Introduction to Concepts of Programming Languages"},"content":{"rendered":"<p>The follows is an introduction to the concepts of Programming Languages. Some of these concepts are the style of language, the identification of typical error when programming, etc.Lets begin by identifying different styles of programming languages.<\/p>\n<p><span style=\"text-decoration: underline;\">Programming languages normally are divided in two categories:<\/span><\/p>\n<p>The first category are languages that behave in a <em>declarative<\/em> way which means we tell the\u00a0 computer what it is going to do.<\/p>\n<p><span style=\"text-decoration: underline;\">Declarative language example:<\/span> In Prolog, we provide a group of facts and rules, its up to the programming language to figure out the answer:<\/p>\n<pre><span style=\"color: #0000ff;\">is_mother_of(maria, pedro). \/* Maria is_mother_of Pedro *\/\r\nis_mother_of(maria, lucia).\/* Maria is_mother_of Lucia *\/\r\n\r\nis_father_of(diego, pedro). \/* Diego is_father_of Pedro *\/\r\nis_father_of(manuel, lucia). \/* Manuel is_father_of Lucia *\/\r\n\r\n\/* Person is_parent_of Child if Person is_mother_of Child *\/\r\nis_parent_of(Person, Child):- is_mother_of(Person, Child).\r\nis_parent_of(Person, Child):- is_father_of(Person, Child).\r\n<\/span><\/pre>\n<p>In this case, we have that a mother, Maria, who is mother of two children, Pedro and Lucia; however, both children have different fathers. Diego is father of Pedro while Manuel is father of Lucia.<\/p>\n<p>Prolog is going to search for the answer for us base on there facts and rules. If we wish for more answers, it will search for the next one. We can keep asking Prolog to keep searching until there are no more answers to be found.<\/p>\n<pre><span style=\"color: #0000ff;\">\/* Prolog give us an answer *\/\r\n?- is_parent_of(Maria, Child).\r\nMaria = maria,\r\nChild = pedro.\r\n<\/span>\r\n<pre><span style=\"color: #0000ff;\">\/* After Prolog give us an answer, we can ask Prolog to search for another answer using ';' *\/\r\n?- is_parent_of(Maria, Child).\r\nMaria = maria,\r\nChild = pedro ;\r\nMaria = maria,\r\nChild = lucia. <\/span><\/pre>\n<p>In the declarative languages, there exist subcategories of programming  languages such as functional languages, dataflow languages, logic  languages (also known as constraint-based languages), and template based languages.<\/p>\n<p><span style=\"text-decoration: underline;\">Functional languages examples:<\/span> Haskell, Lisp (Scheme), MI.<\/p>\n<p>This languages are based on the use of recursive definitions of functions.<\/p>\n<p><span style=\"text-decoration: underline;\">Dataflow languages examples:<\/span> Val, Id.<\/p>\n<p>These languages are defined as tokens (known as nodes) that are used for the flow of information. This kind of language let the user to work on\u00a0 an inherently parallel model.<\/p>\n<p><span style=\"text-decoration: underline;\">Logic (constraint-based) languages examples:<\/span> Prolog, spreadsheets (such as Excel).<\/p>\n<p>This kind of languages are designed so the programmer provide relationships and rules in such a way that the computer try to find the values that will satisfy them.<\/p>\n<p><span style=\"text-decoration: underline;\">Template based languages example:<\/span> XSLT.<\/p>\n<p>The second category are imperative languages in which we tell the computer how to find the answer.<\/p>\n<p><span style=\"text-decoration: underline;\">Imperative language example:<\/span> In C, we must tell the language how to solve the problem.<\/p>\n<pre><span style=\"color: #0000ff;\">\/* This code tell the computer how to do the power of a number *\/\r\nint PowerI(int pow, int number){\r\n\u00a0\u00a0\u00a0 int accumulator, counter;\r\n\u00a0\u00a0\u00a0 for (accumulator = 1, counter = 0; counter &lt; pow; ++counter){\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 accumulator = accumulator * number;\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 return accumulator\r\n}<\/span><\/pre>\n<p>In the imperative languages, there exist subcategories of programming  languages such as scripting languages, object oriented languages, and Von Neumann languages which are based on statements (in honor to the creator of this language\u00a0 John Von Neumman &#8211; <a href=\"http:\/\/en.wikipedia.org\/wiki\/John_von_Neumann\">http:\/\/en.wikipedia.org\/wiki\/John_von_Neumann<\/a>) .<\/p>\n<p><span style=\"text-decoration: underline;\">Scripting languages examples:<\/span> Bash, PHP, ASP, Python, Perl, Ruby.<\/p>\n<p>This kind of languages let the programmer to create components and then combine them. The programmer can create a program and run it in real-time without compiling it, since each instruction is interpreted in real-time, letting the programmer to be able to change the program and witness the results instantaneously. However, there is a trade in speed.<\/p>\n<p><span style=\"text-decoration: underline;\">Object Oriented languages examples:<\/span> Java, C++, Small Talk, Eiffel.<\/p>\n<p>This kind of languages work on the concepts of classes that are the blueprint to create objects. Later, the idea is to make these objects to interact between them.<\/p>\n<p><span style=\"text-decoration: underline;\">Von Neumann languages examples:<\/span> Fortran, Ada, C.<\/p>\n<p>These languages are sequential in their process.<\/p>\n\n<script>\nvar zbPregResult = '0';\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>The follows is an introduction to the concepts of Programming Languages. Some of these concepts are the style of language, the identification of typical error when programming, etc.Lets begin by identifying different styles of programming languages. Programming languages normally are divided in two categories: The first category are languages that behave in a declarative way [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[191,189,186,188,187,196,190,193,195,192,71,194],"class_list":["post-864","post","type-post","status-publish","format-standard","hentry","category-programming","tag-constraint-based","tag-dataflow","tag-declariative","tag-functional","tag-imperative","tag-languages","tag-logic","tag-object-oriented","tag-programming-languages","tag-scripting","tag-template","tag-von-neumann"],"_links":{"self":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=864"}],"version-history":[{"count":12,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/864\/revisions"}],"predecessor-version":[{"id":879,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/864\/revisions\/879"}],"wp:attachment":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=864"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}