Logo
    Search

    Rust for JavaScript Developers - Node vs Rust Concepts

    enJuly 31, 2023

    Podcast Summary

    • Comparing JavaScript and Rust ecosystems with a Pabst Blue Ribbon bottle and Red GreenExploring new programming languages and decorating a workspace can both be enjoyable and inspiring, even when seemingly unrelated topics are discussed.

      The Syntax team discussed the differences between JavaScript and Rust development ecosystems in a beginner-friendly way. Scott Talinski, a developer from Denver, shared his recent discovery of a large Pabst Blue Ribbon bottle at a yard sale and compared it to his office decoration dilemma. He then reminisced about the Canadian television show "Red Green," which he grew up watching and found hilarious. The show's wholesome and humorous skits, set at Possum Lodge, inspired Scott's vision for his office. Despite the seemingly unrelated topics, the conversation highlighted the importance of finding inspiration and creativity in unexpected places. Whether it's learning new programming languages or decorating a workspace, the process can be enjoyable and enlightening. So, keep an open mind and an eye out for unexpected discoveries – you never know what might inspire you next.

    • Discovering Hidden Gems and Unexpected FindsUnexpected treasures can be found in thrift stores, pawn shops, and even tech worlds, with significant value and unique stories attached.

      While exploring various shopping adventures, the speaker discovered unique items with significant value, often in unexpected places like thrift stores and pawn shops. One such find was a taxidermied animal, which sparked an intriguing story about the regulations and high demand for such items. However, the speaker eventually found a nicely mounted set of lake trout instead. Another surprising find was a high-end wooden rimmed Yamaha snare drum purchased for a fraction of its actual value at a pawn shop. In the tech world, the speaker discussed the comparison between Rust and JavaScript. A key difference lies in their respective package managers. In the JavaScript world, Node comes with NPM as the default package manager. On the other hand, Rust has Cargo as its package manager, which offers more than just dependency management. While NPM is an essential component of Node, Cargo plays a more significant role in the Rust ecosystem. As the speakers plan to explore Rust and JavaScript further in upcoming episodes, understanding these differences will be beneficial for those starting to learn Rust or wanting to compare the two languages.

    • Rust's Cargo: An All-in-One Solution for Managing and Building Rust ProjectsCargo is Rust's package manager, test runner, documentation generator, and build tool, configured with TOML, and supports publishing libraries to crates.io.

      In the Rust programming language, Cargo serves as an all-in-one solution for managing and building projects. It acts as the package manager, test runner, documentation generator, and build tool. The configuration file for Cargo is TOML (Tom's Own Markup Language), where dependencies and features are specified. Cargo also facilitates publishing libraries to the package registry, crates.io. Unlike other programming languages with multiple package managers, Rust's community primarily uses Cargo due to its tight integration and comprehensive functionality.

    • Rust's docs.rs: Functional and Code-HeavyRust's docs.rs offers functional and code-heavy documentation, generated directly from the code. It's flexible, quick to access, and mastering it enhances your ability to read and understand technical docs.

      Rust's documentation system, docs.rs, stands out for its functional and code-heavy style. Unlike some documentation on the web that might initially appear overwhelming to those coming from a JavaScript background, spending time learning to read and navigate this documentation will not only improve your understanding of Rust but also enhance your ability to engage with technical documentation in general. Rust's documentation is generated directly from the code itself due to Rust being a fully typed language. While writing comments using a markdown-like syntax, you can easily create documentation with examples and descriptions. The comments are less rigid than JSDoc, allowing for a more flexible approach. The documentation on docs.rs provides quick access to functions, methods, and structs, and even offers a copy-paste feature for ease of use. Although it may take some time to adjust to the style, mastering it will pay off in the long run.

    • Learning Rust for TypeScript developersRust's static typing, memory safety, and multi-threading capabilities make it an attractive alternative to JavaScript for TypeScript developers, offering improved documentation, better control, and predictability.

      Rust and TypeScript share similarities in their static typing systems, making Rust an excellent choice for developers looking to improve their TypeScript skills. Rust's static typing comes built-in, allowing docs and comments to merge, resulting in better-organized documentation. Additionally, Rust offers memory safety without garbage collection and supports multi-threading. While Rust's async await syntax might feel similar to JavaScript, it's essential to note that single threaded awaits remain single threaded. Rust's syntax can sometimes feel JavaScript-like but also have unique quirks, making the learning curve an intriguing challenge. Overall, Rust's static typing, memory safety, and multi-threading capabilities make it an attractive alternative to JavaScript for developers seeking more control and predictability in their projects.

    • Rust's error handling differs from JavaScriptRust uses pattern matching with match keyword for error handling, making it easier to manage compared to try-catch blocks in JavaScript.

      Rust's error handling approach differs significantly from languages like JavaScript. Instead of using try-catch blocks, Rust uses pattern matching with the match keyword. This method allows developers to check for errors or successful results in a function call and handle them accordingly. It's similar to the dot then and dot catch in JavaScript promises but not chained. Rust's error handling syntax is more top-level, making it easier to manage compared to the try-catch block's scope. This approach also makes Rust's error handling more similar to the error handling in callback-based systems. Additionally, Rust's syntax shares similarities with JavaScript, as shown in a simple "hello world" function. The match keyword in Rust is a more complex topic that could be explored further. Overall, Rust's error handling approach provides a more streamlined and manageable way to handle errors compared to other languages.

    • Rust's import syntax is more intuitive and efficientRust's import syntax lets you specify the package name first, followed by the sub-module and function or method, making it easier to use auto-completion and understand the import statement's structure.

      Rust's import syntax, which uses the "use" command followed by the package name and sub-module, allows for a more intuitive and efficient way of importing modules compared to JavaScript's import syntax. The speaker prefers Rust's syntax because it lets you specify the package name first, followed by the sub-module and the specific function or method you want to import. This order makes it easier to use auto-completion and understand the import statement's structure. The speaker also explains that Rust's import statements can look unusual to those accustomed to JavaScript's forward slash or dot notation, but they serve the same purpose: importing modules, sub-modules, or specific functions and methods. The speaker acknowledges that JavaScript's import tooling makes up for its less intuitive syntax, but expresses a preference for Rust's import syntax due to its order and structure.

    • Rust's double colon (::) for namespacing and accessing functions or methodsRust uses double colon (::) for namespacing and accessing functions or methods, while JavaScript uses period (.) for accessing properties or methods on instances. Rust's approach offers a more encapsulated learning experience.

      Rust's double colon (::) serves a similar function as JavaScript's period (.) but is used for namespacing and accessing functions or methods in Rust, whereas in JavaScript, everything is an object and the period is used for accessing properties or methods on instances. The Rust world uses the double colon to pull things out of a namespace, such as calling functions or static methods on things or accessing enum values. This is different from JavaScript where you would always use a period to access anything. Rust's approach offers a more encapsulated learning experience, with Cargo and Rust team resources providing a clear path for development, making it feel similar to TypeScript or JavaScript despite its initial intimidation.

    • Understanding Rust's complex type systemRust has a more complex type system than JavaScript with 13 base types, different array and map usage, and crucial differences in memory management and typing.

      While Rust and JavaScript share some similarities, there are significant differences in their foundational concepts. Rust, for instance, has a more complex type system with 13 different base types, including multiple integer and float types. Arrays and maps exist in Rust, but their usage and behavior differ from JavaScript. Understanding these differences, especially in areas like memory management and typing, is crucial for a smooth transition into Rust programming. In the next episode, we will delve deeper into types, structs, and variables in Rust, highlighting how they differ from JavaScript. Stay tuned for more insights into this exciting new world of programming. Don't forget to visit syntax.fm for the full archive of our shows and don't hesitate to subscribe or leave a review if you enjoy our content.

    Recent Episodes from Syntax - Tasty Web Development Treats

    790: State of JS 2023 Reactions

    790: State of JS 2023 Reactions

    Scott and Wes dive into the 2023 State of JavaScript survey, breaking down the latest trends and pain points in front-end frameworks, build tools, and JavaScript runtimes. Tune in for their hot takes and insights on what’s shaping the JavaScript landscape this year!

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    789: Do More With AI - LLMs With Big Token Counts

    789: Do More With AI - LLMs With Big Token Counts

    Join Scott and CJ as they dive into the fascinating world of AI, exploring topics from LLM token sizes and context windows to understanding input length. They discuss practical use cases and share insights on how web developers can leverage larger token counts to maximize the potential of AI and LLMs.

    Show Notes

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    CJ: X Instagram YouTube TwitchTV

    Randy: X Instagram YouTube Threads

    788: Supabase: Open Source Firebase for Fullstack JS Apps

    788: Supabase: Open Source Firebase for Fullstack JS Apps

    Scott and CJ chat with Paul Copplestone, CEO and co-founder of Supabase, about the journey of building an open source alternative to Firebase. Learn about the tech stack, the story behind their excellent documentation, and how Supabase balances business goals with open-source values.

    Show Notes

    • 00:00 Welcome to Syntax!
    • 00:30 Who is Paul Copplestone?
    • 01:17 Why ‘Supa’ and not ‘Super’?
    • 02:26 How did Supabase start?
    • 08:42 Simplicity in design.
    • 10:32 How do you take Supabase one step beyond the competition?
    • 12:35 How do you decide which libraries are officially supported vs community maintained?
      • 15:17 You don’t need a client library!
    • 16:48 Edge functions for server-side functionality.
    • 18:51 The genesis of pgvector.
    • 20:59 The product strategy.
    • 22:25 What’s the story behind Supabase’s awesome docs?
    • 25:26 The tech behind Supabase.
    • 35:46 How do you balance business goals with open source?
    • 42:01 What’s next for Supabase?
    • 44:15 Supabase’s GA + new features.
    • 48:24 Who runs the X account?
    • 50:39 Sick Picks + Shameless Plugs.

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    CJ: X Instagram YouTube TwitchTV

    Randy: X Instagram YouTube Threads

    787: You Should Try Vue.js

    787: You Should Try Vue.js

    Scott and CJ dive deep into the world of Vue.js, exploring what makes this frontend framework unique and why it stands out from React and Svelte. CJ gives a comprehensive tour, covering everything from getting started to advanced features like state management and Vue’s built-in styles.

    Show Notes

    Vue.js: The Documentary.

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    786: What Open Source license should you use?

    786: What Open Source license should you use?

    Scott and CJ dive into the world of open source, breaking down its meaning, benefits, and the various types of licenses you’ll encounter. From permissive licenses like MIT and Apache 2.0 to copy-left licenses such as GNU GPLv3, they’ll help you choose and apply the right license for your project.

    Show Notes

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    785: What’s Next for NextJS with Tim Neutkens

    785: What’s Next for NextJS with Tim Neutkens

    Scott and Wes dive into the world of Next.js with special guest Tim Neutkens from Vercel. They explore the latest updates, including the React Compiler and React Server Components, discussing their impact on developer workflows and the future of Next.js development.

    Show Notes

    • 00:00 Welcome to Syntax!
    • 00:30 What does the React Compiler do?
    • 05:04 Will React Compiler help with managing Context?
    • 06:39 What happens if you’re not using a React Compiler?
    • 09:30 Will this work on any NextJS version?
    • 12:18 What are React Server Components?
    • 16:28 Shipping all the data inside an encapsulated component.
    • 20:17 Clearing up the frustrations around retrofitting server components.
    • 23:13 Handing migration.
    • 28:30 Is this just a fetch request with props?
    • 36:41 How closely are the NextJS and React teams working?
    • 41:53 Will we ever get Async Client Components?
    • 43:52 Async Local Storage API.
    • 45:31 Turbopack.
    • 57:51 Sick Picks & Shameless Plugs.

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    784: Logging × Blogging × Testing × Freelancing

    784: Logging × Blogging × Testing × Freelancing

    In this Potluck episode, Scott and Wes tackle listener questions on modern blogging, website environmental impact, and using LangChain with LLMs. They also cover CSS hyphens, unit vs. integration testing, and balancing web development with new parenthood.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    783: How We Built a Netflix Style “Save for Offline” Feature Into Syntax

    783: How We Built a Netflix Style “Save for Offline” Feature Into Syntax

    Scott and Wes dive into the world of browser caching for audio files, exploring the File System API and the Cache API. They discuss size restrictions across different browsers, how tools like Riverside.fm leverage IndexedDB, and walk through code examples for creating, retrieving, and managing cached audio data.

    Show Notes

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott:X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    782: The Developer’s Guide To Fonts with Stephen Nixon

    782: The Developer’s Guide To Fonts with Stephen Nixon

    Scott and CJ are joined by Stephen Nixon of ArrowType to delve into the world of fonts and type for developers. They explore the intricacies of font creation, the utility of variable fonts, and offer tips for making visually appealing typography on the web.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott:X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    781: Potluck - The Value of TypeScript × Vue vs Svelte × Leetcode

    781: Potluck - The Value of TypeScript × Vue vs Svelte × Leetcode

    In this potluck episode of Syntax, Scott and CJ serve up a variety of community questions, from the nuances of beginner vs. advanced TypeScript to the pros and cons of SvelteKit. They also discuss falling out of love with React, shipping private packages via NPM, and the eternal struggle of always starting but never finishing projects.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott:X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    Related Episodes

    Dokumentacja w projekcie - Software Engineering at Google

    Dokumentacja w projekcie - Software Engineering at Google
    Wracamy z kolejnym odcinkiem, gdzie analizujemy temat z książki Software Engineering at Google. Tym razem bierzemy na tapet dokumentację w projekcie.

    Dyskutujemy:

    - czy rzeczywiście dokumentacja to pierwsza potrzeba w projekcie?
    - kiedy potrzebujemy dokumentacji?
    - kto powinien być odpowiedzialny za jej utrzymywanie?
    - jakie projekty szczególnie potrzebują dokumentacji?
    - jakie korzyści ma tworzenie dokumentacji?
    - czy możemy zmierzyć ROI z dokmentacji?

    Na te i wiele innych pytań staramy się odpowiedzieć w tym odcinku. Zapraszam do wysłuchania rozmowy na Spotify, Apple Podcasts, Google Podcasts i https://poprostujs.pl

    2022 Predictions

    2022 Predictions

    In this episode of Syntax, Wes and Scott talk through their predictions for 2022.

    LogRocket - Sponsor

    LogRocket lets you replay what users do on your site, helping you reproduce bugs and fix issues faster. It's an exception tracker, a session re-player and a performance monitor. Get 14 days free at logrocket.com/syntax.

    Hashnode - Sponsor

    Everything you need to start blogging as a developer. Own your content, share ideas, and connect with the global dev community! Hashnode is a free developer blogging platform that allows you to publish articles on your own domain and helps you stay connected with a global developer community.

    Hashnode: Everything you need to start blogging as a developer!

    Freshbooks - Sponsor

    Get a 30 day free trial of Freshbooks at freshbooks.com/syntax and put SYNTAX in the "How did you hear about us?" section.

    Show Notes

    ××× SIIIIICK ××× PIIIICKS ×××

    Shameless Plugs

    Tweet us your tasty treats

    675: Potluck × Bun Thoughts × Guesting on Syntax × Why Rust?

    675: Potluck × Bun Thoughts × Guesting on Syntax × Why Rust?

    In this episode of Syntax, Wes and Scott answer your questions about Bun, using custom auth headers, the difference between trpc, REST, or GraphQL, documenting your code, why learn Rust, and more!

    Show Notes

    Take the Syntax Survey

    Attend the Syntax Meetup Oct 10th in Toronto

    ××× SIIIIICK ××× PIIIICKS ×××

    Shameless Plugs

    Tweet us your tasty treats

    Rust for JS Devs — Part 2

    Rust for JS Devs — Part 2

    In this episode of Syntax, Wes and Scott jump into part 2 of their look at Rust for JavaScript developers, including variables in Rust, type systems in Rust, signed and unsigned integers, and more.

    Show Notes

    let x = 5;  // x is immutable let mut x = 5; // x is mutable const MAX_POINTS: u32 = 100_000; // must be defined at compile time 
    • 10:42 Type System in Rust
    • 15:52 Types in Rust
    • 19:06 Why does Rust have signed and unsigned integers?
    • 23:35 Slicing strings with &str
    • 27:35 enum
    • 27:55 struct
    • 28:19 Vec
    • 29:33 HashMap and HashSet
    • 33:00 Converting Signed to Unsigned Numbers
    let unsigned_value: u8 = 200; let signed_value: i8 = unsigned_value as i8; 
    • 36:12 What’s up with &str?
    • 43:31 Rust error messages
    • 45:28 What is a Struct?
    struct User {    username: String,     email: String,     sign_in_count: u64,     active: bool, }  // You can create an instance of a struct like this: let user1 = User {     email: String::from("someone@example.com"),     username: String::from("someusername123"),     active: true,     sign_in_count: 1, };  impl User {     fn login(&mut self) {         self.login_count += 1;     } } 
    • 49:17 SIIIIICK ××× PIIIICKS ×××

    ××× SIIIIICK ××× PIIIICKS ×××

    Shameless Plugs

    Tweet us your tasty treats

    Potluck — VSCode × Vercel vs Netlify × Models × Mutations × Multi-Vendor Platforms × Websites vs Web Apps × More!

    Potluck — VSCode × Vercel vs Netlify × Models × Mutations × Multi-Vendor Platforms × Websites vs Web Apps × More!

    It’s another potluck! In this episode, Scott and Wes answer your questions about VSCode, Vercel vs Netlify, staying up to date with dev concepts, models and mutations, websites vs seb apps, adaptive vs responsive design, and more!

    Freshbooks - Sponsor

    Get a 30 day free trial of Freshbooks at freshbooks.com/syntax and put SYNTAX in the “How did you hear about us?” section.

    Sentry - Sponsor

    If you want to know what’s happening with your code, track errors and monitor performance with Sentry. Sentry’s Application Monitoring platform helps developers see performance issues, fix errors faster, and optimize their code health. Cut your time on error resolution from hours to minutes. It works with any language and integrates with dozens of other services. Syntax listeners new to Sentry can get two months for free by visiting Sentry.io and using the coupon code TASTYTREAT during sign up.

    Vonage - Sponsor

    Vonage is a Cloud Communications platform that allows developers to integrate voice, video and messaging into their applications using their communication APIs. Whether you’re wanting to build video calls into your app, create a Facebook bot, or build applications on top of programmable phone numbers, you’ll have all the tools you need. Use promo code SYNTAX10 for €10 of free credit when signing up at vonage.dev/syntax.

    Show Notes

    02:10 - Sometimes in VSCode when intellisense tells us the TypeScript type of a variable, it just gives the name of the type rather than how the type is defined. This is annoying for objects as I want to know what fields it contains! How do you handle this? Is there some VSCode magic to make it show the full type definition or is there some way to bring up the definition in the .d.ts file?

    04:55 - What techniques do you guys use to keep different tech stack requirements fresh between projects?

    10:35 - How do you feel about Vercel vs. Netlify? Pros/cons? Thanks!

    18:32 - Should a model name be singular or plural?

    22:57 - I’ve just listened to the CSS Typography and Systems Hasty Treat, and realized that we often try to apply website design to web apps (me at least). Can you elaborate on the differences in designing for a website and for a web app?

    25:46 - What’s the difference between adaptive and responsive design?

    32:40 - Multi-vendor platforms? Have you done it before? A partner and I, are planning to build a peer-2-peer platform (similar to Etsy and Amazon, where users can register as a merchant or a buyer). What is the easiest way to make payment transactions (Stripe or PayPal)? Do you know any frameworks that will make my life easier?

    36:16 - Is there a golden rule for mutations? I’ve been using GraphQL for last couple of months, and everything is great as long as I’m just fetching data. When I need to write mutations, the story gets murky. Looking around internet, there are not too many best practices to be found - most of the articles and blogs focus on data fetching.

    42:19 - What do you think about the future of Svelte? I know they are replacing Sapper with SvelteKit, which uses Snowpack. What direction do you think Svelte will go in?

    45:32 - How can I get back into a habit of learning new things and stop heavily relying on video tutorials all the time? I really struggle to sit down and read for long periods of time. Also have you guys came across the Genesis framework, and if so, could you recommend any learning material? Thanks.

    48:54 - My team uses handlebars templates for generating newsletters. The content is coming from a CMS for generating final HTML. I’m fairly new to handlebars and mustache syntax, so instead of learning handlebars I’m thinking about using React to generate the html on server side. I see some great potential here as the entire team is well-versed with React. What is your opinion about this?

    Links

    ××× SIIIIICK ××× PIIIICKS ×××

    Shameless Plugs

    Tweet us your tasty treats!