Introduction to Rust. CC-BY Mozilla. Jonathan Pallant

Size: px
Start display at page:

Download "Introduction to Rust. CC-BY Mozilla. Jonathan Pallant"

Transcription

1 Introduction to Rust CC-BY Mozilla Jonathan Pallant 27 October 2016

2 What is Rust? Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. Out of Mozilla Used in Firefox today on Win/Mac/Linux (Android coming soon) The Servo HTML5 rendering engine (replacing Gecko) is their use-case 27 October

3 Why should I care? Fast like C with excellent C inter-op Segmentation faults are impossible* Null-pointer dereferences are impossible* Buffer overflows are impossible* First class build system / documentation generator / code formatting Rich, expressive type system But unlike C++, the types are sane (e.g. std::string) 27 October

4 The Type System Scalars (u8, i16, f64, etc) Arrays Structs Plain enums Tagged enums Char (32-bit Unicode Scalar Values) Strings (of Unicode characters stored as UTF-8 octets) Slices References Types (even scalars) can implement Traits this is what Rust uses for inheritance The Drop Trait Rust s idea of destructors Types can use Generics 27 October

5 enum Message { Quit, ChangeColor(i32, i32, i32), Move { x: i32, y: i32, Write(String) enum Option<T> { Some(T), None enum Result<T, E> { Ok(T), Err(E) 27 October

6 trait Foo { fn method(&self) -> String; impl Foo for u8 { fn method(&self) -> String { format!("u8: {", *self) impl Foo for String { fn method(&self) -> String { format!("string: {", *self) let msg = 35.method(); 27 October

7 Memory safety Impossible to run off the end of an array You take a slice of an array knows its own length Impossible to leak memory from the heap Impossible to return a reference to memory on the stack Impossible to deference a null pointer Recall Option<T> - allows you to express Some(T) or None Can break these rules by using raw pointers in unsafe blocks 27 October

8 The Borrow Checker You can either have one mutable reference to an object, or multiple immutable references, but not both. Why? Guarantees no race-hazards. Checked at compile time. You can bypass this rule if you really need to, by using an immutable object to wrap a mutable object (subject to some constraints) 27 October

9 match switch on steroids fn get_value() -> Option<i32> { fn test() { let x = match get_value() { Some(i) if i > 5 => "Got an int > 5!", Some(..) => "Got an int!", None => { report_fail(); "No such luck.", ; println!("x = {", x); 27 October

10 Modules No more header files! struct Foo { ; pub struct Bar { ; use my_module::{baz, Qux; pub use my_module::baz; (Also, proper macros, not just text substitution) 27 October

11 Debug output use std::fmt; struct Point { x: i32, y: i32, impl fmt::debug for Point { fn fmt(&self, f: &mut fmt::formatter) -> fmt::result { write!(f, "Point {{ x: {, y: { ", self.x, self.y) let origin = Point { x: 0, y: 0 ; println!("the origin is: {:?", origin); 27 October

12 Debug output use std::fmt; #[derive(debug)] struct Point { x: i32, y: i32, let origin = Point { x: 0, y: 0 ; println!("the origin is: {:?", origin); 27 October

13 Rich standard API Collections Vector, HashMap, BTreeMap, BinaryHeap, etc Sockets/Networking Threads Processes Channels (message passing) I/O & path manipulation etc 27 October

14 Cargo the build system cargo build cargo run cargo test cargo bench cargo install 27 October

15 [package] name = "hello_world" version = "0.1.0" authors = ["Your Name <you@example.com>"] [dependencies] time = "0.1.12" regex = "0.1.41" 27 October

16 Crates.io the package repository First-come, first-served on package names 27 October

17 RustDoc the documentation generator cargo doc Dog-fooding - as used by 27 October

18 RustFmt the code formatter cargo install rustfmt cargo fmt No more arguments about formatting 27 October

19 What s the bad news? Compiling for bare-metal requires unstable features (i.e. subject to change) Binary format is not yet stable Cannot yet use an rlib built in compiler version A with compiler version B So, crates are usually distributed as source The compiler s a bit slow (but it s getting faster) 27 October

20 Where can I learn more? Website - Book - API Docs - Reddit This Week In Rust Jonathan Pallant (github.com/thejpster), Doug Young, Dan Cannell, Andrew Featherstone 27 October

21 UK USA SINGAPORE JAPAN Cambridge Consultants is part of the Altran group, a global leader in Innovation. The contents of this presentation are commercially confidential and the proprietary information of Cambridge Consultants 2016 Cambridge Consultants Ltd. All rights reserved. Registered No England 27 October 2016 WBUMKTG-P-003 v1.1

Introduction to Rust 2 / 101

Introduction to Rust 2 / 101 1 / 101 Introduction to Rust 2 / 101 Goal Have a good chance of being able to read and understand some Rust code. 3 / 101 Agenda 1. What's not that unique about Rust 2. What makes Rust somewhat unique

More information

Programming In Rust. Jim Blandy, / Portland, (Slides are as presented; followup discussion,

Programming In Rust. Jim Blandy, / Portland, (Slides are as presented; followup discussion, Programming In Rust Jim Blandy, Mozilla @jimblandy / Portland, 2015 (Slides are as presented; followup discussion, fixes, etc. on Reddit: http://goo.gl/thj2pw) 2 The set of Rust enthusiasts certainly seems

More information

Rust for C++ Programmers

Rust for C++ Programmers Rust for C++ Programmers Vinzent Steinberg C++ User Group, FIAS April 29, 2015 1 / 27 Motivation C++ has a lot of problems C++ cannot be fixed (because of backwards compatibility) Rust to the rescue! 2

More information

Rust: system programming with guarantees

Rust: system programming with guarantees Rust: system programming with guarantees CRI Monthly Seminar Arnaud Spiwack Pierre Guillou MINES ParisTech, PSL Research University Fontainebleau, July 6th, 2015 1 / 29 High level programming languages

More information

1: /////////////// 2: // 1. Basics // 3: /////////////// 4: 5: // Functions. i32 is the type for 32-bit signed integers 6: fn add2(x: i32, y: i32) ->

1: /////////////// 2: // 1. Basics // 3: /////////////// 4: 5: // Functions. i32 is the type for 32-bit signed integers 6: fn add2(x: i32, y: i32) -> 1: /////////////// 2: // 1. Basics // 3: /////////////// 4: 5: // Functions. i32 is the type for 32-bit signed integers 6: fn add2(x: i32, y: i32) -> i32 { 7: // Implicit return (no semicolon) 8: x + y

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

Rust Advanced Topics

Rust Advanced Topics Rust Advanced Topics Adapted from https://skade.github.io/rust-three-dayscourse/presentation/toc/english.html Generic Functions 1. fn takes_anything(thing: T) -> T { 2. thing 3. } 4. fn main() { 5.

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Structs and Enums in Rust CMSC330 Spring 2018 Copyright 2018 Niki Vazou, the University of Maryland. Some material based on https://doc.rustlang.org/book/second-edition/index.html

More information

$ cat ~/.profile GIT_AUTHOR_NAME=Florian Gilcher TWITTER_HANDLE=argorak GITHUB_HANDLE=skade BLOG=skade.

$ cat ~/.profile GIT_AUTHOR_NAME=Florian Gilcher TWITTER_HANDLE=argorak GITHUB_HANDLE=skade BLOG=skade. Useful Rust $ cat ~/.profile GIT_AUTHOR_NAME=Florian Gilcher GIT_AUTHOR_EMAIL=florian@rustfest.eu TWITTER_HANDLE=argorak GITHUB_HANDLE=skade BLOG=skade.me YAKS=yakshav.es Backend Developer Ruby Programmer

More information

CMSC 330: Organization of Programming Languages. Ownership, References, and Lifetimes in Rust

CMSC 330: Organization of Programming Languages. Ownership, References, and Lifetimes in Rust CMSC 330: Organization of Programming Languages Ownership, References, and Lifetimes in Rust CMSC330 Spring 2018 1 Memory: the Stack and the Heap The stack constant-time, automatic (de)allocation Data

More information

Why you should take a look at

Why you should take a look at Why you should take a look at Antonin Carette - FOSDEM 2018 - Rust devroom Slides and resources available @ github.com/k0pernicus/fosdem_rust_talk 1 Chalut 'tiot biloute! I tried to understand what the

More information

Rust. A new systems programming language. 1.0 was released on May 15th. been in development 5+ years. releases every 6 weeks

Rust. A new systems programming language. 1.0 was released on May 15th. been in development 5+ years. releases every 6 weeks 1 Rust A new systems programming language 1.0 was released on May 15th been in development 5+ years releases every 6 weeks Pursuing the trifecta: safe, concurrent, fast Gone through many radical iterations

More information

Advances in Programming Languages

Advances in Programming Languages Advances in Programming Languages Lecture 18: Concurrency and More in Rust Ian Stark School of Informatics The University of Edinburgh Friday 24 November 2016 Semester 1 Week 10 https://blog.inf.ed.ac.uk/apl16

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Smart Pointers in Rust CMSC330 Spring 2018 Copyright 2018 Michael Hicks, the University of Maryland. Some material based on https://doc.rustlang.org/book/second-edition/index.html

More information

EMBEDDED RUST ON THE BEAGLEBOARD X15

EMBEDDED RUST ON THE BEAGLEBOARD X15 EMBEDDED RUST ON THE BEAGLEBOARD X15 MEETING EMBEDDED Jonathan Pallant 14 November 2018 OUR LOCATIONS CAMBRIDGE BOSTON SINGAPORE SEATTLE SAN FRANCISCO 14 November 2018 2 What is Rust? Statically compiled

More information

Rust. A safe, concurrent, practical language. Graydon Hoare October 2012

Rust. A safe, concurrent, practical language. Graydon Hoare October 2012 Rust A safe, concurrent, practical language Graydon Hoare October 2012 This is not a marketing talk Purpose: Convince you there's something interesting here Provide some technical

More information

Aaron Turon! Mozilla Research

Aaron Turon! Mozilla Research Aaron Turon Mozilla Research C/C++ ML/Haskell Rust Safe systems programming Why Mozilla? Browsers need control. Browsers need safety. Servo: Next-generation browser built in Rust. C++ What is control?

More information

CMSC 330: Organization of Programming Languages. Strings, Slices, Vectors, HashMaps in Rust

CMSC 330: Organization of Programming Languages. Strings, Slices, Vectors, HashMaps in Rust CMSC 330: Organization of Programming Languages Strings, Slices, Vectors, HashMaps in Rust CMSC330 Spring 2018 1 String Representation Rust s String is a 3-tuple A pointer to a byte array (interpreted

More information

Rust intro. (for Java Developers) JFokus #jfokus 1. 1

Rust intro. (for Java Developers) JFokus #jfokus 1. 1 Rust intro (for Java Developers) JFokus 2017 - #jfokus 1. 1 Hi! Computer Engineer Programming Electronics Math

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Rust for high level applications. Lise Henry

Rust for high level applications. Lise Henry Rust for high level applications Lise Henry Who am I Elisabeth Henry A.k.a Lizzie Crowdagger Computer science background Semi-professional fantasy writer I like Rust, but not really into systems programming

More information

Guaranteeing memory safety in Rust

Guaranteeing memory safety in Rust Guaranteeing memory safety in Rust Nicholas D. Matsakis Mozilla Research 1 Hashtable in C / C++ template struct Hashtable { Bucket *buckets; unsigned num_buckets; template

More information

The Case for Building a Kernel

The Case for Building a Kernel The Case for Building a Kernel in Rust Amit Levy Brad Campbell Branden Ghena Pat Pannuto Philip Levis Prabal Dutta Stanford University & University of Michigan September 2nd 2017 Memory and type safety

More information

Oxidising GStreamer. Rust out your multimedia! GStreamer Conference October 2017, Prague. Sebastian 'slomo' Dröge < >

Oxidising GStreamer. Rust out your multimedia! GStreamer Conference October 2017, Prague. Sebastian 'slomo' Dröge < > Oxidising GStreamer Rust out your multimedia! GStreamer Conference 2017 22 October 2017, Prague Sebastian 'slomo' Dröge < > sebastian@centricular.com Introduction Who? What? + What is Rust? Type-safe,

More information

Improving C/C++ Open Source Software Discoverability by Utilizing Rust and Node.js Ecosystems

Improving C/C++ Open Source Software Discoverability by Utilizing Rust and Node.js Ecosystems Improving C/C++ Open Source Software Discoverability by Utilizing Rust and Node.js Ecosystems Kyriakos-Ioannis D. Kyriakou 1, Nikolaos D. Tselikas 1 and Georgia M. Kapitsaki 2 1 Communication Networks

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Closures and Iterators In Rust CMSC330 Spring 2018 Copyright 2018 Michael Hicks, the University of Maryland. Some material based on https://doc.rustlang.org/book/second-edition/index.html

More information

Let s Rust in Samba. Trying to use Samba with Rust libraries. Kai Blin Samba Team. SambaXP

Let s Rust in Samba. Trying to use Samba with Rust libraries. Kai Blin Samba Team. SambaXP Let s Rust in Samba Trying to use Samba with Rust libraries Kai Blin Samba Team SambaXP 2018 2017-06-06 Intro M.Sc. in Computational Biology Ph.D. in Microbiology Samba Team member 2/42 Overview Rust Intro

More information

PyCon Otto 6-9 April 2017 Florence. Rusty Python. Rust, a new language for our programmer tool belt. Matteo

PyCon Otto 6-9 April 2017 Florence. Rusty Python. Rust, a new language for our programmer tool belt. Matteo PyCon Otto 6-9 April 2017 Florence Rusty Python Rust, a new language for our programmer tool belt Matteo Bertini @naufraghi 1 Rust Born as a personal project started in 2006 by Mozilla employee Graydon

More information

When a colleague of mine first enthused to me about Rust, I

When a colleague of mine first enthused to me about Rust, I GRAEME JENKINSON Graeme Jenkinson is Senior Research Associate in the University of Cambridge s Computer Laboratory, leading development of distributed tracing for the Causal, Adaptive, Distributed, and

More information

MY PYTHON IS RUSTING. A PYTHON AND RUST LOVE STORY Ronacher

MY PYTHON IS RUSTING. A PYTHON AND RUST LOVE STORY Ronacher MY PYTHON IS RUSTING A PYTHON AND RUST LOVE STORY Armin @mitsuhiko Ronacher and here is where you can find me twitter.com/@mitsuhiko github.com/mitsuhiko lucumr.pocoo.org/ so I heard you are doing Rust

More information

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,

More information

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 16, SPRING 2013 TOPICS TODAY Project 6 Perils & Pitfalls of Memory Allocation C Function Call Conventions in Assembly Language PERILS

More information

MY GOOD FRIEND RUST. Matthias Endler trivago

MY GOOD FRIEND RUST. Matthias Endler trivago MY GOOD FRIEND RUST Matthias Endler trivago How to write the word Mississippi? How to write the word Mississippi? Mississippi Sebastian is stupid. Oh please tell me more about Matthias Endler! } Düsseldorf,

More information

GEA 2017, Week 4. February 21, 2017

GEA 2017, Week 4. February 21, 2017 GEA 2017, Week 4 February 21, 2017 1. Problem 1 After debugging the program through GDB, we can see that an allocated memory buffer has been freed twice. At the time foo(...) gets called in the main function,

More information

Go Forth and Code. Jonathan Gertig. CSC 415: Programing Languages. Dr. Lyle

Go Forth and Code. Jonathan Gertig. CSC 415: Programing Languages. Dr. Lyle J o n a t h a n G e r t i g P a g e 1 Go Forth and Code Jonathan Gertig CSC 415: Programing Languages Dr. Lyle 2013 J o n a t h a n G e r t i g P a g e 2 Go dogs Go or A Brief History of Go 6 years ago

More information

CS527 Software Security

CS527 Software Security Security Policies Purdue University, Spring 2018 Security Policies A policy is a deliberate system of principles to guide decisions and achieve rational outcomes. A policy is a statement of intent, and

More information

MC: Meta-level Compilation

MC: Meta-level Compilation MC: Meta-level Compilation Extending the Process of Code Compilation with Application-Specific Information for the layman developer (code monkey) Gaurav S. Kc 8 th October, 2003 1 Outline Dawson Engler

More information

Nicholas Matsakis! Mozilla Research

Nicholas Matsakis! Mozilla Research Nicholas Matsakis! Mozilla Research Parallel! Systems programming without the hassle crashes! heisenbugs! fear 2 C/C++: efficiency first! destructors memory layout smart pointers monomorphization Research

More information

Buffer overflow prevention, and other attacks

Buffer overflow prevention, and other attacks Buffer prevention, and other attacks Comp Sci 3600 Security Outline 1 2 Two approaches to buffer defense Aim to harden programs to resist attacks in new programs Run time Aim to detect and abort attacks

More information

The Rust Way of OS Development. Philipp Oppermann

The Rust Way of OS Development. Philipp Oppermann The Rust Way of OS Development Philipp Oppermann May 30, 2018 HTWG Konstanz About Me Computer science student at KIT (Karlsruhe) Writing an OS in Rust blog series (os.phil-opp.com) Embedded Rust development

More information

Time : 3 hours. Full Marks : 75. Own words as far as practicable. The questions are of equal value. Answer any five questions.

Time : 3 hours. Full Marks : 75. Own words as far as practicable. The questions are of equal value. Answer any five questions. XEV (H-3) BCA (6) 2 0 1 0 Time : 3 hours Full Marks : 75 Candidates are required to give their answers in their Own words as far as practicable. The questions are of equal value. Answer any five questions.

More information

Lecture Notes on Memory Layout

Lecture Notes on Memory Layout Lecture Notes on Memory Layout 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 11 1 Introduction In order to understand how programs work, we can consider the functions,

More information

JAVA An overview for C++ programmers

JAVA An overview for C++ programmers JAVA An overview for C++ programmers Wagner Truppel wagner@cs.ucr.edu edu March 1st, 2004 The early history James Gosling, Sun Microsystems Not the usual start for a prog.. language Consumer electronics,

More information

Kakadu and Java. David Taubman, UNSW June 3, 2003

Kakadu and Java. David Taubman, UNSW June 3, 2003 Kakadu and Java David Taubman, UNSW June 3, 2003 1 Brief Summary The Kakadu software framework is implemented in C++ using a fairly rigorous object oriented design strategy. All classes which are intended

More information

STRICT_VARIANT. A simpler variant in C++ Chris Beck

STRICT_VARIANT. A simpler variant in C++ Chris Beck STRICT_VARIANT A simpler variant in C++ Chris Beck https://github.com/cbeck88/strict_variant What is a variant? A variant is a heterogenous container. std::vector many objects of one type std::variant

More information

The Case for N-Body Simulations in Rust

The Case for N-Body Simulations in Rust Int'l Conf. Scientific Computing CSC'16 3 The Case for N-Body Simulations in Rust A. Hansen, M. C. Lewis Department of Computer Science, Trinity University, San Antonio, Texas, United States Abstract In

More information

Memory Corruption 101 From Primitives to Exploit

Memory Corruption 101 From Primitives to Exploit Memory Corruption 101 From Primitives to Exploit Created by Nick Walker @ MWR Infosecurity / @tel0seh What is it? A result of Undefined Behaviour Undefined Behaviour A result of executing computer code

More information

The Rust Programming Language

The Rust Programming Language The Rust Programming Language The Rust Programming Language The Rust Project Developpers The Rust Programming Language, The Rust Project Developpers. Contents I Introduction 7 1 The Rust Programming Language

More information

CS11 C++ DGC. Spring Lecture 6

CS11 C++ DGC. Spring Lecture 6 CS11 C++ DGC Spring 2006-2007 Lecture 6 The Spread Toolkit A high performance, open source messaging service Provides message-based communication Point-to-point messaging Group communication (aka broadcast

More information

Lecture 2, September 4

Lecture 2, September 4 Lecture 2, September 4 Intro to C/C++ Instructor: Prashant Shenoy, TA: Shashi Singh 1 Introduction C++ is an object-oriented language and is one of the most frequently used languages for development due

More information

Sandcrust: Automatic Sandboxing of Unsafe Components in Rust

Sandcrust: Automatic Sandboxing of Unsafe Components in Rust Sandcrust: Automatic Sandboxing of Unsafe Components in Rust Benjamin Lamowski, Carsten Weinhold 1, Adam Lackorzynski 1, Hermann Härtig 1 October 28, 2017 1 Technische Universität Dresden Problems with

More information

Using Static Code Analysis to Find Bugs Before They Become Failures

Using Static Code Analysis to Find Bugs Before They Become Failures Using Static Code Analysis to Find Bugs Before They Become Failures Presented by Brian Walker Senior Software Engineer, Video Product Line, Tektronix, Inc. Pacific Northwest Software Quality Conference,

More information

CSE 303: Concepts and Tools for Software Development

CSE 303: Concepts and Tools for Software Development CSE 303: Concepts and Tools for Software Development Hal Perkins Winter 2009 Lecture 7 Introduction to C: The C-Level of Abstraction CSE 303 Winter 2009, Lecture 7 1 Welcome to C Compared to Java, in rough

More information

CSC2/454 Programming Languages Design and Implementation Records and Arrays

CSC2/454 Programming Languages Design and Implementation Records and Arrays CSC2/454 Programming Languages Design and Implementation Records and Arrays Sreepathi Pai November 6, 2017 URCS Outline Scalar and Composite Types Arrays Records and Variants Outline Scalar and Composite

More information

Modern and Lucid C++ Advanced for Professional Programmers. Part 12 Advanced Library Design. Department I - C Plus Plus Advanced

Modern and Lucid C++ Advanced for Professional Programmers. Part 12 Advanced Library Design. Department I - C Plus Plus Advanced Department I - C Plus Plus Advanced Modern and Lucid C++ Advanced for Professional Programmers Part 12 Advanced Library Design Thomas Corbat / Prof. Peter Sommerlad Rapperswil, 23.02.2017 HS2017 Topics

More information

A program execution is memory safe so long as memory access errors never occur:

A program execution is memory safe so long as memory access errors never occur: A program execution is memory safe so long as memory access errors never occur: Buffer overflows, null pointer dereference, use after free, use of uninitialized memory, illegal free Memory safety categories

More information

Outline. Classic races: files in /tmp. Race conditions. TOCTTOU example. TOCTTOU gaps. Vulnerabilities in OS interaction

Outline. Classic races: files in /tmp. Race conditions. TOCTTOU example. TOCTTOU gaps. Vulnerabilities in OS interaction Outline CSci 5271 Introduction to Computer Security Day 3: Low-level vulnerabilities Stephen McCamant University of Minnesota, Computer Science & Engineering Race conditions Classic races: files in /tmp

More information

Next Gen Networking Infrastructure With Rust

Next Gen Networking Infrastructure With Rust Next Gen Networking Infrastructure With Rust Hi, I m @carllerche You may remember me from Most newer databases are written in a language that includes a runtime C / C++ Memory management we ll do it live

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

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

Malloc Lab & Midterm Solutions. Recitation 11: Tuesday: 11/08/2016

Malloc Lab & Midterm Solutions. Recitation 11: Tuesday: 11/08/2016 Malloc Lab & Midterm Solutions Recitation 11: Tuesday: 11/08/2016 Malloc 2 Important Notes about Malloc Lab Malloc lab has been updated from previous years Supports a full 64 bit address space rather than

More information

CSE 303 Concepts and Tools for Software Development. Magdalena Balazinska Winter 2010 Lecture 27 Final Exam Revision

CSE 303 Concepts and Tools for Software Development. Magdalena Balazinska Winter 2010 Lecture 27 Final Exam Revision CSE 303 Concepts and Tools for Software Development Magdalena Balazinska Winter 2010 Lecture 27 Final Exam Revision Today Final review session! The final is not yet written, but you know roughly what it

More information

DAY 3. CS3600, Northeastern University. Alan Mislove

DAY 3. CS3600, Northeastern University. Alan Mislove C BOOTCAMP DAY 3 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh and Pascal Meunier s course at Purdue Memory management 2 Memory management Two

More information

Arrays and Pointers. CSC209: Software Tools and Systems Programming (Winter 2019) Furkan Alaca & Paul Vrbik. University of Toronto Mississauga

Arrays and Pointers. CSC209: Software Tools and Systems Programming (Winter 2019) Furkan Alaca & Paul Vrbik. University of Toronto Mississauga Arrays and Pointers CSC209: Software Tools and Systems Programming (Winter 2019) Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 2 Alaca & Vrbik (UTM)

More information

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***

More information

Announcements. assign0 due tonight. Labs start this week. No late submissions. Very helpful for assign1

Announcements. assign0 due tonight. Labs start this week. No late submissions. Very helpful for assign1 Announcements assign due tonight No late submissions Labs start this week Very helpful for assign1 Goals for Today Pointer operators Allocating memory in the heap malloc and free Arrays and pointer arithmetic

More information

CMSC 341 Lecture 2 Dynamic Memory and Pointers

CMSC 341 Lecture 2 Dynamic Memory and Pointers CMSC 341 Lecture 2 Dynamic Memory and Pointers Park Sects. 01 & 02 Based on earlier course slides at UMBC Today s Topics Stack vs Heap Allocating and freeing memory new and delete Memory Leaks Valgrind

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 9b Andrew Tolmach Portland State University 1994-2017 Programming in the large Language features for modularity are crucial for writing large programs Idea:

More information

CCReflect has a few interesting features that are quite desirable for DigiPen game projects:

CCReflect has a few interesting features that are quite desirable for DigiPen game projects: CCReflect v1.0 User Manual Contents Introduction... 2 Features... 2 Dependencies... 2 Compiler Dependencies... 2 Glossary... 2 Type Registration... 3 POD Registration... 3 Non-Pod Registration... 3 External

More information

MODERN AND LUCID C++ ADVANCED

MODERN AND LUCID C++ ADVANCED Informatik MODERN AND LUCID C++ ADVANCED for Professional Programmers Prof. Peter Sommerlad Thomas Corbat Director of IFS Research Assistant Rapperswil, FS 2016 LIBRARY API/ABI DESIGN PIMPL IDIOM HOURGLASS

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs. CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs

More information

CPSC 3740 Programming Languages University of Lethbridge. Data Types

CPSC 3740 Programming Languages University of Lethbridge. Data Types Data Types A data type defines a collection of data values and a set of predefined operations on those values Some languages allow user to define additional types Useful for error detection through type

More information

Using XAP Processors in Space Applications

Using XAP Processors in Space Applications Using XAP Processors in Space Applications MESA Roundtable: ESTEC, 4 November 21 Chris Roberts and Alistair Morfey 8 November 21 ASICs-P-78 v1.2 1 2 3 4 Introduction to Cambridge Consultants Challenges

More information

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry:

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry: Logical Diagram VFS, Continued Don Porter CSE 506 Binary Formats RCU Memory Management File System Memory Allocators System Calls Device Drivers Networking Threads User Today s Lecture Kernel Sync CPU

More information

VFS, Continued. Don Porter CSE 506

VFS, Continued. Don Porter CSE 506 VFS, Continued Don Porter CSE 506 Logical Diagram Binary Formats Memory Allocators System Calls Threads User Today s Lecture Kernel RCU File System Networking Sync Memory Management Device Drivers CPU

More information

Next Gen Networking Infrastructure With Rust

Next Gen Networking Infrastructure With Rust Next Gen Networking Infrastructure With Rust Hi, I m @carllerche Let s write a database! Most newer databases are written in a language that includes a runtime. C / C++ Memory management we ll do it live

More information

CSC209 Review. Yeah! We made it!

CSC209 Review. Yeah! We made it! CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions

More information

377 Student Guide to C++

377 Student Guide to C++ 377 Student Guide to C++ c Mark Corner January 21, 2004 1 Introduction In this course you will be using the C++ language to complete several programming assignments. Up to this point we have only provided

More information

Improving Error Checking and Unsafe Optimizations using Software Speculation. Kirk Kelsey and Chen Ding University of Rochester

Improving Error Checking and Unsafe Optimizations using Software Speculation. Kirk Kelsey and Chen Ding University of Rochester Improving Error Checking and Unsafe Optimizations using Software Speculation Kirk Kelsey and Chen Ding University of Rochester Outline Motivation Brief problem statement How speculation can help Our software

More information

the gamedesigninitiative at cornell university Lecture 7 C++ Overview

the gamedesigninitiative at cornell university Lecture 7 C++ Overview Lecture 7 Lecture 7 So You Think You Know C++ Most of you are experienced Java programmers Both in 2110 and several upper-level courses If you saw C++, was likely in a systems course Java was based on

More information

Region-based Memory Management. Advanced Operating Systems Lecture 10

Region-based Memory Management. Advanced Operating Systems Lecture 10 Region-based Memory Management Advanced Operating Systems Lecture 10 Lecture Outline Rationale Stack-based memory management Region-based memory management Ownership Borrowing Benefits and limitations

More information

CS 61C: Great Ideas in Computer Architecture C Pointers. Instructors: Vladimir Stojanovic & Nicholas Weaver

CS 61C: Great Ideas in Computer Architecture C Pointers. Instructors: Vladimir Stojanovic & Nicholas Weaver CS 61C: Great Ideas in Computer Architecture C Pointers Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Agenda Pointers Arrays in C 2 Address vs. Value Consider

More information

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26, SERIOUS ABOUT SOFTWARE Qt Core features Timo Strömmer, May 26, 2010 1 Contents C++ refresher Core features Object model Signals & slots Event loop Shared data Strings Containers Private implementation

More information

Corrections made in this version not in first posting:

Corrections made in this version not in first posting: 1 Changelog 1 Corrections made in this version not in first posting: 12 April 2017: slide 15: correct arrow from B-freed to D-freed 12 April 2017: slide 42: correct phrasing on what is borrowed fuzzing

More information

CS2141 Software Development using C/C++ Debugging

CS2141 Software Development using C/C++ Debugging CS2141 Software Development using C/C++ Debugging Debugging Tips Examine the most recent change Error likely in, or exposed by, code most recently added Developing code incrementally and testing along

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.

More information

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am CMSC 202 Section 010x Spring 2007 Computer Science II Final Exam Name: Username: Score Max Section: (check one) 0101 - Justin Martineau, Tuesday 11:30am 0102 - Sandeep Balijepalli, Thursday 11:30am 0103

More information

Reviewing gcc, make, gdb, and Linux Editors 1

Reviewing gcc, make, gdb, and Linux Editors 1 Reviewing gcc, make, gdb, and Linux Editors 1 Colin Gordon csgordon@cs.washington.edu University of Washington CSE333 Section 1, 3/31/11 1 Lots of material borrowed from 351/303 slides Colin Gordon (University

More information

CS 11 C track: lecture 5

CS 11 C track: lecture 5 CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap Pointers (from last week) Address: location where data stored

More information

Exception Safe Coding

Exception Safe Coding Exception Safe Coding Dirk Hutter hutter@compeng.uni-frankfurt.de Prof. Dr. Volker Lindenstruth FIAS Frankfurt Institute for Advanced Studies Goethe-Universität Frankfurt am Main, Germany http://compeng.uni-frankfurt.de

More information

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 C++\CLI Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 Comparison of Object Models Standard C++ Object Model All objects share a rich memory model: Static, stack, and heap Rich object life-time

More information

CS Programming In C

CS Programming In C CS 24000 - Programming In C Week 16: Review Zhiyuan Li Department of Computer Science Purdue University, USA This has been quite a journey Congratulation to all students who have worked hard in honest

More information

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy CSCI 334: Principles of Programming Languages Lecture 18: C/C++ Homework help session will be tomorrow from 7-9pm in Schow 030A instead of on Thursday. Instructor: Dan Barowy HW6 and HW7 solutions We only

More information

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) Review Final exam Final exam will be 12 problems, drop any 2 Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) 2 hours exam time, so 12 min per problem (midterm 2 had

More information

RustBelt: Securing the Foundations of the Rust Programming Language

RustBelt: Securing the Foundations of the Rust Programming Language RustBelt: Securing the Foundations of the Rust Programming Language Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, Derek Dreyer POPL 2018 in Los Angeles, USA Max Planck Institute for Software Systems

More information

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent

More information

Pointers, Dynamic Data, and Reference Types

Pointers, Dynamic Data, and Reference Types Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple

More information