CS162 Week 1 Kyle Dewey. Overview Basic Introduction CS Accounts Scala survival guide.

Slides:



Advertisements
Similar presentations
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists Dan Grossman Winter 2013.
Advertisements

Chapter 1 Object-Oriented Concepts. A class consists of variables called fields together with functions called methods that act on those fields.
CS162 Week 2 Kyle Dewey. Overview Continuation of Scala Assignment 1 wrap-up Assignment 2a.
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Winter 2013.
Intro to CIT 594
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
COEN Expressions and Assignment
Defining classes and methods Recitation – 09/(25,26)/2008 CS 180 Department of Computer Science, Purdue University.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Road Map Introduction to object oriented programming. Classes
Intro to CIT 594
Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Rossella Lau Lecture 8, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 8: Polymorphism & C++ pointer  Inheritance.
Interfaces. In this class, we will cover: What an interface is Why you would use an interface Creating an interface Using an interface Cloning an object.
Slides prepared by Rose Williams, Binghamton University Chapter 5 Defining Classes II.
Programming in Scala Chapter 1. Scala: both object-oriented and functional Scala blends –object-oriented and –functional programming in a –statically.
CS3 Fall 2005 Lecture week 15. Administrivia The final survey will be up tomorrow: –you NEED to do this to receive a grade on your project! Final: –Saturday,
Type Inference: CIS Seminar, 11/3/2009 Type inference: Inside the Type Checker. A presentation by: Daniel Tuck.
Slide 1. Slide 2 Administrivia Nate's office hours are Wed, 2-4, in 329 Soda! TA Clint will be handing out a paper survey in class sometime this week.
Intro to CIT 594
1 Python Control of Flow and Defining Classes LING 5200 Computational Corpus Linguistics Martha Palmer.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
10-Sep-15 Classes. Classes and objects Scala is an Object-Oriented (O-O), functional language Object-Oriented (O-O) means it’s built around “objects”
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
CS162 Week 1 Kyle Dewey. Overview Basic Introduction CS Accounts Scala survival guide.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods.
Pattern matching. The if expression The else part of an if expression is optional if ( condition ) expression1 else expression2 If the condition evaluates.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
A PEG-based pattern matching library EXtended by back reference with regex-like notation in Scala Kota Mizushima Graduate School of Systems and Information.
APCS Java AB 2004 Review of CS1 and CS2 Review for AP test #1 Sources: 2003 Workshop notes from Chris Nevison (Colgate University) AP Study Guide to go.
E FFECTIVE C# 50 Specific Ways to Improve Your C# Second Edition Bill Wagner محمد حسین سلطانی.
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
CS162 Week 1 Kyle Dewey. Overview Basic Introduction CS Accounts Scala survival guide.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Functions and Methods. Definitions and types A function is a piece of code that takes arguments and returns a result A pure function is a function whose.
Programming in Java CSCI-2220 Object Oriented Programming.
Overview The Basics – Python classes and objects Procedural vs OO Programming Entity modelling Operations / methods Program flow OOP Concepts and user-defined.
PROGRAMMING LANGUAGES: PROLOG, CLOJURE, F# Jared Wheeler.
Object-Oriented Programming Chapter Chapter
RUBY by Ryan Chase.
CSE 413 Languages & Implementation Hal Perkins Autumn 2012 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1.
M1G Introduction to Programming 2 5. Completing the program.
IT108 Objects and Classes Part I George Mason University Revised 4/3/2012.
CIS 270—Application Development II Chapter 8—Classes and Objects: A Deeper Look.
OOP with Objective-C Categories, Protocols and Declared Properties.
Introduction to Object-Oriented Programming Lesson 2.
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
Classes and Objects and Traits And Other Miscellany 25-Jan-16.
Unit Testing with FlexUnit
CISC105 – General Computer Science Class 4 – 06/14/2006.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
INF3110 Group 2 EXAM 2013 SOLUTIONS AND HINTS. But first, an example of compile-time and run-time type checking Imagine we have the following code. What.
COURSE DETAILS SPARK ONLINE TRAINING COURSE CONTENT
Object-Oriented Concepts
Programming Languages Dan Grossman 2013
Generics, Lambdas, Reflections
CS/ENGRD 2110 Fall 2017 Lecture 6: Consequence of type, casting; function equals
The fattest knight at King Arthur's round table was Sir Cumference
Java Programming Language
The Metacircular Evaluator
CMSC 202 Java Primer 2.
„Lambda expressions, Optional”
Generics, Lambdas and Reflection
Presentation transcript:

CS162 Week 1 Kyle Dewey

Overview Basic Introduction CS Accounts Scala survival guide

Office Hour Tuesdays from 11 AM - 12 PM in Phelps 1413 (the TA office) Also by appointment

Google Group We have a Google group (162w13) Feel free to discuss, even post test cases Pretty much anything CS162-related that doesn’t involve sharing code

Communication Policy Assume I’ll take 24 hours to respond to any I’m usually a lot faster than that Google group is usually a better resource I can still answer it Other people can see it Someone else may respond faster

CS Account You will need a CS account One can be created at:

Scala

What? A non-Java language that runs on the Java Virtual Machine (JVM) Essentially a “better Java” Better suited for object-oriented programming and functional programming

Why Less boilerplate More expressive (read: less code) Think more, type less Clarity

Properties and Idioms Everything is an object (unlike Java) Emphasis on immutable state In other words, avoid reassignment

Variable Declaration Two forms: val and var val creates a runtime constant, much like final in Java var creates a typical mutable variable (HIGHLY discouraged and will typically negatively impact grade)

Method Definition Uses the def reserved word Everything is public by default The result of the last expression in the function is what is returned - no need for return (which should be avoided)

Type Inferencer Can automatically determine the type of Variables Function return values Anonymous function parameters Not completely foolproof, but usually excellent

Higher-Order Functions Functions can take other functions as parameters, or even return functions Functions (well, closures) can be created on the fly Note: this is strictly more powerful than function pointers For the JavaScript people: think callbacks

Classes Created with the class reserved word Defaults to public access Constructors are not typical

Traits Created with the trait reserved word Like a mixin in Ruby Think Java interfaces, but they can have methods defined on them More powerful than that, but not relevant to this course

object Used in much the same way as static is in Java Defines both a class and a single instance of that class (and only a single instance) Automated implementation of the Singleton design pattern Keeps everything consistently an object

equals, ==, and eq As with Java, if you want to compare value equality, you must extend equals Case classes automatically do this for you However, instead of saying x.equals(y), merely say x == y If you want reference equality, say: x eq y

Case Classes Behave just like classes, but a number of things are automatically generated for you Including hashCode, equals, and getters Typically used for pattern matching

Pattern Matching Used extensively in Scala Like a super-powerful if Used with the match reserved word, followed by a series of case s

null In general, null is an excellent wonderful/terrible feature Often poorly documented whether or not null is possible Checking for impossible cases Not checking for possible cases

Option A solution: encode null as part of a type For some type, say Object, if null is possible say we have a NullPossible Scala has this, known as Option In general, if null is possible, use Option

Tuples For when you want to return more than one thing Can be created by putting datums in parenthesis Can pattern match on them

Looping Scala has a while loop, but its use is highly discouraged (again, point loss) It’s not actually needed General functional programming style is recursion, but this is usually overkill

Taking a Step Back... When do we write loops? Transform data Scan data Aggregate data Higher-order functions allow us to abstract away much of this

map Applies a given function to each element of a sequence Returns a new sequence that holds the results

filter Takes a predicate, i.e. a function that returns true or false Applies the predicate to each item in a list A new list is returned that contains all the items for which the predicate was true

foldLeft Extremely flexible, but sometimes unwieldy Takes a base element Takes a function that takes a current result and a current list element The function will manipulate result with respect to the current element

Compiling/Running Code Use scalac to compile code Alternatively use fsc, the fast Scala compiler Use scala to run the code scala, scalac, and fsc are all on CSIL

Running the REPL Just type scala at the command line Pretty nifty to quickly check to see what an expression does

Development If you want an IDE, IntelliJ IDEA has been recommended Personally, I use emacs and the scala-mode plugin (needs to be downloaded)

Assignment 1 Due Tuesday Will need most everything shown here Hint hint useful APIs: Seq.mkString Seq.reverse Seq.head Seq.tail