# CSC301 Homepage

Fundamentals of Programming Languages

Fall 2016

## Instructor:

Dr. Lutz Hamel
Tyler Hall 251
Office hours: Monday 11-noon Tyler 251, Wednesday 1-2pm Tyler 251, or by appointment
Email: hamel@cs.uri.edu

## TAs:

Indrani Mandal
Tuesday : 2:00 -3:00 pm
Friday: 11:00 -12:00 pm
Tyler Room 136.
email: indrani_mandal@my.uri.edu

Na Li
Monday 1:00-2:00
Thursday 1:00- 2:00
email: na_li@uri.edu

## Announcements:

[12/9/16] posted assignment# 13
[12/7/16] Solution to the factorial problem given in class today. We need to extend our grammar for Language ONE with the factorial operator which is a high precedence operator:
```ONE-fact:
<exp>* ::= <exp> + <mulexp> | <mulexp>
<mulexp> ::= <mulexp> * <rootexp> | <rootexp>
<rootexp> ::= (<exp>) | <constant> | <rootexp>!
<constant> ::= <all valid integer constants>
```
We now need to extend our semantic Prolog rules:
```  val1(plus(X,Y),Value) :-
val1(X,XValue),
val1(Y,YValue),
Value is XValue + YValue.

val1(times(X,Y),Value) :-
val1(X,XValue),
val1(Y,YValue),
Value is XValue * YValue.

val1(fact(X),Value) :-
val1(X,XValue),
factorial(XValue,Value).

val1(const(X),Value) :- Value = X.
```
Note: Prolog does not have a factorial operator so we have to write our own:
```factorial(0,1).

factorial(N,NF) :-
T is N - 1,
factorial(T,TF),
NF is N*TF.
```

[12/7/16] there is a bootcamp today Wed 12/7 on programming language semantics
[12/2/16] posted assignment #12
[11/28/16] Posted assignment #11
[11/17/16] posted assignment #10
[11/16/16] There will be a bootcamp today on Prolog
[11/15/16] Posted assignment #9
[11/9/16] here is a driver class you can use for assignment #8:
```/* driver class for the Java Calculator.
* You give it an expression in double quotes and it will print out the value:
*      \$ java Calc "1+1"
*      value = 2.0
*      \$
*/

public class Calc
{
public static void main(String [] args)
{
CalcParser parser = new CalcParser(args[0]);
// TODO: This should be changed from value to stack machine code
System.out.println("value = " + parser.getValue());

}
}
```

[11/14/16] posted assignment #9 -- NO LATE SUBMISSIONS ACCEPTED
[11/9/16] posted the midterm solutions on the solutions page
[11/4/16] posted assignment #8
[11/2/16] posted all solutions 1-7
[10/28/16] posted assignment #7
[10/19/16] posted assignment #6
[10/14/16] posted assignment #5
[10/7/16] posted assignment #4
[10/7/16] posted solutions #3
[9/26/16] posted assignment #3
[9/21/16] posted the boot camp solutions
[9/21/16] posted assignment #2 due Friday, no late assignments accepted.
[9/16/16] Posted assignment #1 -- see below
[9/14/16] Posted solutions for the grammar part of session 1 - see bootcamp sessions
[9/7/16] NOTE: do NOT update the Ubuntu OS.  I do not know if all the packages I installed work with the new version of the OS.
Download this file (careful ~2.5GB) and import this into VirtualBox using the file->import appliance menu point. Once imported you can start the machine by double clicking on UbuntuBox.
[9/9/15] Welcome!

## Description:

Language enables thought. In this course we study a class of formal languages known as programming languages. Similar to natural languages, these formal languages enable us to to reason about algorithms and procedures to solve computational problems on computers. However, their formal nature restricts the kind of meanings particular language constructs can assume and therefore makes them amenable for the execution on a computer.

Over the years many different programming language dialects have evolved to address particular technical issues, e.g. object-oriented languages, real-time languages, database query languages, logic languages, etc. Here we study the major structures of modern programming languages. Understanding not only the syntax of a language but also the semantics and implementation techniques of this language will allow you to design better programs. Having deeper insights into the design of a programming language will also enable you to learn new programming languages much faster. Having a thorough understanding of today's languages allows you to design the programming languages of tomorrow.

## Objective

Upon completion of this course
• You will be able to discern and contrast the major programming language paradigms in use today.
• You will be able to pick an appropriate language for the job at hand.
• You will have deeper insights into the evolution of programming languages.

## Assignments:

Email submissions are NOT acceptable for assignments.

For programming assignments you will need to submit your source code and proof that your program runs on sample input, e. g., screen shot or cut and paste the results of the run into a MS Word document. Also, please follow the instructions for each problem carefully.

Handwritten work will not be accepted as programming assignments.