Swift. Introducing swift. Thomas Woodfin

Size: px
Start display at page:

Download "Swift. Introducing swift. Thomas Woodfin"

Transcription

1 Swift Introducing swift Thomas Woodfin

2 Content Swift benefits Programming language Development Guidelines

3 Swift benefits What is Swift Benefits

4 What is Swift New programming language for ios and OS X Development Announced at WWDC2014 after being worked on in secret for 4 years. Used to write application for ios 7+ and OS X Mavericks+. Xcode 6 includes Swift support. Work with Object-C It s possible to add swift to existing Object-C program and allow call methods existing Object-c libraries. Designed to be succinct

5 Benefits Apps run faster Read-Eval-Print-Loop (REPL): The debugging console in Xcode includes an interactive version of the Swift language built using the newest LLVM compiler. Processing Speed: Optimize the native code to reduce the time needed to compile in real-time. Creating and modifying apps can be done in less time, resulting in faster deployment. Elimination of the need to end every command with a semi-colon. Inferred types eliminate the requirement to specify the variable type. Automatic memory management. Interactive playgrounds let developers view the results of code as it is entered, simplifying debugging and testing. Compatible with Objective-C, allowing integration with existing apps without the need to reinvent the wheel.

6 Programming language Constant & Variables Data types Control Flow Functions Class Generics

7 Constant & Variables Definition syntax Defining constant or variables is simple in Swift language, use keyword let to define for constant and var to define for variables.

8 Constant & Variables (Cont) Don t require to specify the type with constant and variables. The compiler automatically detected it based on value that you have assigned to them. Optionals Optionals indicate that a constant or variable allowed to have no value. An optional is written as?. The question mark indicates that the value it contains is optional, meaning that it might contain some value, or it might contain no value.

9 Constant & Variables (Cont) If you define an optional constant or variable without providing a default value, the constant or variable is automatically set to nil:

10 Data types Integers Int UInt Float point Float Double Boolean Bool

11 Data types Type conversion Let s check example in Object-C In Swift you can t do that. You have to decide the type of result statements (it means variables in statements be in same type)

12 Data types - Tuples Group multiple values into a single compound value. You can pass a tuples as a method parameter, return it from a function (or method). Definition syntax: var repsonse: (Int, String) Assign value to tuples repsonse = (10, your value ) Tuples values can be access through their index number or names.

13 Data types Tuples (Cont) Accessing the value through its zero-based index. You can decompose a tuple s contents into separate constants or variables, which you then access as usual:

14 Data types- Strings Definition syntax var companyname = Quantic Mutability In this case you use var keyword to define a String, then it is mutable (can be modified). Use let keyword to define, then it is immutable (can not be modified)

15 Data types- Strings (Cont) Example: var variablestring = "Horse" variablestring += " and carriage" // variablestring is now "Horse and carriage" let constantstring = "Highlander" constantstring += " and another Highlander" // this reports a compile-time error - a constant string cannot be modified Comparison Swift provides three ways to compare string: string and character equality, prefix equality, and suffix equality.

16 Data types- Strings (Cont) String and character equality Use == operator to check equal to and!= operator to check not equal to let yourname = Your name here let sameyourname = " Your name here if yourname == sameyourname { println("that two strings are equal") } Prefix and suffix equality To check whether a string has a particular string prefix or suffix, call the string s hasprefix and hassuffix methods, both of which take a single argument of type String and return a Boolean value.

17 Data types- Strings (Cont) Concatenating Strings and Characters String values can be added together (or concatenated) with operator (+) to create a new String value: let string1 = "hello" let string2 = " there" var welcome = string1 + string2 You can also append a String value to an existing String variable with operator (+=): var instruction = "look over" instruction += string2

18 Data types- ARRAYS Stores multiple values of the same type in an ordered list. Definition syntax: let arr: Array<String> = [ val1, val2, etc ] //or Shorthand Syntax let arr : [String] = [ val1, val2, etc ] //or let arr = [ val1, val2, etc ] Access and modify array content

19 Data types- ARRAYS (Cont) let arr = [ val1, val2, val2 ] println(arr[0]) // Print console first element of array arr[0] = newval1 Note that the first item in the array has an index of 0, not 1. Arrays in Swift are always zero-indexed. You can add a new item to the end of an array by calling the array s append method: arr.append( append new value ) Alternatively, append an array of one or more compatible items with the addition assignment operator (+=): arr += [ val3, val4 ]

20 Data types- DICTIONARIES Stores multiple values of the same type. Each value is associated with a unique key Definition syntax: let dict : Dictionary<String, Int> = [ A : 1, B : 2] //Or Shorthand Syntax let dict : [String : Int] = [ A : 1, B : 2] //Or let dict = [ A : 1, B : 2] Access and modify dictionary content

21 Data types- DICTIONARIES (Cont) let dict : Dictionary<String, Int> = [ A : 1, B : 2] println(dict[ A ])// Print value of key A You can add a new item to a dictionary with syntax dict[ C ] = 3 // Add new Key: Value pairs to the dictionary You can also use the syntax to change the value associated with a particular key dict[ A ] = 2 // Modify the value of key A Remove a key-value pair from a dictionary with the removevalueforkey method dict. removevalueforkey( A )//Remove key A and its value

22 Control Flow IF Switch Loops

23 Control Flow - IF You don t have to add parentheses around the condition. In case complex conditions, you should use them. Conditions must be BooleanType (True or false). You can t check variable directly like Object-C

24 Control Flow - SWITCH Works like many other languages but with some new features and small differences: Support any kind of data, not only integer. No need for break statements.

25 Control Flow SWITCH (Cont) Each case must contain at least one executable statement. Multiple matches for a single switch case can be separated by commas.

26 Control Flow SWITCH (Cont)

27 Control Flow SWITCH (Cont) You can also use the range of values for checking in case. Ranges are identified You can use tuples to test multiple values in the same switch statement. Each element of the tuple can be tested against a different value or range of values. Alternatively, use the underscore (_) identifier to match any possible value

28 Control Flow SWITCH (Cont) A switch case can blind the values of variable to temporary constants or variable and use it in the body of the case.

29 Control Flow SWITCH (Cont) A switch case can use a where clause to check for additional conditions.

30 Control Flow - LOOPS Work like many other languages but with some small differences: Don t have to write the parentheses. For-in loop to iterate over collections of data. Also it can be used with ranges.

31 Functions Functions is created using key word func. In parameters: name and type of variable between : You can describe or name variable parameters of the function by writing the name before it or add # if it is already an appropriate name to use.

32 Functions (Cont) Function parameters are constant by default and you can t change value them.

33 Functions (Cont) To change variable parameters in function: you have to copy the values to other variables OR write var before the name

34 Functions (Cont) If you want a function to modify a parameter s value, and you want those changes to persist after the function call has ended, define that parameter as an in-out parameter instead.

35 Functions (Cont) To return values in function, you have to write type of returned info after () and -> Functions can take variable number of arguments using

36 Functions (Cont) In Swift, functions are first-class type, so you can pass it as parameter or return it as a result.

37 Class Swift is object oriented language and you can create your own custom classes. Unlike other programming languages, Swift does not require you to create separate interface and implementation files for custom classes. You define a class in a single file. To create a class, you use keyword class and then you can list all properties and methods of class.

38 Class (Cont) In creating new instance of your class, you don t use keyword like Object-C: new, alloc, init. Just the class name and parentheses (). Class instances are passed by reference types.

39 Class (Cont)

40 Class (Cont) In Swift, a class can inherit from another class using : Calling super is required when you override any initializer from super class. Use keyword override when you want to override a function from your super class.

41 Class (Cont)

42 Class (Cont) All properties in example above called stored properties, because we use it to store values. Stored properties can be either variable stored properties or constant stored properties. In Swift, we have other type called Computed properties as that properties don t store anything but we compute the value from other properties. They provide a getter and an optional setter to retrieve and set other properties and values indirectly.

43 Class (Cont)

44 Class (Cont) Type method in Swift is a way to define methods that are called on the type itself. You indicate type methods for classes by writing the keyword class before the method s func keyword.

45 Class (Cont)

46 Generics Generic code enables you to write flexible, reusable functions and types that can work with any type. Generics are used to allow you to use the same code for different types. For example, Swift s Array and Dictionary types are both generic collections.

47 Generics (cont)

48 Development Guidelines Install & Using development tool Demo Application

49 Install & Using development tool To develop ios apps in Swift, you need: A Mac computer running OS X or later Xcode (latest version) ios SDK To download the latest version of Xcode

50 Install & Using development tool Create New project with Swift Open Xcode from the /Applications directory. The Xcode welcome window appears.

51 Install & Using development tool

52 Install & Using development tool In the welcome window, click Create a new Xcode project (or choose File > New > Project). Xcode opens a new window and displays a dialog in which you choose a template.

53 Install & Using development tool

54 Install & Using development tool In the ios section at the left of the dialog, select Application. In the main area of the dialog, click Single View Application and then click Next. In the dialog that appears, name your app and choose additional options for your project.

55 Install & Using development tool

56 Install & Using development tool Click Next. In the dialog that appears, choose a location to save your project and click Create. Xcode opens your new project in a window (called the workspace window):

57 Install & Using development tool

58 Install & Using development tool Now you can run the project on ios simulator. Click on run button and look.

59 Install & Using development tool

60 Demo Application Basic UI Mix Swift code and Object-C code

61 Mix Swift code and Object-C code Objective-C and Swift files can coexist in a single project, whether the project was originally an Objective-C or Swift project. You can simply add a file of the other language directly to an existing project.

62 Mix Swift code and Object-C code

63 Mix Swift code and Object-C code 1. Importing Objective-C into Swift To import Objective-C files into your Swift code, you rely on an Objective-C bridging header to expose those files to Swift. Xcode offers to create this header file when you add a Swift file to an existing Objective-C app, or an Objective-C file to an existing Swift app.

64 Mix Swift code and Object-C code

65 Mix Swift code and Object-C code If you accept, Xcode creates the header file with names it by your product module name followed by adding -Bridging-Header.h

66 Mix Swift code and Object-C code How to import Objective-C code into Swift code In your project, open bridging header file, import every Objective-C header you want to use in Swift.

67 Mix Swift code and Object-C code In Build Settings, make sure the Objective-C Bridging Header was set under Swift Compiler - Code Generation.

68 Mix Swift code and Object-C code 2. Importing Swift into Objective-C To import Swift code into Objective-C, you rely on an Xcode-generated header file. This automatically generated file is an Objective-C header that declares the Swift interfaces in your target. The name of this header is your product module name followed by adding "-Swift.h. The file is hidden, you can t see in your project.

69 Mix Swift code and Object-C code

70 Mix Swift code and Object-C code How to import Swift code into Objective- C code Import the Swift code into any Objective-C.m file using this syntax #import ProductModuleName- Swift.h

71 References Learn Swift

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

Porting Objective-C to Swift. Richard Ekle

Porting Objective-C to Swift. Richard Ekle Porting Objective-C to Swift Richard Ekle rick@ekle.org Why do we need this? 1.2 million apps in the ios App Store http://www.statista.com/statistics/276623/numberof-apps-available-in-leading-app-stores/

More information

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C? Questions Exams: no Get by without own Mac? Why ios? ios vs Android restrictions Selling in App store how hard to publish? Future of Objective-C? Grading: Lab/homework: 40%, project: 40%, individual report:

More information

Xcode 6 and ios 8 What s New for Software Developers

Xcode 6 and ios 8 What s New for Software Developers Xcode 6 and ios 8 What s New for Software Developers August 2014 Norman McEntire! norman.mcentire@servin.com Slides and Video of this presentation will be posted on Tuesday Aug 26 here: http://servin.com!1

More information

SWIFT! init(title: String) { self.title = title } // required initializer w/ named parameter

SWIFT! init(title: String) { self.title = title } // required initializer w/ named parameter SWIFT! class Session { let title: String // constant non-optional field: can never be null and can never be changed var instruktør: Person? // variable optional field: null is permitted var attendees:

More information

Scala : an LLVM-targeted Scala compiler

Scala : an LLVM-targeted Scala compiler Scala : an LLVM-targeted Scala compiler Da Liu, UNI: dl2997 Contents 1 Background 1 2 Introduction 1 3 Project Design 1 4 Language Prototype Features 2 4.1 Language Features........................................

More information

Introduction to Swift. Dr. Sarah Abraham

Introduction to Swift. Dr. Sarah Abraham Introduction to Swift Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2018 What is Swift? Programming language for developing OSX, ios, WatchOS, and TvOS applications Best of C and Objective-C

More information

ios Application Development Lecture 2: Seminar and Unit 1

ios Application Development Lecture 2: Seminar and Unit 1 ios Application Development Lecture 2: Seminar and Unit 1 Dr. Simon Völker & Philipp Wacker Media Computing Group RWTH Aachen University Winter Semester 2017/2018 http://hci.rwth-aachen.de/ios Swift 18

More information

Mobile Application Programming. Swift Classes

Mobile Application Programming. Swift Classes Mobile Application Programming Swift Classes Swift Top-Level Entities Like C/C++ but unlike Java, Swift allows declarations of functions, variables, and constants at the top-level, outside any class declaration

More information

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309 A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48

More information

SWIFT BASICS

SWIFT BASICS SWIFT BASICS jhkim@dit.ac.kr www.facebook.com/jhkim3217 2014. 7. 19 Reference Swift Guide, 2014 AppCode.com Swift Tutorial: A Quick Start, Ray Wenderlich background new programming language for ios, OS

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

IBM Case Manager Mobile Version SDK for ios Developers' Guide IBM SC

IBM Case Manager Mobile Version SDK for ios Developers' Guide IBM SC IBM Case Manager Mobile Version 1.0.0.5 SDK for ios Developers' Guide IBM SC27-4582-04 This edition applies to version 1.0.0.5 of IBM Case Manager Mobile (product number 5725-W63) and to all subsequent

More information

ITP 342 Mobile App Dev. Functions

ITP 342 Mobile App Dev. Functions ITP 342 Mobile App Dev Functions Functions Functions are self-contained chunks of code that perform a specific task. You give a function a name that identifies what it does, and this name is used to call

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data Declaring Variables Constant Cannot be changed after a program is compiled Variable A named location in computer memory that can hold different values at different points in time

More information

SPARK-PL: Introduction

SPARK-PL: Introduction Alexey Solovyev Abstract All basic elements of SPARK-PL are introduced. Table of Contents 1. Introduction to SPARK-PL... 1 2. Alphabet of SPARK-PL... 3 3. Types and variables... 3 4. SPARK-PL basic commands...

More information

ITP 342 Mobile App Dev. Strings

ITP 342 Mobile App Dev. Strings ITP 342 Mobile App Dev Strings Strings You can include predefined String values within your code as string literals. A string literal is a sequence of characters surrounded by double quotation marks (").

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Mobile Application Programming. Swift Classes

Mobile Application Programming. Swift Classes Mobile Application Programming Swift Classes Swift Objects Classes, structures, and enums are all object types with different defaults in usage Classes are reference types that share the same object when

More information

GaE Graphs Ain t Easy. Andrew Jones (adj2129) Kevin Zeng (ksz2109) Samara Nebel (srn2134)

GaE Graphs Ain t Easy. Andrew Jones (adj2129) Kevin Zeng (ksz2109) Samara Nebel (srn2134) GaE Graphs Ain t Easy Andrew Jones (adj2129) Kevin Zeng (ksz2109) Samara Nebel (srn2134) Introduction Graphs Complex data structure Ubiquitous and fundamental Goal: We want to provide the end user a streamlined

More information

SWIFT - CLOSURES. Global Functions Nested Functions Closure Expressions. Have a name. Capture values from enclosing function

SWIFT - CLOSURES. Global Functions Nested Functions Closure Expressions. Have a name. Capture values from enclosing function http://www.tutorialspoint.com/swift/swift_closures.htm SWIFT - CLOSURES Copyright tutorialspoint.com Closures in Swift are similar to that of self-contained functions organized as blocks and called anywhere

More information

Worksheet 6: Basic Methods Methods The Format Method Formatting Floats Formatting Different Types Formatting Keywords

Worksheet 6: Basic Methods Methods The Format Method Formatting Floats Formatting Different Types Formatting Keywords Worksheet 1: Introductory Exercises Turtle Programming Calculations The Print Function Comments Syntax Semantics Strings Concatenation Quotation Marks Types Variables Restrictions on Variable Names Long

More information

Functions and Collections. Dr. Sarah Abraham

Functions and Collections. Dr. Sarah Abraham Functions and Collections Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2016 Functions Self-contained chunks of code to perform a specific task Function name is called in order to perform

More information

Python - Variable Types. John R. Woodward

Python - Variable Types. John R. Woodward Python - Variable Types John R. Woodward Variables 1. Variables are nothing but named reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.

More information

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and

More information

Advanced Algorithms and Computational Models (module A)

Advanced Algorithms and Computational Models (module A) Advanced Algorithms and Computational Models (module A) Giacomo Fiumara giacomo.fiumara@unime.it 2014-2015 1 / 34 Python's built-in classes A class is immutable if each object of that class has a xed value

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory

More information

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ 0.1 Introduction This is a session to familiarize working with the Visual Studio development environment. It

More information

CSC Web Programming. Introduction to JavaScript

CSC Web Programming. Introduction to JavaScript CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

The Pyth Language. Administrivia

The Pyth Language. Administrivia Administrivia The Pyth Language Lecture 5 Please make sure you have registered your team, created SSH keys as indicated on the admin page, and also have electronically registered with us as well. Prof.

More information

Try the following example using Try it option available at the top right corner of the following sample code box:

Try the following example using Try it option available at the top right corner of the following sample code box: About the Tutorial Swift 4 is a new programming language developed by Apple Inc for ios and OS X development. Swift 4 adopts the best of C and Objective-C, without the constraints of C compatibility. Swift

More information

Xcode & Swift: Introduction

Xcode & Swift: Introduction Dr.-Ing. Thomas Springer M.Sc. Martin Weißbach Concept You need Apple Computer Xcode 8 (ios device) Hands on course to learn how to program ios 1/1/0 means 45min lecture, 45min seminar introducing concepts

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

Beyond Blocks: Python Session #1

Beyond Blocks: Python Session #1 Beyond Blocks: Session #1 CS10 Spring 2013 Thursday, April 30, 2013 Michael Ball Beyond Blocks : : Session #1 by Michael Ball adapted from Glenn Sugden is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike

More information

Review (Basic Objective-C)

Review (Basic Objective-C) Classes Header.h (public) versus Implementation.m (private) @interface MyClass : MySuperclass... @end (only in header file) @interface MyClass()... @end (only in implementation file) @implementation...

More information

Type Conversion. and. Statements

Type Conversion. and. Statements and Statements Type conversion changing a value from one type to another Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 2 tj Suppose

More information

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

More information

Recap: Functions as first-class values

Recap: Functions as first-class values Recap: Functions as first-class values Arguments, return values, bindings What are the benefits? Parameterized, similar functions (e.g. Testers) Creating, (Returning) Functions Iterator, Accumul, Reuse

More information

Mobile Application Development

Mobile Application Development Mobile Application Development Lecture 12 Introduction to ObjectiveC 2013/2014 Parma Università degli Studi di Parma Lecture Summary ObjectiveC language basics Classes and objects Methods Instance variables

More information

Python Evaluation Rules

Python Evaluation Rules Python Evaluation Rules UW CSE 160 https://courses.cs.washington.edu/courses/cse160/15sp/ Michael Ernst and Isaac Reynolds mernst@cs.washington.edu April 1, 2015 Contents 1 Introduction 2 1.1 The Structure

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

Data Structures (list, dictionary, tuples, sets, strings)

Data Structures (list, dictionary, tuples, sets, strings) Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access

More information

CMSC 330: Organization of Programming Languages. Rust Basics

CMSC 330: Organization of Programming Languages. Rust Basics CMSC 330: Organization of Programming Languages Rust Basics CMSC330 Spring 2018 1 Organization It turns out that a lot of Rust has direct analogues in OCaml So we will introduce its elements with comparisons

More information

Chapter 2 Welcome App

Chapter 2 Welcome App 2.1 Introduction Chapter 2 Welcome App 1. A app is an app that can run on iphones, ipod touches and ipads. a. multi-purpose b. global c. unrestricted d. universal Ans: d. universal 2. You can your apps

More information

Lab 7: OCaml 12:00 PM, Oct 22, 2017

Lab 7: OCaml 12:00 PM, Oct 22, 2017 CS17 Integrated Introduction to Computer Science Hughes Lab 7: OCaml 12:00 PM, Oct 22, 2017 Contents 1 Getting Started in OCaml 1 2 Pervasives Library 2 3 OCaml Basics 3 3.1 OCaml Types........................................

More information

Python in 10 (50) minutes

Python in 10 (50) minutes Python in 10 (50) minutes https://www.stavros.io/tutorials/python/ Python for Microcontrollers Getting started with MicroPython Donald Norris, McGrawHill (2017) Python is strongly typed (i.e. types are

More information

iphone Application Programming Lecture 3: Swift Part 2

iphone Application Programming Lecture 3: Swift Part 2 Lecture 3: Swift Part 2 Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Review Type aliasing is useful! Escaping keywords could be useful! If you want

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify

More information

STRUCTURING OF PROGRAM

STRUCTURING OF PROGRAM Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the

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

Glossary. For Introduction to Programming Using Python By Y. Daniel Liang

Glossary. For Introduction to Programming Using Python By Y. Daniel Liang Chapter 1 Glossary For Introduction to Programming Using Python By Y. Daniel Liang.py Python script file extension name. assembler A software used to translate assemblylanguage programs into machine code.

More information

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017 Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable

More information

Control Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping

Control Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping Control Structures A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping Conditional Execution if is a reserved word The most basic syntax for

More information

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators Objectives Chapter 4: Control Structures I (Selection) In this chapter, you will: Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)

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/58 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

CSc Introduction to Computing

CSc Introduction to Computing CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments

More information

Functions & Variables !

Functions & Variables ! Functions & Variables 02-201! What Is Programming? Programming is clearly, correctly telling a computer what to do. Programming Executable Program Algorithm: (English) instructions to the computer Programming

More information

PREPARING FOR THE FINAL EXAM

PREPARING FOR THE FINAL EXAM PREPARING FOR THE FINAL EXAM CS 1110: FALL 2017 This handout explains what you have to know for the final exam. Most of the exam will include topics from the previous two prelims. We have uploaded the

More information

Java+- Language Reference Manual

Java+- Language Reference Manual Fall 2016 COMS4115 Programming Languages & Translators Java+- Language Reference Manual Authors Ashley Daguanno (ad3079) - Manager Anna Wen (aw2802) - Tester Tin Nilar Hlaing (th2520) - Systems Architect

More information

Introductory ios Development

Introductory ios Development Introductory ios Development 152-164 Unit 2 - Basic Objective-C Syntax Quick Links & Text References Console Application Pages Running Console App Pages Basic Syntax Pages Variables & Types Pages Sequential

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

Reverse Engineering Swift Apps. Michael Gianarakis Rootcon X 2016

Reverse Engineering Swift Apps. Michael Gianarakis Rootcon X 2016 Reverse Engineering Swift Apps Michael Gianarakis Rootcon X 2016 # whoami @mgianarakis Director of SpiderLabs APAC at Trustwave SecTalks Organiser (@SecTalks_BNE) Flat Duck Justice Warrior #ducksec Motivation

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

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program:

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program: Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams

More information

Senthil Kumaran S

Senthil Kumaran S Senthil Kumaran S http://www.stylesen.org/ Agenda History Basics Control Flow Functions Modules History What is Python? Python is a general purpose, object-oriented, high level, interpreted language Created

More information

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d. Chapter 4: Control Structures I (Selection) In this chapter, you will: Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)

More information

DSC 201: Data Analysis & Visualization

DSC 201: Data Analysis & Visualization DSC 201: Data Analysis & Visualization Arrays Dr. David Koop Class Example class Rectangle: def init (self, x, y, w, h): self.x = x self.y = y self.w = w self.h = h def set_corner(self, x, y): self.x =

More information

Using Scala for building DSL s

Using Scala for building DSL s Using Scala for building DSL s Abhijit Sharma Innovation Lab, BMC Software 1 What is a DSL? Domain Specific Language Appropriate abstraction level for domain - uses precise concepts and semantics of domain

More information

Issue with Implementing PrimeSieve() in Go

Issue with Implementing PrimeSieve() in Go Slices 02-201 Issue with Implementing PrimeSieve() in Go func PrimeSieve(n int) [n+1]bool { var iscomposite [n+1]bool //ERROR! biggestprime := 2 for biggestprime < n for i:=2; i

More information

CS 360: Programming Languages Lecture 10: Introduction to Haskell

CS 360: Programming Languages Lecture 10: Introduction to Haskell CS 360: Programming Languages Lecture 10: Introduction to Haskell Geoffrey Mainland Drexel University Thursday, February 5, 2015 Adapted from Brent Yorgey s course Introduction to Haskell. Section 1 Administrivia

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

C++ & Object Oriented Programming Concepts The procedural programming is the standard approach used in many traditional computer languages such as BASIC, C, FORTRAN and PASCAL. The procedural programming

More information

Introduction to Python

Introduction to Python Introduction to Python Version 1.1.5 (12/29/2008) [CG] Page 1 of 243 Introduction...6 About Python...7 The Python Interpreter...9 Exercises...11 Python Compilation...12 Python Scripts in Linux/Unix & Windows...14

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs.

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs. Java SE11 Development Java is the most widely-used development language in the world today. It allows programmers to create objects that can interact with other objects to solve a problem. Explore Java

More information

GNU ccscript Scripting Guide IV

GNU ccscript Scripting Guide IV GNU ccscript Scripting Guide IV David Sugar GNU Telephony 2008-08-20 (The text was slightly edited in 2017.) Contents 1 Introduction 1 2 Script file layout 2 3 Statements and syntax 4 4 Loops and conditionals

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Fall 2017 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory All

More information

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public

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

Begin at the beginning

Begin at the beginning Begin at the beginning Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set of

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

The current topic: Python. Announcements. Python. Python

The current topic: Python. Announcements. Python. Python The current topic: Python Announcements! Introduction! reasons for studying languages! language classifications! simple syntax specification Object-oriented programming: Python Types and values Syntax

More information

Richard Mallion. Swift for Admins #TEAMSWIFT

Richard Mallion. Swift for Admins #TEAMSWIFT Richard Mallion Swift for Admins #TEAMSWIFT Apple Introduces Swift At the WWDC 2014 Keynote, Apple introduced Swift A new modern programming language It targets the frameworks for Cocoa and Cocoa Touch

More information

2 nd Week Lecture Notes

2 nd Week Lecture Notes 2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

ios: Objective-C Primer

ios: Objective-C Primer ios: Objective-C Primer Jp LaFond Jp.LaFond+e76@gmail.com TF, CS76 Announcements n-puzzle feedback this week (if not already returned) ios Setup project released Android Student Choice project due Tonight

More information

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh C# Fundamentals Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh Semester 1 2018/19 H-W. Loidl (Heriot-Watt Univ) F20SC/F21SC 2018/19

More information

Maxime Defauw. Learning Swift

Maxime Defauw. Learning Swift Maxime Defauw Learning Swift SAMPLE CHAPTERS 1 Introduction Begin at the beginning, the King said, very gravely, and go on till you come to the end: then stop. Lewis Carroll, Alice in Wonderland Hi and

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Mostly Swift but some other stuff too Autolayout teaser Quick review of what we learned in Concentration CountableRange of floating point numbers Tuples Computed

More information

Statements 2. a operator= b a = a operator b

Statements 2. a operator= b a = a operator b Statements 2 Outline Note: i=i+1 is a valid statement. Don t confuse it with an equation i==i+1 which is always false for normal numbers. The statement i=i+1 is a very common idiom: it just increments

More information

BEGINNING ios PROGRAMMING

BEGINNING ios PROGRAMMING BEGINNING ios PROGRAMMING GEORGIA TECH RESEARCH NETWORK OPERATIONS CENTER (RNOC) *slides are based on the presentations by Professor Russell J Clark and Brian Davidson Swi$ Objec+ve- C OPTIONS RubyMo+on

More information

Lecture 2 Tao Wang 1

Lecture 2 Tao Wang 1 Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors

More information

Java Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M.

Java Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M. Java Language Essentials Java is Case Sensitive All Keywords are lower case White space characters are ignored Spaces, tabs, new lines Java statements must end with a semicolon ; Compound statements use

More information