e010: Macros rule!

January 18, 2016 16:32 7.1 MB Downloads: 0

Macros rule! NotesBecause of the way macros are exported—before name resolution on crates occurs—the documentation for the macros defined in the source for this episode occurs in the Macros section of the show_notes crate documentation, rather than within the documentation for this module. (See the Rust Book discussion of documenting macros for details.) Even so, the source is still in this module; see the implementations for details. Links Rust book: Macros Rust by Example: Macros Rust reference: Macros “Macro by Example” (original paper) Nick Cameron: Macros Macros in Rust Part 1: macro_rules! Part 2: procedural macros Part 3: hygiene Part 4: scoping and import/export Part 5: current problems and possible solutions Part 6: more issues with macro_rules! concat_idents and macros in ident positions Macro plans, overview Macro hygiene in all its guises and variations Sets of scopes macro hygiene Macro plans: syntax Procedural macros, framework Sponsors Aleksey Pirogov Chris Palmer Derek Morr Hamza Sheikh Luca Schmid Micael Bergeron Ralph Giles (“rillian”) reddraggone9 William Roe Become a sponsor Patreon Venmo Dwolla Cash.me Follow New Rustacean: Twitter: @newrustacean App.net: @newrustacean Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

e009: Composing a Rustic tune

January 09, 2016 17:23 7.0 MB Downloads: 0

Notes Last time, we looked at generics and traits at a high level. This time, we dig deeper on traits, looking specifically at std::iter::Iterator as an example of a powerful trait that can be composed across types, and then at how we might compose multiple traits on a single type. We also talk about the syntax for traits, the use of marker traits, some of the things you can’t presently do with traits, and even just a smidge about the future of traits in Rust. All that in less than 20 minutes! You’ll find today’s source example fairly interesting, I think: it’s just one type, but it uses almost every concept discussed on the show today! Links Nick Cameron: “Thoughts on Rust in 2016” “Upcoming breakage starting in Rust 1.7, from RFCs 1214 and 136” RFC 1214: Clarify (and improve) rules for projections and well-formedness RFC 136: Ban private items in public APIs The Rust Book: Traits Trait objects (dynamic dispatch) The Rust reference: std::iter and std::iter::Iterator Add Drop PartialEq and Eq PartialOrd and Ord Special traits Trait objects RFC: impl specialization Aaron Turon: “Specialize to reuse” Sponsors Aleksey Pirogov Chris Palmer Derek Morr Hamza Sheikh Luca Schmid Micael Bergeron Ralph Giles (“rillian”) reddraggone9 William Roe Become a sponsor Patreon Venmo Dwolla Cash.me Follow New Rustacean: Twitter: @newrustacean App.net: @newrustacean Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

e008: Just like something else

December 27, 2015 17:37 6.86 MB Downloads: 0

Notes In this episode we cover—at a very high level—two more fundamental concepts in Rust programming: generics and traits. Generics gives us the abilitty to write types and functions which can be used with more than one type. Traits give us the ability to specify behavior which can be implemented for more than one type. The combination gives us powerful tools for higher-level programming constructs in Rust. Comments on source code Now that we have a handle on how tests work, we’ll use them to validate the behavior of our code going forward. This is great: we can show that the tests do what we think. To today’s point, though: we actually know even apart from whether the tests run successfully that these generic functions and the associated traits are behaving as we want. Failure with generics is a compile-time error, not a runtime error. Links Rust Book Generics Traits – includes a discussion of trait bounds and generic traits* Rust by Example Generics Traits Generic traits Traits bounds Generics and traits in use in Diesel Sponsors Chris Palmer Derek Morr Luca Schmid Micael Bergeron Ralph Giles (“rillian”) reddraggone9 William Roe Become a sponsor Patreon Venmo Dwolla Cash.me Follow New Rustacean: Twitter: @newrustacean App.net: @newrustacean Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

e007: Testify

December 13, 2015 18:46 7.42 MB Downloads: 0

Notes All about testing in Rust! In order, we take a look at: Why you need tests. Unit tests in other (dynamically-typed) languages vs. in Rust. How to write unit tests in Rust. How and why to write integration tests in Rust. How and why to use benchmarks in Rust. The detailed code samples for this episode are heavy on showing; because of the nature of test functions, you will be best off just reading the source rather than leaning heavily on the descriptions generated by rustdoc. (The descriptions are still there, but they’re much less useful than they have been in previous episodes.) In particular, the test module here is excluded because of the use of the #[cfg(test)] attribute marker on it. Because we are using the feature-gated benchmarking functionality, the show notes “library” can now only be compiled with the Rust nightly (as of 1.5, the version current as this episode is produced). One thing that isn’t necessarily obvious from reading the test documentation in the Rust book and Rust reference: the extern crate test statement needs to be not in this module, but at the module (lib.rs) which defines the library/crate; in this case, show_notes/lib.rs. Links Rust Book: Testing Attributes Benchmark tests Rust reference: Attributes Diesel (Rust ORM) 31: Oxidizing an ORM 32: Bug for Bug Compatibility Sponsors Chris Palmer Derek Morr Luca Schmid Micael Bergeron Ralph Giles (“rillian”) reddraggone9 William Roe Become a sponsor Patreon Venmo Dwolla Cash.me Follow New Rustacean: Twitter: @newrustacean App.net: @newrustacean Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

Bonus 2: Legacy Code

December 06, 2015 9:41 4.08 MB Downloads: 0

Legacy Code Software developers spend a large part of our careers dealing with legacy code. But what is the best way to deal with legacy code? When should you rip out the old and rewrite it, and when should you opt for smaller clean-up jobs because, however ugly, what is already present works? Sponsors Chris Palmer Derek Morr Luca Schmid Micael Bergeron Ralph Giles (“rillian”) reddraggone9 William Roe Become a sponsor Patreon Venmo Dwolla Cash.me Follow New Rustacean: Twitter: @newrustacean App.net: @newrustacean Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

Bonus 1: Polyglot Programming Promises and Perils

November 25, 2015 8:28 3.57 MB Downloads: 0

Polyglot Programming Promises and Perils Sometimes, you’re doing a technical interview, and you just cannot figure out why your JavaScript function isn’t behaving like it should… and then, prompted by the interviewer, you realize that you’re not returning anything. Polyglot programming is beautiful, and wonderful, and sometimes it bites you when you aren’t looking. Links Scala F♯ Elixir Sponsors reddraggone9 Chris Patti Become a sponsor Patreon Venmo Dwolla Cash.me Follow New Rustacean: Twitter: @newrustacean App.net: @newrustacean Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

e006: Modularize this!

November 16, 2015 18:22 9.3 MB Downloads: 0

Notes Today, we are talking about modules, packages, and APIs in Rust. Taking a bit of a breather after some pretty hard material the last few weeks. For reference, the Rust book section on Crates and Modules will be very helpful. Corrigenda I accidentally called this episode 5, instead of episode 6. Whoops. Just before the 15:00 mark, while discussing libraries, I referred to “e006.md” when I meant to say “e006.rs”. Slips of the tongue inspired by the fact that Rust (delightfully) uses Markdown for its documentation. Links Roguelike in Rust Yehuda Katz on Ruby FFI Sponsors reddraggone9 Chris Patti Become a sponsor Patreon Venmo Dwolla Cash.me Follow New Rustacean: Twitter: @newrustacean App.net: @newrustacean Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

e005: Allocate it where?

November 08, 2015 18:30 9.55 MB Downloads: 0

Allocate it where? Subject: Returning functions from other functions, and thinking about the stack, the heap, and reference types. MP3 Notes This episode, we look at returning functions from other functions, and as part of that discuss some basics about the stack and the heap—and why we need to care about them for returning functions. The functions themselves are not especially interesting; they just show you the basic form you use to return functions from other functions, and how to then use them in another function. You’ll want to take a detailed look instead at the documentation for each (or just read the source!), because that’s where the meat of the discussion in this week’s code is. Links Rust 1.4 release announcement “Clarify (and improve) rules for projections and well-formedness” MSVC support tracking issue Rust 1.4 full release notes “What and where are the stack and the heap?” Sponsors reddraggone9 Chris Patti Become a sponsor Patreon Venmo Dwolla Cash.me Follow New Rustacean: Twitter: @newrustacean App.net: @newrustacean Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

e004: Functionalized

October 29, 2015 17:07 9.26 MB Downloads: 0

Date: October 29, 2015 Subject: Functions, methods, closures, and function as arguments! Notes This week’s episode covers the basics of all sorts of functions: normal functions, methods, and closures. Closures An explanation (in Ruby) by Martin Fowler Rust book Rust by Example “What is a closure?” (Progammers Stack Exchange) – the first answer is the best, but the second answer may be a helpful stepping stone for people just getting their heads around this and coming from OOP languages like C++ or Java (even though I disagree with the explanation in some ways). “What is a closure?” (Stack Overflow) – careful, thorough answer using JavaScript as an example. Links Exercism (hat tip: Lechindanier on GitHub) Rust Learning Rust and Swift (viii) Follow/Support New Rustacean: Twitter: @newrustacean App.net: @newrustacean Patreon Dwolla Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

e003: No. more. nulls.

October 21, 2015 16:51 8.37 MB Downloads: 0

No More Nulls Subject: Enumerated (enum) types, pattern matching, and meaningful return types. Notes Today’s episode discusses, in order: Enumerated types, with an eye to the difference between structs and enums, and to the differences between enums in C and in Rust. Pattern matching, with a focus on using them with enumerated types and some discussion about how they differ from switch blocks in C-like languages. Using the Option and Result enumerated types with pattern matching to provide meaningful returns from functions safely. Order There is a specific order to the examples below, and it is not the automatically-alphabetized order rendered by rustdoc. Instead, you should work through in the sequence they appear in the source: RelatedishThings demonstrate_basic_enumeration demonstrate_match get_an_option demonstrate_option get_a_result demonstrate_result Links New Rustacean Pull Request #1 Work on IDE support! Landing page My chosen tool: JetBrains/IntelliJ Rustlings Rust FFI Omnibus Follow/Support New Rustacean: Twitter: @newrustacean App.net: @newrustacean Patreon Email: <!-- h='&#110;&#x65;&#x77;&#114;&#x75;&#x73;&#116;&#x61;&#x63;&#x65;&#x61;&#110;&#46;&#x63;&#x6f;&#x6d;';a='&#64;';n='&#104;&#x65;&#108;&#108;&#x6f;';e=n+a+h; document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>'); // --> hello at newrustacean dot com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho

e002: Something borrowed, something… moved?

October 11, 2015 17:12 9.1 MB Downloads: 0

Something borrowed, something… moved? Subject: The struct data type constructor, and the basics of Rust’s “ownership” concept and “borrowing” and “moving”. Follow/Support New Rustacean: Twitter: @newrustacean App.net: @newrustacean Patreon Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho Notes Today’s episode discusses, and the associated source code demonstrates, a few basic behaviors of structs… including borrowing! After taking a short look at one of Rust’s basic approaches to creating new types, we dive into a fairly thorough overview of how borrowing works in fairly run-of-the-mill Rust code. This is a basic introduction, and as such I’m not getting into things like heap-allocated memory (Box) or dealing with move semantics with threads or closures. (I haven’t actually figured those out well enough yet to write something like this for them!) As usual, you’ll want to have the src open to see what I’m doing with the components documented below. Links rustfmt – a tool for formatting Rust code repo “rustfmt-ing Rust` Reddit discussion RFC for incremental compilation Text of the RFC GitHub pull request

e001: Document All the Things

October 03, 2015 17:06 8.28 MB Downloads: 0

Document all the things! Subject: Documentation in general, and rustdoc and cargo doc in particular. Follow/Support New Rustacean: Twitter: @newrustacean App.net: @newrustacean Patreon Email: hello@newrustacean.com Chris Krycho Twitter: @chriskrycho App.net: @chriskrycho Notes This is a mostly-empty module, and it is intended as such. Why? Well, because almost all the sample code exists in these comments, which serve as the show notes. If you listen to the episode or take a look at the source files, you’ll see how it works! The components below are included solely so you can see how the docstrings work with each kind of thing. Make sure to click on the names of the items: there is more documentation there. Again, take a look at the source to see how it looks in the context of a file module. Note that this module-level docstring uses rather than `///`-style comments. This is because this docstring is documenting the item which contains it, rather than the following item. Per [Rust RFC 505][1], the preferred approach is always to use the "following" form (`///`) rather than the "containing" form (), except for module-level docs like these. (I will be following RFC 505 throughout.) Links Rust and MSVC tracking issue Other documentation tools: Predecessors: Python’s Sphinx tool Doxygen JSDoc JavaDoc Other new languages with Markdown tooling Julia has a built-in documentation system Elixir has ex_doc Rust 1.3 release announcement Rust’s package hosting: crates.io Crater for testing for backwards compatibility Semantic versioning “Stability as a Deliverable”: Rust official blog post on version stability, backwards compatibility, and release channels. The Rust book chapter on rustdoc

e000: Hello, world!

September 24, 2015 17:11 8.32 MB Downloads: 0

Hello, World! Subject: The host, the language, and the show! Today’s show is pretty meta. You can skip it if you just want to start with something more technical, but I thought listeners might want to know a little about the origins of the show and my own background, so that’s what you get today. Next time, we’ll be tackling the rustdoc command in some detail. This is an almost-empty module: we aren’t doing any fun code samples yet. I included the standard “Hello, world!” example, because how could I not? However, at some point in the future, there will be much more detailed code samples available: in the GitHub repository for the show in the show notes attached to each episode Hopefully, the result will be a pretty helpful bunch of side content along with the audio of the podcast itself.