UP | HOME

Language Design
Lecture 2

Table of Contents

Review

  • What is a compiler?
  • Compilers vs. interpreters
  • Symbols vs. meaning

Questions about the last class?

Quiz

Quiz Discussion

Language design brainstorming notes

  • spaces in variables (b), a says no
    • underscores instead of spaces
  • latin alphabet, arabic numerals
  • use emojis?
    • unicode allows this i think
  • create shortcuts
    • public static void
      • #define MACRO public static void
        • use c preprocessor?
  • arithmetic expressions
    • nand is enough?
    • symbols, keywords
      • or instead of ||
      • one instead 1
      • two thousand and three
    • operators
    • numbers
  • functions
    • utility: reusable
    • maps a name to some copmutation, series of instructions
    • C identifiers: start character or underscore, and is a sequence of characters, underscores, digits
    • declaration: int sq; // i'm creating a new name, and i'm saying its type is an integer type
      • what if you didn't have to declare the type? infer it autoamically?
      • who cares what type it is? (some care, some don't)
        • x = 7
        • x = "jfksdlk"
        • x = x + 10
        • int f() { return 1; } f = 10;
    • sq.f = "2";
  • types
    • want the language to tell us when we get types wrong
auto x;  // double
auto y;  // int 

x = 1 + 2.0;  // plus(1, 2.0)
y = 1 + 7     // plus(1, 7)


x = "string"

polymorhpism: the same symbol has different types under different contexts

language:

  • c-like types, delcaration (type inference personal project)

strong definition: no untrapped errors, no invalid programs are allowed to run/compile

types: set of possible values, a set of operators on those values

  • numbers, int, floating point (some limited range)
    • y = x + 1?
      • x = 2 print(y); print(y);
      • 3, 3
      • print(y) -> print(x+1); x = 10; print(x+1) -> print(10+1)
      • 3, 11
  • no operators, just functions
    • recursion
    • scope?
  • branching, conditionals
  • while loops?
  • symbols to store values, variables

paradigms:

  • impertaive, recipe style
  • functional

the symbol for the number one is "1"

<1> - this means the symbol 1 - this means the math notion of one (or assembly representation)

<1 + 3> => 4 // symbols 1 followed by + followed by 3, evaluates to the math number 4

Resources on Lanugage Design

Homework

  • Clone source code example repo (see webcourses)
  • Add example programs as pull requests

Author: Paul Gazzillo

Created: 2022-02-14 Mon 11:49