Programming Languages

Joseje Sinohui

Abstraction

public class Animal extends LivingThing
{
     private Location loc;
     private double energyReserves;

     public boolean isHungry() {
         return energyReserves < 2.5;
     }
     public void eat(Food food) {
         // Consume food
         energyReserves += food.getCalories();
     }
     public void moveTo(Location location, Double distance) {
         // Move to new location
         this.loc = location;
         energyReserves -= distance;

     }
}
thePig = new Animal();
theCow = new Animal();
if (thePig.isHungry()) {
    thePig.eat(tableScraps);
}
if (theCow.isHungry()) {
    theCow.eat(grass);
}
theCow.moveTo(theBarn);

Definition

A programming language is a formal computer language  or constructed language designed to communicate instructions to a machine.

Machine Code

 

b8    21 0a 00 00   #moving "!\n" into eax
a3    0c 10 00 06   #moving eax into first memory location
b8    6f 72 6c 64   #moving "orld" into eax
a3    08 10 00 06   #moving eax into next memory location
b8    6f 2c 20 57   #moving "o, W" into eax
a3    04 10 00 06   #moving eax into next memory location
b8    48 65 6c 6c   #moving "Hell" into eax
a3    00 10 00 06   #moving eax into next memory location
b9    00 10 00 06   #moving pointer to start of memory location into ecx
ba    10 00 00 00   #moving string size into edx
bb    01 00 00 00   #moving "stdout" number to ebx
b8    04 00 00 00   #moving "print out" syscall number to eax
cd    80            #calling the linux kernel to execute our print to stdout
b8    01 00 00 00   #moving "sys_exit" call number to eax
cd    80            #executing it via linux sys_call

First-Generation Programming Languages

Second-Generation Programming Languages

Assemby Languages

 

section     .text
global      _start               ;must be declared for linker (ld)

_start:                          ;tell linker entry point

    mov     edx,len              ;message length
    mov     ecx,msg              ;message to write
    mov     ebx,1                ;file descriptor (stdout)
    mov     eax,4                ;system call number (sys_write)
    int     0x80                 ;call kernel
    mov     eax,1                ;system call number (sys_exit)
    int     0x80                 ;call kernel

section     .data

msg     db  'Hello, world!',0xa  ;our dear string
len     equ $ - msg              ;length of our dear string

Examples

  • ARM
  • MIPS
  • x86

Third-Generation Programming Languages

Introducing Compilers


/* Hello World program */

#include<stdio.h>

main()
{
    printf("Hello World");

}

Examples:

  • C
  • FORTRAN
  • COBOL
  • BASIC
  • PASCAL

Arnold C

IT'S SHOWTIME
TALK TO THE HAND "hello world"
YOU HAVE BEEN TERMINATED

Fourth-Generation Programming Languages

More Abstraction

 

// my first program in C++
#include <iostream>

int main()
{
  std::cout << "Hello World!";
}
# Hello World program in Python 3

print("Hello World!")

Ejemplos:

  • Java
  • C++
  • Python
  • Go
  • JavaScript
  • Ruby

non-Turing Complete

  • Most markup languages(XML, HTML, Markdown, etc)
  • Most Database control languages or query languages(SQL)
  • Regular Expressions (REGEX)
  • Frameworks (Ruby on Rails, Django, ASP.NET MVC)

Taxonomies

Interpreted vs

Compiled


age = 19

if age >= 18:
    print("Es mayor de edad")

else:
    prnt(Es menor de edad")
  • Structured

 

 

  • Object Oriented

 

 

  • Functional

Paradigms

squares = map(lambda x: x * x, [0, 1, 2, 3, 4])

print squares
# => [0, 1, 4, 9, 16]
class Human{

    int age;
    int height;
    int weight;
    String name;
    
}

Human pedrito = new Human();

Use the right tool for the job

That's all folks

Made with Slides.com