lunes, 13 de abril de 2020

5 Ruby and the Interpreter Pattern


As stated in  “Language Design and Implementation using Ruby and the Interpreter Pattern” by Ariel Ortiz, we notice a different way to approach common code. The way Ruby approaches problems is object oriented and using interpreters, like Python. Which makes it easier to modify and expand. The SIF (S-expression Interpreter Framework) for Ruby determines a type of coding that builds up with an essential foundation: “The core of the SIF is very simple. It only supports integers, symbols, lists, and procedures.” (2)

Ruby is incredibly flexible and develops the programmer’s mind to think in an abstract way. Since there are multiple ways to extend the language, programming becomes synonymous with building. Ortiz mentions a few ways to produce new procedures to tackle problems. The code itself contains a few primitive procedures like arithmetic and it is possible to simply define a new primitive procedure to affect your code. It is also possible to create new classes with the special form function:
“For example, suppose we want to implement the if special form. Its syntax and semantics are as follows: Syntax: (if condition consequent alternative) Semantics: Evaluate condition, if the resulting value is not an empty list, evaluate and return consequent, otherwise evaluate and return alternative.” (3)

As Ortiz mentions, Ruby has the advantage of having its syntax and semantics separate. This means it is doubly important to know how to structure each of them to create a functional code. That said, that is why I believe it to be an excellent learning tool for programmers who want to delve deep into the core of code structure. Although, it is also true that if you do not understand its core procedures your code will not work. And, it develops the good habit of creating from scratch instead of copying and pasting from other code examples commonly found on opensource and alike.

No hay comentarios:

Publicar un comentario

7 Lin Clark on WebAssembly

Typically, we use an array of code to create a website. HTML is used for its structure, CSS for styling and Javascript for the website’s beh...