CPS 530 Study Guide - Summer 2018, Comprehensive Midterm Notes - Type System, Type Inference, Smalltalk

116 views56 pages
CPS 530
MIDTERM EXAM
STUDY GUIDE
Fall 2018
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 56 pages and 3 million more documents.

Already have an account? Log in
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 56 pages and 3 million more documents.

Already have an account? Log in
Jan’s Somewhat Half-Assed Guide to Mason’s fucking wildride.
No seriously, i’d rather trust United to fly me somewhere than him to teach.
I’d rather get in a car with Paul Walker than him teaching this class.
I’d even trust Bill Cosby to buy me a fucking drink more than this guy. Anyways:
Notes about general comparative programming languages:
Smalltalk is an object-oriented, dynamically typed, reflective programming language. What
does this mean?
Everything in smalltalk is an object.
Dynamically typed, you don’t have to declare a type in small talk
Haskell is a purelyfunctional programming language, with non-strict semantics and strong static
typing.
Functional means, basically, it treats its evaluations like math, data is immutable
Haskell is lazy, meaning (non-strict semantics) it isn’t going to evaluate something if it isn’t
directly part of a function call.
Also has strong typing. This means that if the types are off, haskell will fail to compile
Literally the biggest sticking point of Haskell is monads
These are blocks of computation, kinda like functions, but they NEED parameters,
According to Mason, Java doesn’t have Monads. Literally Google Java Monads and all
you’ll see is how Java 8 has fucking monads.
Haskell has similar semantics to the language Miranda. Do with that what you will.
Elixir is functional and concurrent.
Again, functional, shit in this language is immutable. Why the FUCK you would make a
game with constant changing states like snakes-and-ladders is fucking beyond me.
Concurrent means that it’s the type of language that allows several things happening at
once, concurrently, which is why Elixir is used for things like chatrooms.
Rust is functional and imperative. Well it combines the two to be honest
Yes things are immutable, but the language is also procedural, meaning code does depend
on state.
Smalltalk Notes
Smalltalk was created as the language to underpin the “new world of computing exemplified by
human computer symbiosis”
o No I’m not making that fucking up. Now this language has been relegated to a bunch of
old dudes.
You know, its kind of poetic irony. I’ll let you all figure that out on your own
o Allowable characters (remember this language is old af)
A-Z, a-z, 0-9, .+/*~<>@%|&?
Blank,tab,cr,ff,if
o Variables!
Must be declared before use
Shared vars begin with uppercase
Local vars begin with lowercase
Reserved names are nil, true, false, self, super, and Smalltalk
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 56 pages and 3 million more documents.

Already have an account? Log in
Variable scope:
o Global
o Local to a method
o Local to a black
Sample Transcript
o Transcript clear. //clears transcript window
o Transcript show: ‘Hello World’. //output string in transcript
Assignment
o | x y |
o x := 5 //assignment
o x := y := 6 //compound assignment
o x := Object new. //bind to allocated instance
Conversion
o | x |
o X := 3.99 asInteger.
Blocks
o |x y z|
o x := [y :=1. z:=2.]. x value /////simple block assignment
o X := [:argOne :argTwo | argOne, and ‘, argTwo.]. ////block with argument passing
o Transcript show: (x value: ‘Firstvalue: ‘Second’); cr.
Method calls:
o Unary methods are messages with no arguments
o Binary methods
o Keyword methods are messages with selectors including colons
Conditional Statements
o | x |
o X > 10 ifTrue: [aBlock]
Note: Yes you can nest them
X > 10 ifTrue: [x > 5 ifTrue: [aBlock]].
Man I wish I didn’t have to hate this language
Iterations
o | x y |
o X := 4. Y := 1.
o [x > 0] whileTrue: [x := x – 1. Y:=y *2]
o 1 to: x do: [:a |y := y * 2]
Ordered Collections
o | b x y sum max|
o X := OrderedCollection with: 4 with: 3 with: 2 with: 1. //creates a collection with up to 4
elements
o X := OrderedCollection new. ////allocate it
o X add: 3; add: 2; add: 1; add: 4; yourself. ///add elements to collection
o Y := addFirst: 5.
Return
o ^
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 56 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers