SlideShare a Scribd company logo
Rust
Hack & Learn
Session #2
Robert “Bob” Reyes
05 Jul 2016
#MozillaPH
#RustPH
Check-in at Swarm &
Foursquare!
#MozillaPH
#RustPH
If you’re on social media, please use
our official hashtags for this event.
Agenda
• Mozilla in the Philippines
• Type Option in Rust
• Conditional Statements
• Loops
• Functions
• What to expect on Session 3?
Target Audience
• People with some background in
programming (any language).
• People with zero or near-zero knowledge
about Rust (Programming Language).
• People who wants to learn a new
programming language.
What is
Mozilla?
#MozillaPH
History of Mozilla
On 23 Feb 1998,
Netscape Communications Corp.
created a project called
Mozilla (Mosaic Killer + Godzilla).
Mozilla was launched 31 Mar 1998.
The
Mozilla Manifesto
Mozilla’s Mission
To ensure the Internet
is a global public
resource, open &
accessible to all.
Get involved …
Firefox Student
Ambassadors (FSA)
http://fsa.mozillaphilippines.org
Internship
at Mozilla
https://careers.mozilla.org/university/
Some stuff that we
are working on …
MozillaPH Rust Hack & Learn Session 2
#MozillaPH
MozillaPH Rust Hack & Learn Session 2
How to be part of
MozillaPH?
Areas of Contribution
 Helping Users
(Support)
 Testing & QA
 Coding
 Marketing
 Translation &
Localization
 Web Development
 Firefox Marketplace
 Add-ons
 Visual Design
 Documentation &
Writing
 Education
http://join.mozillaph.org
Join MozillaPH now!
http://join.mozillaph.org
Co-work from
MozSpaceMNL
http://mozspacemnl.org
MozillaPH Rust Hack & Learn Session 2
#MozillaPH
Let’s get to know
each other first.
What is your name?
From where are you?
What do you do?
Why are you here?
Where are the
MENTORS?
Please feel free to approach & ask
help from them 
What is
Rust?
What is Rust?
• Rust is a systems programming language
that runs blazingly fast, prevents
segfaults, & guarantees thread safety.
• Compiles to Native Code like C++ & D.
• Strength includes memory safety &
correctness (just like in C).
“Rust is a modern native-code language
with a focus on safety.”
Why
Rust?
Top 10 IoT Programming
Languages
1. C Language
2. C++
3. Python
4. Java
5. JavaScript
6. Rust
7. Go
8. Parasail
9. B#
10.Assembly
• No particular order.
• Based on popularity & following.
Mozilla &
Rust
Mozilla ❤️ Rust
• Rust grew out of a personal project by
Mozilla employee Graydon Hoare.
• Rust is sponsored by Mozilla Research
since 2009 (announced in 2010).
Type Option in
Rust
Type Option
• Type Option represents an optional value
• Every Option is either:
• Some  contains a value
or
• None  does not contain any value
Type Option
• Option types are very common in Rust code & can be
used as:
• Initial values
• Return values for functions that are not defined over
their entire input range (partial functions)
• Return value for otherwise reporting simple errors,
where None is returned on error
• Optional struct fields
• Struct fields that can be loaned or "taken" Optional
function arguments
• Nullable pointers
• Swapping things out of difficult situations
Conditionals in
Rust
If/Else Statement
If/Else Statement
• if-else in Rust is similar to other languages.
• However, the boolean condition doesn't need to be
surrounded by parentheses, &
• Each condition is followed by a block.
• if-else conditionals are expressions  all branches
must return the same type.
[Samples] If/Else
fn main() {
let n = 5;
if n < 0 {
println!(“{} is negative”, n);
} else if n > 0 {
println!(“{} is positive”, n);
} else {
println!(“{} is zero”, n);
}
}
[Samples] If/Else
 Add to the end of the previous example
let big_n =
if n < 10 && n > -10 {
println!(“and is a small number,
increase ten-fold”);
10 * n
} else {
println!(“and is a big number, reduce
by two”);
n / 2
};
println!(“{} -> {}”, n, big_n);
}
Loops in
Rust
Loop in Rust
• Rust provides a loop keyword to indicate an infinite
loop.
• The break statement can be used to exit a loop at
anytime,
• The continue statement can be used to skip the rest
of the iteration & start a new one.
[Samples] Loop
fn main() {
let mut count = 0u32;
println!(“Let’s count until infinity!”);
loop {
count +=1;
if count == 3 {
println!(“three”);
continue;
}
println!(“{}”, count);
if count == 5 {
println!(“OK, that’s enough!”);
break;
} } }
Nesting &
Labels
Nesting & Labels
• It is possible to break or continue outer loops when
dealing with nested loops.
• In these cases
• the loops must be annotated with some 'label
and
• the label must be passed to the break/continue
statement.
[Samples] Nesting & Labels
fn main() {
‘outer: loop {
println!(“Entered the outer loop”);
‘inner: loop {
println!(“Entered the inner
loop”);
break ‘outer;
}
println!(“This point will never be
reached”);
}
println!(“Exited the outer loop”);
}
While
Statement
While Statement
• The while keyword can be used to loop until a
condition is met.
• while loops are the correct choice when you’re not
sure how many times you need to loop.
[Samples] While Statement
fn main() {
let mut n = 1;
while n < 101 {
if n % 15 == 0 {
println!(“fizzbuzz”);
} else if n % 3 == 0 {
println!(“fizz”);
} else if n % 5 == 0 {
println!(“buzz”);
} else {
println!(“{}”, n);
}
n += 1;
} }
For & Range
Statement
For & Range Statement
• The for in construct can be used to iterate through
an Iterator.
• One of the easiest ways to create an iterator is to use
the range notation a..b.
• This will yield values from a (inclusive) to b (exclusive)
in steps (increment) of one.
[Samples] For & Range
fn main() {
for n in 1..101 {
if n % 15 == 0 {
println!(“fizzbuzz”);
} else if n % 3 == 0 {
println!(“fizz”);
} else if n % 5 == 0 {
println!(“buzz”);
} else {
println!(“{}”, n);
}
}
}
Match Statement
Match Statement
• Rust provides pattern matching via
the match keyword.
• Can be used like a switch statement in C.
[Samples] Match
fn main() {
let number = 13;
println!(“Tell me about {}”, number);
match number {
1 => println!(“one!”),
2 | 3 | 5 | 7 | 11 => println!(“prime”),
13…19 => println!(“a teen!”),
_ => println!(“not special”),
}
}
[Samples] Match
fn main() {
let boolean = true;
let binary = match boolean {
false => 0,
true => 1,
};
println!(“{} -> {}”, boolean, binary);
}
If Let
Statement
If Let Statement
• if let is a cleaner alternative to match statement.
• It allows various failure options to be specified.
[Samples] If Let
fn main() {
let number = Some(7);
let letter: Option<i32> = None;
let emoticon: Option <i32> = None;
if let Some(i) = number {
println!(“Matched {:?}!”, i);
} else {
println!(“Didn’t match a number. Let’s
go with a letter!”);
};
let i_like_letters = false;
<continued…>
[Samples] If Let
if let Some(i) = emoticon {
println!(“Matched {:?}!”, i);
} else if i_like_letters {
println!(“Didn’t matched a number. Let’s
go with a letter!”);
} else {
println!(“I don’t like letters. Let’s go
with an emoticon :)!”);
};
}
While Let
Statement
While Let Statement
• Similar to if let.
• while let can make awkward match sequences
more tolerable.
[Samples] While Let
fn main() {
let mut optional = Some(0);
while let Some(i) = optional {
if i > 9 {
println!(“Greater than 9, quit!”);
optional = None;
} else {
println!(“’i’ is ‘{:?}’.
Try again.”, i);
optional = Some(i + 1);
}
}
}
Functions in
Rust?
Functions in Rust
• Functions are declared using the fn keyword
• Arguments are type annotated, just like variables
• If the function returns a value, the return type must be
specified after an arrow ->
• The final expression in the function will be used as
return value.
• Alternatively, the return statement can be used to return
a value earlier from within the function, even from inside
loops or if’s.
[Samples] Functions
• Fizz Buzz Test
• "Write a program that prints the numbers from 1 to
100.
• But for multiples of three print “Fizz” instead of the
number
• For the multiples of five print “Buzz”.
• For numbers which are multiples of both three and
five print “FizzBuzz”."
[Samples] Functions
fn main() { fizzbuzz_to(100);
}
fn is_divisible_by(lhs: u32,
rhs: u32) -> bool {
if rhs == 0 {
return false;
}
lhs % rhs == 0
}
fn fizzbuzz(n: u32) -> () {
if is_divisible_by(n, 15)
{
println!(“fizzbuzz”);
} else if
is_divisible_by(n, 3) {
println!(“fizz”);
} else if
is_divisible_by(n, 5) {
println!(“buzz”);
} else { println!(“{}”,
n);
}
}
fn fizzbuzz_to(n: u32) {
for n in 1..n + 1 {
fizzbuzz(n);
}
}
Q&A
References
facebook.com/groups/rustph
https://rustph.slack.com
To request invite:
https://rustphslack.herokuapp.com
Reference Materials
• The Rust Programming Language Book
• https://doc.rust-lang.org/book/
• Rust by Example
• http://rustbyexample.com
• Rust User Forums
• https://users.rust-lang.org
• https://internals.rust-lang.org
What to expect
on Session #3?
Next: Session #3
• We need VOLUNTEERS to talk about:
• Rust Standard Library
• Vectors
• Strings
• Concurrency
• Error Handling
WANTED:
RustPH Mentors
WANTED: RustPH Mentors
• REQUIREMENTS:
 You love teaching other developers while learning
the Rust programming language.
• RustPH Mentors Meeting on Wed 13 Jul 2016 from
1900H to 2100H at MozSpaceMNL.
• MEETING AGENDA:
• Draw out some plans on how to attract more
developers in learning Rust.
• How to make developer journey in learning Rust a
fun yet learning experience.
Group Photo
Thank you!
Maraming salamat po!
http://www.mozillaphilippines.org
bob@mozillaph.org

More Related Content

What's hot

On the Edge Systems Administration with Golang
On the Edge Systems Administration with GolangOn the Edge Systems Administration with Golang
On the Edge Systems Administration with Golang
Chris McEniry
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Rajesh Rajamani
 
Python Intro
Python IntroPython Intro
Python Intro
Tim Penhey
 
Python basic
Python basicPython basic
Python basic
SOHIL SUNDARAM
 
GO programming language
GO programming languageGO programming language
GO programming language
tung vu
 
Intro to Python Workshop San Diego, CA (January 19, 2013)
Intro to Python Workshop San Diego, CA (January 19, 2013)Intro to Python Workshop San Diego, CA (January 19, 2013)
Intro to Python Workshop San Diego, CA (January 19, 2013)
Kendall
 
Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert
QA TrainingHub
 
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Codemotion
 
ProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacementProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacement
Wei-Ning Huang
 
Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-Programmers
Ahmad Alhour
 
Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015
Younggun Kim
 
Ry pyconjp2015 karaoke
Ry pyconjp2015 karaokeRy pyconjp2015 karaoke
Ry pyconjp2015 karaoke
Renyuan Lyu
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
Aakashdata
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Kiran Vadakkath
 
Python in real world.
Python in real world.Python in real world.
Python in real world.
Alph@.M
 
Beginning Python
Beginning PythonBeginning Python
Beginning Python
Ankur Shrivastava
 
Getting Started with Python
Getting Started with PythonGetting Started with Python
Getting Started with Python
Sankhya_Analytics
 
Python 101
Python 101Python 101
Python 101
Ahmet SEĞMEN
 
Python: the Project, the Language and the Style
Python: the Project, the Language and the StylePython: the Project, the Language and the Style
Python: the Project, the Language and the Style
Juan-Manuel Gimeno
 
Welcome to Python
Welcome to PythonWelcome to Python
Welcome to Python
Elena Williams
 

What's hot (20)

On the Edge Systems Administration with Golang
On the Edge Systems Administration with GolangOn the Edge Systems Administration with Golang
On the Edge Systems Administration with Golang
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Intro
Python IntroPython Intro
Python Intro
 
Python basic
Python basicPython basic
Python basic
 
GO programming language
GO programming languageGO programming language
GO programming language
 
Intro to Python Workshop San Diego, CA (January 19, 2013)
Intro to Python Workshop San Diego, CA (January 19, 2013)Intro to Python Workshop San Diego, CA (January 19, 2013)
Intro to Python Workshop San Diego, CA (January 19, 2013)
 
Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert
 
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
 
ProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacementProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacement
 
Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-Programmers
 
Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015
 
Ry pyconjp2015 karaoke
Ry pyconjp2015 karaokeRy pyconjp2015 karaoke
Ry pyconjp2015 karaoke
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Python in real world.
Python in real world.Python in real world.
Python in real world.
 
Beginning Python
Beginning PythonBeginning Python
Beginning Python
 
Getting Started with Python
Getting Started with PythonGetting Started with Python
Getting Started with Python
 
Python 101
Python 101Python 101
Python 101
 
Python: the Project, the Language and the Style
Python: the Project, the Language and the StylePython: the Project, the Language and the Style
Python: the Project, the Language and the Style
 
Welcome to Python
Welcome to PythonWelcome to Python
Welcome to Python
 

Similar to MozillaPH Rust Hack & Learn Session 2

Python Loop
Python LoopPython Loop
Python Loop
Soba Arjun
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
Prakash Jayaraman
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
Aniruddha Chakrabarti
 
Python_Loops.pptxpython loopspython loopspython loopspython loopspython loops...
Python_Loops.pptxpython loopspython loopspython loopspython loopspython loops...Python_Loops.pptxpython loopspython loopspython loopspython loopspython loops...
Python_Loops.pptxpython loopspython loopspython loopspython loopspython loops...
RutviBaraiya
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
Ruth Marvin
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
ssuserd10678
 
ForLoops.pptx
ForLoops.pptxForLoops.pptx
ForLoops.pptx
RabiyaZhexembayeva
 
Python if_else_loop_Control_Flow_Statement
Python if_else_loop_Control_Flow_StatementPython if_else_loop_Control_Flow_Statement
Python if_else_loop_Control_Flow_Statement
AbhishekGupta692777
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
Connex
 
ppt7
ppt7ppt7
ppt7
callroom
 
ppt2
ppt2ppt2
ppt2
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
ppt9
ppt9ppt9
ppt9
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
ppt30
ppt30ppt30
ppt30
callroom
 
ppt17
ppt17ppt17
ppt17
callroom
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
callroom
 
ppt21
ppt21ppt21
ppt21
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 

Similar to MozillaPH Rust Hack & Learn Session 2 (20)

Python Loop
Python LoopPython Loop
Python Loop
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
Python_Loops.pptxpython loopspython loopspython loopspython loopspython loops...
Python_Loops.pptxpython loopspython loopspython loopspython loopspython loops...Python_Loops.pptxpython loopspython loopspython loopspython loopspython loops...
Python_Loops.pptxpython loopspython loopspython loopspython loopspython loops...
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Loops in Python.pptx
 
python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
 
ForLoops.pptx
ForLoops.pptxForLoops.pptx
ForLoops.pptx
 
Python if_else_loop_Control_Flow_Statement
Python if_else_loop_Control_Flow_StatementPython if_else_loop_Control_Flow_Statement
Python if_else_loop_Control_Flow_Statement
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt9
ppt9ppt9
ppt9
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt30
ppt30ppt30
ppt30
 
ppt17
ppt17ppt17
ppt17
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 
ppt21
ppt21ppt21
ppt21
 
name name2 n
name name2 nname name2 n
name name2 n
 

More from Robert 'Bob' Reyes

Localization at Mozilla
Localization at MozillaLocalization at Mozilla
Localization at Mozilla
Robert 'Bob' Reyes
 
Firefox Dev Tools for WordPress Developers (WordCamp Iloilo 2019)
Firefox Dev Tools for WordPress Developers (WordCamp Iloilo 2019)Firefox Dev Tools for WordPress Developers (WordCamp Iloilo 2019)
Firefox Dev Tools for WordPress Developers (WordCamp Iloilo 2019)
Robert 'Bob' Reyes
 
Build (Web)VR with A-Frame (COSCUP 2019 Taipei)
Build (Web)VR with A-Frame (COSCUP 2019 Taipei)Build (Web)VR with A-Frame (COSCUP 2019 Taipei)
Build (Web)VR with A-Frame (COSCUP 2019 Taipei)
Robert 'Bob' Reyes
 
Challenges & Opportunities the Data Privacy Act Brings
Challenges & Opportunities the Data Privacy Act BringsChallenges & Opportunities the Data Privacy Act Brings
Challenges & Opportunities the Data Privacy Act Brings
Robert 'Bob' Reyes
 
Rust 101 (2017 edition)
Rust 101 (2017 edition)Rust 101 (2017 edition)
Rust 101 (2017 edition)
Robert 'Bob' Reyes
 
Building a Rust Community from Scratch (COSCUP 2017)
Building a Rust Community from Scratch (COSCUP 2017)Building a Rust Community from Scratch (COSCUP 2017)
Building a Rust Community from Scratch (COSCUP 2017)
Robert 'Bob' Reyes
 
Mozilla + Rust at PCU Manila 02 DEC 2016
Mozilla + Rust at PCU Manila 02 DEC 2016Mozilla + Rust at PCU Manila 02 DEC 2016
Mozilla + Rust at PCU Manila 02 DEC 2016
Robert 'Bob' Reyes
 
MozillaPH Localization in 2016
MozillaPH Localization in 2016MozillaPH Localization in 2016
MozillaPH Localization in 2016
Robert 'Bob' Reyes
 
Mozilla & Connected Devices
Mozilla & Connected DevicesMozilla & Connected Devices
Mozilla & Connected Devices
Robert 'Bob' Reyes
 
HTML 5 - The Future is Now
HTML 5 - The Future is NowHTML 5 - The Future is Now
HTML 5 - The Future is Now
Robert 'Bob' Reyes
 
Getting started on MDN (Mozilla Developer Network)
Getting started on MDN (Mozilla Developer Network)Getting started on MDN (Mozilla Developer Network)
Getting started on MDN (Mozilla Developer Network)
Robert 'Bob' Reyes
 
Mozilla & the Open Web
Mozilla & the Open WebMozilla & the Open Web
Mozilla & the Open Web
Robert 'Bob' Reyes
 
Firefox OS
Firefox OSFirefox OS
Firefox OS
Robert 'Bob' Reyes
 
MozTour University of Perpetual Help System - Laguna (Binan)
MozTour University of Perpetual Help System - Laguna (Binan)MozTour University of Perpetual Help System - Laguna (Binan)
MozTour University of Perpetual Help System - Laguna (Binan)
Robert 'Bob' Reyes
 
Firefox 101 (FSA Camp Philippines 2015)
Firefox 101 (FSA Camp Philippines 2015)Firefox 101 (FSA Camp Philippines 2015)
Firefox 101 (FSA Camp Philippines 2015)
Robert 'Bob' Reyes
 
FOSSASIA 2015: Building an Open Source Community
FOSSASIA 2015: Building an Open Source CommunityFOSSASIA 2015: Building an Open Source Community
FOSSASIA 2015: Building an Open Source Community
Robert 'Bob' Reyes
 
Welcome to MozSpaceMNL
Welcome to MozSpaceMNLWelcome to MozSpaceMNL
Welcome to MozSpaceMNL
Robert 'Bob' Reyes
 
MozillaPH Trainers Training
MozillaPH Trainers TrainingMozillaPH Trainers Training
MozillaPH Trainers Training
Robert 'Bob' Reyes
 
Mozilla Reps Program
Mozilla Reps ProgramMozilla Reps Program
Mozilla Reps Program
Robert 'Bob' Reyes
 
Women and the open web
Women and the open webWomen and the open web
Women and the open web
Robert 'Bob' Reyes
 

More from Robert 'Bob' Reyes (20)

Localization at Mozilla
Localization at MozillaLocalization at Mozilla
Localization at Mozilla
 
Firefox Dev Tools for WordPress Developers (WordCamp Iloilo 2019)
Firefox Dev Tools for WordPress Developers (WordCamp Iloilo 2019)Firefox Dev Tools for WordPress Developers (WordCamp Iloilo 2019)
Firefox Dev Tools for WordPress Developers (WordCamp Iloilo 2019)
 
Build (Web)VR with A-Frame (COSCUP 2019 Taipei)
Build (Web)VR with A-Frame (COSCUP 2019 Taipei)Build (Web)VR with A-Frame (COSCUP 2019 Taipei)
Build (Web)VR with A-Frame (COSCUP 2019 Taipei)
 
Challenges & Opportunities the Data Privacy Act Brings
Challenges & Opportunities the Data Privacy Act BringsChallenges & Opportunities the Data Privacy Act Brings
Challenges & Opportunities the Data Privacy Act Brings
 
Rust 101 (2017 edition)
Rust 101 (2017 edition)Rust 101 (2017 edition)
Rust 101 (2017 edition)
 
Building a Rust Community from Scratch (COSCUP 2017)
Building a Rust Community from Scratch (COSCUP 2017)Building a Rust Community from Scratch (COSCUP 2017)
Building a Rust Community from Scratch (COSCUP 2017)
 
Mozilla + Rust at PCU Manila 02 DEC 2016
Mozilla + Rust at PCU Manila 02 DEC 2016Mozilla + Rust at PCU Manila 02 DEC 2016
Mozilla + Rust at PCU Manila 02 DEC 2016
 
MozillaPH Localization in 2016
MozillaPH Localization in 2016MozillaPH Localization in 2016
MozillaPH Localization in 2016
 
Mozilla & Connected Devices
Mozilla & Connected DevicesMozilla & Connected Devices
Mozilla & Connected Devices
 
HTML 5 - The Future is Now
HTML 5 - The Future is NowHTML 5 - The Future is Now
HTML 5 - The Future is Now
 
Getting started on MDN (Mozilla Developer Network)
Getting started on MDN (Mozilla Developer Network)Getting started on MDN (Mozilla Developer Network)
Getting started on MDN (Mozilla Developer Network)
 
Mozilla & the Open Web
Mozilla & the Open WebMozilla & the Open Web
Mozilla & the Open Web
 
Firefox OS
Firefox OSFirefox OS
Firefox OS
 
MozTour University of Perpetual Help System - Laguna (Binan)
MozTour University of Perpetual Help System - Laguna (Binan)MozTour University of Perpetual Help System - Laguna (Binan)
MozTour University of Perpetual Help System - Laguna (Binan)
 
Firefox 101 (FSA Camp Philippines 2015)
Firefox 101 (FSA Camp Philippines 2015)Firefox 101 (FSA Camp Philippines 2015)
Firefox 101 (FSA Camp Philippines 2015)
 
FOSSASIA 2015: Building an Open Source Community
FOSSASIA 2015: Building an Open Source CommunityFOSSASIA 2015: Building an Open Source Community
FOSSASIA 2015: Building an Open Source Community
 
Welcome to MozSpaceMNL
Welcome to MozSpaceMNLWelcome to MozSpaceMNL
Welcome to MozSpaceMNL
 
MozillaPH Trainers Training
MozillaPH Trainers TrainingMozillaPH Trainers Training
MozillaPH Trainers Training
 
Mozilla Reps Program
Mozilla Reps ProgramMozilla Reps Program
Mozilla Reps Program
 
Women and the open web
Women and the open webWomen and the open web
Women and the open web
 

Recently uploaded

Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
Larry Smarr
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
Stephanie Beckett
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
Larry Smarr
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
Matthew Sinclair
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
Safe Software
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
huseindihon
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
Awais Yaseen
 
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Erasmo Purificato
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
Andrey Yasko
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
Aurora Consulting
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
Enterprise Wired
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
Matthew Sinclair
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 

Recently uploaded (20)

Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
 
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 

MozillaPH Rust Hack & Learn Session 2

  • 1. Rust Hack & Learn Session #2 Robert “Bob” Reyes 05 Jul 2016 #MozillaPH #RustPH
  • 2. Check-in at Swarm & Foursquare!
  • 3. #MozillaPH #RustPH If you’re on social media, please use our official hashtags for this event.
  • 4. Agenda • Mozilla in the Philippines • Type Option in Rust • Conditional Statements • Loops • Functions • What to expect on Session 3?
  • 5. Target Audience • People with some background in programming (any language). • People with zero or near-zero knowledge about Rust (Programming Language). • People who wants to learn a new programming language.
  • 8. History of Mozilla On 23 Feb 1998, Netscape Communications Corp. created a project called Mozilla (Mosaic Killer + Godzilla). Mozilla was launched 31 Mar 1998.
  • 10. Mozilla’s Mission To ensure the Internet is a global public resource, open & accessible to all.
  • 14. Some stuff that we are working on …
  • 18. How to be part of MozillaPH?
  • 19. Areas of Contribution  Helping Users (Support)  Testing & QA  Coding  Marketing  Translation & Localization  Web Development  Firefox Marketplace  Add-ons  Visual Design  Documentation & Writing  Education http://join.mozillaph.org
  • 24. Let’s get to know each other first. What is your name? From where are you? What do you do? Why are you here?
  • 25. Where are the MENTORS? Please feel free to approach & ask help from them 
  • 27. What is Rust? • Rust is a systems programming language that runs blazingly fast, prevents segfaults, & guarantees thread safety. • Compiles to Native Code like C++ & D. • Strength includes memory safety & correctness (just like in C). “Rust is a modern native-code language with a focus on safety.”
  • 29. Top 10 IoT Programming Languages 1. C Language 2. C++ 3. Python 4. Java 5. JavaScript 6. Rust 7. Go 8. Parasail 9. B# 10.Assembly • No particular order. • Based on popularity & following.
  • 31. Mozilla ❤️ Rust • Rust grew out of a personal project by Mozilla employee Graydon Hoare. • Rust is sponsored by Mozilla Research since 2009 (announced in 2010).
  • 33. Type Option • Type Option represents an optional value • Every Option is either: • Some  contains a value or • None  does not contain any value
  • 34. Type Option • Option types are very common in Rust code & can be used as: • Initial values • Return values for functions that are not defined over their entire input range (partial functions) • Return value for otherwise reporting simple errors, where None is returned on error • Optional struct fields • Struct fields that can be loaned or "taken" Optional function arguments • Nullable pointers • Swapping things out of difficult situations
  • 37. If/Else Statement • if-else in Rust is similar to other languages. • However, the boolean condition doesn't need to be surrounded by parentheses, & • Each condition is followed by a block. • if-else conditionals are expressions  all branches must return the same type.
  • 38. [Samples] If/Else fn main() { let n = 5; if n < 0 { println!(“{} is negative”, n); } else if n > 0 { println!(“{} is positive”, n); } else { println!(“{} is zero”, n); } }
  • 39. [Samples] If/Else  Add to the end of the previous example let big_n = if n < 10 && n > -10 { println!(“and is a small number, increase ten-fold”); 10 * n } else { println!(“and is a big number, reduce by two”); n / 2 }; println!(“{} -> {}”, n, big_n); }
  • 41. Loop in Rust • Rust provides a loop keyword to indicate an infinite loop. • The break statement can be used to exit a loop at anytime, • The continue statement can be used to skip the rest of the iteration & start a new one.
  • 42. [Samples] Loop fn main() { let mut count = 0u32; println!(“Let’s count until infinity!”); loop { count +=1; if count == 3 { println!(“three”); continue; } println!(“{}”, count); if count == 5 { println!(“OK, that’s enough!”); break; } } }
  • 44. Nesting & Labels • It is possible to break or continue outer loops when dealing with nested loops. • In these cases • the loops must be annotated with some 'label and • the label must be passed to the break/continue statement.
  • 45. [Samples] Nesting & Labels fn main() { ‘outer: loop { println!(“Entered the outer loop”); ‘inner: loop { println!(“Entered the inner loop”); break ‘outer; } println!(“This point will never be reached”); } println!(“Exited the outer loop”); }
  • 47. While Statement • The while keyword can be used to loop until a condition is met. • while loops are the correct choice when you’re not sure how many times you need to loop.
  • 48. [Samples] While Statement fn main() { let mut n = 1; while n < 101 { if n % 15 == 0 { println!(“fizzbuzz”); } else if n % 3 == 0 { println!(“fizz”); } else if n % 5 == 0 { println!(“buzz”); } else { println!(“{}”, n); } n += 1; } }
  • 50. For & Range Statement • The for in construct can be used to iterate through an Iterator. • One of the easiest ways to create an iterator is to use the range notation a..b. • This will yield values from a (inclusive) to b (exclusive) in steps (increment) of one.
  • 51. [Samples] For & Range fn main() { for n in 1..101 { if n % 15 == 0 { println!(“fizzbuzz”); } else if n % 3 == 0 { println!(“fizz”); } else if n % 5 == 0 { println!(“buzz”); } else { println!(“{}”, n); } } }
  • 53. Match Statement • Rust provides pattern matching via the match keyword. • Can be used like a switch statement in C.
  • 54. [Samples] Match fn main() { let number = 13; println!(“Tell me about {}”, number); match number { 1 => println!(“one!”), 2 | 3 | 5 | 7 | 11 => println!(“prime”), 13…19 => println!(“a teen!”), _ => println!(“not special”), } }
  • 55. [Samples] Match fn main() { let boolean = true; let binary = match boolean { false => 0, true => 1, }; println!(“{} -> {}”, boolean, binary); }
  • 57. If Let Statement • if let is a cleaner alternative to match statement. • It allows various failure options to be specified.
  • 58. [Samples] If Let fn main() { let number = Some(7); let letter: Option<i32> = None; let emoticon: Option <i32> = None; if let Some(i) = number { println!(“Matched {:?}!”, i); } else { println!(“Didn’t match a number. Let’s go with a letter!”); }; let i_like_letters = false; <continued…>
  • 59. [Samples] If Let if let Some(i) = emoticon { println!(“Matched {:?}!”, i); } else if i_like_letters { println!(“Didn’t matched a number. Let’s go with a letter!”); } else { println!(“I don’t like letters. Let’s go with an emoticon :)!”); }; }
  • 61. While Let Statement • Similar to if let. • while let can make awkward match sequences more tolerable.
  • 62. [Samples] While Let fn main() { let mut optional = Some(0); while let Some(i) = optional { if i > 9 { println!(“Greater than 9, quit!”); optional = None; } else { println!(“’i’ is ‘{:?}’. Try again.”, i); optional = Some(i + 1); } } }
  • 64. Functions in Rust • Functions are declared using the fn keyword • Arguments are type annotated, just like variables • If the function returns a value, the return type must be specified after an arrow -> • The final expression in the function will be used as return value. • Alternatively, the return statement can be used to return a value earlier from within the function, even from inside loops or if’s.
  • 65. [Samples] Functions • Fizz Buzz Test • "Write a program that prints the numbers from 1 to 100. • But for multiples of three print “Fizz” instead of the number • For the multiples of five print “Buzz”. • For numbers which are multiples of both three and five print “FizzBuzz”."
  • 66. [Samples] Functions fn main() { fizzbuzz_to(100); } fn is_divisible_by(lhs: u32, rhs: u32) -> bool { if rhs == 0 { return false; } lhs % rhs == 0 } fn fizzbuzz(n: u32) -> () { if is_divisible_by(n, 15) { println!(“fizzbuzz”); } else if is_divisible_by(n, 3) { println!(“fizz”); } else if is_divisible_by(n, 5) { println!(“buzz”); } else { println!(“{}”, n); } } fn fizzbuzz_to(n: u32) { for n in 1..n + 1 { fizzbuzz(n); } }
  • 67. Q&A
  • 71. Reference Materials • The Rust Programming Language Book • https://doc.rust-lang.org/book/ • Rust by Example • http://rustbyexample.com • Rust User Forums • https://users.rust-lang.org • https://internals.rust-lang.org
  • 72. What to expect on Session #3?
  • 73. Next: Session #3 • We need VOLUNTEERS to talk about: • Rust Standard Library • Vectors • Strings • Concurrency • Error Handling
  • 75. WANTED: RustPH Mentors • REQUIREMENTS:  You love teaching other developers while learning the Rust programming language. • RustPH Mentors Meeting on Wed 13 Jul 2016 from 1900H to 2100H at MozSpaceMNL. • MEETING AGENDA: • Draw out some plans on how to attract more developers in learning Rust. • How to make developer journey in learning Rust a fun yet learning experience.
  • 77. Thank you! Maraming salamat po! http://www.mozillaphilippines.org bob@mozillaph.org

Editor's Notes

  1. - IDE for Rust
  2. - IDE for Rust
  3. - IDE for Rust
  4. - IDE for Rust
  5. - IDE for Rust
  6. - image processing in rust - is rust OO
  7. - IDE for Rust
  8. - image processing in rust - is rust OO