Is there an issue? Send a MessageReason:
None
Changed line(s) 3,4 (click to see context) from:
Rust is a [[https://en.wikipedia.org/wiki/Type_system#STATIC statically-typed]], [[https://en.wikipedia.org/wiki/Programming_paradigm#Support_for_multiple_paradigms multi-paradigm]], [[https://en.wikipedia.org/wiki/Concurrent_computing concurrent]] UsefulNotes/ProgrammingLanguage with an emphasis on '''''speed''''' and '''''safety'''''. While a relatively new language, Rust has managed to be [[https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages Github's most beloved programming language since 2016]].
to:
Rust is a [[https://en.wikipedia.org/wiki/Type_system#STATIC statically-typed]], [[https://en.wikipedia.org/wiki/Programming_paradigm#Support_for_multiple_paradigms multi-paradigm]], [[https://en.wikipedia.org/wiki/Concurrent_computing concurrent]] UsefulNotes/ProgrammingLanguage MediaNotes/ProgrammingLanguage with an emphasis on '''''speed''''' and '''''safety'''''. While a relatively new language, Rust has managed to be [[https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages Github's most beloved programming language since 2016]].
Is there an issue? Send a MessageReason:
Is there an issue? Send a MessageReason:
None
Changed line(s) 14,23 (click to see context) from:
[[hardline]]
[[folder:Code Examples]]
!!!Hello Rust
@@'''[[gray:fn]]''' [[gray:main]]'''[[gray:(){]]'''\\
[[gray:println'''!(''']][[red:"Hello World!"]][[gray:''')''';]]\\
'''[[gray:}]]'''\\
@@
to:
These are some of features of Rust that help it stand out and what makes it increasingly popular for programmers used to C and C++. This isn't a comprehensive list however.
!!! Expression based
In Rust, any part of the function body can be considered an ''expression'', or something that returns a value. This allows for an implicit return of a value in a function by omitting the semi-colon where one would traditionally use the keyword ''return''
!!!Data ownership and lifetime
Part of how Rust achieves memory safety is enforcing a few rules regarding data ownership and lifetime. Ownership is the idea that some function owns the data. Once the function is done, if ownership was not explicitly transferred, then the data is automatically dropped from memory. Other functions can also ''borrow'' data, allowing a read-only reference to the data. However, if the ownership is transferred in the middle of a function, the function that used to own said data can no longer use it unless the new owner passes it back.
All of this is handled by the compiler by the way, meaning if the programmer doesn't keep up with this, the compiler will tell them of it.
'''Example of ownership'''
@@fn print_string(s: String) {\\
println!("{}", s);\\
}\\
Changed line(s) 25,38 (click to see context) from:
Outputs Hello World to the console using the println! macro. You must wrap your program in the 'main' function.
!!!Variable Declaration and Concatenation
@@'''[[gray:fn]]''' [[gray:main]]'''[[gray:(){]]'''\\
[[gray:'''let''' a =]] [[teal:10]][[gray:;]]\\
[[gray:'''let''' b =]] [[teal:7]][[gray:;]]\\
[[gray:'''let''' c =]] [[red:"hi"]][[gray:;]]\\
[[gray:println'''!(]]'''[[red:"{}"]][[gray:, a+b''')''';]]\\
// Outputs 17\\
[[gray:println'''!(''']][[red:"{}"]][[gray:, b+c''')''';]]\\
// Throws an error\\
[[gray:println'''!(]]'''[[red:"Hello and {}"]][[gray:, c''')''';]]\\
// Outputs Hello and hi\\
'''[[gray:}]]'''\\
!!!Variable Declaration and Concatenation
@@'''[[gray:fn]]''' [[gray:main]]'''[[gray:(){]]'''\\
[[gray:'''let''' a =]] [[teal:10]][[gray:;]]\\
[[gray:'''let''' b =]] [[teal:7]][[gray:;]]\\
[[gray:'''let''' c =]] [[red:"hi"]][[gray:;]]\\
[[gray:println'''!(]]'''[[red:"{}"]][[gray:, a+b''')''';]]\\
// Outputs 17\\
[[gray:println'''!(''']][[red:"{}"]][[gray:, b+c''')''';]]\\
// Throws an error\\
[[gray:println'''!(]]'''[[red:"Hello and {}"]][[gray:, c''')''';]]\\
// Outputs Hello and hi\\
'''[[gray:}]]'''\\
to:
!!!Variable Declaration and Concatenation
@@'''[[gray:fn]]''' [[gray:main]]'''[[gray:(){]]'''\\
[[gray:'''let''' a =]] [[teal:10]][[gray:;]]\\
[[gray:'''let''' b =]] [[teal:7]][[gray:;]]\\
[[gray:'''let''' c =]] [[red:"hi"]][[gray:;]]\\
[[gray:println'''!(]]'''[[red:"{}"]][[gray:, a+b''')''';]]\\
let s = String::from("Hello, World");\\
print_string(s); // s consumed by print_string\\
//
[[gray:println'''!(''']][[red:"{}"]][[gray:, b+c''')''';]]\\
//
// Outputs Hello and hi\\
'''[[gray:}]]'''\\
!!!Memory Safety and Management
One standout feature of Rust is that it does not have a ''null'' value. This was done because ''null'' has wrecked havoc on a lot of other programming languages because you're not supposed to use null for anything, and using it either causes an outright error or unpredictable behavior. It's been called by its inventor [[https://www.google.com/search?q=null+the+billion+dollar+mistake The Billion Dollar Mistake]]
While not exactly a standout feature, but one that sets it apart from other languages made since the mid 90s is the lack of a garbage collector. Resources are taken through the [[https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization Resource Acquisition Is Initialization (RIAA)]] principle and optionally through a reference counter. In addition, all variables have read-only access, requiring an explicit declaration of ''mut'' (for mutable) if the variable can be changed.
!!!The Rust Compiler
The tool that turns Rust code into a program, and one that's rather powerful. The compiler handles all of the memory checking, which includes making that pointers have some reference to something before being used. By more or less forcing the programmer to fix their issues up front, programs written in Rust tend to be highly reliable from the get go.
The other feature of the compiler is that it's really helpful in pointing out what the problem is in a more useful way than most compilers, especially from popular ones like gcc for C (though gcc has gotten better at reporting issues with code).
[[hardline]]
!!Code Examples
[[folder:Hello Rust]]
@@'''[[gray:fn]]''' [[gray:main]]'''[[gray:(){]]'''\\
[[gray:println'''!(''']][[red:"Hello World!"]][[gray:''')''';]]\\
'''[[gray:}]]'''\\
@@
Changed line(s) 41,44 (click to see context) from:
Rust uses the let keyword to declare variables for all data types; unusual for a low level language. Rust will not concatenate a string and a number automatically and will throw an error in the compiler.
!!!For Loops
!!!For Loops
to:
!!!For Loops
[[/folder]]
[[folder:Variable Declaration and Concatenation]]
Changed line(s) 46,48 (click to see context) from:
[[gray:'''for''' i '''in''']] [[teal:0]]..[[teal:10]] '''[[gray:{]]'''\\
[[gray:println'''!(''']][[red:"{}"]],i'''[[gray:)]]''';\\
'''[[gray:}]]'''\\
[[gray:println'''!(''']][[red:"{}"]],i'''[[gray:)]]''';\\
'''[[gray:}]]'''\\
to:
[[gray:println'''!(''']][[red:"{}"]],i'''[[gray:)]]''';\\
'''[[gray:}]]'''\\
[[gray:'''let''' b =]] [[teal:7]][[gray:;]]\\
[[gray:'''let''' c =]] [[red:"hi"]][[gray:;]]\\
[[gray:println'''!(]]'''[[red:"{}"]][[gray:, a+b''')''';]]\\
// Outputs 17\\
[[gray:println'''!(''']][[red:"{}"]][[gray:, b+c''')''';]]\\
// Throws an error\\
[[gray:println'''!(]]'''[[red:"Hello and {}"]][[gray:, c''')''';]]\\
// Outputs Hello and hi\\
Changed line(s) 52,53 (click to see context) from:
Rust’s for loops work a bit differently than in other languages. In this example, 0..10 is an expression that takes a start and an end position, and gives an iterator over those values. The upper bound is exclusive though, so the loop will print 0 through 9, not 10.
to:
Changed line(s) 56 (click to see context) from:
to:
[[folder:For Loops]]
@@'''[[gray:fn]]''' [[gray:main]]'''[[gray:(){]]'''\\
[[gray:'''for''' i '''in''']] [[teal:0]]..[[teal:10]] '''[[gray:{]]'''\\
[[gray:println'''!(''']][[red:"{}"]],i'''[[gray:)]]''';\\
'''[[gray:}]]'''\\
'''[[gray:}]]'''\\
@@
\\
Rust’s for loops work a bit differently than in other languages. In this example, 0..10 is an expression that takes a start and an end position, and gives an iterator over those values. The upper bound is exclusive though, so the loop will print 0 through 9, not 10.
[[/folder]]
@@'''[[gray:fn]]''' [[gray:main]]'''[[gray:(){]]'''\\
[[gray:'''for''' i '''in''']] [[teal:0]]..[[teal:10]] '''[[gray:{]]'''\\
[[gray:println'''!(''']][[red:"{}"]],i'''[[gray:)]]''';\\
'''[[gray:}]]'''\\
'''[[gray:}]]'''\\
@@
\\
Rust’s for loops work a bit differently than in other languages. In this example, 0..10 is an expression that takes a start and an end position, and gives an iterator over those values. The upper bound is exclusive though, so the loop will print 0 through 9, not 10.
[[/folder]]
Is there an issue? Send a MessageReason:
None
Deleted line(s) 15,18 (click to see context) :
----
[[folder:Code Examples]]
[[folder:Code Examples]]
Added DiffLines:
[[folder:Code Examples]]
Is there an issue? Send a MessageReason:
None
Changed line(s) 3,4 (click to see context) from:
Rust is a [[https://en.wikipedia.org/wiki/Type_system#STATIC statically-typed]], [[https://en.wikipedia.org/wiki/Programming_paradigm#Support_for_multiple_paradigms multi-paradigm]], [[https://en.wikipedia.org/wiki/Concurrent_computing concurrent]] UsefulNotes/ProgrammingLanguage with an emphasis on '''speed''' and '''safety'''. While a relatively new language, Rust has managed to be [[https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages Github's most beloved programming language since 2016]].
to:
Rust is a [[https://en.wikipedia.org/wiki/Type_system#STATIC statically-typed]], [[https://en.wikipedia.org/wiki/Programming_paradigm#Support_for_multiple_paradigms multi-paradigm]], [[https://en.wikipedia.org/wiki/Concurrent_computing concurrent]] UsefulNotes/ProgrammingLanguage with an emphasis on '''speed''' '''''speed''''' and '''safety'''.'''''safety'''''. While a relatively new language, Rust has managed to be [[https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages Github's most beloved programming language since 2016]].
Changed line(s) 10,11 (click to see context) from:
Rust began as side project of Mozilla employee, Graydon Hoare. Mozilla got involved in 2009 and sponsored the language once it was mature enough to run basic tests and demonstrate its core concepts. Featuring both Mozilla and Non-Mozilla developers, Rust is developed by a diverse and global community of enthusiasts. Rustc (Rust's compiler) has over 1,000 unique contributors.
to:
Rust began as side project of Mozilla employee, Graydon Hoare. Mozilla got involved in 2009 and sponsored the language once it was mature enough to run basic tests and demonstrate its core concepts. Featuring both Mozilla and Non-Mozilla developers, Rust is developed by a diverse and global community of enthusiasts. Rustc rustc (Rust's compiler) has over 1,000 unique contributors.
Changed line(s) 27,28 (click to see context) from:
Outputs Hello World to the console.
to:
Outputs Hello World to the console.
console using the println! macro. You must wrap your program in the 'main' function.
Changed line(s) 43,44 (click to see context) from:
descrition
to:
Is there an issue? Send a MessageReason:
None
Changed line(s) 48 (click to see context) from:
'''[[gray:for''' i '''in]]''' [[teal:0]]..[[teal:10]] '''[[gray:{]]'''\\
to:
Is there an issue? Send a MessageReason:
None
Changed line(s) 48 (click to see context) from:
'''[[gray:for]]''' i '''[[gray:in]]''' [[teal:0]]..[[teal:10]] '''[[gray:{]]'''\\
to:
Is there an issue? Send a MessageReason:
None
Changed line(s) 49 (click to see context) from:
[[gray:println'''gray:!(''']][[red:"{}"]],i'''[[gray:)]]''';\\
to:
Is there an issue? Send a MessageReason:
None
Changed line(s) 54,55 (click to see context) from:
to:
Is there an issue? Send a MessageReason:
None
Changed line(s) 23 (click to see context) from:
[[gray:println'''!(''']][[red:"Hello World!"]]'''[[gray:)]]'''[[gray:;]]\\
to:
[[gray:println'''!(''']][[red:"Hello World!"]]'''[[gray:)]]'''[[gray:;]]\\World!"]][[gray:''')''';]]\\
Changed line(s) 31,34 (click to see context) from:
let a = 10;\\
let b = 7;\\
let c = "hi";\\
println!("{}", a+b);\\
let b = 7;\\
let c = "hi";\\
println!("{}", a+b);\\
to:
let
[[gray:'''let''' b
let
[[gray:'''let''' c
println!("{}", a+b);\\
[[gray:println'''!(]]'''[[red:"{}"]][[gray:, a+b''')''';]]\\
Changed line(s) 36 (click to see context) from:
println!("{}", b+c);\\
to:
Changed line(s) 38 (click to see context) from:
[[gray:println]]'''[[gray:!(]]'''[[red:"Hello and {}"]][[gray:, c''')''';]]\\
to:
Changed line(s) 49 (click to see context) from:
println'''[[gray:!(]]'''[[red:"{}"]],i'''[[gray:)]]''';\\
to:
Is there an issue? Send a MessageReason:
None
Changed line(s) 23 (click to see context) from:
[[gray:println'''!(''']][[rede"Hello World!");\\
to:
Is there an issue? Send a MessageReason:
None
Changed line(s) 22,24 (click to see context) from:
@@fn main(){\\
println!("Hello World!");\\
}\\
println!("Hello World!");\\
}\\
to:
println!("Hello
[[gray:println'''!(''']][[rede"Hello World!");\\
Changed line(s) 30,40 (click to see context) from:
@@fn main(){\\
let a = 10;\\
let b = 7;\\
let c = "hi";\\
println!("{}", a+b);\\
// Outputs 17\\
println!("{}", b+c);\\
// Throws an error\\
println!("Hello and {}", c);\\
// Outputs Hello and hi\\
}\\
let a = 10;\\
let b = 7;\\
let c = "hi";\\
println!("{}", a+b);\\
// Outputs 17\\
println!("{}", b+c);\\
// Throws an error\\
println!("Hello and {}", c);\\
// Outputs Hello and hi\\
}\\
to:
let
let a =
let
let b =
let
let c =
println!("{}", a+b);\\
//
println!("{}", a+b);\\
// Outputs
println!("{}", b+c);\\
//
println!("{}", b+c);\\
// Throws an
println!("Hello
[[gray:println]]'''[[gray:!(]]'''[[red:"Hello and
//
// Outputs Hello and hi\\
Changed line(s) 47,51 (click to see context) from:
@@[[gray:fn]] main[[gray:(){]]\\
[[gray:for]] i [[gray:in]] [[teal:0]]..[[teal:10]] [[gray:{]]\\
println[[gray:!(]][[red:"{}"]],i[[gray:)]];\\
[[gray:}]]\\
[[gray:}]]\\
[[gray:for]] i [[gray:in]] [[teal:0]]..[[teal:10]] [[gray:{]]\\
println[[gray:!(]][[red:"{}"]],i[[gray:)]];\\
[[gray:}]]\\
[[gray:}]]\\
to:
[[gray:for]]
'''[[gray:for]]''' i
println[[gray:!(]][[red:"{}"]],i[[gray:)]];\\
[[gray:}]]\\
[[gray:}]]\\
println'''[[gray:!(]]'''[[red:"{}"]],i'''[[gray:)]]''';\\
'''[[gray:}]]'''\\
'''[[gray:}]]'''\\
Is there an issue? Send a MessageReason:
None
Changed line(s) 3,7 (click to see context) from:
Rust is a [[https://en.wikipedia.org/wiki/Type_system#STATIC statically-typed]], [[https://en.wikipedia.org/wiki/Programming_paradigm#Support_for_multiple_paradigms multi-paradigm]], [[https://en.wikipedia.org/wiki/Concurrent_computing concurrent]] UsefulNotes/ProgrammingLanguage with an emphasis on '''speed''' and '''safety'''. While a relatively new language, Rust managed to be [[https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages Github's most beloved programming language since 2016]].
You can try out Rust for yourself [[https://play.rust-lang.org/ here]]
You can try out Rust for yourself [[https://play.rust-lang.org/ here]]
to:
Rust is a [[https://en.wikipedia.org/wiki/Type_system#STATIC statically-typed]], [[https://en.wikipedia.org/wiki/Programming_paradigm#Support_for_multiple_paradigms multi-paradigm]], [[https://en.wikipedia.org/wiki/Concurrent_computing concurrent]] UsefulNotes/ProgrammingLanguage with an emphasis on '''speed''' and '''safety'''. While a relatively new language, Rust has managed to be [[https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages Github's most beloved programming language since 2016]].
You can try out Rust for yourself [[https://play.rust-lang.org/here]]
here]].
You can try out Rust for yourself [[https://play.rust-lang.org/
Added DiffLines:
!!!Hello Rust
Added DiffLines:
!!!Variable Declaration and Concatenation
@@fn main(){\\
let a = 10;\\
let b = 7;\\
let c = "hi";\\
println!("{}", a+b);\\
// Outputs 17\\
println!("{}", b+c);\\
// Throws an error\\
println!("Hello and {}", c);\\
// Outputs Hello and hi\\
}\\
@@
\\
descrition
!!!For Loops
@@[[gray:fn]] main[[gray:(){]]\\
[[gray:for]] i [[gray:in]] [[teal:0]]..[[teal:10]] [[gray:{]]\\
println[[gray:!(]][[red:"{}"]],i[[gray:)]];\\
[[gray:}]]\\
[[gray:}]]\\
@@
\\
@@fn main(){\\
let a = 10;\\
let b = 7;\\
let c = "hi";\\
println!("{}", a+b);\\
// Outputs 17\\
println!("{}", b+c);\\
// Throws an error\\
println!("Hello and {}", c);\\
// Outputs Hello and hi\\
}\\
@@
\\
descrition
!!!For Loops
@@[[gray:fn]] main[[gray:(){]]\\
[[gray:for]] i [[gray:in]] [[teal:0]]..[[teal:10]] [[gray:{]]\\
println[[gray:!(]][[red:"{}"]],i[[gray:)]];\\
[[gray:}]]\\
[[gray:}]]\\
@@
\\
Is there an issue? Send a MessageReason:
None
Added DiffLines:
[[quoteright:250:https://static.tvtropes.org/pmwiki/pub/images/rustthrow.jpeg]]
Rust is a [[https://en.wikipedia.org/wiki/Type_system#STATIC statically-typed]], [[https://en.wikipedia.org/wiki/Programming_paradigm#Support_for_multiple_paradigms multi-paradigm]], [[https://en.wikipedia.org/wiki/Concurrent_computing concurrent]] UsefulNotes/ProgrammingLanguage with an emphasis on '''speed''' and '''safety'''. While a relatively new language, Rust managed to be [[https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages Github's most beloved programming language since 2016]].
You can try out Rust for yourself [[https://play.rust-lang.org/ here]]
!!History
Rust began as side project of Mozilla employee, Graydon Hoare. Mozilla got involved in 2009 and sponsored the language once it was mature enough to run basic tests and demonstrate its core concepts. Featuring both Mozilla and Non-Mozilla developers, Rust is developed by a diverse and global community of enthusiasts. Rustc (Rust's compiler) has over 1,000 unique contributors.
By 2011, Rust had successfully compiled itself and was shortly after released to the public in January, 2012.
----
[[folder:Code Examples]]
[[hardline]]
@@fn main(){\\
println!("Hello World!");\\
}\\
@@
\\
Outputs Hello World to the console.
[[/folder]]
!!Works Written in Rust
[[folder:Software]]
* Components in the ''Firefox'' browser such as [[https://blog.mozilla.org/firefox/put-trust-rust-shipping-now-firefox/ an MP4 parser for video files have been rewritten in Rust]]
[[/folder]]
----
Rust is a [[https://en.wikipedia.org/wiki/Type_system#STATIC statically-typed]], [[https://en.wikipedia.org/wiki/Programming_paradigm#Support_for_multiple_paradigms multi-paradigm]], [[https://en.wikipedia.org/wiki/Concurrent_computing concurrent]] UsefulNotes/ProgrammingLanguage with an emphasis on '''speed''' and '''safety'''. While a relatively new language, Rust managed to be [[https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages Github's most beloved programming language since 2016]].
You can try out Rust for yourself [[https://play.rust-lang.org/ here]]
!!History
Rust began as side project of Mozilla employee, Graydon Hoare. Mozilla got involved in 2009 and sponsored the language once it was mature enough to run basic tests and demonstrate its core concepts. Featuring both Mozilla and Non-Mozilla developers, Rust is developed by a diverse and global community of enthusiasts. Rustc (Rust's compiler) has over 1,000 unique contributors.
By 2011, Rust had successfully compiled itself and was shortly after released to the public in January, 2012.
----
[[folder:Code Examples]]
[[hardline]]
@@fn main(){\\
println!("Hello World!");\\
}\\
@@
\\
Outputs Hello World to the console.
[[/folder]]
!!Works Written in Rust
[[folder:Software]]
* Components in the ''Firefox'' browser such as [[https://blog.mozilla.org/firefox/put-trust-rust-shipping-now-firefox/ an MP4 parser for video files have been rewritten in Rust]]
[[/folder]]
----