Compiler-Driven Development in Rust

Compiler-Driven Development in Rust, including TDD, CDD, and the Typestate Pattern.
Today's sponsor: Quadratic, check them out at www.quadratichq.com
When I write a new Rust program, I don't start with functions or methods or any runtime code. I start with the model of my application, expressed with Rust's rich type system.
Interacting with the real-world, on disk or through the network is too slow for me, at first, I need to iterate faster than that, to sketch out my ideas, unconstrained by the outside world.
This compile-checked whiteboarding I call Compiler-Driven Development.
❤️ If you would like to support what I do, I have set up a patreon here: / noboilerplate - Thank you!
📄 All my videos are built in compile-checked markdown, transcript sourcecode available here github.com/0atman/noboilerplate this is also where you'll find links to everything mentioned.
🖊️ Corrections are in the pinned ERRATA comment.
🦀 Start your Rust journey here: • How to Learn Rust
👕 Bad shirts available here www.teepublic.com/user/no-boi...
🙏🏻 CREDITS & PROMO
My name is Tris Oaten and I produce fast, technical videos.
Follow me here tech.lgbt/deck/@noboilerplate
Website for the show: noboilerplate.org
Come chat to me on my discord server: / discord
If you like sci-fi, I also produce a hopepunk podcast narrated by a little AI, videos written in Rust! www.lostterminal.com
If urban fantasy is more your thing, I also produce a podcast of wonderful modern folktales www.modemprometheus.com
👏🏻 Special thanks to my patreon sponsors:
- Jaycee,
- Gregory Taylor,
- Ything LLC
And to all my patrons!

Пікірлер: 374

  • @NoBoilerplate
    @NoBoilerplate10 күн бұрын

    ERRATA - Sorry about my voice in this video, I've delayed publishing for a month due to getting over Covid, and I simply can't wait any longer! I am totally fine (got all vaccines), but my voice is still croakier than I'd like! - 'Geocache' is missing the final 'e' in example 1. - 9:20 I LOVE Red Means Recording, Jeremy's videos have been an inspiration to me as a musician and video maker for years! In addition to the pinned video at this timecode, I made a few 'RMR'-style videos, my favourite of this is my cover of Love on a Real Train: kzread.info/dash/bejne/iWWhx8eqgbW4Yps.html - Do check the markdown source for all links, butthe typestate pattern article is here cliffle.com/blog/rust-typestate/ - 8:56 variants is misspelled (and likely in other places too, freakin' schwas ruining my day!)

  • @RenderingUser

    @RenderingUser

    10 күн бұрын

    Days since last errata: 0

  • @kyay10

    @kyay10

    10 күн бұрын

    "(got all vaccines)" hopefully you got super-autism now!!!

  • @kveonlichman2917

    @kveonlichman2917

    10 күн бұрын

    8:56 variants is misspelled

  • @Jianju69

    @Jianju69

    10 күн бұрын

    Nobody notices your voice is slightly different.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    It's actually the other way around, autism causes vaccines! Here's my video on autism btw: kzread.info/dash/bejne/dpyNlciuXbzNeLg.html

  • @annotated_
    @annotated_10 күн бұрын

    My headcannon is that every video on this channel are just snippets of Seth rambling about random topics to his friends.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Funny story, that's *ALSO* half of what Lost Terminal is! (have you heard about this engine that burns Iron? Or this cool story from the early internet? or about this weird amateur radio trick? etc!)

  • @half_invisible

    @half_invisible

    10 күн бұрын

    ​@@NoBoilerplate Great show! I've been enjoying it! Just wanted to let you know that the recap section on the website is two seasons out of date (well, three if you want to recap season 16 before it's released ;D).

  • @RustyNova

    @RustyNova

    10 күн бұрын

    ... And the shampoo bottles

  • @ved_s

    @ved_s

    10 күн бұрын

    In the alternate timeline, where Seth knows Rust

  • @sunofabeach9424

    @sunofabeach9424

    9 күн бұрын

    to his colleagues on company time

  • @qexat
    @qexat10 күн бұрын

    "When you think about it, tests and types are similar" next step is having an embedded proof assistant DSL in Rust and it will unify the two :D

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    ugh, I'd LOVE that! Excitingly, it's absolutely possible to do so, someone just has to write a complex enough macro! (deptypes has the right idea: lib.rs/crates/deptypes)

  • @qexat

    @qexat

    10 күн бұрын

    @@NoBoilerplate My reply got deleted (probably because of links) but there is also an interested project - based on a paper - called RefinedRust!

  • @lorenzn5601

    @lorenzn5601

    9 күн бұрын

    @@NoBoilerplate There is also prusti which has pretty good tooling (which is a problem I usually have with most for research software)

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    oh cool! What makes me excited is that whatever is built can be written as simple libraries using the macro system!

  • @vasilvass

    @vasilvass

    7 күн бұрын

    ​@@qexatKani would be quite close to that

  • @dronicx7974
    @dronicx797410 күн бұрын

    I've been subconsciously doing CDD the entire time I've beed doing Rust. Before learning Rust, I worked with Typescript wayyy too much and from there I subconsciously learned to let the type system handle a lot of runtime checks. In TS land, this doesn't help (hence my many frustrations with TS) because the types are literally a facade. Rust actually not letting you run a program until you fix ALL type issues beforehand and Rust having an extremely complex and easy to use type system is what makes CDD viable and enjoyable in it. I highly doubt CDD in many other compiled languages would be as fun and model-asserting as Rust.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    RIGHT! Rust Doesn't have features that other languages dont, but it makes them coherant and MANDATORY!

  • @nicholas_obert
    @nicholas_obert9 күн бұрын

    One thing to always keep in mind, and I'm guilty too sometimes cause I'm lazy, don't ever push your code assuming it's sound just because it compiles. Logic errors are always behind the corner and hiding under the carpet. This is why tests are also a good practice. For large projects it may be worth the effort to create a rich development environment with automatic testing tools specific to the job

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Totally agree. For me, CDD is the whiteboard, TDD is the prototype, and functional testing gets you to production. But you must START with CDD 😀

  • @69k_gold
    @69k_gold10 күн бұрын

    What I love about Rust is the compiler gives so many errors that, once we are done fixing our mistakes, there's no room for bugs, unless our logic was wrong in the first place

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    if it compiels, it works!

  • @NickAc
    @NickAc10 күн бұрын

    loved the Red Means Recording reference!

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Jeremy's a great guy!

  • @tserhey

    @tserhey

    9 күн бұрын

    This wasn’t a connection I was expecting, but I can’t say I’m disappointed! 😊

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    I mean, I'm much poorer (financially) because of how much I love his channel, but I'm rich in synthesisers 😀

  • @NickAc

    @NickAc

    9 күн бұрын

    @@NoBoilerplate haha, that's the spirit!

  • @twenty-fifth420
    @twenty-fifth42010 күн бұрын

    "I want to roll for a new boilerplate upload.' "Roll it." "Nat 20." 🗿

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    I'm sorry it's taken so long! RSI is a hell of a thing - I'm on the road to recovery finally :-)

  • @twenty-fifth420

    @twenty-fifth420

    10 күн бұрын

    @@NoBoilerplate For better or worse, I stopped keeping up with code tubers since I have been on my own project (fantasy console) and writing for a novel. I have reached the point where my code feeds into my writing and vice versa lol. Plus, glad to see you recovered

  • @raphaeld9270

    @raphaeld9270

    9 күн бұрын

    @@NoBoilerplate Hopefully you have a more ergonomic setup. Not sure about you, but switching to a split keyboard with a vertical mouse in the middle of the two halves helped me a lot when I began developing wrist pains. Oh, and good wrist rest pads too.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    many thanks for the tips! my stupid self-imposed 16-hour days gave me RSI even using a split kb and mouse! oops! breaks saved me!

  • @mysterry2000
    @mysterry200010 күн бұрын

    Oh man you're finally back! Imma grab my popcorn and enjoy you tell us the best things about Rust 🍿 Thanks for being with us!

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    I'm sorry it's taken so long! RSI is a hell of a thing - I'm on the road to recovery finally :-)

  • @mysterry2000

    @mysterry2000

    10 күн бұрын

    @@NoBoilerplate Nah dw about it! Whether it's you taking a break or you gifting us a video, all of us are glad you're here either way 😁 Loved the video btw! the TypeState pattern literally had me going all 🤩

  • @b_dawg_17
    @b_dawg_1710 күн бұрын

    Every new pattern or feature of Rust I learn from these videos feels like a glimpse into the future of programming. This feels like what programming should feel like, and it's incredibly satisfying.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Thank you! This is why I can't *not* make these videos raving about this language. and it's #19th most popular in the world! YOU CAN GET PAID TO WRITE THIS!

  • @jofla

    @jofla

    8 күн бұрын

    You know there are lots of languages that already achieve the same? Rust is not discovering "CDD" and some could argue that is not the best at doing it too

  • @b_dawg_17

    @b_dawg_17

    8 күн бұрын

    @@jofla I honestly don't know of any. Do you have any examples?

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    I don't need Rust to be the best at it. I'd be writing Haskell or another ML language if I cared about 'best'. I want my language to be popular and powerful. Go is the former, Haskell is the latter, Rust is both. redmonk.com/rstephens/2024/03/08/top20-jan2024/

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    My assumption is that they assume compiled languages are all the same, which is reasonable if you've not tried an ML or Haskell style type system before!

  • @VimCommando
    @VimCommando10 күн бұрын

    This is such an amazing pattern I stumbled into last week. When refactoring Rust code, like changing the return type or number of arguments to a function, the compiler immediately tells you the exact location of each breaking change you need to fix. It is awesome 🤩

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    The compiler is so helpful!

  • @infernussynek6439
    @infernussynek643910 күн бұрын

    You are one of the fewest (if not any) people on KZread i watch immediately any new video i see. Thank you for doing good work and for the spark of the unusual your channel carry compared to the copy-paste, soulless corporate content so abundant on KZread.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Thank you so much, I really appreciate you saying so ☺️

  • @RenderingUser
    @RenderingUser10 күн бұрын

    bro finally uploaded, and within just two monthly polyphasic sleep cycles

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    RSI + Covid are a hell of a thing to get at once! Both getting better :-D

  • @RenderingUser

    @RenderingUser

    10 күн бұрын

    @@NoBoilerplate no way. you got covid after all the covid hype ended?

  • @hanifarroisimukhlis5989

    @hanifarroisimukhlis5989

    9 күн бұрын

    @@RenderingUser Looking the other way doesn't magically make the virus disappear. (That's kinda why i still put precaution till this day)

  • @rantingrodent416

    @rantingrodent416

    9 күн бұрын

    @@RenderingUser Yeah unfortunately the actual virus is unaware of its hype status and continues to do its thing despite how hard we're trying to pretend it isn't.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    The good news, if my personal experience is anything to go by, the trend for plague viruses to get less deadly and more contagious certainly seems to be the case with the variant I got. I almost didn't notice it for the last 3 weeks, unless I did anything strenuous on that day (then I'd be strangely tired)

  • @Leafygreens48
    @Leafygreens4810 күн бұрын

    THE BROTHER DROPPEDDD!!!!!! 🐐🐐🐐🐐

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Rumours of my death have been greatly exaggerated :-P

  • @TheFireMage100
    @TheFireMage100Күн бұрын

    This might be the most complicated yet subtle No Boilerplate video Ive seen, or maybe I just havent had enough coffee yet. Definitely glad for the .md documents because I can tell pouring over those is going to be very useful

  • @dylancode
    @dylancode10 күн бұрын

    Rust's compiler is honestly just so great. I really hate the move towards dynamically-typed and interpreted languages like Python - you sacrifice so much and gain so little. Keep up the excellent videos!

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    There's a killer feature for interpreted language - state preservation between code changes. The browser and how you use python for ML are two HUGE applications. But yes, if you don't need a long-running interpreter, it's time for Rust!

  • @jordixboy

    @jordixboy

    10 күн бұрын

    you gain so little? meh I think then you dont actually what you are talking about.

  • @red_roy

    @red_roy

    10 күн бұрын

    different languages are best for different applications. python is the second best for all applications ;)

  • @papakamirneron2514

    @papakamirneron2514

    10 күн бұрын

    @@red_roy What's n°1? Haskell?

  • @donaldtrump2

    @donaldtrump2

    10 күн бұрын

    @@red_roy you just contradicted yourself with your second sentence.

  • @sambazeley5366
    @sambazeley536610 күн бұрын

    This channel is incredible. Thank you so much! I feel like my rust code gets better every time I watch one of these

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Thank you! Heh, my code gets better every time I make one of this videos!

  • @funkdefied1
    @funkdefied110 күн бұрын

    I love this. This is the truth that I’ve learned through intuition and experience, but that I never had words for it.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Thank you! It's so hard to put these kinds of ideas into simple terms, if I had more time, the video would have been shorter :-D

  • @computerfan1079
    @computerfan107910 күн бұрын

    Get better soon Triss! Your quality just keeps on being great, incredable work!

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Thank you so much! Regular breaks are the core of my recovery!

  • @spr3ez
    @spr3ez10 күн бұрын

    Gotta love it when you release a new banger

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Thank you!

  • @RolandHaller
    @RolandHaller8 күн бұрын

    I practice ADD Attention Driven Development. Basically I follow my fancy until I get to a state that does not motivate me anymore. Once again great video.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Thank you so much! Also, you should check out my adhd video 😅

  • @kira.herself
    @kira.herself10 күн бұрын

    the typestate pattern is really really cool and I want to see it being used more, I wish the language had a more streamlined way to write those tho

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    There's always way to improve things, certainly, but it's the best language for concisely expressing the typestate pattern that I have seen!

  • @RustyNova

    @RustyNova

    10 күн бұрын

    I could see having a derive macro that would automatically generate the states. You would define all the states and content using an enum, and it would generate from it. For the impls I don't know enough to tell how, but a simple attribute above a function to filter only some states could be great.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Yeah, a simple macro would do it. That'd be cool. My Light example is the absolute simplest I could boil it down to - using it with traits (as the Cliffle article shows) is the best way to do it, and there's a bit more boilerplate there. some work has begun already lib.rs/crates/typestate

  • @kintrix007

    @kintrix007

    9 күн бұрын

    How about Haskell, though? What I love about Haskell is that the compiler can actually ensure that the only valid type parameter you can apply to Light are On and Off. The equivalent of Light would be a compiler error.

  • @hanifarroisimukhlis5989

    @hanifarroisimukhlis5989

    9 күн бұрын

    @@kintrix007 In that case, you can't actually *make* Light because the new() method is only defined for Light I mean, you _can_ declare a variable/field of having that type. But you can't actually assign anything to it, making it practically useless.

  • @greyw0lv
    @greyw0lv10 күн бұрын

    I really enjoy your videos, because of you i dipped my toe into rust between semesters last spring. I should have more free time soon to properly make something with rust.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    So exciting! Make sure to run `bacon clippy` while you code 😀

  • @terraria9934
    @terraria993410 күн бұрын

    you have single handily convinced me to try and learn rust

  • @holonaut

    @holonaut

    9 күн бұрын

    let us know how it went

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    this is the way!

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    MISSION ACCOMPLISHED! So excited for you, here's my video on how I recommend learning it: kzread.info/dash/bejne/ZJyMsMZvqJzZitY.html

  • @kellybmackenzie
    @kellybmackenzie10 күн бұрын

    Awesome video! Haskell's abd Rust's amazing type systems have made CDD the norm for me too. It feels awesome!

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    SUCH a comfortable way of living!

  • @kamalhm-dev
    @kamalhm-devКүн бұрын

    That type state pattern is interesting! cant wrap my heads around implementing it in real projects though, definitely need more examples

  • @RulerOfCakes
    @RulerOfCakes10 күн бұрын

    Bravo. Yet another fantastic video on Rust! I really wish I could use the typestate pattern as elegantly in other languages as well.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Thank you very much! Certainly, you can still use the pattern, not as elegantly at all :(

  • @jumbledfox2098
    @jumbledfox209810 күн бұрын

    NEW RUST VIDEO YEAH! I love rust sooo much, thanks for all the brilliant videos :3

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Thank you! I'm a big fan too! If you can believe it :-D

  • @CollinWilliams-by5cs
    @CollinWilliams-by5cs8 күн бұрын

    Another one hit it out of the park. I would never have fallen in love with Rust if not for this channel. Please keep making videos, Tris! ❤

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Thank you so much, that's really nice of you to say! There's not SO much left I want to say about Rust, but I'll certainly keep raving about features I love as I find them!

  • @hanifarroisimukhlis5989
    @hanifarroisimukhlis59899 күн бұрын

    That's exactly what i do with new Rust projects: 1. Write out all the prototype code 2. Hit compile (almost always error) 3. Refactor until pass 4. Add extra feature (clap, log, config, etc) It's insanely efficient. Since i already have the model inside my head, all i need is type the code and the compiler will make sure it's semantically correct. No worry about logic error, i already thunk about edge/corner cases, validation, etc. And if any is missed, simple unit test or (in extremely complex case) fuzzing will do the rest.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    This is my workflow too - CDD, TDD, Feature Tests, Production, Forget about it for 4 years because it's done. I LOVE writing rust code so much for this exact reason.

  • @wybewestra7050

    @wybewestra7050

    8 күн бұрын

    Ooh, can concur on the "forget about it, because it will work.". One year ago I cobbled together an rss/atom feedreader server with a web frontend. Both in rust. It has been running flawlessly on my raspberry pi ever since, and I use it every day. I wouldn't thrust code I write in python or c++ to do the same 😄.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    I love how you can just build stuff and then move ON! (I might have done a video on this topic!)

  • @ahuman32478
    @ahuman3247810 күн бұрын

    I was wondering if you could make a video discussing how to shift from OOP-oriented thinking to whatever system works best with Rust. I've watched your "Rust data modeling with enums" (or whatever it's called) video, but I don't really think it shows what to use instead of OOP, rather it just shows how useful enums are. OOP structured programs have a graph-like structure, and it's pretty difficult to implement graph-like data structures in Rust. Glad you've had a smooth recovery from Covid, and excellent Rust video as usual

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Re-watch that video, the part that allows the graph-like thinking you hope for is the normalisation section. Think of it as tables in a database, not animal genetics. It took me a long time to unlearn OOP, python helped me, Haskell was revolutionary, Rust finished my path ☺️

  • @ahuman32478

    @ahuman32478

    9 күн бұрын

    @@NoBoilerplate Alright. By the way, when I talk about "graph-like structures", I'm not referring to inheritance, I know that it's bad. Rather, I'm talking about the ability to have different objects directly referenced by various others as many times as you want. In Rust, you can only have one owner of a (mutable) reference normally to ensure program validity, but it's very limiting. I'm trying to program a transportation network where it would be nice to have one object be owned multiple times, but solutions like Rc make the program look ugly and much more complex. I assume Rust is purposely designed this way to discourage the patterns I was using. To avoid this, I decided to assign items IDs and created connections between transportation sites using their IDs rather than direct references. Is this in line with what you were trying to communicate in your video? Thanks

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    I think you're on the right path, here's how to fix your complexity issue - abstraction. Use Rc for the plumbing of your code, but abstract that complexity through layers of your code. Imagine a web server like Actix or Rocket or Axum. You better believe they're using some GNARLY clever stuff behind the scenes, but I as the web developer never see that, because they've abstracted it away from me, as they damn well should. unsafe abstracts pointer access, String abstracts bytes - to program is to compose layers of abstraction. Refactor with that in mind, and you'll find your solution. Same as in any language, I bet! Good luck - come ask for help in my discord if you need it, there are far smarter folks than I there ☺️

  • @dylancode
    @dylancode10 күн бұрын

    Who on earth would dislike this video?! C++ and Python developers worried about their career, maybe?

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    I imagine Python - the #1 language in the world - will be around for a while! Especially if they use github.com/PyO3/pyo3

  • @dylancode

    @dylancode

    10 күн бұрын

    @@NoBoilerplate I hadn't heard of pyo3 actually, thanks for the info!

  • @vidal9747

    @vidal9747

    10 күн бұрын

    I really don't get the rate. Python is a good enough interpreted language. Rust is a compiled language. They are totally different things. I like both. I will not be making my plots in Rust for a single use application. I don't need to fight with the compiler for plotting some data and formatting it well. Single use scripts are much better in Python. Large projects can become an unmaintainable mess. That is why Rust is better. Stop being monogamous with your programming languages.

  • @dylancode

    @dylancode

    9 күн бұрын

    @@vidal9747 Absolutely! The comment was a joke, but Python is definitely better for throwaway scripts (and I often use it for that).

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    15-years of writing python here - it's the most popular language in the world for a REASON! There's lots of applications I would not use it for any more, but there's still plenty I *would*!

  • @geeshta
    @geeshta6 күн бұрын

    The typestate pattern is exactly what I have been looking for! I have an immedieate use for it!

  • @geeshta

    @geeshta

    6 күн бұрын

    It reminds me of "Literal" types in TS or Python which I like to abuse a lot

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    extremely cool! This kind of lightweight dependent types is so handy. There's some work on it in the Rust ecosystem, and I'm excited that when they are ready, they'll be a simple macro away from integrating with my exisint code!

  • @CrIMeFiBeR
    @CrIMeFiBeR7 күн бұрын

    I don't like writing unit tests, because they go out of date, models change we needed to get 100% coverage for the build pipeline, so it was some stupid tests that didn't test what they needed to. But man, I love the compiler and errors in there, I am all for CDD

  • @GreeneThumbs
    @GreeneThumbs8 күн бұрын

    I completely agree with this. I practice and advocate for type-driven development with TypeScript on my team.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    when I must code js, I write typescript - the correct default 👌

  • @stevenbroshar7948
    @stevenbroshar79489 күн бұрын

    A stop sign is similar to a fire truck. Both made of metal, for safety and red in color.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    what do you mean?

  • @itsmeagain1415
    @itsmeagain14158 күн бұрын

    I think I've seen this typestate pattern used in some of the more elegantly crafted C++ libraries I've seen! and tbh I've seen it in some places in the standard library too, but that monstrousity has nothing more going for it in this regard

  • @greasedweasel8087
    @greasedweasel808710 күн бұрын

    Love the video! I’ve always maintained that rustc is a greater asset to the language than any individual Option or #[proc_macro] could ever be. A mild nitpick is in the comment on the slide beginning at 8:41, you have varients (e), instead of the correctly spelled variants (a)

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Thank you, added to the errata pinned comment

  • @haraldbackfisch1981
    @haraldbackfisch19819 күн бұрын

    "Compiler-checked whiteboarding" - thanks ill steal that

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    yoink! Just be sure to send folks my way 😉

  • @haraldbackfisch1981

    @haraldbackfisch1981

    6 күн бұрын

    @@NoBoilerplate but of course, also without stealing anything.. thanks for ur output :)

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    Pleasure, it's all public domain ☺️

  • @somefrenchguy2091
    @somefrenchguy209110 күн бұрын

    I'm so happy to have a new video from you, my RSS feed needed the update

  • @half_invisible

    @half_invisible

    10 күн бұрын

    Woah, you have RSS for no boilerplate uploads? How would I set that up? Thanks :)

  • @somefrenchguy2091

    @somefrenchguy2091

    10 күн бұрын

    @@half_invisible I have a Nextcloud instance hosted on my HomeServer and the included RSS app can just take the link to a YT channel :) I believe most RSS aggregator are able to do it

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    I use miniflux for that! RSS is truly wonderful. Aaron Schwartz left us a wonderful gift and did not deserve what happened to him 💔

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    most rss readers can subscribe to youtube channels, RSS rules!

  • @Zylak77
    @Zylak778 күн бұрын

    Thank you for all your videos man! You continuously inspire me to be a better developer. Can't thank you enough!

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    my pleasure!

  • @fuzzy-02
    @fuzzy-027 күн бұрын

    "So, at what time do you live? I'm alive past midnight in the clubs" "I live at compile time." "Oh? And how many did you 'compile'? Heheh" "Well, there was this beauty last night..." "And?" "Well... when I compiled I got an error not found..."

  • @codingblade2634
    @codingblade263410 күн бұрын

    You are just too good at talking. Love you.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Thank you! if you want HOURS MORE I'm half-way through season 16 of my audiofiction podcast, Lost Terminal: kzread.info/dash/bejne/omeWpqdym9bgfcY.html I'd love to know what you think!

  • @drawtree
    @drawtree6 күн бұрын

    Consider compiler as a sort of assistant AI. Which never hallucinates, always correct, catches all of your mistakes, sometimes even suggests improvements.

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    rust and languages like it are so good to use with ai tools like copilot because of the extra context they give to the LLM, and the extra confidence they give to me in inspecting what my 1000 clueless interns have written for their group project today 😀

  • @Turalcar
    @Turalcar8 күн бұрын

    1:50 We actually do run servers with debug symbols in production and, in case of Rust, with RUST_BACKTRACE=1 (although, I think it's been about a year since I last saw a stacktrace in production).

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    You're welcome to do what you like there, of course! There's quite a bit of granularity, not just debug/release - make sure you're getting the right mix of fast execution and debugability. I'd also prefer instrumentation (perhaps with tracing) to relying on stacktraces.

  • @meyou118
    @meyou11810 күн бұрын

    love the take, thx... yeh if it compiles pretty sure it works! (rust reminds me a lot of scala, without the JVM! - which is a good thing)

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Ah Scala, my first love. Can you believe they dropped XML literals from the base install? Short sighted that is. Rust has that feature as a macro! Love that. I talk about rust vs scala in this video, btw: kzread.info/dash/bejne/qKOGpLVpoperqaw.html

  • @johanngambolputty5351
    @johanngambolputty53518 күн бұрын

    TDD kinda reminds me of generative adversarial NN's, where you have a generator and a discriminator each having the goal of catching out the other, self adversarial programing if you will.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    interesting!

  • @Turalcar
    @Turalcar8 күн бұрын

    10:34 First time I implemented typestate pattern was before I knew what it was called. I was generating C++ builders with a bitmask template parameter for required fields so that build() would only compile when all required fields are set. Most examples in Rust taught that this could be vastly simplified if I enforced the order of required fields.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Great minds!

  • @iamacar1017
    @iamacar101710 күн бұрын

    yooo new boilerplate

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    :-D

  • @MrVanshajSaxena

    @MrVanshajSaxena

    10 күн бұрын

    No boilerplate

  • @huxleyleigh4856
    @huxleyleigh48564 күн бұрын

    The typestate pattern seems similar to dependent type theory. In the programming language Idris2 that uses dependent type theory directly you can do proof driven development :)

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    Yeah! dependent types are SO cool, there are a few rust crates starting down this road. One of the features I love about Rust is because you have a macro system, you can just build in dependent types natively, and the become a first-class feature os this popular language: lib.rs/crates/deptypes

  • @huxleyleigh4856

    @huxleyleigh4856

    3 күн бұрын

    ​@@NoBoilerplate I just finished my first year of studying computer science at uni and really enjoyed the predicate logic. From there I got into Dependent Type theory through a club so it's awesome to be able to see I can incorporate simple proofs into my Rust programs. Thanks so much for the recommendation! (And for getting me into this awesome language)

  • @antonchinaev3495
    @antonchinaev34957 күн бұрын

    I actually use this in typescript. Types there also can be quite powerful if you know how to use them

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Big fan of typescript, when I work in a js framework, this is what I use!

  • @Blaineworld
    @Blaineworld9 күн бұрын

    this is kind of something i figured out on my own. in a text adventure io library i still haven’t finished, i had a Pen struct that handles printing text, which can be turned into a Prompt struct that handles reading commands and then turning that part of the text into just a summary of the command. i had not thought to use a generic parameter for this and i will look into that. maybe.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Games are FULL of state machines that would be amazing modelled using the typestate pattern - read the cliffle article I linked to to see all of it's power!

  • @asdf8asdf8asdf8asdf
    @asdf8asdf8asdf8asdf10 күн бұрын

    Thanks!

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    My pleasure!

  • @exotic-gem
    @exotic-gem10 күн бұрын

    I’ve been skeptical of Rust for a while, as a C developer first and foremost, but I think I might try it. I fear it will demand I surrender more control than I am comfortable doing, but I hope it will optimize the code in ways any C compiler simply cannot.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Don't believe what people say, try it out for yourself. Here's how I recommend getting started: kzread.info/dash/bejne/ZJyMsMZvqJzZitY.html

  • @porky1118
    @porky11184 күн бұрын

    12:00 I did something similar to this for Geometric Algebra. If I multiply two versor types, the result is always a versor type. All versor types have the same implementations for all methods. In this case, both versors and non-versor multivectors have the same methods, but some have different implementations. I wasn't able to implement it in Rust, though. It requires compile time code execution and const generics. The only language which is powerful enough is probably Scopes. Maybe C++ can do, too.

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    Rust *has* first-class compile-time execution, in the macro system, here's my video on it: kzread.info/dash/bejne/f4uGsrt7n6arkbw.html And though I'm not familiar with exactly what you need, rust also has const generics for 7 years: practice.course.rs/generics-traits/const-generics.html

  • @porky1118

    @porky1118

    3 күн бұрын

    @@NoBoilerplate Rust macros are far from powerful enough. I could technically create a macro which generates all types for N-Dimensional GA. But then if multiple libraries use this macro, these libraries will be incompatible, since both generate their own multivector types. Besides that, I have to choose a dimension in advance. The number of multivector types for each dimension N is at least 2^N. It's technically possible, but it's not great. What's great about scopes is that there are macros, which return types and memoize their results. So if I have a multivector type as a macro (for example a quaternion MultiVector!), it would implicitly create the type definition only once at toplevel, and every usage of this macro will refer to the same type.

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    oh cool! First I heard of Scopes, very neat! The behaviour you describe (creating a type at top-level then every usage of the macro re-using the top-level type) certainly could be written as a simple rust macro.

  • @porky1118

    @porky1118

    3 күн бұрын

    @@NoBoilerplate I'm pretty sure it's not possible. I would have to manually call some macro a toplevel to create the type first, and then maybe have another macro to use this type.

  • @xianzhang2178
    @xianzhang21785 күн бұрын

    Although the compiler does a lot of checks in Rust, this does not mean that unit testing is completely meaningless. We still need to test the correctness of the logic and whether the results are consistent with expectations.

  • @NoBoilerplate

    @NoBoilerplate

    4 күн бұрын

    Absolutely right. I feel like the dream workflow is: CDD, TDD, Feature tests, E2E tests - KINDOF in that order!

  • @Mokodokococo
    @Mokodokococo10 күн бұрын

    About the TypeState pattern. What happens if you send a light as parameter with Light and you want to call `flip` on it. It won't know which `flip` it should call. I wish you made an entire video about this pattern. Seems great :D

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    OH I COULD HAVE MADE A WHOLE VIDEO ON IT! It's my fav pattern! I believe the answer is to use Rust's generics - this is what the trait system is for - many standard library functions can accept any kind of string (not just String or str or osstring etc) by specifying traits that parameters should adhere to, rather than concrete types.

  • @liesdamnlies3372
    @liesdamnlies337210 күн бұрын

    Find someone to love you like this guy loves Rust.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    I actually love loads of other things more than Rust - but Rust allows me to FINISH my code and go and go live my life 😀

  • @NetherFX
    @NetherFX10 күн бұрын

    Seeing 11:10, you might be interested in learning about the PhantomData marked in the std. If you only use the state for defining functions and you never read this value, making it a zero-sized type is an option (Maybe you're planning on making a billion lights, who knows!).

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Quite right! PhantomData is mentioned in the linked Cliffle post - I stripped out as much as I could - traits, boxed state data, phantomdata etc - to make my demo as small as possible.

  • @NetherFX

    @NetherFX

    10 күн бұрын

    @@NoBoilerplate That's fair, a very informative video as always (:

  • @ericng8807
    @ericng880710 күн бұрын

    It's been too long since you uploaded a Rust video! Ended up using Go

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    That sounds like a "you" problem ;-) I really like Go too! If Rust didn't exist, I'd be happily using it. Many similar good decisions over there. And, of course, quite a few ones I don't agree with.

  • @Alex-cx7tv
    @Alex-cx7tv10 күн бұрын

    Depending on if I’m writing the code for school/personal use that will never see a server/robot I’ll use CDD all day everyday. If I’m getting paid for it, I’ll spend an hour writing a largely if a is true then test pass type test because it’s a requirement in the work place. I.e self evident tests

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    There's nothing worse than writing bullshit code, even if you're getting paid for it. You deserve more, annoy your colleagues with perfectly modelled code at work, too 😀

  • @praguevara
    @praguevara10 күн бұрын

    Really liked the light switch example, but could not find the link in the description. Perhaps you could add it?

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    I don't normally put links in the description (WAY to many! I put them in my original markdown script, linked on github). But you're right, I should make an exception for this one!

  • @praguevara

    @praguevara

    10 күн бұрын

    Haha I'm reading it right now and you're right, it's great!

  • @ethanchristensen7388
    @ethanchristensen738810 күн бұрын

    Have you looked into inline const assertions, and what they mean for CDD?

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    Yeah, smells similar, right? I considered expanding CDD to include compile-time TDD using const, but that's just TDD running at compile-time, there's nothing super compelling there. MODELLING your application using the type system is where the real power is!

  • @fabricehategekimana5350
    @fabricehategekimana53507 күн бұрын

    Tbh I prefer using "Type driven development". In mathematic logic, a type is the equivalent of a proposition/theorem and a member of this type is a proof. Like an image is equivalent to 1000 words, a type is equivalent to 1000 tests👌

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    love it!

  • @2000krzysztof
    @2000krzysztof9 күн бұрын

    I understand the usefulness of this but I think a mix of both would be the best practice. Using cdd is good for the general structure of the program but for things that can't really be checked at compile time like some maths calculations or off by one errors might still need tdd. But I don't know if there is a way to do it with cdd I would be impressed

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    I too think that there's a clear workflow: CDD, TDD, Functional Tests, Interactive Tests pure code -> impure code. CDD is the first step, for SURE. BTW, Rust can run arbitrary code at compile time, so you COULD if you want run unit-test-style code all ins your CDD workflow, check out my video on const: kzread.info/dash/bejne/qKOGpLVpoperqaw.html

  • @nergy1013
    @nergy10138 күн бұрын

    As always I appreciate the new views you give on “other sides” of programming I dont usually encounter in daily work. However I seem to be missing the point where CDD is asserting actual behaviour and outcome of code, instead of testing wether or not your program compiles and handles every possible case (also a good thing, but different entirely). Im sure if you want to *test and record the behaviour of your code*, you will have to end up writing tests still… or am I missing something? Thx to anyone to answer or discuss. Cheers!

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Quite right, CDD is the first step - quickly sketching out the core model of your code. One should RELUCTANTLY move on to TDD and so on only after exhausting CDD!

  • @JohnnySacc
    @JohnnySacc10 күн бұрын

    At work I very seldom actually run the services I'm writing locally. Just as you say: I write, I run clippy, then I push and let CI take care of the rest.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    The dream! CDD first, then TDD, and finally some functional tests for production!

  • @12rjig13gb
    @12rjig13gb9 күн бұрын

    if you want the maximum help from the compiler, the coding style have to be changed too. For example, if there is a catch all arm in match enum like "_ => do_something()", then the compiler won't notify you if you add more variants to your enum later on.. So you need to be careful with those small pitfalls, same thing might happen with #[non_exhaustve] enum too

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    That's why I run clippy super strict so it keeps me honest! rust-lang.github.io/rust-clippy/master/index.html#/wildcard_enum_match_arm

  • @guard13007
    @guard130074 күн бұрын

    Red does indeed mean recording.

  • @THEMithrandir09
    @THEMithrandir0910 күн бұрын

    To me TDD was less about shipping correct code and more about designing code that's ergonomic/easy to use/test and to show that the code is able to do what the (actual) user wants it to do. Having the tests around is just a nice side-effect. Nevertheless, this looks very interesting. And great video as always :)

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    "what the actual user wants" I think you're talking about BDD tests there, larger tests that are based on user stories? TDD is quite a pure, simple theory, at its heart is just "how to code without fooling yourself!".

  • @THEMithrandir09

    @THEMithrandir09

    9 күн бұрын

    @NoBoilerplate Well, user of the code or "actual" user are both very broad, and I meant it that way. User of the code is probably another dev or yourself in the future. TDD makes you write ergonomic interfaces because you'd be insane to think up a bad complicated interface for code that doesn't exist. You state what you want to do. And TDD tests can vary wildy in scope, depending on what you're working on. You might call them by different names like integration, acceptance or behaviour tests, or whatever, but at the core, you wrote a test first, made it pass and hopefully didn't forget to refactor, which counts as TDD in my book. If you enter the testcase from a function call or a call to a webapi for which you are writing a new endpoint doesn't matter, really. In fact, the latter case can be better because it's less coupled to the code you are/will be testing, which is super important to look out for.

  • @ErikBongers
    @ErikBongers9 күн бұрын

    I like the Lights example: it's code that doesn't produce any runtime. All structs are empty. Indeed, empty structs may help you to create semantic-only types that have no runtime effect, and only serve to guide the compiler. I guess I do "compiler driven refactoring" when I'm writing some code where I think 'Hey...if I were to call that function now...things would crash. How can I protect myself from that?" I will then refactor so the compiler no longer allows me to do this or that. I guess this is the opposite of good old win32 functions where the documentations says: "This parameter is reserved. If you pass anything other than NULL, the function call will fail."

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Oh, the cliffle article I linked to has a few options for storing other information in the state - I just kept it very tiny for my example. Do read it!

  • @zerker2000
    @zerker20008 күн бұрын

    "The rust compiler is faster than a REPL" XD XD

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    To be clear, I said, "The compiler is faster than all these methods, but to be fair, and balanced, it's because it's doing less." I've written production lisp at a bank, I LOVE repl-driven development, but compiler-driven is SO much faster!

  • @anon_y_mousse

    @anon_y_mousse

    7 күн бұрын

    @@NoBoilerplate I'm not sure why you'd believe that given how slow Rust compiles, even when working incrementally. Every REPL that I know of can use the full width and breadth of the language, even down to importing modules, and thus iteration is nearly instantaneous because it's a simple matter of :w from the other window and the up arrow key followed by enter to rerun the import line again.

  • @carterplasek498
    @carterplasek4989 күн бұрын

    Is there any significance to the roundabout in London the coordinates point to?

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    WELL SPOTTED! Trafalgar Square is often given as the centre of London, I suppose I pulled those from the london wiki page!

  • @jackcrump-leys5457
    @jackcrump-leys545710 күн бұрын

    I have a feeling that this guy is a fan of rust.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Garbage game for garbage people

  • @jackcrump-leys5457

    @jackcrump-leys5457

    9 күн бұрын

    @@NoBoilerplate game? I mean the programming language.

  • @ameypendokhare3832
    @ameypendokhare383210 күн бұрын

    red means recording 😌

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    LOVE Jeremy (though my bank account doesn't!)

  • @vidstige
    @vidstige9 күн бұрын

    "If it compiles, it works". Great quote! This has been my feeling as well, and it's awesome. the The light switch example in the end though... Not so convincing? What good does that really do? Maybe it was just a poor example?

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Quite possibly, It's the absolute smallest example I could show. Maybe I should have gone with the classic traffic light? DO read the linked cliffle article, it's so powerful!

  • @foresthobo1166
    @foresthobo116610 күн бұрын

    What is mean by "model" in this video? It seems to have some additional meaning I'm not familiar with.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    With an advanced type system, you can use types not just to store some values, but express relationships between types, including behaviours that would otherwise have to be enforced in your run-time program (think of rust's enums: they *model* a requirement that they must be in exactly one state at a time) You can model your application on a whiteboard, or in UML or in dedicated prototyping tools, but in Rust, you can model a LOT of logic inside the type system!

  • @pcache
    @pcache9 күн бұрын

    very intriguing topic, maybe i'll try to incorporate it into my programming. in a serious production environment though, having tests, especially integration tests, is invaluable and the final sanity check between you and the client. one big advantage of traditional tests is that they are maintained separately from your developed program. in CDD, any refactoring work on the types or function signatures would leave me wondering if I haven't unwittingly created holes undetectable by the compiler's static analysis, right? i think it's a nice addition to existing good practices. leveraging the compiler to reduce the number of errors during development. but without tests i would feel my code flimsy and naked.

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Oh of course, I agree. CDD is the first step, but once you've got the pure model of the code correct, developing runtime features using TDD, then putting into place feature tests and so on is of course essential.

  • @RustyNova
    @RustyNova10 күн бұрын

    Welp. Thank you for making me want to yet again refactor my code to use typestate patterns. I got this awful struct with an optional field that is wanted to be Some() 75% of the time, and I keep having to deal with checking/propagating None. This definitely would help enforce it

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    You know what you have to do 😀

  • @pokefreak2112
    @pokefreak211210 күн бұрын

    I'm confused about the type state pattern, since the Light just takes an unconstrained type parameter couldn't you pass in any type? How do your consumers know you're supposed to only create a Light and Light And not a Light?

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Very good point! The example is as cut-down as I could possibly make it, so I swerved constraining the type by trait, which would solve your problem. It's not even much more code, but for a quick intro to typestate, I swerved it. Check out the Cliffle article, it's amazing!

  • @justinchase1534
    @justinchase15348 күн бұрын

    This is just OOP. This is done in every language with a type system.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Not quite. There are type systems and there are type systems. Certainly, you can do the basics of the typestate pattern in any language, and it's a good idea. But there are powerful parts of the ML-inspired Rust type system that lend themselves to compiler-driven development. Here's one of my videos talking about some of the magic that the Rust compiler can do, I'd love to know what you think: kzread.info/dash/bejne/qKOGpLVpoperqaw.html

  • @hearteyedgirl
    @hearteyedgirl10 күн бұрын

    yey more rust

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    this is the way

  • @mika2666
    @mika266610 күн бұрын

    🤩

  • @johnwilliams7999
    @johnwilliams79997 күн бұрын

    I've missed your videos

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Thank you! I'm so glad to be back making videos again ☺️

  • @rsaad24
    @rsaad248 күн бұрын

    I wonder, how reliable this is for serious production use cases, how to figure out which pathes/cases are not safe/covered? Cuz if I cannot figure that out it means that all guarantees are void.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Using the type system, in any language, is 100% reliable, if it's not, it's a compiler bug. Rust's type system can encode far more information than other popular languages (such as, say, Java or Go), and so you can extend these 100% guarantees to much more of your code, leaving less requiring unit testing.

  • @Mawkler
    @Mawkler10 күн бұрын

    Awesome that your videos are public domain now as well! Have you considered posting them to PeerTube and/or Odysee as well?

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Odysee is a non-starter for me, as is anything blockchain. PeerTube is a real possibility - activitypub is a great option, and I've been delighted with Mastodon! (Please excuse me, I must point out that everyone on my patreon and ko-fi can watch ad-free and without (google's) tracking.)

  • @holonaut
    @holonaut9 күн бұрын

    fn five() -> i32 { 6 } Ah yes, the perfect implementation with nothing left to be desired

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    so perfect!

  • @CielMC
    @CielMC6 күн бұрын

    I think 11:30 should be enum On {} and enum Off {} with PhantomData as it does not make sense to have “an On”

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    All the code you see in my videos is stripped out and compiled as I write it, it's all valid! you can drop the {} in this case, which is super handy.

  • @CielMC

    @CielMC

    3 күн бұрын

    @@NoBoilerplate You misunderstood, I know you can create unit structs like that, but I am proposing zero-variant enums, Unit structs still have one value, the unit. But that doesn't make sense, you can't have "an on", so the type `On` should have zero values, as in it does not exist at runtime but only as a type, so it should be `enum On {}` instead of `struct On`

  • @CielMC

    @CielMC

    3 күн бұрын

    The difference being that you cannot construct an `enum On {}`, it cannot exist as a value, unlike a unit `struct On` which has one possible value being `On`

  • @NoBoilerplate

    @NoBoilerplate

    3 күн бұрын

    oh got it! yes that's a very semantically satisfying improvement 😀

  • @CielMC

    @CielMC

    3 күн бұрын

    @@NoBoilerplate Indeed it is :D, changed my life when I found that zero variant enums can be used like this.

  • @mf_glitch
    @mf_glitch9 күн бұрын

    i swear there is a part of me, just wants to learn to code so i could understand develepors who i've subscribe to for their non coding related post.

  • @laundmo

    @laundmo

    9 күн бұрын

    why not? start somewhere, build things, don't get stuck in tutorial hell by actually expanding on the tutorials contents, there are tons of free resources online!

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Do it! It's so easy to start, here's my video on how to kzread.info/dash/bejne/ZJyMsMZvqJzZitY.html

  • @LovelyBozo
    @LovelyBozo8 күн бұрын

    remember rustaceans, if statements are ugly. match for the win!

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    yeah! ugly and less semantic!

  • @justsomeonepassingby3838
    @justsomeonepassingby383810 күн бұрын

    What you describe in this video is almost exactly how i wrote code in rust. Except, i would have to run through my entire codebase every time i changed my data types however, i stopped using rust after realizing that making the rust compiler into a Lisp library is the only way to apply the unix philosophy to compilers and to extend the language organically. In the (very) long term, i think lisp will still outlast rust and import its features.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    I love lisp, I have described Rust as "lisp and haskell in C's clothing" in previous videos. I agree, lisp will outlast Rust. However, this begs the question "What *IS* lisp"? - Is it lambda calculus? if so commonlisp is not lisp, it's got loads of junk like classes and non-functional stuff in, a concession to practicality. - Is lisp s-expressions? McCarthy would ask what about m-expression, then. - Is lisp a language with Graham's 9 lisp features: Conditionals, first-class functions, recursion, no compiler types, GC, expressions, symbols, tree-based syntax, the language always available? Then Rust is as much a lisp as clojure, it has 8/9 of those features! (and "no compiler types" doesn't sound like a feature I value) It's very easy for an *idea* to live forever. Perhaps one day lisp will conquer the world. It'll need better type handling than typed clojure if I am to use it, if that is the case :-)

  • @justsomeonepassingby3838

    @justsomeonepassingby3838

    10 күн бұрын

    @@NoBoilerplate TL;DR: i deviated from lisp towards what uses i have for lisp which rust cannot fit. I go back to rust vs lisp at the end Thanks for replying. I love your videos. I recently went back from rust fanatism to lisp elitism, but i am not a lisp guru (i usually use python, i tried to switch to rust everywhere but running a rust IDE and compiler in a virtual machine is too expensive. I might try again after i fix my VM obsession, if the rust compiler adds better support for shared library compilation of dependencies to reduce linking time) I have watched your previous videos, and at that time i almost accepted the idea that rust was "as powerful as lisp, just much harder to meta-program". However, the metaprogramming part of lisp is almost skipped over by rust. It almost looks like the rust developpers knew everything from haskell to c++ and assembly, but only knew lisp marginally. Maybe this is due to lisp being the radical opposite of static languages like haskell. To me, the most important features lisp still has over every other languages are: -an axiomatic (self-mutating) language where everything is defined in itself (this makes it a language that "scales with abstractions" and gives the user a new point of view where the language is something mutable instead of a set of constraints like haskell) -a language that maximize user power/expressivity, over safety, correctness and even performance (this allows some classes of algorithms that would be completely impossible in stricter languages, such as mutating cons cells to implement efficient queues) The latter is completely opposite with what makes a language scalable in a project with lots of developpers (lisp is more suited to small teams), and actually makes it harder to prove that a program works as intended (instead, tests are done through interactive debugging until things "seem to work") To be fair, the reason why i care more about "abstractive scalability" and interactive debugging even over developper efficiency, code correctness and performance, is because i am gambling on AI becoming as good as humans at programming. To prepare for this scenario, i want to make lisp into the universal language for everything written by AI. In summary, i want: -a haxe-like cross-programming language (lisp can do this easily with its simple, data-oriented syntax) -a language that does not become obsolete in the next decades, regardless of the type of project (this is where the "abstractive scalability" comes into play) -a simple core that could be written/understood by an AI (currently reduced down to 50 lines of python to describe evaluation rules) -interactive debugging, since this would allow AI to use a bottom-up, exploratory approach instead of writing 200 lines of code that is incorrect in a single prompt -the runtime does not matter. The final executables (including its own interpreter) are cross-programmed With all that said, no of my requirements are related to my own programming. I do not have a complete mastery over lisp (even though i am trying), and i dare not claim that lisp is the best language for actual programmers (since i know how powerful static languages can be). I am still going to favor lisp over rust, because i think lisp has the potential to stay my entire career and fit every use case i encounter. To conclude with some "downsides" i could The only real complaints i have about rust are: -having to always be aware of low level details (this is not a bad thing, but this combined with the compilation time of static dependencies make rust uncompetitive for "quick and dirty" projects) -having all the complexity of the rust compiler in a single place goes against the unix minimalist philosophy (this makes the language almost impossible to understand and contribute to, but that's a tradeoff all static languages accept in exchange for more powerful control over the code -using a text-based representation for syntax (something any serious language does, but i think we can move past that someday, and lisp seems closer to that as it can be viewed as a raw AST, edited structurally in emacs, and encoded as any data format like json or lists) There are also major downsides to lisp (like the obsolescence of the ansi common lisp standard, the unuseability of scheme, the fragmentation of the implementation strategies for macros or continuations,...) But currently, guile and picolisp seem to fit for my taste for my quest of the perfect language. I hope reading this won't take you as much time as it took me to write

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Let me help you with compile times first before getting back to lisp. Something's set up wrongly on your vm: rust is not slow to compile. here are some things to try: - compile *twice* and forget how long the first compile took. first compile times get amortized to zero, and rust's incrimental compilation makes most subsequent compiles near instant. - Think of this as an initial `npm install` or `pip install` or `gem install` etc - first time slow, subsequent times fast - sccache - Sccache provides a global cross-project deps cache, you should always be using it (the arch linux wiki has a great page on it) - I can't help your slow ides. I used doom emacs great with rust, and I currently use neovim with lazynvim, both are faster than any ide. RIGHT. Regarding the rest of your comment, - lack of metaprogramming - lack of a small core - having to always be aware of low level details - the blub paradox I'm pleased to say that your assumptions here simply aren't true. We're here because Rust does all these well! - the whole language is indeed always available, in rust's macro system (please watch my video on this here kzread.info/dash/bejne/f4uGsrt7n6arkbw.html and let me know what you think!) - Rust is programmed in rust, using macros system. While a tiny part of it is bootstrapped in machine code (just like any lisp) the rest is written in Rust (kzread.info/dash/bejne/qGqG2qysm5vVpLw.html) - You DON'T have to always be aware of low-level details. Rust's genius (but confusingly-named) `unsafe` system allows us to build safe abstractions on inherently unsafe real-world hardware. I was a web developer for 15 years, 2 of those writing clojure professionally. I don't care about low-level details. If rust didn't provide best-in-class abstractions (lisp-style macros) I would not care about Rust and I'd probably be using picolisp too 😀

  • @justsomeonepassingby3838

    @justsomeonepassingby3838

    9 күн бұрын

    @@NoBoilerplate Thanks for replying, but please let us spare ourselves some time T_T about my problems with rust, i think my last comment wasn't clear enough. By compilation time, i actually meant linking time (by default, everything is linked statically, so using multiple large libraries like rocket and surrealdb means the linker has to do a lot of work each time). Static analysis means i don't have to compile often, though. I have tried to solve this problem with dynamic linking. This works great, but only for a single large dependency, because shared dependencies between large libraries must not be duplicated. Theoretically, this problem is easy to solve (by linking to the same crate dynamically from multiple places), except the libraries themselves have to add a setting to their cargo file to allow dynamic linking with their dependencies (and most don't). So the cargo developpers have to make this setting implicit before all dependencies can be made dynamic. My other performance problem is that since i do everything in virtual machine, adding 10GB of compiled libraries to my rust VM is expensive (i can't just reclaim the space by deleting it, i have to "defragment" my VM or make a new one). My (jetbrains at first, then vim) rust setup was fine at first, but doing it a few times and failing to setup vim correctly (after doing it repeatedly before) made me go back to python. Now the ideological (useless) part, and a bit more about why lisp is lisp: Overall, rust is still a great language for the elite. I still love it, i just don't use it because i am a VM freak with too many specific requirements. I don't even care that much about lisp except for the interactive development experience, which i can usually reproduce in python About metaprogramming in rust: rust's syntax is complex. Have you ever written your own rust macros ? I didn't (and i never had the need for it, to be fair). From what i theoretically know (since i haven't written one), rust macros like vec! can only accept a finite number of parameters. Rust written as a raw AST and with parenthesis could be a lisp too, but then it would require more I didn't know rust itself was bootstrapped with macros, but i guess it makes sense. This is interesting, thanks for mentioning it. The other part where i wasn't clear enough is that my "having to always be aware of low level details", i also didn't actually mean low level details. I was referring to memory management. I got far enough in rust that i could write a parser combinator library with closures, and i could manage reference lifetimes without much trouble, but some types of algorithms are just impossible because they cannot be defined with statically correct algorithms. I know rust has GC features like refcount, i just haven't been able to spend enough time with rust to master them. Please don't try to justify how rust is a great language, i already know. Rust is how i learnt advanced memory management techniques when i came from python (though i did learn assembly, lisp, ocaml and compilers before joining the cult), and made me a better developper. There is another thing lisp (and many other dynamic languages) do that rust cannot do: some abstractions (like dynamic typing, garbage collection, or continuations) can be made efficient to the point where it becomes a net plus. Garbage collection, for example, can be made incremental or even real-time. For applications that do not need this feature, stop-the-world GCs can be even faster than manual memory management (though the memory waste feels bad). For the user, the language is just simpler: memory is easier to manage, and some algorithms that were not even possible by tracking memory manually can now be implemented without leaking memory. In lisp, these abstractions (conditions/tail call optimization, optional type annotations and garbage collected cons cells) are the main way to program at all. And i think this is why macros are the obvious solution to everything in lisp (lisp macros don't just rely on lists and macros, they also massively rely on variadic functions, lexical closures AND dynamic binding, and just plain recursion) I think it's the set of these features (with more or less equivalent features in other lisps, like call/cc in scheme to implement a high level, safe goto) that makes lisp a lisp. And the fact that rust misses these features might be the reason why rust users do not rely so much on metaprogramming It's not that metaprogramming is a requirement. Rust is a great language as it is. To go back to lisp vs rust: Rust is a language that starts by being perfect. The best way to learn rust is to accept that idea until it makes sense. I think your videos do a great job of showing that. The usual answer to doubt is "keep calm and trust the compiler". Maybe this will end like C++, with a big refactor into a new language decades later, i don't know. Lisp is a language that tries its best to give you unlimited power, and allows the user to get the job done, even if the job is to write C. Lisp makes no promise about the future, except being easy to bootstrap and not having to care about following standards when configuring my Nyxt browser. Both languages are great (except rust is perfect and lisp makes everything possible) i will still prefer lisp because it fits my style of solo development more than rust. Thanks for replying. I never doubted the perfection of rust in the first place, i just want to use guix and guile right now because that's what motivates me currently. I'll probably go back to rust at some point, and i still keep rust in my resume

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    My apologies, I think I understand where you're coming from a lot more now, thank you for taking the time. Yes, the linking time was brutal - did you see that super recently the linker was switched? 40% reduction in linking times as of: blog.rust-lang.org/2024/05/17/enabling-rust-lld-on-linux.html But that was just the low-hanging fruit, plenty of optimisations still to make, and I look forward to them. Until then, we seem to be going about things very differently - I run on the fastest bare-metal machine I can, whereas you're running on VMs, with the inherent challenges and advantages there. Have you heard of my new god, nixos, by chance? 😉 best of both worlds there - I can isolate what I want, and get bare-metal speed for everything. "Have you ever written your own rust macro" is a very amusing question for me. I was asked that EXACT question after I presented this talk (kzread.info/dash/bejne/nZNo1K6yobTLcaQ.html) at ClojureX 2017 - but this was about writing macros in lisp! I think macros are inherently strange, no matter the syntax. My answer then is my answer now: "You may not write macros day-to-day, but your code is cleaner and more elegant for having them in your language." I would be raving about Haskell if it were only a bit more popular. It supports lisp syntax btw 😉

  • @anon_y_mousse
    @anon_y_mousse7 күн бұрын

    Maybe I just need a better example to help me visualize generically how this could be applied because that link which talks about HTTP requests seems convoluted and full of too much boilerplate, which kind of seems like a natural negative consequence of how Rust implements enums. For instance, if I were implementing a mechanism to handle requests, I'd put everything in that one class, and there would be no need to return different structs or whatever. This also kind of strikes me as one of the quirky flaws of method chaining because then you have to return different types to allow the chain to continue. Of course, since we're talking about HTTP requests, I'd probably just fill in default details and have functions to let the user replace the defaults or not if they shouldn't care. Certain things would obviously be an error, like a lack of target IP and so on, but there are things which the user might not want to care about, or shouldn't have to manually handle. For instance, one of the things about the example that strikes me as wrong is the status codes being passed as magic numbers/strings instead of having a set of enumerated names so the user doesn't need to know the actual status code, such as just STATUS_OK instead of passing (200, "OK"). And on top of that the content length being set by the user passing anything at all. That's one of those things that would never be explicit in such a library were I writing it because the user could pass the wrong value and that's a huge flaw, where instead the library should calculate it for you and set it automatically. The two examples he gives of where such things go wrong in C++ I agree with, but they're also kind of irrelevant. Sure, move semantics should probably be implemented better and more at the compiler level, but things like closing files really is better with RAII and it's just a matter of slightly modifying those classes. Of course, I don't agree that Rust actually makes these things easier or ergonomic as that code looks disgusting and makes me want to barf worse than reading STL code in C++.

  • @eventh1987
    @eventh19879 күн бұрын

    I love the idea of the TypeState pattern. I love compile-time checks and guarantees in general. Faster feedback and everything else. But I have some hesitance about using it, after having tried using it. I've been working a pretty large personal rust project (a game-adjacent app) for a while, and it had a lot of these kinds of invariants that on the surface I would have loved to encode in types. The problem is, as far as I've seen working on my project on and off for the past 4 years, that at some point you need _so_ many generics and types that not only do you run out of names for everything, more importantly, your code just ends up an unwieldy mess of deeply nested types. I ended up having to refactor my code to just check a lot of invariants on start up rather than have everything in the type system. What do you (or anyone reading this) think about how TypeState scales up with bigger projects? Genuinely curious what people's experiences are using this "in the wild". BTW long time lurker. Love your videos. The videos are just so stylish and every time I get exposed to new ideas or less talked about ideas that makes me re-evaluate how I code. Keep up the great work!

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Thank you so much, that's very kind of you to say! Naming, program organisation, namespaces - Rust has the same design challenges as any other language, it's the hardest part, honestly! Come ask that question on my discord - there's genius overe there!

  • @eventh1987

    @eventh1987

    6 күн бұрын

    @@NoBoilerplate I just might. And you're very much welcome :>

  • @nightshade427
    @nightshade4279 күн бұрын

    running the rust compiler takes same amount of time as running test suite for other platforms with time to get a snack 🤣

  • @laundmo

    @laundmo

    9 күн бұрын

    i mean, the first time sure. but the build caching is pretty damn good. so unless you build in release mode while testing - dont - its pretty fast the second, third, etc. time you compile some iterative changes.

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    Don't repeat stuff you've heard other people say - give it a try! Wouldn't it be amazing if what I'm saying was true? 😉 kzread.info/dash/bejne/ZJyMsMZvqJzZitY.html

  • @nightshade427

    @nightshade427

    7 күн бұрын

    I was just messing, I like rust, zig, and c

  • @nUrnxvmhTEuU
    @nUrnxvmhTEuU9 күн бұрын

    6:05 "designed for data scientists, engineers and allists" 😂

  • @NoBoilerplate

    @NoBoilerplate

    9 күн бұрын

    Ha! I think probably the opposite is true, I sure love a table! Listening back, I think I clearly said "analysts", and my script matches that 😀

  • @l0gic23
    @l0gic2310 күн бұрын

    Quadratic seems awesome. Take that "Smartsheet", et.! Quadratic, are you accessible? Ensure your product is fully Accessable - you ad your CFO can thank me later

  • @csongorzih5094
    @csongorzih50949 күн бұрын

    The typestate pattern looks just like the bloc pattern's state definitions lol

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    ew, gross. Sorry reading the flutter docs made my eyes bleed. I THINK the main difference is all states are proven by rust at compile time, and no unit testing is required because the compiler proves that there are no possible invalid states in your whole codebase.

  • @PeidosFTW
    @PeidosFTW7 күн бұрын

    0:44 Some more news reference?

  • @techpriest4787
    @techpriest478710 күн бұрын

    So. First CDD then TDD for what is left.

  • @NoBoilerplate

    @NoBoilerplate

    10 күн бұрын

    You've got it!

  • @fedeanastasis7040
    @fedeanastasis70409 күн бұрын

    People complain rust is slow to compile but forget or doesn't know what its doing behind the scene

  • @NoBoilerplate

    @NoBoilerplate

    7 күн бұрын

    people who say that just repeat stuff they've heard, they've not actually compiled any rust 🤣