Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rust in Metal Fabrication

Avatar for Taiga Merlin Taiga Merlin
November 07, 2020

Rust in Metal Fabrication

Selecting a programming language has far-reaching implications for any development team, affecting everything from new employee training to system architecture. As a team developing enterprise software in the metal fabrication industry in Japan, we were drawn by the Rust type system and its ability to represent complex domain models. However, managing and growing a technical team around the Rust language has not been without its challenges. In this talk, we look forward to sharing some of our experiences building enterprise applications in Rust.

Avatar for Taiga Merlin

Taiga Merlin

November 07, 2020
Tweet

More Decks by Taiga Merlin

Other Decks in Programming

Transcript

  1. Agenda - Overview - What is metal fabrication? - Enterprise

    software in metal fabrication - Rust in enterprise software - Technical aspects - Non-technical aspects
  2. Enterprise software in metal fabrication Design Purchasing Manufacturing Logistics -

    CAD 3D modeling - Simulation tools - Version control - Buy raw materials - Approval workflows - Integration with accounting system - Scheduling workers and machines - Manufacturing planning system - Ensure traceability - Track inventory - Track delivery
  3. Enterprise software in metal fabrication Design Purchasing Manufacturing Logistics -

    CAD 3D modeling - Simulation tools - Version control - Buy raw materials - Approval workflows - Integration with accounting system - Scheduling workers and machines - Manufacturing planning system - Ensure traceability - Track inventory - Track delivery
  4. Enterprise software in metal fabrication Design Purchasing Manufacturing Logistics -

    CAD 3D modeling - Simulation tools - Version control - Buy raw materials - Approval workflows - Integration with accounting system - Scheduling workers and machines - Manufacturing planning system - Ensure traceability - Track inventory - Track delivery - Streamline workflows - Enforce data integrity policies - Track flow of physical goods and money
  5. Agenda - Overview - Technical aspects - Domain driven design

    with Rust - Impressions of the library ecosystem - Non-technical aspects
  6. Domain driven design with Rust - Enums are amazing -

    Markers for compile time data type checking
  7. Enums are amazing enum PaintColor { RGB(u8, u8, u8), CMYK(u8,

    u8, u8, u8), PhysicalColorSample, } fn handle_paint_color(color: &PaintColor) { match color { PaintColor::RGB(r, g, b) => { } PaintColor::CMYK(c, m, y, k) => { }, // PhysicalColorSample => { } ⇐ uncommenting will fix E0004 compile error } }
  8. Markers for compile time data type checking #[derive(Clone, Debug, PartialEq,

    Eq)] pub struct Money<T> { amount: Decimal, currency: PhantomData<T>, }
  9. Markers for compile time data type checking #[derive(Clone, Debug, PartialEq,

    Eq)] pub struct Money<T> { amount: Decimal, currency: PhantomData<T>, } pub enum JPY {} pub enum USD {}
  10. Markers for compile time data type checking #[derive(Clone, Debug, PartialEq,

    Eq)] pub struct Money<T> { amount: Decimal, currency: PhantomData<T>, } pub enum JPY {} pub enum USD {} fn main() { let jpy_1 = Money::<JPY>::new(Decimal::new(1, 0)); let usd_1 = Money::<USD>::new(Decimal::new(1, 0)); let result = jpy_1 + usd_1; // Compilation error! }
  11. Markers for compile time data type checking #[derive(Clone, Debug, PartialEq,

    Eq)] pub struct Money<T> { amount: Decimal, currency: PhantomData<T>, } pub enum JPY {} pub enum USD {} fn main() { let jpy_1 = Money::<JPY>::new(Decimal::new(1, 0)); let usd_1 = Money::<USD>::new(Decimal::new(1, 0)); let result = jpy_1 + usd_1; // Compilation error! } error[E0308]: mismatched types --> src/main.rs:153:27 | 153 | let result = jpy_1 + usd_1; | ^^^^^ expected enum `JPY`, found enum `USD` | = note: expected struct `Money<JPY>` found struct `Money<USD>`
  12. Impressions of the library ecosystem - Good: high quality coverage

    across our needs - RabbitMQ: lapin - Redis: r2d2_redis - PostgreSQL: diesel, sqlx - gRPC: tower-grpc/tonic
  13. Impressions of the library ecosystem - Good: high quality coverage

    across our needs - RabbitMQ: lapin - Redis: r2d2_redis - PostgreSQL: diesel, sqlx - gRPC: tower-grpc/tonic - Wish: examples of production use cases - “production ready” can be subjective - “[real world product] is using [library name]” adds concreteness - eg: started using tower-grpc because linkerd was successful with it
  14. Impressions of the library ecosystem - Good: high quality coverage

    across our needs - RabbitMQ: lapin - Redis: r2d2_redis - PostgreSQL: diesel, sqlx - gRPC: tower-grpc/tonic - Wish: examples of production use cases - “production ready” can be subjective - “[real world product] is using [library name]” adds concreteness - eg: started using tower-grpc because linkerd was successful with it - Wish: async/await guidance
  15. Agenda - Overview - Technical aspects - Non-technical aspects -

    Hiring talent - New engineer training - Managing and sharing knowledge - Community work
  16. Hiring talent - Deciding what qualities to look for in

    a candidate - Familiarity with a type system resembling traits/generics (Java, Haskell, TypeScript, etc) - Familiarity with notions of functional programming - Familiarity with computer architecture and memory management (C, C++) - Creating a meaningful job description - From a recruitment perspective, Rust is certainly a distinguishing factor - Providing enough information to understand the enterprise domain
  17. New engineer training - Supporting (re)learning of foundational concepts (memory,

    etc) - Utilizing community resources (many in Japanese as well!) - Self-learning through conversations with the compiler - Acknowledging when Rust is not the best choice
  18. Managing and sharing knowledge - Critical mass of Rustaceans motivated

    to share new learnings - Creating a Rustacean community within the development team - Fostering culture of staying up to date
  19. Community work - Success of the community contributes to the

    success of the business - As corporations, it is important that we participate in the community - In this pandemic, CADDi started shitamachi-rs in collaboration with LayerX
  20. Closing words on Rust in metal fabrication - Technical aspects

    - Rust is a great language for developing enterprise software for complex domains - Library ecosystem maturity can be difficult to gauge - Non-technical aspects - A different kind of effort is required for hiring and training - The friendly and welcoming community is wonderful - Let’s share real world use cases of Rust and support the Rust community