In Search of Code Purity

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 พ.ย. 2024

ความคิดเห็น • 433

  • @NoBoilerplate
    @NoBoilerplate  10 หลายเดือนก่อน +117

    ERRATA
    - Wikipedia's got a great overview of Formal Methods: en.wikipedia.org/wiki/Formal_methods
    - 7:00 : typoe Cofigurable -> Configurable.
    - 9:04 typo: faddone -> addone

    • @raskr8137
      @raskr8137 10 หลายเดือนก่อน +13

      The quote at the end says "purerer" instead of "purer"

    • @ToranSharma
      @ToranSharma 10 หลายเดือนก่อน +1

      5:41 should rstest be in the [dev-dependencies] section?

    • @Isaac-zy5do
      @Isaac-zy5do 10 หลายเดือนก่อน +2

      Coq has been renamed to rocq for obvious reasons. (If you're interested, thr new name is short for Rocquencourt, where the prover was first developed)

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      ah, probably

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      hehe yes, that's me being daft

  • @mattiasmartens9972
    @mattiasmartens9972 10 หลายเดือนก่อน +725

    "I am not sure if what you want is actually what will make you happy" is such a baller comment to leave on someone's technical question

    • @FrederikSchumacher
      @FrederikSchumacher 9 หลายเดือนก่อน +13

      You can't always get what you want
      But if you try sometimes you just might find
      You get what you need

    • @KoltPenny
      @KoltPenny 9 หลายเดือนก่อน +7

      Your average SO answer.

    • @irlshrek
      @irlshrek 9 หลายเดือนก่อน +13

      thats some gandalf level shit

    • @kevinsmirnov264
      @kevinsmirnov264 9 หลายเดือนก่อน +2

      Especially when giving no more information

  • @oredaze
    @oredaze 10 หลายเดือนก่อน +164

    "It's not C++, but better. It's haskell standing on lisps shoulders, hiding in C's coat to sneak into production"
    Ok, that is next level :D I love it. I am not a programmer (just like reading about it as a hobby), but you may make me start learning it for real with your videos and rust.
    Are you interested in making videos targeting beginners (using rust of course)? It would be an interesting idea/challenge to teach rust as first lang.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +16

      Thank you! I already did: th-cam.com/video/CJtvnepMVAU/w-d-xo.html

    • @BboyKeny
      @BboyKeny 10 หลายเดือนก่อน +1

      Do it!! Programming is tons of fun.

    • @creativecraving
      @creativecraving 9 หลายเดือนก่อน +1

      Programming is empowering, and very fun if you like hard, structured things like RimWorld or Dwarf Fortress or Factorio. It can also be painful to learn and do at times. (You're always building new brain muscles.) Best of luck!

  • @mskiptr
    @mskiptr 10 หลายเดือนก่อน +124

    I don't think we _have to_ compromise.
    Designing an ergonomic language that can still be formally verified is definitely a challenge, but I am confident that with managed effects, capabilities and dependent types we will one day create something you can fairly quickly iterate on at first and later on still add proofs, formally verified optimizations, etc.

    • @mskiptr
      @mskiptr 10 หลายเดือนก่อน +49

      Just a quick "ad" for three languages:
      - Ownership and borrowing of linear resources are basically purity. You just need a capability system. For an excellent example of that, see Austral.
      - If you want to see Haskell, but with neatly integrated formal methods, take a look at Idris.
      - And purely functional languages can absolutely be ergonomic. Elm is the easiest language I've ever seen.

    • @laundmo
      @laundmo 10 หลายเดือนก่อน +5

      hmm, and yet nobody has managed yet. Rusts practicality is imo a big reason its actually gotten popular unlike many other languages which try new thinga

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +26

      I applaud the effort, but over and over we have seen that if you make that language, no-one will use it enough to solve the problems in the world we're hoping to solve, and it'll be another Haskell, languishing with Matlab on this graph redmonk.com/sogrady/2023/05/16/language-rankings-1-23/
      All the features you mentioned in your other comment can be built inside rust using the Macro system, and many of them are (go check lib.rs!) which is tremendously exciting!

    • @Speykious
      @Speykious 10 หลายเดือนก่อน +39

      @@NoBoilerplate I don't think it's a good argument to only look at the failures of today's languages. I too am hopeful for such a language to exist. After all, before Rust, it was either you manage pointers directly and have to compromise on safety (even in C++ where you have somewhat decent pointer management helpers), or you use a garbage collector and have to compromise on performance. Rust made it so you don't have that compromise anymore _by language design._ Language design is the kind of stuff that can solve these problems, so being hopeful about it isn't unrealistic.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +21

      Totally agreed, and I'm expecting the next best thing to be bootstrapped in Rust :-D

  • @Vingdoloras
    @Vingdoloras 10 หลายเดือนก่อน +268

    Love how this channel has turned into a huge ad for Rust. I've been reading about Rust from an outside perspective for years but always thought it'd be annoying/painful to get into. Your videos slowly warmed me up to the idea that this is not the case.
    Someone got me a physical copy of Crafting Interpreters for Christmas and I decided to pick up a new compiled language before I work through the book (the last compiled language I used was Java 8-9 around 10 years ago and I did not feel like going back to Java lol). Went through your entire Rust playlist during downtime between festivity-related business and started working through the rust book, one chapter a day. It's been a blast so far!

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +58

      Wonderful! yes, I'm desperate to tell people about this incredible language because it's so *chill* to code in, I don't write... BUGS!

    • @creativecraving
      @creativecraving 9 หลายเดือนก่อน +4

      Speaking as a relative newbie, you'll want to have tight integration between rust and your IDE, so you can proactively respond to error messages, at least until you instinctively learn the rust idioms. VSCode does this okay with minimal setup.
      The type system makes a very strong contract with your code, so I find myself twiddling function signatures a lot to change the contract to allow me to add the behavior I need.
      This is more rewarding than debugging, but is a big time-sink in the beginning. Occasionally, I realize I'm not smart enough to express what I want in the type system, so I have to move on to a different strategy.
      I recommend learning about type aliases early on, as they can help save typing when you're repeating a long type annotation and need to tweak it.
      Also, Rust a lot easier to learn if you already know Haskell. Then, all you have to learn are lifetimes and borrows + syntactic differences.
      You don't have to learn to build or understand macros upfront, although you'll probably use a few. Just treat them like the annotations and typeless functions from other languages at the start. That mental model is working okay so far.
      Coming from an OO language, you'll find several new things: composition used in place of inheritance; new and powerful kinds of polymorphism; sum types (enums); enums used instead of null (Option/Result); traits instead of interfaces.

    • @axelcool1234
      @axelcool1234 9 หลายเดือนก่อน +1

      What a coincidence! I've started to read the Rust book as I plan to tackle the Crafting Interpreters book with Rust!

    • @em_the_bee
      @em_the_bee 6 หลายเดือนก่อน

      And why exactly do you love it?.. Are you that much in need of someone confirming your point of view that all the kilotons of Rust ads out there are not enough for you?

    • @Vingdoloras
      @Vingdoloras 6 หลายเดือนก่อน

      @@em_the_bee ​ Are you getting angry about a comment I made months ago on a video? Wow!
      Maybe read more than the first sentence of a comment before replying with passive aggressive questions, though. The second and third sentence of my comment answer your question and point out that what you're trying to complain about is not what's happening.

  • @Turalcar
    @Turalcar 10 หลายเดือนก่อน +32

    7:11 probably the best description of function purity (and encapsulation in general) and why it's good

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +3

      thank you so much!

  • @ItsVasl
    @ItsVasl 10 หลายเดือนก่อน +87

    Such possitiveness, you are a stress relief!
    A big fan of lost terminal as well btw:)

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +6

      Thank you so much!

  • @N....
    @N.... 10 หลายเดือนก่อน +4

    It's nice to see C++'s constexpr being brought to life in Rust as well, that's really cool as it has many of the same benefits in both languages. Being able to easily see a function has no side effects just from glancing for that `const` is really useful.

  • @sebred
    @sebred 10 หลายเดือนก่อน +7

    I am a fan of formal methods and rust has so much to offer in that area. One of the most interesting things for me is how the compiler has so much information about the code that some very interesting optimisations become available. And while most of my more esoteric projects in rust eventually end in me bemoaning the absence of dependent types (const generics are not enought) the rest of the time I am quite glad that I do not have to depend on somebody doing very elaborate type shenaningans.

  • @CalifornianViking
    @CalifornianViking 10 หลายเดือนก่อน +4

    I love the perspective you bring to programming. You are like the carpenter who is also a philosopher. You understand the practicality while putting it in the context of the meaning of life.
    One commenter says that the channel is an ad for Rust. I disagree with this comment. I am confident that you will call out the things you do not like, and I don't believe you are paid.

  • @xore_1798
    @xore_1798 10 หลายเดือนก่อน +33

    Man your video's are hella motivating. You're an inspiration, keep up the good work!

  • @linkernick5379
    @linkernick5379 10 หลายเดือนก่อน +6

    I have made the transition from Haskell to Rust too, for me the main reason was the lack of control over inner runtime "gears" that made really hard the performance tuning. I liked pretty much the monads and the type system though.

  • @codetothemoon
    @codetothemoon 10 หลายเดือนก่อน +6

    “…Production, the popular night club where all the popular languages hang out” - 😂 amazing

  • @rahul38474
    @rahul38474 10 หลายเดือนก่อน +4

    I feel like Zig also incorporates concepts of pure functions through the compile time evaluation. Functions that run at comptime cannot have any runtime side effects. The compiler caches the call of the function, so calling a function with the same inputs at comptime will be guaranteed to produce the same result. It also doesn’t have many of the limitations of Rust const fn. You can have any loop you want (and even inline the loops too, if the bounds are compile time known). Additionally, you can assert and compileError or panic to stop the compiler. And since some comptime functions can also run at runtime, you can keep the purity of the function too (only it won’t be guaranteed unless you run the function at compile time first to verify).

    • @scion911
      @scion911 10 หลายเดือนก่อน +1

      I see zig comptime more comparable to c++ consteval/constexpr it's more of a compile time execution for a function (I absolutely love it, I use them as primary design for 2 of my major projects). But I doubt they are similar to rust const fn... For example floating point operations are allowed.

  • @scion911
    @scion911 10 หลายเดือนก่อน +4

    Hi tris, a random viewer here with a take... This seems very similar to c++ consteval/constexpr, and zig comptime functions. In c++ consteval/constexpr is very strict scope like in rust although comparably less strict, it allows arithmetic on Floats etc. but rest are pretty similar. To me it just seems very similar in terms of purity, one of my tricks when writing a pure function in c++ is to just slap a constexpr at it and see if the code compiles...

  • @Nellak2011
    @Nellak2011 10 หลายเดือนก่อน +5

    I tgought this same exact question when searching for a Full Stack JS replacement. I am completely done with stupid preventable bugs with JS, so I am moving to greener pastures.
    Front End -> ReScript
    Back End -> Rust or Elixir

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +3

      oh ho ho, you should try leptos.dev

    • @randomthings1553
      @randomthings1553 10 หลายเดือนก่อน +1

      Depending on what you do with elixir you don’t even need the front end you can use the liveview

    • @Nellak2011
      @Nellak2011 10 หลายเดือนก่อน

      @@randomthings1553 I know Elixir is great, however, Phoenix has limited React support.

  • @june_m12
    @june_m12 10 หลายเดือนก่อน +9

    Great video! I have spoken with my friends (one of whom is a Haskell enthusiast) about purity several times in the past, and kept coming back to const fns. It is kind of disappointing how limited they are, but I came to the same realization that due to the borrow checker, I really don't *need* a purity system. If a function takes in no mutable parameters, I can be reasonably sure it's not going to have any side effects *that matter to my code*.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +9

      You've got it exactly. Also, we don't need Rust to be Haskell, we've already got Haskell! We need something that brings MOST of Haskell's features to the masses, and that's Rust

    • @Randych
      @Randych 10 หลายเดือนก่อน +1

      @@NoBoilerplate imo if that was your message, then const fns is very far from something that I'd call best for showcasing this

  • @SimonClarkstone
    @SimonClarkstone 10 หลายเดือนก่อน +2

    AFAICT, the subset of Rust that uses mutable borrows and mutable local variables, but is otherwise pure, can be mechanically converted into normal pure code (e.g. Haskell) by changing all the mutable borrows into passing-in values to functions which then return (alongside the proper return value) the updated value that gets re-incorporated into the datastructure whence it was mutably borrowed (and all the mutations of local variables must be turned into Static Single-Assignment, and loops into recursion, etc).
    I noticed this in Advent of Code 2022, when one of my Rust solutions was similar to an online Haskell solution, but with mutable borrows instead of returning updated parts of datastructures from functions.

  • @theKC66Youtube
    @theKC66Youtube 10 หลายเดือนก่อน +9

    I'm glad your channel exists. I got back to learning Rust again after i dropped out for a while. Thank you for existing!

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +3

      My pleasure, this kind of excitment is what I'm here for!

    • @creativecraving
      @creativecraving 9 หลายเดือนก่อน

      @@NoBoilerplate You're causing me to hate the language (C#) I use at my day job. Presumably, that's _also_ the excitement you are here for! :-p :-D

    • @mello1016
      @mello1016 9 หลายเดือนก่อน

      @@creativecraving C# is the cream at the top, appreaciate it, 99% things are much worse

  • @zanbaldwin
    @zanbaldwin 10 หลายเดือนก่อน +10

    How did I not know about const functions? The way you presented this has given me so many ideas :) I really liked this video

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      Zan! Hope you're having a great time. Yeah, right!? What else is this fun language hiding from us!

  • @SimonClarkstone
    @SimonClarkstone 10 หลายเดือนก่อน +5

    0:40 Now I have that tune in my head.

  • @user-zz6fk8bc8u
    @user-zz6fk8bc8u 10 หลายเดือนก่อน +6

    Formally proving code is almost mever done, not even in medical devices and at NASA. Sometimes very very small parts of the code base are formally proven. But it doesn't really solve much because compilers are to complicated to formally prove, CPU microcode is not formally proved, the hardware itself isn't. And even if all that where, if a cosmic ray hits the hardware in an unlucky way, all bets are off. In practice software is split into small units and those are tested to a required level.

    • @thiagoandrade9217
      @thiagoandrade9217 หลายเดือนก่อน

      ? Almost all hardware companies have an formal verification team tô verify hardware, a lot of compiler optimizations are verified to prove that they doesn't change the code, in general software development yes formal verification is not used but in critical systems it is, and right now there are a lot of formal verification about distributed systems protocols and smart contract, the only phrase of your comment that is Almost right is the first one.

    • @user-zz6fk8bc8u
      @user-zz6fk8bc8u หลายเดือนก่อน

      @@thiagoandrade9217 All those formal verifications only proof very small, niche specific stuff. In practice it's almost always next to impossible to even get your axioms right. The proof starts with the axioms but the proof itself can verify those and that's actually the hard part. So even if you formally "proof" something doesn't mean a lot in practice without proper testing.

    • @thiagoandrade9217
      @thiagoandrade9217 หลายเดือนก่อน

      @@user-zz6fk8bc8u This is not precise, in some situation they use formal verification in just some parte of the software, but in a lot other they don't.
      The other thing that you said, I think you are using The Word axiom in the sense of specifications, yes you prove only the specification if this specification does not match what you want in real life your proof is worth nothing, but knowing if an formal specification matches what you want is not a very dificult job in most contexts, specially ones that the domingo you are working with has easygoing mappings to mathematical strcutures.
      And again In hardware formal verification is extensive, extensive used, altough you have more than one formal verification technique, like model checking that doesn't require you to make the proof yourself, use of theorem provers are not insignificant, in software it is an area that is growing, again for critical systems it is used, In Airbus they use Coq to verify airplane software, in Paris metro they use Coq also, Lean is being used right now in conjuction with AI models to verify their output, it is a growing field formal verification of smart contracts because usually they are not a very big piece of code that once deployed cant be changed.
      Anyway I'm giving just examples from the top of my head, you can just search for jobs or teams in formal verification, Amazon has like 15 teams that develop and do researxh in this área, almost all the big software companies has at least one team in this area, and I am very confident that NASA has a team in this area aswell it would be just stop risking lives of people by not doing what is know to be the golden standard of trust in code.
      The problem is what you said, yes it is dificult, most of these position ask you to have at least a Masters or even an Phd in an area equivalent to computer science, that is why it is not mote generalized.
      It may not be relevant in the context your work because of investment you need to put in and in some contexts, tests fill in the gaps Ok, but is an area that always has been important and it is growing in an world that is consistently requiring more security and correctness

    • @thiagoandrade9217
      @thiagoandrade9217 หลายเดือนก่อน

      @@user-zz6fk8bc8u if you search an github repo named "companies that use formal verification" you'll se a more broadsr list than mine, and you'll se that NASA is in the list

  • @jonnyso1
    @jonnyso1 10 หลายเดือนก่อน +3

    Rust has so many well thought little design decisions that add up without you noticing that when I work on other languages I can't put my finger on it but it always feels like something is missing.

    • @littlecurrybread
      @littlecurrybread 10 หลายเดือนก่อน +1

      yes! Absolutely. In games there's a term called game feel, it's a bunch of little decisions that add up and elevate a game for the user. There's a similar thing I experience using rust.

  • @esra_erimez
    @esra_erimez 10 หลายเดือนก่อน +3

    4:48 "crushing march of efficiency" "too practical" some of the reason that I absolutely *love* Go.

    • @laundmo
      @laundmo 10 หลายเดือนก่อน +1

      except it sacrifices so much in the name of "practicality" that it loops back to being a hindrance

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      Why doesn't go.dev have syntax highlighting?

    • @Randych
      @Randych 10 หลายเดือนก่อน +1

      congratulations and condolences on loving the beaver

  • @Skerathh
    @Skerathh 10 หลายเดือนก่อน +1

    This channel inspired me to cover Rust in my upcoming bachelor's thesis (somehow, I haven't figured out yet what practical topic I could cover as I have to be very specific with things). I really want to see it get adopted more.

  • @trevorroddy3773
    @trevorroddy3773 10 หลายเดือนก่อน +1

    loved haskell in school and am now two weeks into learning Rust, again your video has been perfectly timed. excellent!

  • @mikehoughton204
    @mikehoughton204 10 หลายเดือนก่อน +1

    Thanks! Your vids are sweet and to the point. Excellent signal/noise ratio! :)

  • @KawaiiNiko
    @KawaiiNiko 4 หลายเดือนก่อน

    I’m really early in my programming journey, and I don’t really understand a lot of these videos, but I still love listening along. Thank you so much for these videos Tris.

  • @VioletCowelicious
    @VioletCowelicious 10 หลายเดือนก่อน +1

    I've coded webapps in Haskell professionally (specifically reflex, an FRP framework).
    It was a great experience. Without FRP it would have been painful though.

  • @be1tube
    @be1tube 10 หลายเดือนก่อน +3

    Unfortunately, neither Haskell nor Rust has a version of "purity" that allows you to guarantee that a subset of the code will not crash/panic at runtime. This was my biggest disappointment with Haskell.

  • @TRK--xk7bb
    @TRK--xk7bb 10 หลายเดือนก่อน +1

    "I was going to have to act, if I wanted to live in a different world" - why does a banger song started playing in my head after hearing that?

  • @loupax
    @loupax 10 หลายเดือนก่อน +1

    I love the description you gave to Go, especially because it’s not a compliment.
    I know it’s completely counter intuitive but I get a strong feeling of PHP when I work in Go, and I can’t put my finger on why.

  • @earthmusician
    @earthmusician 10 หลายเดือนก่อน +4

    I feel like this video is a great way of explaining modularity of Rust as a language. Making Rust more specialized i.e. making Rust a more pure language via an easily controlled limitations by adding rules to compile e.g. minimalistic linting and some added packages is definitely is a great boon to language. Also, the phrase "Rust is a pure as possible, but no purer", really solidified the idea in the end. Your video gave me just one more reason to love Rust, and insight into programming languages in general. Thanks for the great videos as always!

  • @djazz0
    @djazz0 10 หลายเดือนก่อน +3

    4:21 Nim is my go to these days. So much fun to code microcontrollers in. Not sure how having memory management is a downside?
    Sure it’s a bit obscure, and the stdlib needs work. I don’t use the stdlib for embedded anyway.

  • @Ketsur0n
    @Ketsur0n 10 หลายเดือนก่อน +1

    Hey mister no boilerplate I started following you some months ago your videos on time management and such really helped me out ❤ thank you

  • @abdallahmeddah8461
    @abdallahmeddah8461 8 หลายเดือนก่อน

    Funny, I am using this video as a motivational source to learn rust, I read the documentation, do some rustlings exercices, get mad because I don't understand something, come back to this video for motivation, repeat. Thank you!

  • @AkilManivannan
    @AkilManivannan 10 หลายเดือนก่อน +1

    I tried Rust and had some fun before giving up since I found it too slow to write with, but after seeing so many of your videos, I'm going to dive back in and try again 😅

    • @laundmo
      @laundmo 10 หลายเดือนก่อน +1

      it takes much longer than other languages to reach a proficiency where you're fast. but it saves a lot of time in other areas like debugging of complec problems.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      It's only slow using your old coding techniques and habits. If you code, compile, test, look at an error and try to guess what's wrong, it'll certainly be slower!
      But with rust you can code faster by using what I think of as "Compiler Driven Development", using clippy to give you incredible feedback, before you even run your code!
      th-cam.com/video/CJtvnepMVAU/w-d-xo.html

  • @smarterlife7331
    @smarterlife7331 3 หลายเดือนก่อน

    Hi dear @NoBoilerPlate. When I first heard about Rust, I was very excited, I started researching more, watched most of you videos (but not this one up until now), started learning and programming in rust, but then along the way, I was leaning towards C, as it is such a pure language, without any bloat, it is it is like a transparent, beautiful, sharpest knife you will ever see. Yes, it has some boilerplate, yes it has dangerous memory management, yes you need to do a lot more coding, yes it lacks modernity and tools, but man.. so beautiful language the C is..... Now watching this video of you, I am confused again... Please enlight me with one, beautiful comment that will make me jump to the Rust ship and never look back... Thanks in advance...

  • @ChristopherVogt1
    @ChristopherVogt1 10 หลายเดือนก่อน

    Over my 5 years as a Haskell developer in industry I found Haskell no hassle, but a joy to use for just about any programming tasks. Web services, API clients, html and code generation, writing cli tools, servers, web sockets, parsers, interfacing with OpenGL all work quite straight forwardly and quite elegantly. There is a tough initial learning curve doing pure fp and monadic IO, which seems to deter many people. But once through it, it does no longer get in the way and I did not find there to be a compromise necessary. What Haskell really suffers from is that it only has a small community like Python in the early 2000s. There are fewer library and dev tooling choices and some struggle with maintenance. That said eventhough Haskell has much more effective safety than main stream languages, it is still quite limited in what is practical to prove. Maybe that's why what is there right now does IMHO not have the practical problems No Boilerplate seems to suspect.

  • @Jonathanlouisa
    @Jonathanlouisa 10 หลายเดือนก่อน +2

    I got into coding last year in April. I started with The Odin project and I loved it. I learned the MERN stack. I jump to ruby and ruby on Rails, which is pretty nice, but I discovered my dislike for implicitly typed languages. I looked at Python but I didn't get any tingles and then I learned Rust and again I discovered something new about myself, I discovered my dislike for weak typed languages. I absolutely adore Rust, but as I'm planning on building a PAAS on a timeline, I still have to go with something like Ruby on Rails or NextJS as a team of two newby devs. Feels bad man...

    • @avidrucker
      @avidrucker 10 หลายเดือนก่อน +1

      Best of luck to you!

    • @Jonathanlouisa
      @Jonathanlouisa 10 หลายเดือนก่อน +1

      ty@@avidrucker

  • @Nimward
    @Nimward 10 หลายเดือนก่อน +1

    Happy to see more Rust videos. I've watched every video, some multiple times. Re Nim, I've been publishing a series of videos exploring the language by writing an interpreter in it. For anyone interested in Nim, you might enjoy and I appreciate any feedback.

  • @Blaineworld
    @Blaineworld 8 หลายเดือนก่อน

    before rust, i didn’t “get” iterators. now that i’ve used them in rust i get it.
    one little thing that i like is that a for-loop between two numbers is written like:
    for i in start..end { /* blah */ }
    in a traditional for-loop, the end expression is, at least conceptually, evaluated with every iteration of the loop, but in this syntax, the range is constructed and _then_ iterated over, which makes me feel much less anxious if the end expression is something expensive, while also making the code actually cleaner.
    i have similarly grown to appreciate other “functional” concepts as well.

  • @AK-vx4dy
    @AK-vx4dy 10 หลายเดือนก่อน +1

    Your conclusions are so unconvetional but the same so practical. Never stop to be amazing !

  • @teometz7838
    @teometz7838 10 หลายเดือนก่อน +2

    Your comments about Go got me so curious. You say: it's too practical and efficient, no beauty in it but not in terms of syntax, and yet it almost worked for you. I would love it if you could expand on what you mean with all of that?

  • @ojasmishra3487
    @ojasmishra3487 10 หลายเดือนก่อน +6

    I want a formal programming language that disallows stack allocations because moving rsp is a side effect.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +2

      I mean, that's kinda rust const functions!

    • @aakarshanraj1176
      @aakarshanraj1176 10 หลายเดือนก่อน

      even better, i want a programming language that disallows changing rip register

  • @katie-ampersand
    @katie-ampersand 10 หลายเดือนก่อน +8

    love the lil' _(it's rust)_ there

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      hehe, gotcha!

  • @nWestie
    @nWestie 10 หลายเดือนก่อน

    From what I can tell the main reason rust is compared to C++ is some see it as a successor to it - a powerful, fast running language to write performant code for operating systems, and robots, and the fact that it has kinda similar syntax. It is very clear upon looking deeper that they are very different languages

  • @okie9025
    @okie9025 10 หลายเดือนก่อน +5

    4:30 could you explain the "garbage collector" part for Nim? I'm not a Nim user, but don't all of the languages on the list except Rust use a garbage collector? Why is Nim's garbage collector emphasized here?

    • @dolorsitametblue
      @dolorsitametblue 10 หลายเดือนก่อน +3

      I also don't understand. Nim is also, probably, had one of the best GCs from that list: fast, deterministic, low-overhead, no 'StopTheWorld', memory safe, thread local.
      But it's definitely not an issue now with ARC/ORC being default in 2.0.

  • @Sad_Bumper_Sticker
    @Sad_Bumper_Sticker 10 หลายเดือนก่อน +1

    „I want my code to be poetry”. Obsessive compulsive utopian JOY.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      there's even no syntax highlighting on go.dev/ it's like they hate joy!?

  • @laundmo
    @laundmo 10 หลายเดือนก่อน +2

    Really liked this video. very clear and well reasoned, and about a topic which hasnt gotte enough love!

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      Thank you so much Laund, and thank you for your help!

    • @Speykious
      @Speykious 10 หลายเดือนก่อน

      Agreed

  • @iilugs
    @iilugs 10 หลายเดือนก่อน +1

    Food in a plate, tea in a mug, warm slippers and a No Boilerplate video..... can life get any better?

  • @FabianVilersBe
    @FabianVilersBe 10 หลายเดือนก่อน +2

    Good content, as always. There's small typo on 7:00 : Cofigurable -> Configurable. Also on 9:04 : faddone -> addone.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      thank you!

    • @FabianVilersBe
      @FabianVilersBe 10 หลายเดือนก่อน

      @@NoBoilerplate made a PR 👍

  • @thomasfrans1185
    @thomasfrans1185 10 หลายเดือนก่อน

    I love the quotes in these videos. They capture the idea of Rust so well.

  • @edgeeffect
    @edgeeffect 9 หลายเดือนก่อน

    "Haskel standing on LISP's shoulders, hiding in C's raincoat trying to sneak into production" needs to be made into a cartoon!!!!

  • @sambroderick5156
    @sambroderick5156 10 หลายเดือนก่อน

    One of your best so far. Bit dense but invites deep thought.

  • @szyszak
    @szyszak 9 หลายเดือนก่อน

    "we are going to have to act, if we want to live in a different world" - oh, that sudden urge to blast C&C OST during my next coding session

  • @ajs1998
    @ajs1998 10 หลายเดือนก่อน +1

    I think Lean 4 is the closest thing to a perfect language for me. If it's good enough to prove the most complicated theorems in math, then it's good enough to prove simpler practical things. It's just so clean and powerful

    • @laundmo
      @laundmo 10 หลายเดือนก่อน

      hmm, whats the progress on its ecosystem like? is it general purpose enough to cover various topics from graphics, ui, web, api etc?

    • @ajs1998
      @ajs1998 10 หลายเดือนก่อน

      @@laundmo it's still very new and focused on mathematics built by mathematicians. But I have no doubt you can extend it to do whatever you want a programming language to do. In fact the former executive director (David Thrane Christiansen) of the Haskell Foundation recently moved to doing research for Lean, and just yesterday demo'd his markdown-like syntax in Lean used to generate documentation. I wish I could fast forward a few years to see what Lean is capable of, it seems very promising to me

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +3

      Oh nice, I'll check it out too. Note: I'm not here raving about Rust because I think it's the best language, I'm here raving about rust because I can get paid to write *nearly* the best language :-D

    • @cpl.226
      @cpl.226 10 หลายเดือนก่อน +2

      Lean is a proof assistant, not a general purpose programming language. Dependent types are great for encoding fiber bundles and what have you, but several languages that employ dependent types have failed to gain any sort of mainstream traction as they are simply far too complicated and cumbersome for any sort of practical program that isn’t written by PhD students.

  • @kellybmackenzie
    @kellybmackenzie 9 หลายเดือนก่อน

    I adore Haskell so much and this video makes me so happy! I love it!

  • @Alazoral
    @Alazoral 10 หลายเดือนก่อน +1

    Provable code is actually very easy in any language. Just look at the code. If you're looking at code, you've proven that it is in fact code and can rest easy on the mathematical certainty that the system that it's running is 100% code.

  • @ogeidyt
    @ogeidyt 10 หลายเดือนก่อน +2

    damn no way bro has tried coq

  • @jackhales6179
    @jackhales6179 10 หลายเดือนก่อน

    This video couldn't have come at a better time for me. In the middle of learning Rust for the 2nd/3rd time, starting to get it, and this cut at the reason I was looking at it. The "const fn" attributes you describe remind me of Python's Numba library, where there are similar restrictions in NoPython mode. That library is one of the reasons I went further into Rust, because Numba is so fast, but Rust was faster. Thanks!

  • @angeldude101
    @angeldude101 10 หลายเดือนก่อน +1

    I'm always unsure whether to consider &mut parameters to be "pure" or not. In one sense, they're obviously being mutated outside of the return value, but in another, the fact that it's explicitly marked means that you can basically just treat it as an explicit return value with more ergonomic syntax and more efficient performance. At least, this is at the function definition site. On the caller's side, it's less clear when a method call would mutate its receiver.
    The lack of printing in const fn is probably my single biggest concern about them, since it's extremely useful to know the actual value that the function is being passed so that you can better determine what exactly you're supposed to block and how. Without knowing the actual type you should use or what preconditions have seemingly been forgotten, and without being able to just print out the value that shouldn't've made it through, the only remaining options are to either remove the const flag, or use a debugger to be able to effectively insert extra print points ad-hoc. I'm pretty sure several pure functional languages have impure escape hatches specifically for printf debugging (even if laziness means they're not as useful as they'd be in a strict language).
    There's also the matter of const traits still being unstable, so if you have a pure function that you want to make generic over a particular (presumably pure) trait, you can't actually mark it as const quite yet.

    • @piotrfila3684
      @piotrfila3684 10 หลายเดือนก่อน +1

      I agree, I don't see how &mut could cause problems here, as only one mutable reference can exist at a time. They are also very useful, I use them to compute FFTs at compile time (unfortunately requires nightly compiler for now).
      Printing could be considered pure if it's write-only from the point of view of the code - even though it's mutating global state it can't have any side effects if no function is allowed to read the log. Maybe for now we could have a macro that appends a message to a file instead of printing?

  • @kinomonogatari
    @kinomonogatari 10 หลายเดือนก่อน +1

    Woah these reminded me of Fortran's pure subroutines and functions.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      easy to do in a simple language, imagine doing that in a language that runs in the browser ;-)

    • @kinomonogatari
      @kinomonogatari 10 หลายเดือนก่อน

      @@NoBoilerplate Haha fair enough. Glad I chose to be a physicist instead.

  • @Mohammed24441
    @Mohammed24441 9 หลายเดือนก่อน

    Aren't formal methods used to specify systems/applications before even getting to the coding part? That's where they come in useful cause they enforce reasoning about the What before starting implementing/code the How.
    That's the beauty of formal methods where they help formulate the Functional Requirements into a formula that is hard to misunderstand before finally, a programmer translates the requirement into code.
    You even get to run and test the specifications using model checkers to validate before moving forward to the coding aspect.

  • @doce3609
    @doce3609 10 หลายเดือนก่อน

    Thank you to introducing me to this clippy option. I love it

  • @spycemyster
    @spycemyster 10 หลายเดือนก่อน +1

    Your videos are so inspiring and informative! I'm wondering what your opinion is on C#? I'm a game developer and I code everyday in it. I also know a little bit of Rust and from what I see, C# feels like an "easier" version of Rust. It's type-safe, has compile-time source-generation, the newer versions are including more and more functional patterns and paradigms, and it's still fairly performative (though not as much as Rust).

  • @Felipe-53
    @Felipe-53 10 หลายเดือนก่อน

    You are a very inspirational person! Your work is awesome! Thanks!

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      Thank you so much! I'm hoping to help as many folks as I can (and I'm learning a lot in the process!)

  • @Dr_Dude
    @Dr_Dude 3 หลายเดือนก่อน +1

    a fellow formal methods! subscribing.

    • @NoBoilerplate
      @NoBoilerplate  3 หลายเดือนก่อน +2

      solidarity! (and commiserations 😅)

    • @Dr_Dude
      @Dr_Dude 3 หลายเดือนก่อน +1

      @@NoBoilerplate 😂 indeed it is

  • @jacrease8880
    @jacrease8880 10 หลายเดือนก่อน

    these videos are what got me into rust and i love it

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      wonderful, thank you!

  • @sungwonchung
    @sungwonchung 10 หลายเดือนก่อน

    You're the reason I'm learning rust!

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      WONDERFUL! You're going to have a really great time!

  • @patrickmwangi7918
    @patrickmwangi7918 10 หลายเดือนก่อน +1

    "Beauty is in the eye of the binary holder" 😄

  • @skytech2501
    @skytech2501 10 หลายเดือนก่อน

    Finally! Waited so long for Rust treat😂

  • @Sakurina
    @Sakurina 10 หลายเดือนก่อน +2

    Not a Rust developer, but I have watched all the videos on the channel so I’m not sure if I’m missing something… if the Rust macro runs at compile time, would that imply that the PATH from the macro version would be the PATH environment variable of the machine that built the code, and not the one running the code? They seem to be presented as equivalent in the video, but I don’t get it unless you force the user to build on whatever machine they are deploying to or if I’m missing something else.

    • @laundmo
      @laundmo 10 หลายเดือนก่อน

      const functions can run at compile time too. if you could call the env method in a const context, it would be the same as the macro. but you can't. so you use env!() for the compiling machine and env() for the running one

  • @Pikrass
    @Pikrass 10 หลายเดือนก่อน

    One big reason you probably shouldn't make all possible functions const, most notably if you're writing a library: turning a const function into a non-const one is a breaking change, since your users won't be able to use it in their const functions anymore. So adding the "const" keyword should not be automatic: you have to think about whether you could need non-pure stuff in your implementation in the future (including loops etc).

  • @schrenk-d
    @schrenk-d 10 หลายเดือนก่อน

    So interesting.
    I'd imagine the allowing the macro system in const fn's could possibly get a little bit messy when it comes to cross compiling.
    I'll have to experiment.

  • @tgirlshark
    @tgirlshark 10 หลายเดือนก่อน

    gosh I love your videos, none are like yours
    also rayon is already 9 years old whoa whaa

  • @FelixNielsen
    @FelixNielsen 10 หลายเดือนก่อน

    We can at the very least agree that imposing reasonable restrictions can, and usually will result in better code, and indeed better programmers.
    I am of course very much a purist, and firmly believe that while there may be multiple "not wrong" ways of doing things, if there is more than one right one, you're doing something wrong. It is perhaps my greatest frustration, and will continue to be so, as of course what i desire is unattainable.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      Hi felix! Yeah, reminds me of the big lesson Python learned, which was to do the opposite of Perl:
      Perl "There's more than one way of doing it"
      Python: "There should be one-- and preferably only one --obvious way to do it."

    • @FelixNielsen
      @FelixNielsen 10 หลายเดือนก่อน

      @@NoBoilerplate Indeed, and it's not just a matter of safe and efficient code either, but also learning. It can be rather difficult sometimes, to fully comprehend how something actually works, if there is a 100 different "right" methods of doing it, naturally including 100 different explanations, if you're lucky.
      Of course sometimes there has to be several paths to the same destination, and the path itself can sometimes explain a great deal about the purpose, say
      2^n-1 or (1

  • @huantian
    @huantian 10 หลายเดือนก่อน +1

    Nim mentioned! But seriously, I do think Nim has a place here. It stands in the middle of that Venn diagram you show, but leans more toward the practical side, whereas rust leans a bit more to the provable side. Both are great and have their place I’d say. Nim is held back by its obscurity, but I believe that it will continue to grow and will be a great option one day.

  • @nekomakhea9440
    @nekomakhea9440 10 หลายเดือนก่อน

    The efficiency-at-all-costs description of Go makes me think of depression-inducing soviet brutalist architecture, but in programming language form...

  • @AndreiGeorgescu-j9p
    @AndreiGeorgescu-j9p 9 หลายเดือนก่อน

    Haskell is getting dependent types added to the GHC so most of the you want is going to be natively supported. And I know other people have said this but Rust isn't an fp language nor is a general purpose language so most general purpose applications wouldn't use it because it deals with plenty of unnecessary details the same way formal proofs are. And haskell is far more practical than nearly every general purpose language, pretty much by definition

  • @DeclanMBrennan
    @DeclanMBrennan 10 หลายเดือนก่อน

    That was very well presented and tantalising and moreover is a timely prompt for me to get beyond my very superficial knowledge of Rust.
    *A correct program but not necessary the right correct program* ? 🙂
    I'm not an expert in proofs, but they have always seemed like an impractical panacea to me, except in very simple use-cases. Sure we could formally prove that the code matches a potentially very elaborate specification but how do we know that the specification matches what we really wanted the program to do?

  • @rotaerk
    @rotaerk 10 หลายเดือนก่อน +1

    I don't agree with you that Haskell is "too complicated for general programming". Every language has a learning curve, but most are similar enough to one another that knowledge of one starts you closer to the top of the curve with the next. Haskell is different enough from the rest that even if you're familiar with them, you're still probably going to start near the bottom of the curve. (I think experienced programmers have a tendency to expect to be able to read code in languages they don't know, by drawing from their experience with similar languages. This doesn't work with Haskell.) But once you get past the learning curve, it's very practical to use for general programming.
    You mention that you "would probably dislike coding [web apps] in Haskell", but this is actually a pretty popular use-case for the language. I suspect you haven't actually given the language enough of a chance, so you're limited to *speculating* on how practical it might be in theory.

    • @laundmo
      @laundmo 10 หลายเดือนก่อน

      haskell has been around for how long compared to it's current popularity?
      if you were right, it'd be more popular. it's not and rust is

    • @rotaerk
      @rotaerk 10 หลายเดือนก่อน

      @@laundmo There are plenty of factors that contribute to a language's popularity beyond how practical it is to use. Its lower popularity relative to rust is not an indication that it is less practical to use.

  • @JonathanPlasse
    @JonathanPlasse 10 หลายเดือนก่อน

    Awesome video, thank you!

  • @woosix7735
    @woosix7735 6 หลายเดือนก่อน

    One of the things that rubs my the wrong way about rust in the context of functional programming is how they don’t like recursive functions, which for me is foundational for FP.

  • @hwndept
    @hwndept 10 หลายเดือนก่อน

    Love your videos! Keep it up!

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      thank you, I will!

  • @RenderingUser
    @RenderingUser 10 หลายเดือนก่อน +2

    TH-cam didn't send me notifs for this video. What happened

  • @user-hk3ej4hk7m
    @user-hk3ej4hk7m 10 หลายเดือนก่อน

    Reminds me of what c++ is doing with constexpr functions

  • @TheSast
    @TheSast 10 หลายเดือนก่อน +1

    What are your favourite clippy (or rustc) lints? especially allow-by-default that you'd like to be warn by default, or perhaps even deny or forbid.

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      they're in this video!

    • @TheSast
      @TheSast 10 หลายเดือนก่อน +1

      @@NoBoilerplate I couldn't be sure you didn't hide a few more XD
      Recently I've been on a kind of clippy addiction, went and tried to make as many lints work together as possible just for the fun of it, I ended up discovering quite a few that I like.
      The most memorable ones for me must be:
      - infinite_loop = "forbid", I think this should just be considered a compilatiom error, as `!` should not coerce into `()`, it can make it quite hard to predict the behaviour of a function, especially game loop related ones, for the same reasin I wish `Result>` should be mandatory over `dyn Box` in fallible loops.
      - allow_attributes = "forbid", I see no reason not to use `allow` over `expect` if `lint_reasons` is enabled.
      - mod_module_files = "deny", this naming scheme can make traversal via file finders quite difficult
      - non_ascii_idents = "deny", without it it can be hard to understand contributioms on an open project with devs who speak different primary languages.

    • @Randych
      @Randych 10 หลายเดือนก่อน +1

      #[deny(unwrap_used)]
      #[deny(expect_used)]
      😐

  • @meanmole3212
    @meanmole3212 10 หลายเดือนก่อน

    That C&C reference short circuted by hungover brain

  • @DrThalnos
    @DrThalnos 10 หลายเดือนก่อน +2

    I know it is not very new, but FORTRAN has the explicit decleration of pure functions and subroutine and is very low level

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน

      If you have no other systems to handle side-effects and mutation, tagging whole functions as pure isn't a bad idea. Rust has a much more nuanced way of doing things :-)

  • @dpcxx
    @dpcxx 10 หลายเดือนก่อน

    There is a language that wants to be born that is like Rust (allow mutability and references), but uses capability-system like features to guarantees that if a file-system capability wasn't passed to a certain objects/code, they will not be able to touch the file system, etc. . Basically - language prevents action at the distance - any code can be much easier reasoned about what can it do, even if buggy/malicious. In such language `unsafe` would be a capability itself. This would improve by a lot real life composability of software, which is currently limited by the matter of trust (no one has time to review all the ever-updated code of your dependencies).

    • @0LoneTech
      @0LoneTech 9 หลายเดือนก่อน

      I've seen a few attempts, but the closest that springs to mind is Haskell. Specifically, Safe Haskell with the ability to restrict and trust specific modules, and particularly how Haskell code can be inferred safe. I'm not so sure about Rust, since I found you could do things like global inline assembly to produce link level side effects without using the unsafe keyword.
      The feature is known as an effect system.

  • @pancakedrivet
    @pancakedrivet 10 หลายเดือนก่อน

    Hey Tris, thanks for another great video. It once again comes as I'm reasoning through something similar with some side project rust code. I have a struct of state that I use throughout a program, and I've been iteratively making the things that update it smaller and easier to reason about. I didn't realise that what I was doing was making my methods more functionally pure, but now I have a reason to lean in even further!
    The only thing that I didn't quite get (maybe I just need to read around it some more) but I see what we can and can't do with `const fn`, but I didn't really understand why we would want to opt in to them, given that we are wilfully limiting ourselves to what const funds are able to do, versus "being good citizens" with limiting side effects in regular functions?

  • @dingus4138
    @dingus4138 10 หลายเดือนก่อน

    Great video as always! Personally I don’t like working with Rust, I prefer to be a dumb Gopher writing basic code 😅 but it is fun to see how things are in rust land

    • @NoBoilerplate
      @NoBoilerplate  10 หลายเดือนก่อน +1

      hey, second best (imo) isn't so bad! 😅

  • @W1ngSMC
    @W1ngSMC 10 หลายเดือนก่อน +2

    7:53 Small correction, that isn't idempotence.
    Idempotence is applying some (idempotent) function multiple times always yields the same result.
    E.g:
    x =/= y =/= z =/= w (they could be equal but don't have to be, that makes it boring)
    f(x) = y
    f(f(x)) = y
    f(z) = w
    f(w) = w
    Example for f in linear algebra with screwed up Matlab notation for matrices (; is new row space is new column):
    f([x; y]) = [1 0; 0 0] * [x; y] = [x; 0]

  • @MixturaLife
    @MixturaLife 9 หลายเดือนก่อน

    Got Tom Scott vibes from this video and I like it )

  • @coolkattcoder
    @coolkattcoder 10 หลายเดือนก่อน

    It would be nice to have a compile time function type or something. As sometimes having code that could differ based on the processor is ok. For example I might want to do some matrix math which could involve sin and cos for rotation, and save the result to a const variable. Let us say the worst thing happens, and somehow we have a 90 degree difference between a runtime rotated object, and a compile time rotated object. It won't matter for game development, because the player would never know what rotation was intended unless they check the code. Perhaps it would be nice to have some sort of unconst block that alllows running non-const functions in a const function, when it is known that bad things won't happen.
    Edit: Just got to the macro part of the vid, I had no idea that macros could do that, I'm going to quickly mess around with trig functions in macros, and see what happens. I may delete this comment if macros are good enough!!!
    Update to the Previous Edit: Perhaps with proc macros it might be possible (but they are even more inconvenient than build scripts)! However with regular macros I don't see how this would be possible.

  • @michaelschnell5633
    @michaelschnell5633 10 หลายเดือนก่อน

    Great stuff to know ! And to remember ....

  • @hojjat5000
    @hojjat5000 10 หลายเดือนก่อน

    I have to use Go at work. I miss Rust so much. Every time I handle error, define an enum, write a switch case,... it hurts my soul.

  • @CJMay
    @CJMay 10 หลายเดือนก่อน

    Nice command and conquer reference

  • @franklinyiu1770
    @franklinyiu1770 10 หลายเดือนก่อน +2

    Does C++ get the same effect as Rust's const with constexpr? If not all the way, does it at least get most of the benefits?