5
Programming languages Goal: Need a way to describe algorithmic steps such that computer can use them to execute process Programming language defines syntax and seman;cs needed to translate our computa;onal ideas into mechanical steps

Lecture2_1 6.00.1x edx

  • Upload
    jjbb8

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture2_1 6.00.1x edx

Programming  languages  

•  Goal:  – Need  a  way  to  describe  algorithmic  steps  such  that  computer  can  use  them  to  execute  process  

– Programming  language  defines  syntax  and  seman;cs  needed  to  translate  our  computa;onal  ideas  into  mechanical  steps  

Page 2: Lecture2_1 6.00.1x edx

Op;ons  for  programming  languages  

Compiler   Object  code  

Source  code   Output  Interpreter  Checker  

Page 3: Lecture2_1 6.00.1x edx

Op;ons  for  programming  languages  

•  Low  level  language  uses  instruc;ons  similar  to  internal  control  unit:  – Move  data  from  one  loca;on  to  another  –  Execute  a  simple  ALU  opera;on  –  Jump  to  new  point  in  sequence  based  on  test  

•  Checker  confirms  syntax,  sta;c  seman;cs  correct  •  Interpreter  just  follows  sequence  of  simple  instruc;ons  

Source  code  Low  level  

Output  Interpreter  Checker  

Page 4: Lecture2_1 6.00.1x edx

Op;ons  for  programming  languages  

•  A  high  level  language  uses  more  abstract  terms  –  invert  a  matrix,  compute  a  func;on  

•  In  a  compiled  language,  those  abstrac;ons  are  converted  back  into  low  level  instruc;ons,  then  executed  

Compiler   Object  code  

Source  code  High  level  

Output  Interpreter  Checker  

Page 5: Lecture2_1 6.00.1x edx

Op;ons  for  programming  languages  

•  In  an  interpreted  language,  special  program  converts  source  code  to  internal  data  structure,  then  interpreter  sequen;ally  converts  each  step  into  low  level  machine  instruc;on  and  executes  

•  We  are  going  to  use  Python,  which  belongs  to  this  class  of  programming  languages  

Source  code  High  level    

Output  Interpreter  Checker