SlideShare a Scribd company logo
1 of 79
Rust
Hack & Learn
Session #1
Robert “Bob” Reyes
14 Jun 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
• Installing Rust
• Hello World, the Rust way
• Intro to Cargo
• IDE Support
• Variables & Constants
• Simple Arithmetic Functions
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
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
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.
Rust
vs Go
Rust vs Go
• Rust shares many of Go's qualities but
solves one major problem of Go:
• Go doesn't automatically share information between
different "channel" data structures
 "race condition"
• A runaway situation in which a system can spiral
out of control because different processes are
working at odds with one another.
• Rust includes functions that eliminate
race conditions, making it a less-risky
language than Go for highly concurrent
programs.
Low-Level
vs
High-Level
Low-Level Programming
• (CS) a programming language that
provides little or no abstraction from a
computer's instruction set architecture
• commands or functions in the language
map closely to processor instructions.
• generally referred as either machine
code or assembly language.
• E.g. Assembly Language
High-Level Programming
• (CS) a programming language with strong
abstraction from the details of the
computer.
• Compared to low-level programming
languages
• may use natural language elements.
• may automate (or even hide entirely)
significant areas of computing systems
(e.g. memory management).
• E.g. COBOL, Fortran, LISP, ALGOL
Programming Languages
Hardware
Machine Language
Assembly Language
High-Level Language
Fortran | C | Pascal
OO & Visual Languages
C++ | D | Rust
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).
Features of
Rust?
Features of Rust
• Zero-cost abstractions
• Move semantics
• Guaranteed memory safety
• Threads without data races
• Trait-based generics
• Pattern matching
• Type inference
• Minimal runtime
• Efficient C bindings
Projects using
Rust
Projects Using Rust
 Magic Pocket
 Dropbox's file storage system that powers their
Diskotech petabyte storage machines.
 Servo
 Mozilla's new parallel rendering engine developed
in collaboration with Samsung.
 OpenDNS
 Uses Rust in two of its components.
 Redox OS
 A microkernel operating system being developed
in Rust.
Installing
Rust
Installing Rust
• Installer for Windows, Mac OS X & Linux available via
https://www.rust-lang.org
• If you wish to run Rust on your local machine when
you’re offline.
• Rust Playground [https://play.rust-lang.org]
• If you are online, you may opt to use this one
instead.
• You may use ANY text editor to code in Rust.
• As a practice, please save your Rust code
using .rs file extension.
Function
Main()
Function main()
• Every Rust program must have at least one (01)
function.
• Simplest possible function declaration is named as
“main”
fn main() {
}
• Functions can also take arguments
fn print_number(x:i32) {
println!(“x is: {}”, x);
}
Hello World
in Rust
helloworld.rs
fn main()
{
println!(“Hello world in Rust!”);
}
Cargo
Cargo
• A tool that allows Rust projects to declare their various
dependencies & ensure that you’ll always get a
repeatable build.
• Cargo does:
1. Introduces two (02) metadata files with various bits
of project information.
2. Fetches & builds your project’s dependencies.
3. Invokes rustc or another build tool with the correct
parameters to build your project.
4. Introduces conventions to make working with Rust
projects easier.
Cargo
• To start a new project with Cargo, we invoke in the
command line:
cargo new hello_world --bin
• Cargo will generate the following files & folders:
 Cargo.toml [file]
 src [folder]
 main.rs [file]
• Acts as a manifest file
• Contains all of the metadata that Cargo needs to
compile your project.
TOML, what?!
TOML
• Tom’s Obvious, Minimal Language
(or some say, Tom’s Own Markup Language)
• Created by Tom Preston-Werner
• Aims to be a minimal configuration file format that's
easy to read due to obvious semantics.
• Designed to map unambiguously to a hash table.
• Should be easy to parse into data structures in a wide
variety of languages.
Cargo.toml
Cargo.toml
[package]
name = "hello_world”
version = "0.1.0”
authors = ["Your Name <you@example.com>"]
IDE Support
IDE Support
• Modern IDEs give developers a massive increase in
productivity.
• Several community projects have provided an excellent
start towards IDE support.
• Good IDE support requires a number of components:
• The compiler must be modified to operate in a
different mode.
• Must provide name & type information from the
compiler to the IDE.
• Must write plugins for the IDEs themselves so they
know what to do with Rust projects.
IDE Support
• Available IDE Plugins:
• Eclipse [https://github.com/RustDT/RustDT]
• Intellij IDEA [https://github.com/intellij-rust/intellij-rust]
• Visual Studio [https://github.com/PistonDevelopers/VisualRust]
• Editor Plugins:
• Atom [https://atom.io/packages/language-rust]
• Emacs [https://github.com/rust-lang/rust-mode]
• Sublime Text [https://packagecontrol.io/packages/Rust]
• Vim [https://github.com/rust-lang/rust.vim]
• Visual Studio Code
[https://github.com/saviorisdead/RustyCode]
More on IDE Support
https://www.rust-lang.org/ides.html
Types &
Variables
Variables
• Variable Declaration
fn main() {
let a:u8 = 123;
}
• Whereas
• a  variable
• u8  data type (unsigned; 0 or positive; 8-bit)
• 123  value of variable “a”
Numeric Data Types
• i8  8-bit signed integer
• i16  16-bit signed integer
• i32  32-bit signed integer
• i64  64-bit signed integer
• u8  8-bit unsigned integer
• u16  16-bit unsigned integer
• u32  32-bit unsigned integer
• u64  64-bit unsigned integer
• isize  pointer-size signed integer
• usize  pointer-size unsigned integer
• f32/f64  32/64-bit floating point
Mutability
in Rust
Mutability
• The ability to change something.
• Mutable variable binding.
• You’re allowed to change what the binding points to.
let x = 5;
x = 6;  will result to an error!
• We can use the mut keyword:
let mut x = 5;
x = 6;  no problem; no error!
Constants
• Aside from using variables, we can also declare
constants in Rust:
const PI:u8 = 3;
 no fixed memory address
 memory safety is NOT compromised
static X:i32 = 123;
Operators
in Rust
Arithmetic Operators
+  addition & array/string concatenation
-  subtraction
*  multiplication
/  quotient
%  remainder
Arithmetic Operators
• Rust DOES NOT support ++ and – used in other
programming languages.
• a = a+1; or
• a += 1;
• b = b-1; or
• b -= 1;
• You may also use the following in Rust
• *=
• /=
• %=
Arithmetic Operators
let mut a = 2+3*4;
println!(“Answer = {}.”, a);
let mut a = (2+3)*4;
println!(“Answer = {}.”, a);
Arithmetic Operators
let mut a = 10/3;
println!(“Answer = {}.”, a);
let mut a = 10%3;
println!(“Answer = {}.”, a);
let a=10;
println!(“Remainder of {} / {}
= {}”, a, 3, (a%3));
More Sample
(Try them out)
Arithmetic Operators (eg1)
fn main() {
let num1 = 20;
let num2 = 10;
println!(“The SUM of the numbers =
{}”, (num1 + num2));
println!(”The DIFFERENCE of the
numbers = {}”, (num1 – num2));
… and so on
Arithmetic Operators (eg2)
fn main() {
let num1 = 20;
let num2 = 10;
let sum = num1 + num2;
let dif = num1 – num2;
let pro = num1 * num2;
let quo = num1 / num2;
println!(“The SUM of the numbers =
{}”, sum);
… and so on
Q&A
References
facebook.com/groups/rustph
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 #2?
Next: Session #2
• Rust Standard Library
• Functions
• Conditional Statements
• Loops
• Vectors
• Strings
• Concurrency
• Error Handling
Group Photo
Thank you!
Maraming salamat po!
http://www.mozillaphilippines.org
bob@mozillaph.org

More Related Content

What's hot

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 replacementWei-Ning Huang
 
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 2016Codemotion
 
Introduction to fedora 20cat
Introduction to fedora   20catIntroduction to fedora   20cat
Introduction to fedora 20catMedo EL-Masry
 
FOSS, history and philosophy
FOSS, history and philosophyFOSS, history and philosophy
FOSS, history and philosophyAhmed Mekkawy
 
NSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishNSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishFlorent Pillet
 
Intoduction to Linux
Intoduction to LinuxIntoduction to Linux
Intoduction to LinuxAnshul Sharma
 
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 GolangChris McEniry
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Chris McEniry
 
Open Source Everything
Open Source EverythingOpen Source Everything
Open Source EverythingOWASP Nagpur
 
Breaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success StoryBreaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success StorySage Sharp
 
D1T3-Anto-Joseph-Droid-FF
D1T3-Anto-Joseph-Droid-FFD1T3-Anto-Joseph-Droid-FF
D1T3-Anto-Joseph-Droid-FFAnthony Jose
 
Foss-Free and Open Source Software
Foss-Free and Open Source SoftwareFoss-Free and Open Source Software
Foss-Free and Open Source SoftwareManish Lonewolf
 

What's hot (20)

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
 
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
 
I believe in rust
I believe in rustI believe in rust
I believe in rust
 
Introduction to fedora 20cat
Introduction to fedora   20catIntroduction to fedora   20cat
Introduction to fedora 20cat
 
FOSS, history and philosophy
FOSS, history and philosophyFOSS, history and philosophy
FOSS, history and philosophy
 
Making Gentoo Tick
Making Gentoo TickMaking Gentoo Tick
Making Gentoo Tick
 
NSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishNSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - English
 
Intoduction to Linux
Intoduction to LinuxIntoduction to Linux
Intoduction to Linux
 
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
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
 
tizen-oshw-tds14sh
tizen-oshw-tds14shtizen-oshw-tds14sh
tizen-oshw-tds14sh
 
Open Source Everything
Open Source EverythingOpen Source Everything
Open Source Everything
 
Ubuntu Quick Guide
Ubuntu Quick GuideUbuntu Quick Guide
Ubuntu Quick Guide
 
Breaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success StoryBreaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success Story
 
Fedora Introduction
Fedora IntroductionFedora Introduction
Fedora Introduction
 
D1T3-Anto-Joseph-Droid-FF
D1T3-Anto-Joseph-Droid-FFD1T3-Anto-Joseph-Droid-FF
D1T3-Anto-Joseph-Droid-FF
 
Tizen platform-dev-tds14sh
Tizen platform-dev-tds14shTizen platform-dev-tds14sh
Tizen platform-dev-tds14sh
 
Python workshop
Python workshopPython workshop
Python workshop
 
Introduction to FOSS world
Introduction to FOSS worldIntroduction to FOSS world
Introduction to FOSS world
 
Foss-Free and Open Source Software
Foss-Free and Open Source SoftwareFoss-Free and Open Source Software
Foss-Free and Open Source Software
 

Similar to MozillaPH Rust Hack & Learn Session 1

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 2016Robert 'Bob' Reyes
 
Introduction to Rust (Presentation).pptx
Introduction to Rust (Presentation).pptxIntroduction to Rust (Presentation).pptx
Introduction to Rust (Presentation).pptxKnoldus Inc.
 
Introduction to r
Introduction to rIntroduction to r
Introduction to rgslicraf
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesLinaro
 
Some wonderful Linux softwares for daily use
Some wonderful Linux softwares for daily useSome wonderful Linux softwares for daily use
Some wonderful Linux softwares for daily usearun.arwachin
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingAkhil Kaushik
 
Copmuter Languages
Copmuter LanguagesCopmuter Languages
Copmuter Languagesactanimation
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxlemonchoos
 
программное обеспечение (по)
программное обеспечение (по) программное обеспечение (по)
программное обеспечение (по) victoria_4
 
Lisbon rust lang meetup#1
Lisbon rust lang meetup#1Lisbon rust lang meetup#1
Lisbon rust lang meetup#1João Oliveira
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011Patrick Walton
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189Mahmoud Samir Fayed
 
Script of Scripts Polyglot Notebook and Workflow System
Script of ScriptsPolyglot Notebook and Workflow SystemScript of ScriptsPolyglot Notebook and Workflow System
Script of Scripts Polyglot Notebook and Workflow SystemBo Peng
 
Entrepreneur’s guide to programming
Entrepreneur’s guide to programmingEntrepreneur’s guide to programming
Entrepreneur’s guide to programmingChris Callahan
 

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

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
 
Rust 101 (2017 edition)
Rust 101 (2017 edition)Rust 101 (2017 edition)
Rust 101 (2017 edition)
 
Embedded Rust
Embedded RustEmbedded Rust
Embedded Rust
 
Introduction to Rust (Presentation).pptx
Introduction to Rust (Presentation).pptxIntroduction to Rust (Presentation).pptx
Introduction to Rust (Presentation).pptx
 
Rust
RustRust
Rust
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
 
Some wonderful Linux softwares for daily use
Some wonderful Linux softwares for daily useSome wonderful Linux softwares for daily use
Some wonderful Linux softwares for daily use
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Copmuter Languages
Copmuter LanguagesCopmuter Languages
Copmuter Languages
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptx
 
программное обеспечение (по)
программное обеспечение (по) программное обеспечение (по)
программное обеспечение (по)
 
Lisbon rust lang meetup#1
Lisbon rust lang meetup#1Lisbon rust lang meetup#1
Lisbon rust lang meetup#1
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189
 
Rust programming-language
Rust programming-languageRust programming-language
Rust programming-language
 
Script of Scripts Polyglot Notebook and Workflow System
Script of ScriptsPolyglot Notebook and Workflow SystemScript of ScriptsPolyglot Notebook and Workflow System
Script of Scripts Polyglot Notebook and Workflow System
 
Rustbridge
RustbridgeRustbridge
Rustbridge
 
Entrepreneur’s guide to programming
Entrepreneur’s guide to programmingEntrepreneur’s guide to programming
Entrepreneur’s guide to programming
 

More from 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 BringsRobert '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
 
MozillaPH Localization in 2016
MozillaPH Localization in 2016MozillaPH Localization in 2016
MozillaPH Localization in 2016Robert '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
 
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 CommunityRobert 'Bob' Reyes
 
Mozilla in the Philippines & Online Privacy (Social Media Day 2013)
Mozilla in the Philippines & Online Privacy (Social Media Day 2013)Mozilla in the Philippines & Online Privacy (Social Media Day 2013)
Mozilla in the Philippines & Online Privacy (Social Media Day 2013)Robert 'Bob' Reyes
 
Webmaker Presentation of Bob Reyes during WoMoz PHL Kick-off
Webmaker Presentation of Bob Reyes during WoMoz PHL Kick-offWebmaker Presentation of Bob Reyes during WoMoz PHL Kick-off
Webmaker Presentation of Bob Reyes during WoMoz PHL Kick-offRobert '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
 
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)
 
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
 
Mozilla in the Philippines & Online Privacy (Social Media Day 2013)
Mozilla in the Philippines & Online Privacy (Social Media Day 2013)Mozilla in the Philippines & Online Privacy (Social Media Day 2013)
Mozilla in the Philippines & Online Privacy (Social Media Day 2013)
 
Webmaker Presentation of Bob Reyes during WoMoz PHL Kick-off
Webmaker Presentation of Bob Reyes during WoMoz PHL Kick-offWebmaker Presentation of Bob Reyes during WoMoz PHL Kick-off
Webmaker Presentation of Bob Reyes during WoMoz PHL Kick-off
 

Recently uploaded

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 

Recently uploaded (20)

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 

MozillaPH Rust Hack & Learn Session 1

  • 1. Rust Hack & Learn Session #1 Robert “Bob” Reyes 14 Jun 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 • Installing Rust • Hello World, the Rust way • Intro to Cargo • IDE Support • Variables & Constants • Simple Arithmetic Functions
  • 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 …
  • 15.
  • 17.
  • 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
  • 22.
  • 23. Let’s get to know each other first. What is your name? From where are you? What do you do? Why are you here?
  • 24. Where are the MENTORS? Please feel free to approach & ask help from them 
  • 26. 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.”
  • 28. 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.
  • 30. Rust vs Go • Rust shares many of Go's qualities but solves one major problem of Go: • Go doesn't automatically share information between different "channel" data structures  "race condition" • A runaway situation in which a system can spiral out of control because different processes are working at odds with one another. • Rust includes functions that eliminate race conditions, making it a less-risky language than Go for highly concurrent programs.
  • 32. Low-Level Programming • (CS) a programming language that provides little or no abstraction from a computer's instruction set architecture • commands or functions in the language map closely to processor instructions. • generally referred as either machine code or assembly language. • E.g. Assembly Language
  • 33. High-Level Programming • (CS) a programming language with strong abstraction from the details of the computer. • Compared to low-level programming languages • may use natural language elements. • may automate (or even hide entirely) significant areas of computing systems (e.g. memory management). • E.g. COBOL, Fortran, LISP, ALGOL
  • 34. Programming Languages Hardware Machine Language Assembly Language High-Level Language Fortran | C | Pascal OO & Visual Languages C++ | D | Rust
  • 36. 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).
  • 38. Features of Rust • Zero-cost abstractions • Move semantics • Guaranteed memory safety • Threads without data races • Trait-based generics • Pattern matching • Type inference • Minimal runtime • Efficient C bindings
  • 40. Projects Using Rust  Magic Pocket  Dropbox's file storage system that powers their Diskotech petabyte storage machines.  Servo  Mozilla's new parallel rendering engine developed in collaboration with Samsung.  OpenDNS  Uses Rust in two of its components.  Redox OS  A microkernel operating system being developed in Rust.
  • 42. Installing Rust • Installer for Windows, Mac OS X & Linux available via https://www.rust-lang.org • If you wish to run Rust on your local machine when you’re offline. • Rust Playground [https://play.rust-lang.org] • If you are online, you may opt to use this one instead. • You may use ANY text editor to code in Rust. • As a practice, please save your Rust code using .rs file extension.
  • 44. Function main() • Every Rust program must have at least one (01) function. • Simplest possible function declaration is named as “main” fn main() { } • Functions can also take arguments fn print_number(x:i32) { println!(“x is: {}”, x); }
  • 47. Cargo
  • 48. Cargo • A tool that allows Rust projects to declare their various dependencies & ensure that you’ll always get a repeatable build. • Cargo does: 1. Introduces two (02) metadata files with various bits of project information. 2. Fetches & builds your project’s dependencies. 3. Invokes rustc or another build tool with the correct parameters to build your project. 4. Introduces conventions to make working with Rust projects easier.
  • 49. Cargo • To start a new project with Cargo, we invoke in the command line: cargo new hello_world --bin • Cargo will generate the following files & folders:  Cargo.toml [file]  src [folder]  main.rs [file] • Acts as a manifest file • Contains all of the metadata that Cargo needs to compile your project.
  • 51. TOML • Tom’s Obvious, Minimal Language (or some say, Tom’s Own Markup Language) • Created by Tom Preston-Werner • Aims to be a minimal configuration file format that's easy to read due to obvious semantics. • Designed to map unambiguously to a hash table. • Should be easy to parse into data structures in a wide variety of languages.
  • 53. Cargo.toml [package] name = "hello_world” version = "0.1.0” authors = ["Your Name <you@example.com>"]
  • 55. IDE Support • Modern IDEs give developers a massive increase in productivity. • Several community projects have provided an excellent start towards IDE support. • Good IDE support requires a number of components: • The compiler must be modified to operate in a different mode. • Must provide name & type information from the compiler to the IDE. • Must write plugins for the IDEs themselves so they know what to do with Rust projects.
  • 56. IDE Support • Available IDE Plugins: • Eclipse [https://github.com/RustDT/RustDT] • Intellij IDEA [https://github.com/intellij-rust/intellij-rust] • Visual Studio [https://github.com/PistonDevelopers/VisualRust] • Editor Plugins: • Atom [https://atom.io/packages/language-rust] • Emacs [https://github.com/rust-lang/rust-mode] • Sublime Text [https://packagecontrol.io/packages/Rust] • Vim [https://github.com/rust-lang/rust.vim] • Visual Studio Code [https://github.com/saviorisdead/RustyCode]
  • 57. More on IDE Support https://www.rust-lang.org/ides.html
  • 59. Variables • Variable Declaration fn main() { let a:u8 = 123; } • Whereas • a  variable • u8  data type (unsigned; 0 or positive; 8-bit) • 123  value of variable “a”
  • 60. Numeric Data Types • i8  8-bit signed integer • i16  16-bit signed integer • i32  32-bit signed integer • i64  64-bit signed integer • u8  8-bit unsigned integer • u16  16-bit unsigned integer • u32  32-bit unsigned integer • u64  64-bit unsigned integer • isize  pointer-size signed integer • usize  pointer-size unsigned integer • f32/f64  32/64-bit floating point
  • 62. Mutability • The ability to change something. • Mutable variable binding. • You’re allowed to change what the binding points to. let x = 5; x = 6;  will result to an error! • We can use the mut keyword: let mut x = 5; x = 6;  no problem; no error!
  • 63. Constants • Aside from using variables, we can also declare constants in Rust: const PI:u8 = 3;  no fixed memory address  memory safety is NOT compromised static X:i32 = 123;
  • 65. Arithmetic Operators +  addition & array/string concatenation -  subtraction *  multiplication /  quotient %  remainder
  • 66. Arithmetic Operators • Rust DOES NOT support ++ and – used in other programming languages. • a = a+1; or • a += 1; • b = b-1; or • b -= 1; • You may also use the following in Rust • *= • /= • %=
  • 67. Arithmetic Operators let mut a = 2+3*4; println!(“Answer = {}.”, a); let mut a = (2+3)*4; println!(“Answer = {}.”, a);
  • 68. Arithmetic Operators let mut a = 10/3; println!(“Answer = {}.”, a); let mut a = 10%3; println!(“Answer = {}.”, a); let a=10; println!(“Remainder of {} / {} = {}”, a, 3, (a%3));
  • 70. Arithmetic Operators (eg1) fn main() { let num1 = 20; let num2 = 10; println!(“The SUM of the numbers = {}”, (num1 + num2)); println!(”The DIFFERENCE of the numbers = {}”, (num1 – num2)); … and so on
  • 71. Arithmetic Operators (eg2) fn main() { let num1 = 20; let num2 = 10; let sum = num1 + num2; let dif = num1 – num2; let pro = num1 * num2; let quo = num1 / num2; println!(“The SUM of the numbers = {}”, sum); … and so on
  • 72. Q&A
  • 75. 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
  • 76. What to expect on Session #2?
  • 77. Next: Session #2 • Rust Standard Library • Functions • Conditional Statements • Loops • Vectors • Strings • Concurrency • Error Handling
  • 79. 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. - image processing in rust - is rust OO