Lecture 1. Basic Ruby 1 / 61

Size: px
Start display at page:

Download "Lecture 1. Basic Ruby 1 / 61"

Transcription

1 Lecture 1 Basic Ruby 1 / 61

2 What does this do? 3.times do print 'Hello, world!' end 2 / 61

3 Why Ruby? Optimized for programmer happiness Used for Ruby on Rails Very popular web framework 3 / 61

4 Course Policies 4 / 61

5 Prerequisites CIS 120 (or instructor permission) Basic HTML/CSS knowledge Codecademy Mozilla Developer Network W3Schools Please speak with us if you do not have the prerequisites or have any other concerns 5 / 61

6 CIS 19x Course Structure 3 shared lectures during semester 8/28: Git 9/11: Command Line 9/18: How the Web works Learn about language in "recitation" sections 6 / 61

7 CIS 196 Course Structure Lecture Topics: 3 weeks on Ruby programming language 6 weeks on Ruby on Rails web framework 5 weeks on miscellaneous topics 9 homework assignments 1 final project For more details, read the course syllabus 7 / 61

8 Grading 70% - Homework 25% - Final Project 5% - In-class Participation 8 / 61

9 Homework Due on Thursdays at 11:59pm through GitHub Classroom Unlimited submissions Your latest submission will be used for grading One free late day to use on any assignment After, 20% will be deducted for each day late 9 / 61

10 Homework Grading Correctness (15 pts) Style (5 pts) Best Practices (5 pts) Full credit if you pass all tests on Travis CI (unless told otherwise) Full credit if you have no Rubocop offenses TAs will manually grade your code to ensure the Ruby Way 10 / 61

11 Final Project Must be a web app built using Ruby on Rails Must be approved by Desmond/Sanjana ahead of time Milestones to help keep you on track Will be "due" the last day of class Demo on one of the Reading Days at the Project Fair 11 / 61

12 In-class Participation Attending and participating in lectures will be very beneficial for you To help encourage you to come to class, we will use Poll Everywhere during class Polls will be scattered throughout lecture You will receive participation grade based on: Completing polls while in class 12 / 61

13 Poll Everywhere Get started by going to When asked to provide a screen name, make it your preferred first name combined with your last name Otherwise you won't get points for participating 13 / 61

14 Which site uses Ruby on Rails? GitHub Piazza Canvas Airbnb All of the above! Poll 14 / 61

15 Why are you taking this class? Poll 15 / 61

16 Academic Integrity Don't copy/paste others' code Don't have mid-level discussions High-Level Discussion What is Rails used for? Mid-Level Discussion How did you do Homework 1? Low-Level Discussion What is the syntax for iterators? 16 / 61

17 O ce Hours Weekday Time TA Thursday 5-7pm Desmond Tuesday 7-9pm Sanjana Wednesday 5-7pm Zena Tuesday 6-8pm Edward TBD TBD Zhilei All office hours will be held in Moore / 61

18 Course Websites CIS 196 Website - All relevant course info Piazza - All course discussions & communication GitHub - Homework assignment management Travis CI - Results of tests run on submission Note that we will be using travis-ci.com Canvas - Viewing grades 18 / 61

19 Ruby 19 / 61

20 What you'll need Text editor (Sublime Text is probably easiest) Command Line If you use Windows, you must use a Linux VM or dual boot Linux Ruby We have provided a VM here with Ruby and Rails pre-installed If you run Ruby on Windows, I nor your TAs will debug for you 20 / 61

21 Installing Ruby Use the Ruby Version Manager (RVM) to manage and install Ruby versions Use this even if you plan on just using one version In this class, we will be using version Make sure you download the correct version 21 / 61

22 Resources Use the Ruby Docs whenever you get stuck Make sure you're looking at the correct version (2.5.1) This class will follow this style guide 10 points of your homework grade come from style and best practices 5 of which come from Rubocop (more on this later) 22 / 61

23 History of Ruby Ruby was designed in the mid-90s by Yukihiro "Matz" Matsumoto Influenced by Perl, Smalltalk, Eiffel, Ada & Lisp (Matz's favorite languages) Achieved mass acceptance in 2006 Much of Ruby's success and growth can be attributed to Rails Read about Matz's inspiration for Ruby here 23 / 61

24 Running Ruby Use a REPL (Read-Execute-Print-Loop) with the irb command in terminal Allows you to write and execute Ruby code from the Command Line This is great for testing Get out of the REPL by entering quit Execute.rb files with the ruby command: ruby file.rb 24 / 61

25 Types in Ruby Almost everything in Ruby is an object Ruby is strongly typed Every object has a fixed type Ruby is dynamically typed Variables do not need to be initialized Compare to Java which is statically typed 25 / 61

26 Will this give me an error? int_var = 5 int_var = 'five' Poll 26 / 61

27 Printing in Ruby You can print a value with three different commands: print, puts, and p print outputs the value and returns nil puts outputs the value with a newline and returns nil p both outputs and returns the value I'll use p in my examples since it formats output better I will denote output with #=> p 'hello world' #=> "hello world" 27 / 61

28 Numerics There are several types of numbers in Ruby Unlike Java, numbers are also objects in Ruby The main ones you'll be using are instances of the Integer and Float classes This is helpful to know when looking at the Ruby Docs If you see anything about FixNum or BigNum, note that they were deprecated in Ruby / 61

29 Local Variables Since Ruby is dynamically typed, you don't need to declare types (like int, String, etc.) Local variables are assigned to bare words foo = 100 p foo #=> / 61

30 Strings Strings can be denoted with either single or double quotes They can be concatenated together with + and appended with << hello = 'Hello' world = 'world!' foo = hello + ', ' + world p foo #=> "Hello, world!" p hello #=> "Hello" hello << '!' p hello #=> "Hello!" Note that concatenation did not change the variable, but appending did 30 / 61

31 Escaped Characters only work in Double Quotes print 'hello\nworld' #=> hello\nworld print "hello\nworld" #=> hello world 31 / 61

32 Only Double Quotes support String Interpolation When inserting variables into strings, string interpolation is preferred Put local variable betwen the curly braces in #{} This calls to_s on the variable foo = 5 p "Hello, #{foo}!" #=> "Hello, 5!" # Compare to: p 'Hello, ' + foo.to_s + '!' #=> "Hello, 5!" 32 / 61

33 When to use Single Quotes vs. Double Quotes Use double quotes if: You're using escaped characters or string interpolation You want to include single quotes in the string In all other cases, use single quotes It makes for more readable code 33 / 61

34 Which has the best Ruby style? Poll '5 + 5 = ' + (5 + 5).to_s "5 + 5 = 10" "5 + 5 = #{5 + 5}" 34 / 61

35 Symbols Denoted with a colon in front They are immutable For example, you cannot do :a << :b because that would change :a They are unique The equal? method checks if the two objects are the same 'hi'.equal? 'hi' #=> false :hi.equal? :hi #=> true 35 / 61

36 Boolean States All Ruby objects have boolean states of either true or false In fact, the only two objects in Ruby that are false are nil and false itself All other objects are true nil is an object that represents nothingness Kind of like Java's null 36 / 61

37 If Statements Conditionals can be used for control flow and to return different values based on the condition They implicitly return the last evaluated expression Use the elsif keyword for more branching foo = if true 1 elsif false 2 else 3 end p foo #=> 1 37 / 61

38 Unless Statements Evaluated when the condition is false Equivalent to if not Note that you should never have an unless statement followed by an else Instead, use an if... else flow unless false p 'hello' end #=> "hello" 38 / 61

39 Conditional Modi ers if and unless can be placed at the end of the line This helps code read more like English These are prefered for one liners p 'hello' if true #=> "hello" p 'bye' unless false #=> "bye" 39 / 61

40 Ternary Operator When using one line if-else statements, favor the ternary operator p true? 'hello' : 'goodbye' #=> "hello" p false? 'hello' : 'goodbye' #=> "goodbye" 40 / 61

41 Which of these has the best Ruby style? p 'hello' if not 'Desmond'.nil? p 'hello' unless 'Desmond'.nil? p 'Desmond'? ('Sanjana'? 'hello' : 'goodbye') : 'hi' p 'hello' if 'Desmond' Poll 41 / 61

42 Methods Parentheses around arguments can be omitted if unambiguous Our Style Guide has a lot to say about methods & parentheses def hi 'hello, there' end def hello(name) puts "hello, #{name}" end puts hi #=> "hello, there" hello('matz') #=> "hello, Matz" hello 'DHH' #=> "hello, DHH" 42 / 61

43 Implicit Returns Methods in Ruby always return exactly one thing They will return the last executed expression This means that you do not have to explicitly type return x at the end of the method Only use the return keyword when you want to exit a method early 43 / 61

44 Method Names While not strictly enforced, Ruby has certain conventions with naming methods If a method ends in:?, it should return a boolean (e.g. Array#empty?) =, it should write to a variable (e.g. writer methods)!, it should potentially change the variable being called on or perform some other dangerous action (e.g. String#capitalize!) You will encounter each kind as the course progresses 44 / 61

45 Default Arguments Denoted with an equal sign and value in method signature Optional when calling method def hello(name = 'world') p "Hello, #{name}" end hello #=> "Hello, world" hello('matz') #=> "Hello, Matz" 45 / 61

46 Guard Clauses Instead of wrapping an entire method in a conditional, use a guard clause to exit early # bad def foo(bar) if bar p 'hello' p 'goodbye' end end # good def foo(bar) return unless bar p 'hello' p 'goodbye' end 46 / 61

47 What's wrong with this method? def hello(name) return unless name puts "Hello #{name}" puts 'Goodbye' if not name.empty? end Poll It uses parentheses in the method definition It uses the return keyword It uses string interpolation instead of concatenation It uses if not Nothing! 47 / 61

48 Arrays Instantiated with [] or Array.new, but [] is preferred Note that you don't have to specify a size Arrays are heterogeneous Elements can be of different types The shovel operator << is the preferred way to add elements to the end of an array a = [] a << 1 p a #=> [1] 48 / 61

49 Iterators There are for... in loops in Ruby, but they are discouraged You will never have to use one in this class The Ruby Way is to use iterators The most basic one is the each iterator foo = [1, 2, 3] foo.each do num print "#{num} " end #=> "1 2 3 " 49 / 61

50 Blocks This is the code between the do and end keywords It is convention to use the do... end keywords when the block spans multiple lines But they should be replaced by { } when the method is only one line long Or a method is being chained off of the block [1, 2, 3].each { n print "#{n} " } #=> "1 2 3 " p [1, 2, 3].map { n n + 1 }.join(' ') #=> "2 3 4" 50 / 61

51 Hashes Used to store key-value pairs Like maps in Java Instantiated with {} and Hash.new but {} is preferred Keys can be ANY object They're often symbols Values can be accessed with [] foo = {} foo[:hello] = 'world' p foo #=> {:hello=>"world"} p foo[:hello] #=> "world" 51 / 61

52 Alternate Hash Syntax => is called a hash rocket It is the default notation linking key and value Starting with Ruby 2.0, an alternate syntax can be used Only when the key is a symbol This syntax is preferred if all keys are symbols foo = { foo: 'bar', baz: 'foobar' } p foo #=> {:foo=>"bar", :baz=>"foobar"} 52 / 61

53 Managing Dependencies 53 / 61

54 Gems Ruby libraries are called gems The command to install them is gem install gem_name When installed, the gem is installed in the current Ruby version's gem directory To use a gem, pass the name of the gem as a string to the require method at the top of the file (e.g. require pry) 54 / 61

55 The Bundler Gem Bundler is used to manage dependencies, comes in handy in large projects Install the gem using gem install bundler To use, create Gemfile in the directory & add gems to it Run bundle install or bundle for short to install all gems in the Gemfile 55 / 61

56 The Pry Gem A very useful gem for debugging gem install pry and add require pry to the top of the file Insert the line binding.pry in a Ruby file When you run the program, Ruby will stop at that line and give you a REPL with all variables in scope binding.pry must be deleted from your homework assignments before submitting because it will cause your tests to fail 56 / 61

57 The Rubocop Gem Rubocop will be used to grade for Style To run Rubocop: 1. Install Rubocop by running gem install rubocop 2. Make sure that you're in the directory that you want to check 3. Run rubocop 57 / 61

58 The RSpec Gem RSpec will be used for testing Be sure to run gem install rspec You will learn more about RSpec and writing tests in 2 lectures For now, you will be able to run pre-written tests by running rspec from the Command Line 58 / 61

59 Homework 1 59 / 61

60 Homework 1 Released now, due next Thursday at 11:59pm When you get started, you'll want to run gem install bundler and bundle install You can run rspec at any time during development to see how you're doing against the test cases You can run rubocop at any time to see how you're doing on style This means that you don't have to submit every time you want to see your output 60 / 61

61 Homework 1 You will: Set up everything you need to get started with Ruby Complete 5 methods designed to get you more comfortable with Ruby Submit to GitHub Classroom & view results on Travis CI You will fill out exercises.rb There is a provided file called bin/console.rb that will execute your code You can run ruby bin/console.rb and call all of the methods that you defined in exercises.rb 61 / 61

Lecture 2. Object Orientation 1 / 50

Lecture 2. Object Orientation 1 / 50 Lecture 2 Object Orientation 1 / 50 Homework 1 Homework 1 was due last night You will be graded on: Correctness: 15 points (passing all RSpec tests) Style: 5 points (having no Rubocop style offenses) Best

More information

Lecture 2. Object Orientation 1 / 51

Lecture 2. Object Orientation 1 / 51 Lecture 2 Object Orientation 1 / 51 Homework 1 Homework 1 was due at noon You will be graded on: Correctness: 15 points (passing all RSpec tests) Style: 5 points (having no Rubocop style offenses) Best

More information

Lecture 3. Miscellaneous Ruby and Testing 1 / 48

Lecture 3. Miscellaneous Ruby and Testing 1 / 48 Lecture 3 Miscellaneous Ruby and Testing 1 / 48 Homework 1 Grades were released! TAs provided feedback on best practices, but did not take off points Keep the comments in mind for future assignments! Any

More information

Lecture 3. Miscellaneous Ruby and Testing 1 / 40

Lecture 3. Miscellaneous Ruby and Testing 1 / 40 Lecture 3 Miscellaneous Ruby and Testing 1 / 40 Homework 1 Grades were released! TAs provided feedback on best practices, but did not take off points Keep the comments in mind for future assignments! Any

More information

Lecture 2. Object Orientation

Lecture 2. Object Orientation Lecture 2 Object Orientation 1 Homework 0 Grades Homework 0 grades were returned earlier this week Any questions? 2 Homework 1 Homework 1 is due tonight at 11:59pm You will be graded on: Correctness: 15

More information

Lecture 3. Miscellaneous Ruby and Testing

Lecture 3. Miscellaneous Ruby and Testing Lecture 3 Miscellaneous Ruby and Testing 1 Sublime Text Guide I wrote a quick Sublime Text Guide that will help with Rubocop offenses It ll walk you through: Using spaces instead of tabs by default Using

More information

CIS192: Python Programming

CIS192: Python Programming CIS192: Python Programming Introduction Harry Smith University of Pennsylvania January 18, 2017 Harry Smith (University of Pennsylvania) CIS 192 Lecture 1 January 18, 2017 1 / 34 Outline 1 Logistics Rooms

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

CIS192 Python Programming. Robert Rand. August 27, 2015

CIS192 Python Programming. Robert Rand. August 27, 2015 CIS192 Python Programming Introduction Robert Rand University of Pennsylvania August 27, 2015 Robert Rand (University of Pennsylvania) CIS 192 August 27, 2015 1 / 30 Outline 1 Logistics Grading Office

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 3 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

Lecture 4. Ruby on Rails 1 / 52

Lecture 4. Ruby on Rails 1 / 52 Lecture 4 Ruby on Rails 1 / 52 Homeworks 2 & 3 Grades were released for homework 2 Homework 3 was due last night Everyone got a style freebie since my default setup ignores spec files and I didn't change

More information

Computer Science Seminar. Whats the next big thing? Ruby? Python? Neither?

Computer Science Seminar. Whats the next big thing? Ruby? Python? Neither? Computer Science Seminar Whats the next big thing? Ruby? Python? Neither? Introduction Seminar Style course unlike many computer science courses discussion important, encouraged and part of your grade

More information

CSE : Python Programming

CSE : Python Programming CSE 399-004: Python Programming Lecture 2: Data, Classes, and Modules January 22, 2007 http://www.seas.upenn.edu/~cse39904/ Administrative things Teaching assistant Brian Summa (bsumma @ seas.upenn.edu)

More information

CSE 341, Autumn 2015, Ruby Introduction Summary

CSE 341, Autumn 2015, Ruby Introduction Summary CSE 341, Autumn 2015, Ruby Introduction Summary Disclaimer: This lecture summary is not necessarily a complete substitute for atting class, reading the associated code, etc. It is designed to be a useful

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

Your First Ruby Script

Your First Ruby Script Learn Ruby in 50 pages Your First Ruby Script Step-By-Step Martin Miliauskas @mmiliauskas 1 Your First Ruby Script, Step-By-Step By Martin Miliauskas Published in 2013 by Martin Miliauskas On the web:

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013

CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013 CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Winter 2013 Ruby logistics Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage

More information

CS 5142 Scripting Languages

CS 5142 Scripting Languages CS 5142 Scripting Languages 10/25/2012 Ruby 1 Outline Ruby Martin Hirzel 2 About Ruby Invented 1995 by Yokihiro Matz Matsumoto Influenced by SmallTalk Everything is an object (even e.g., integers) Blocks

More information

Ruby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework

Ruby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework Ruby logistics CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Autumn 2018 Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage

More information

PHP. Interactive Web Systems

PHP. Interactive Web Systems PHP Interactive Web Systems PHP PHP is an open-source server side scripting language. PHP stands for PHP: Hypertext Preprocessor One of the most popular server side languages Second most popular on GitHub

More information

CS 241 Data Organization using C

CS 241 Data Organization using C CS 241 Data Organization using C Fall 2018 Instructor Name: Dr. Marie Vasek Contact: Private message me on the course Piazza page. Office: Farris 2120 Office Hours: Tuesday 2-4pm and Thursday 9:30-11am

More information

Introduction to: Computers & Programming: Review prior to 1 st Midterm

Introduction to: Computers & Programming: Review prior to 1 st Midterm Introduction to: Computers & Programming: Review prior to 1 st Midterm Adam Meyers New York University Summary Some Procedural Matters Summary of what you need to Know For the Test and To Go Further in

More information

Overview of the Ruby Language. By Ron Haley

Overview of the Ruby Language. By Ron Haley Overview of the Ruby Language By Ron Haley Outline Ruby About Ruby Installation Basics Ruby Conventions Arrays and Hashes Symbols Control Structures Regular Expressions Class vs. Module Blocks, Procs,

More information

15.1 Origins and Uses of Ruby

15.1 Origins and Uses of Ruby 15.1 Origins and Uses of Ruby - Designed by Yukihiro Matsumoto; released in 1996 - Use spread rapidly in Japan - Use is now growing in part because of its use in Rails - A pure object-oriented purely interpreted

More information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Fall 2017 Miniassignment 1 50 points Due Date: Monday, October 16, 11:59 pm (midnight) Late deadline (25% penalty): Tuesday, October 17, 11:59 pm General information This assignment is to be

More information

CIS 3308 Web Application Programming Syllabus

CIS 3308 Web Application Programming Syllabus CIS 3308 Web Application Programming Syllabus (Upper Level CS Elective) Course Description This course explores techniques that are used to design and implement web applications both server side and client

More information

Lecture 8. Validations & Sessions 1 / 41

Lecture 8. Validations & Sessions 1 / 41 Lecture 8 Validations & Sessions 1 / 41 Advanced Active Record 2 / 41 More Complex Queries Arel provides us with a number of methods to query our database tables So far, we've only used find which limits

More information

Ruby. Mooly Sagiv. Most slides taken from Dan Grossman

Ruby. Mooly Sagiv. Most slides taken from Dan Grossman Ruby Mooly Sagiv Most slides taken from Dan Grossman Ruby dynamic, reflective, object-oriented, general-purpose programming language Designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto

More information

San José State University Computer Science CS 122 Advanced Python Programming Spring 2018

San José State University Computer Science CS 122 Advanced Python Programming Spring 2018 Course and Contact Information San José State University Computer Science CS 122 Advanced Python Programming Spring 2018 Instructor: Office Location: Telephone: Email: Office Hours: Class Days/Time: Classroom:

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu/program/philippines-summer-2012/ Philippines Summer 2012 Lecture 1 Introduction to Python June 19, 2012 Agenda About the Course What is

More information

CS 241 Data Organization. August 21, 2018

CS 241 Data Organization. August 21, 2018 CS 241 Data Organization August 21, 2018 Contact Info Instructor: Dr. Marie Vasek Contact: Private message me on the course Piazza page. Office: Room 2120 of Farris Web site: www.cs.unm.edu/~vasek/cs241/

More information

CS11 Java. Fall Lecture 1

CS11 Java. Fall Lecture 1 CS11 Java Fall 2006-2007 Lecture 1 Welcome! 8 Lectures Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7-8 Lab Assignments Made available on Mondays Due one week later Monday, 12 noon

More information

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST) Programming Concepts & Algorithms Course Syllabus Course Title Course Code Computer Department Pre-requisites Course Code Course Instructor Programming Concepts & Algorithms + lab CPE 405C Computer Department

More information

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration STATS 507 Data Analysis in Python Lecture 2: Functions, Conditionals, Recursion and Iteration Functions in Python We ve already seen examples of functions: e.g., type()and print() Function calls take the

More information

Lecture 1. Course Overview Types & Expressions

Lecture 1. Course Overview Types & Expressions Lecture 1 Course Overview Types & Expressions CS 1110 Spring 2012: Walker White Outcomes: Basics of (Java) procedural programming Usage of assignments, conditionals, and loops. Ability to write recursive

More information

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN What languages do you know? CSC 326H1F, Programming Languages The usual suspects: C, C++, Java fine languages nearly the same Perhaps you've also learned some others? assembler Basic, Visual Basic, Turing,

More information

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points Files to submit: 1. HW3.py This is a PAIR PROGRAMMING Assignment: Work with your partner! For pair

More information

Lecture 14. Moving Forward 1 / 23

Lecture 14. Moving Forward 1 / 23 Lecture 14 Moving Forward 1 / 23 Course Evaluations Remember to fill out course evaluations for this class! Please provide honest and constructive feedback on the course Anything that you'd want me to

More information

Announcements. 1. Forms to return today after class:

Announcements. 1. Forms to return today after class: Announcements Handouts (3) to pick up 1. Forms to return today after class: Pretest (take during class later) Laptop information form (fill out during class later) Academic honesty form (must sign) 2.

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 05 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions / Comments? recap and some more details about variables, and if / else statements do lab work

More information

Computer Science II Lecture 1 Introduction and Background

Computer Science II Lecture 1 Introduction and Background Computer Science II Lecture 1 Introduction and Background Discussion of Syllabus Instructor, TAs, office hours Course web site, http://www.cs.rpi.edu/courses/fall04/cs2, will be up soon Course emphasis,

More information

Installation Download and installation instructions can be found at

Installation Download and installation instructions can be found at IntroductiontoRuby Ruby (http://www.ruby-lang.org/en/ ) is a reflective, dynamic, objectoriented, single-pass interpreted programming language. It also has some functional programming features such as

More information

CS 11 java track: lecture 1

CS 11 java track: lecture 1 CS 11 java track: lecture 1 Administrivia need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi need to know UNIX www.its.caltech.edu/its/facilities/labsclusters/ unix/unixtutorial.shtml

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

INFS 2150 (Section A) Fall 2018

INFS 2150 (Section A) Fall 2018 INFS 2150 (Section A) Fall 2018 Introduction to Web Development Class meets TUE & THU: 12:30am-1:45pm: in Wheatley 114 Instructor: Peter Y. Wu Office: Wheatley 309 Office Hours: Tuesday 9:00 am-12:00 noon;

More information

Introduction to Ruby on Rails

Introduction to Ruby on Rails Introduction to Ruby on Rails Ralf Teusner ralf.teusner@hpi.de Software Engineering II WS 2018/19 Prof. Plattner, Dr. Uflacker Enterprise Platform and Integration Concepts group Introduction to Ruby on

More information

CS143 Handout 05 Summer 2011 June 22, 2011 Programming Project 1: Lexical Analysis

CS143 Handout 05 Summer 2011 June 22, 2011 Programming Project 1: Lexical Analysis CS143 Handout 05 Summer 2011 June 22, 2011 Programming Project 1: Lexical Analysis Handout written by Julie Zelenski with edits by Keith Schwarz. The Goal In the first programming project, you will get

More information

CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September

CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September CS 1313 010: Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September 19 2018 This second assignment will introduce you to designing, developing, testing

More information

Introduction to Ruby. SWEN-250 Personal Software Engineering

Introduction to Ruby. SWEN-250 Personal Software Engineering Introduction to Ruby SWEN-250 Personal Software Engineering A Bit of History Yukihiro "Matz'' Matsumoto Created a language he liked to work in. Been around since mid-90s. Caught on in early to mid 00s.

More information

Python I. Some material adapted from Upenn cmpe391 slides and other sources

Python I. Some material adapted from Upenn cmpe391 slides and other sources Python I Some material adapted from Upenn cmpe391 slides and other sources Overview Names & Assignment Data types Sequences types: Lists, Tuples, and Strings Mutability Understanding Reference Semantics

More information

Introducing: main Function, Comments, Statements

Introducing: main Function, Comments, Statements Once you're seated, please respond to the poll at pollev.com/compunc If you are not registered for PollEverywhere, please go ahead and do so before class begins! Lecture 01 Take on Me Practice: Primitive

More information

Introduction CMSC 330: Organization of Programming Languages. Books on Ruby. Applications of Scripting Languages

Introduction CMSC 330: Organization of Programming Languages. Books on Ruby. Applications of Scripting Languages Introduction CMSC 330: Organization of Programming Languages Ruby is an object-oriented, imperative scripting language I wanted a scripting language that was more powerful than Perl, and more object-oriented

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

Ruby: Objects and Dynamic Types

Ruby: Objects and Dynamic Types Ruby: Objects and Dynamic Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 5 Primitive vs Reference Types Recall Java type dichotomy: Primitive: int, float,

More information

Functions. Nate Foster Spring 2018

Functions. Nate Foster Spring 2018 Functions Nate Foster Spring 2018 A0: Warmup Worth only 1% of final grade; other assignments will be 5% much easier coding problems intended to give you low-stakes experience with 3110 workflow Please

More information

INF4820: Algorithms for Artificial Intelligence and Natural Language Processing. Common Lisp Fundamentals

INF4820: Algorithms for Artificial Intelligence and Natural Language Processing. Common Lisp Fundamentals INF4820: Algorithms for Artificial Intelligence and Natural Language Processing Common Lisp Fundamentals Stephan Oepen & Murhaf Fares Language Technology Group (LTG) August 30, 2017 Last Week: What is

More information

CGS 3066: Spring 2015 JavaScript Reference

CGS 3066: Spring 2015 JavaScript Reference CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within

More information

Introduction to Ruby on Rails

Introduction to Ruby on Rails Introduction to Ruby on Rails Keven Richly keven.richly@hpi.de Software Engineering II WS 2017/18 Prof. Plattner, Dr. Uflacker Enterprise Platform and Integration Concepts group Introduction to Ruby on

More information

CSC 172 Data Structures and Algorithms. Fall 2017 TuTh 3:25 pm 4:40 pm Aug 30- Dec 22 Hoyt Auditorium

CSC 172 Data Structures and Algorithms. Fall 2017 TuTh 3:25 pm 4:40 pm Aug 30- Dec 22 Hoyt Auditorium CSC 172 Data Structures and Algorithms Fall 2017 TuTh 3:25 pm 4:40 pm Aug 30- Dec 22 Hoyt Auditorium Agenda Administrative aspects Brief overview of the course Hello world in Java CSC 172, Fall 2017, UR

More information

Ruby on Rails Welcome. Using the exercise files

Ruby on Rails Welcome. Using the exercise files Ruby on Rails Welcome Welcome to Ruby on Rails Essential Training. In this course, we're going to learn the popular open source web development framework. We will walk through each part of the framework,

More information

Object-Oriented Programming for Managers

Object-Oriented Programming for Managers 95-807 Object-Oriented Programming for Managers 12 units Prerequisites: 95-815 Programming Basics is required for students with little or no prior programming coursework or experience. (http://www.andrew.cmu.edu/course/95-815/)

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG 1 Notice Prepare the Weekly Quiz The weekly quiz is for the knowledge we learned in the previous week (both the

More information

Language Proposal: tail

Language Proposal: tail Language Proposal: tail A tail recursion optimization language Some Wise Gal Team Roles Team Members UNIs Roles Sandra Shaefer Jennifer Lam Serena Shah Simpson Fiona Rowan sns2153 jl3953 ss4354 fmr2112

More information

CS503 Advanced Programming I CS305 Computer Algorithms I

CS503 Advanced Programming I CS305 Computer Algorithms I Syllabus: CS503 Advanced Programming I CS305 Computer Algorithms I Course Number: CS503-50/CS305-50 Course Title: Advanced Programming I/Computer Algorithms I Instructor: Richard Scherl Office: Howard

More information

Key Differences Between Python and Java

Key Differences Between Python and Java Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

More information

Introduction. CSC 440: Software Engineering Slide #1

Introduction. CSC 440: Software Engineering Slide #1 Introduction CSC 440: Software Engineering Slide #1 Topics 1. Course Goals 2. Programming: Small vs. Large 3. Challenges of Large Programs 4. Software Processes and Methods 5. Teams and Roles 6. Rails

More information

CS 240 Fall Mike Lam, Professor. Just-for-fun survey:

CS 240 Fall Mike Lam, Professor. Just-for-fun survey: CS 240 Fall 2014 Mike Lam, Professor Just-for-fun survey: http://strawpoll.me/2421207 Today Course overview Course policies Python Motivation Computers are digital Data is stored in binary format (1's

More information

S206E Lecture 19, 5/24/2016, Python an overview

S206E Lecture 19, 5/24/2016, Python an overview S206E057 Spring 2016 Copyright 2016, Chiu-Shui Chan. All Rights Reserved. Global and local variables: differences between the two Global variable is usually declared at the start of the program, their

More information

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful

More information

CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013

CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013 CS252 Advanced Programming Language Principles Prof. Tom Austin San José State University Fall 2013 What are some programming languages? Why are there so many? Different domains Mobile devices (Objective

More information

Lists, loops and decisions

Lists, loops and decisions Caltech/LEAD Summer 2012 Computer Science Lecture 4: July 11, 2012 Lists, loops and decisions Lists Today Looping with the for statement Making decisions with the if statement Lists A list is a sequence

More information

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30 CS31 Discussion 1E Jie(Jay) Wang Week1 Sept. 30 About me Jie Wang E-mail: holawj@gmail.com Office hour: Wednesday 3:30 5:30 BH2432 Thursday 12:30 1:30 BH2432 Slides of discussion will be uploaded to the

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 9: OCT. 4TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 9: OCT. 4TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 9: OCT. 4TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignments Reading Assignment: Chapter 3: Introduction to Parameters and Objects The Class 9 Exercise

More information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Spring 2018 Miniassignment 1 40 points Due Date: Thursday, March 8, 11:59 pm (midnight) Late deadline (25% penalty): Friday, March 9, 11:59 pm General information This assignment is to be done

More information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Fall 2018 Miniassignment 1 40 points Due Date: Friday, October 12, 11:59 pm (midnight) Late deadline (25% penalty): Monday, October 15, 11:59 pm General information This assignment is to be done

More information

COMP-520 GoLite Tutorial

COMP-520 GoLite Tutorial COMP-520 GoLite Tutorial Alexander Krolik Sable Lab McGill University Winter 2019 Plan Target languages Language constructs, emphasis on special cases General execution semantics Declarations Types Statements

More information

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB!

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB! CS61C L03 Introduction to C (pt 2) (1)! inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 3 Introduction to C (pt 2) 2010-06-23!!!Instructor Paul Pearce! The typical! development cycle!

More information

Welcome to... CS113: Introduction to C

Welcome to... CS113: Introduction to C Welcome to... CS113: Introduction to C Instructor: Erik Sherwood E-mail: wes28@cs.cornell.edu Course Website: http://www.cs.cornell.edu/courses/cs113/2005fa/ The website is linked to from the courses page

More information

Computer Science 210: Data Structures

Computer Science 210: Data Structures Computer Science 210: Data Structures Welcome to Data Structures! Data structures are fundamental building blocks of algorithms and programs Csci 210 is a study of data structures design efficiency implementation

More information

Syllabus COSC-051-x - Computer Science I Fall Office Hours: Daily hours will be entered on Course calendar (or by appointment)

Syllabus COSC-051-x - Computer Science I Fall Office Hours: Daily hours will be entered on Course calendar (or by appointment) Syllabus COSC-051-x - Computer Science I Fall 2018 Instructor: Jeremy Bolton, Ph.D. Asst Teaching Professor Department of Computer Science Office: TBD (see Course calendar for office hours) Email: jeremy.bolton@georgetown.edu

More information

Introduction to Ruby on Rails

Introduction to Ruby on Rails Introduction to Ruby on Rails Software Engineering II WS 2016/17 Arian Treffer arian.treffer@hpi.de Prof. Plattner, Dr. Uflacker Enterprise Platform and Integration Concepts group Introduction to Ruby

More information

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen CSCI 136 Data Structures & Advanced Programming Fall 2018 Instructors Bill Lenhart & Bill Jannen Administrative Details Class roster: Who s here? And who s trying to get in? Handout: Class syllabus Lecture

More information

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D 1/60 Interactive use $ python Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information.

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

TTh 9.25 AM AM Strain 322

TTh 9.25 AM AM Strain 322 TTh 9.25 AM - 10.40 AM Strain 322 1 Questions v What is your definition of client/server programming? Be specific. v What would you like to learn in this course? 2 Aims and Objectives v Or, what will you

More information

CIS*1500 Introduction to Programming

CIS*1500 Introduction to Programming CIS*1500 Introduction to Programming CIS*1500 Learning to program The basic constructs of programming Programming in the C language Solving real problems Not just about coding! About me??? Some basic things...

More information

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

CS 240 Fall 2015 Section 004. Alvin Chao, Professor CS 240 Fall 2015 Section 004 Alvin Chao, Professor Today Course overview Data Structures / Algorithms Course policies The C language Motivation Computers are digital Data is stored in binary format (1's

More information

FRAC: Language Reference Manual

FRAC: Language Reference Manual FRAC: Language Reference Manual Justin Chiang jc4127 Kunal Kamath kak2211 Calvin Li ctl2124 Anne Zhang az2350 1. Introduction FRAC is a domain-specific programming language that enables the programmer

More information

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting Your factors.c and multtable.c files are due by Wednesday, 11:59 pm, to be submitted on the SoC handin page at http://handin.cs.clemson.edu.

More information

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1, 2, and 3, Spring 2018

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1, 2, and 3, Spring 2018 San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1, 2, and 3, Spring 2018 Course and Contact Information Instructor: Suneuy Kim Office

More information

CME 193: Introduction to Scientific Python Lecture 1: Introduction

CME 193: Introduction to Scientific Python Lecture 1: Introduction CME 193: Introduction to Scientific Python Lecture 1: Introduction Nolan Skochdopole stanford.edu/class/cme193 1: Introduction 1-1 Contents Administration Introduction Basics Variables Control statements

More information

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003 Control Flow COMS W1007 Introduction to Computer Science Christopher Conway 3 June 2003 Overflow from Last Time: Why Types? Assembly code is typeless. You can take any 32 bits in memory, say this is an

More information

CS1 Lecture 3 Jan. 18, 2019

CS1 Lecture 3 Jan. 18, 2019 CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques () Lecture 1 Welcome Introduction to Program Design Introductions Dr. Mitch Marcus Levine 503 http://www.cis.upenn.edu/~mitch/ mitch@cis.upenn.edu Dr. Stephanie Weirich*

More information

Typescript on LLVM Language Reference Manual

Typescript on LLVM Language Reference Manual Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String

More information

by the evening of Tuesday, Feb 6

by the evening of Tuesday, Feb 6 Homework 1 Due 14 February Handout 6 CSCI 334: Spring 2018 Notes This homework has three types of problems: Self Check: You are strongly encouraged to think about and work through these questions, and

More information