Bringing pattern matching to Dart

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

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

  • @MarcusTwichel
    @MarcusTwichel ปีที่แล้ว +33

    Bob! I learned how compliers work from your book in my senior year compiler course, and now watching you talk about ASTs in the real world is so fulfilling ☺ thank you for all the hard work and an amazing language 💯

    • @safiussifat
      @safiussifat ปีที่แล้ว +1

      what is the name of the book?

    • @AnthonyBullard
      @AnthonyBullard ปีที่แล้ว +4

      @Safius Silat Crafting Interpreters

    • @safiussifat
      @safiussifat ปีที่แล้ว +1

      @@AnthonyBullard thank you

  • @AnthonyBullard
    @AnthonyBullard ปีที่แล้ว +31

    Thank you Bob (and of course the rest of the Dart team) for finally bringing this and tuples(err, records) to the language. I know I bugged you all about these features a lot all the way back in 2019.
    This goes to show that Dart at 3.0 will be the most improved language over the last five years

    • @AnthonyBullard
      @AnthonyBullard ปีที่แล้ว +2

      Oh, and I loved Crafting Interpreters

    • @AnthonyBullard
      @AnthonyBullard ปีที่แล้ว +4

      Oh, and thank you for value semantics! That really makes my day. Now only value classes are missing 😉

  • @tomchapman128
    @tomchapman128 ปีที่แล้ว +11

    Switch expressions are a great addition! Love them in C# and really appreciate them in Dart now!

  • @keylinwu4483
    @keylinwu4483 ปีที่แล้ว +5

    Thank you for all these improvements! Architecture and structure in dart projects it's every new feature more powerful, clean, and beautiful! Coming from Swift, pattern matching and sealed unions is a crucial language features, and I've been missing that a lot! Thanks again!! Happy and can't wait to try all this!🤩

  • @dillonnys7707
    @dillonnys7707 ปีที่แล้ว +24

    Thanks for your hard work, Bob, and to everyone on your team! Really looking forward to playing with these features 😃

  • @yonoseespanol
    @yonoseespanol ปีที่แล้ว +7

    Dang -- switch case pattern matching is awesome. Very impressed!

  • @Gabriel_Bento
    @Gabriel_Bento ปีที่แล้ว +1

    That's really incredible! Today I've just started reading his book and for my surprise, i click in a Flutter video and guess who is hosting? The GOAT himself 👏🏻👏🏻

  • @esc4p3EP
    @esc4p3EP ปีที่แล้ว +2

    At last! I've been wanting comparison in switches since Dart 1. Thanks guys! 👍

  • @DaewonTech
    @DaewonTech ปีที่แล้ว +6

    ⛱ Summary
    1:54 Multiple Returns
    6:09 Control Flow in Argument Lists
    8:26 JSON Destructuring
    10:28 Usable Switches
    13:43 Object Destructuring
    15:28 Functional Style Coding

  • @truthmatters7573
    @truthmatters7573 ปีที่แล้ว +13

    Can't wait for Dart 3 to ship! :D Great work all of you

  • @prerakmann1418
    @prerakmann1418 ปีที่แล้ว +3

    Damn, this just made 2023 the best year 🔥

  • @trymnilsen549
    @trymnilsen549 ปีที่แล้ว +4

    Thanks bob and rest of the team, excited for it!

  • @hyungtaecf
    @hyungtaecf ปีที่แล้ว +4

    I simply love it! This is so useful in so many ways! Thanks for your hard work!!

  • @infinitezymalny
    @infinitezymalny ปีที่แล้ว +3

    Wow, json pattern matching is amazing! It will simplify work with json.

  • @Pesthuf
    @Pesthuf ปีที่แล้ว +12

    Ah, ADTs! I've liked Dart before, but all these features really make it way better.
    The language deserves better than to be regarded as merely "the language Flutter apps are written in" - I think it ticks pretty much all the boxes of what I want in a language and how it can be deployed.

    • @merthyr1831
      @merthyr1831 ปีที่แล้ว +3

      Yes! I love dart so much. I wish more people appreciated it outside of Flutter :)

  • @bselwesiuk
    @bselwesiuk ปีที่แล้ว +2

    Such an amazing job by the Dart team, thank you!

  • @WilsonSilva90
    @WilsonSilva90 ปีที่แล้ว

    Hey, we got Bob Nystrom on our team! I love his Game Programming Patterns book. This is so cool 💪🏾

  • @guildem
    @guildem ปีที่แล้ว +4

    Finally, tuples, and switch returning value like Rust. this is great !

  • @SEGVeenstra
    @SEGVeenstra ปีที่แล้ว +2

    I cannot believe how exited I am for these features. (Thx Bob for explaining it so well!)
    Is this how people feel when watching tv and their sports team is winning?

  • @thanhdatvo0
    @thanhdatvo0 ปีที่แล้ว +3

    We love this man! now we can make function return error and exception, same as golang and rust!

  • @souljorn1
    @souljorn1 ปีที่แล้ว +2

    Great work and presentation. This all looks amazing.

  • @FilipePratadeLima
    @FilipePratadeLima ปีที่แล้ว

    This is awesome... Im falling in love with Dart after so many years in Typescript (won't even mention Javascript) Land. Thank you.

  • @voncth5791
    @voncth5791 ปีที่แล้ว +2

    Thank for your amazing work dart folks!

  • @akay5042
    @akay5042 ปีที่แล้ว +4

    I can already see pattern matching and sealed classes optimising my current code. Thanks!

  • @irhasdev
    @irhasdev ปีที่แล้ว +1

    Is so amazing to see the Dart lang developer are also music instrument developer

  • @aldeywahyuputra5719
    @aldeywahyuputra5719 ปีที่แล้ว

    12:42 YESSS!!!! THIS IS SO AWESOME!!!
    OH THANK YOU DART TEAM FOR SWITCH AS EXPRESSION, ILYSM!!! ❤❤❤❤

  • @jaweene
    @jaweene ปีที่แล้ว +2

    Some of these features are very practical!

  • @danvilela
    @danvilela ปีที่แล้ว +1

    I LOVE THIS!! Thanks Dart team!!!

  • @rahuldange
    @rahuldange ปีที่แล้ว +2

    Just one word. Amazing!!!!💙

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

    Crafting Interpreters is the best book I have ever read

  • @slyblood85
    @slyblood85 ปีที่แล้ว

    Dudes got a pretty sick setup

  • @greglee7708
    @greglee7708 ปีที่แล้ว +3

    Functional programming was always my favourite

  • @richardambler
    @richardambler ปีที่แล้ว

    I'm already drooling. Exciting times!

  • @noursalman932
    @noursalman932 ปีที่แล้ว

    So excited for conditional arguments

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

    2:00 Multiple Returns
    6:22 Control Flow In Argument Lists
    10:28 Usable Switches
    13:36 Object Destructuring
    15:30 Functional-Style Programming

  • @alurma
    @alurma ปีที่แล้ว

    Cool! Two questions:
    1) Does this essentially make enums unnecessary? I understand that backwards compatibility may mean that they stay in the language.
    2) Is Haskell style pattern matching supported, allowing to match both parts and the whole thing?
    Haskell working example:
    Input: let a@(b : c) = [1, 2] in (a,b,c)
    Output: ([1,2],1,[2])

  • @kevinchadwick8993
    @kevinchadwick8993 ปีที่แล้ว

    I think I will try to move case expressions to where case statements are allowed as it is much more readable. I love the case statements now, they remind me of my favourite language Ada. I love the data validation options. Ada has a Valid check for records. Pattern matching seems more flexible but can you get it wrong?

  • @0xba1
    @0xba1 ปีที่แล้ว +4

    Love everything about this, except the $1 and $2 indexing for records, gives me "bad feelings". Love it, can't wait!

    • @qG0L0r6W
      @qG0L0r6W ปีที่แล้ว +3

      It's on purpose. If you're not using destructuring to access the properties without names, you better give them proper names, otherwise it's going to be confusing regarding of whether it's $1, _1, first, second, etc.

    • @GeorgeNoiseless
      @GeorgeNoiseless ปีที่แล้ว

      Having positional access as an option is quite sensible

    • @andreygritsay762
      @andreygritsay762 ปีที่แล้ว

      @@qG0L0r6W but why use dollar sign and not just numbers?

    • @iGhostr
      @iGhostr ปีที่แล้ว +7

      Why it's just 1 or 2 dollars... quite cheap if you ask me

    • @jonathanduck5333
      @jonathanduck5333 ปีที่แล้ว +1

      @@andreygritsay762 I also wonder why start at 1 and not at 0 as is usual in programming

  • @blablablabla29382
    @blablablabla29382 ปีที่แล้ว +2

    Nice voice quality, ty !

  • @YukiAttano
    @YukiAttano ปีที่แล้ว

    Isn't the last mentioned part "functional-style programming", where we are using the sealed classes in switch case operations, the same as doing "if else" with some compiler sugar? or do they generate an enum in the background for matching the right type? (It's a performance question, do we have the casting overhead on all checks?)

  • @fille.imgnry
    @fille.imgnry 18 วันที่ผ่านมา

    Dart is becoming one my fav langs ❤

  • @aislanarislou
    @aislanarislou ปีที่แล้ว +2

    This is one of the awesome things I was missing in Dart.
    Now I'm hopefully waiting for Pipes to be part of Dart as well, so we can make really awesome and readable codebases that Dart deserves.

    • @yonoseespanol
      @yonoseespanol ปีที่แล้ว +1

      You can use pipe semantics via operator overloading. Not an exact fix..

    • @aislanarislou
      @aislanarislou ปีที่แล้ว

      @@yonoseespanol can you to exemplify this approach ?

  • @CoderJava
    @CoderJava ปีที่แล้ว +2

    This is so cool. I love it.

  • @thomasjarvstrand1511
    @thomasjarvstrand1511 ปีที่แล้ว +1

    Wow. Just wow. Can't wait!

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

    Great overview!

  • @XSmile2008
    @XSmile2008 ปีที่แล้ว

    Finally! In 2023 we finally can use `when` like statement that was added in Kotlin in around 2012)

  • @GJJ2019
    @GJJ2019 ปีที่แล้ว +2

    this some awesome stuff cant wait :)

  • @leanghenglim
    @leanghenglim ปีที่แล้ว +1

    Ugh, I just got schooled around unnecessary switch breaks. You mean to tell me I didn't need to use it all these time... they are quite annoying. Lol

  • @deniszavarzin2768
    @deniszavarzin2768 ปีที่แล้ว +2

    With pattern matching soon we will see new generic features and Prisma-like ORM. This is amazing.

  • @鄭小白-n4p
    @鄭小白-n4p 3 หลายเดือนก่อน

    It's easy to make a compiler now!

  • @zark4711
    @zark4711 ปีที่แล้ว

    For ADTs I would have liked the enums with associated values approach from Swift more instead of subclassing. Haskells handels them beautifully as there is not difference between enum and class/struct. But then you have all this OO in other languages and somehow need to cope with it. Kotlin also uses subclassing as a solution, it is a little clumsy, but it works. For Dart < 3 I implemented classes, that have an enum for the case and a bunch of optional variables - only one filled for the appropriate case - which would be tedious, if I wasn't using Sourcery for generating all this. It is good to finally support ADTs in any way.

  • @msh_dev
    @msh_dev ปีที่แล้ว +6

    What about Static meta programming?

    • @jonathan-dias
      @jonathan-dias ปีที่แล้ว +6

      will come after Dart 3. From the issue they say they will probably release a beta of metaprogramming later this year

    • @msh_dev
      @msh_dev ปีที่แล้ว

      @@jonathan-dias What do you think will static meta programming will help a lot of developers.

    • @jonathan-dias
      @jonathan-dias ปีที่แล้ว

      @@msh_dev definitely.

  • @AlexanderMazuruk
    @AlexanderMazuruk ปีที่แล้ว +2

    Awesome stuff! Thanks

  • @felipeemidio7240
    @felipeemidio7240 ปีที่แล้ว

    Man... that's... just... beautiful!!

  • @holthuizenoemoet591
    @holthuizenoemoet591 ปีที่แล้ว

    I really like Dart to get more populair for general computing, like a more robust Typescript alternative

  • @fibulawars
    @fibulawars ปีที่แล้ว +2

    I like this guy

  • @Walid-bv9vy
    @Walid-bv9vy ปีที่แล้ว

    i appreciate your work

  • @rafaelfranco7643
    @rafaelfranco7643 ปีที่แล้ว +1

    awesome!!!

  • @bernaferrari
    @bernaferrari ปีที่แล้ว

    I don't understand how "when" is different from "&&", how to "case" the if, and how :key works, is that the name of the return value?

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

    Incredible!

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

    This is 🔥🔥!!

  • @web3tel
    @web3tel ปีที่แล้ว +1

    it is amazing, thank you!

  • @alurma
    @alurma ปีที่แล้ว

    Beautiful

  • @anujsaini7846
    @anujsaini7846 ปีที่แล้ว

    can we use records as tuple for passing data to riverpod providers using family?

    • @ElteHupkes
      @ElteHupkes ปีที่แล้ว

      I see no reason why not, I think they're going to be very useful for this indeed.

  • @kerandonovan7255
    @kerandonovan7255 ปีที่แล้ว

    Awesome!

  • @prerakmann1418
    @prerakmann1418 ปีที่แล้ว

    Can Records be extracted to a Typedef?

  • @jalalokbi2875
    @jalalokbi2875 ปีที่แล้ว

    That's great news :)

  • @deniszavarzin2768
    @deniszavarzin2768 ปีที่แล้ว

    What font is used in this slides?

  • @loclethai
    @loclethai ปีที่แล้ว

    thanks

  • @catbb
    @catbb ปีที่แล้ว

    nothing about destructuring assignment ?

  • @이운영-i9q
    @이운영-i9q ปีที่แล้ว

    I love it!!!! ❤️ 😍

  • @r.i.c.o9820
    @r.i.c.o9820 ปีที่แล้ว

    Sounds interesting

  • @weathercontrol0
    @weathercontrol0 ปีที่แล้ว

    Still waiting for union types

  • @samueladole6074
    @samueladole6074 ปีที่แล้ว

    So much Gold in Dart

  • @evgeniykalaganov6753
    @evgeniykalaganov6753 ปีที่แล้ว

    1. destructuring variables and objects just -stealed- borrowed from Kotlin :), 2. that “awesome” proposal about …() for widget parameters is really ugly, 3. destructuring json looks cool, 4. switch returning a result looks great (thanks Kotlin)

  • @edenassos
    @edenassos ปีที่แล้ว

    I would rather be able to use Rust with Flutter.

  • @Voltra_
    @Voltra_ ปีที่แล้ว

    Sounds great, but would have expected something closer to Haskell or Rust to be able to finally get rid of some of the weird codegen for proper BLoC implementations

  • @saiphaneeshk.h.5482
    @saiphaneeshk.h.5482 ปีที่แล้ว

    Will there be any stable framework for dart backend?

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

    who is using pattern and records in their code

  • @nunebhargav
    @nunebhargav ปีที่แล้ว

    When Dart adopts Rust features 🔥🔥

    • @richardambler
      @richardambler ปีที่แล้ว +1

      Actually, these are features that have existed in various languages, such as the ML family of languages, for a long time. I think what we're seeing is a case of modern programming languages converging to support the same set of great features that have arisen in different languages at different times over the past 50 years or so.

  • @meyeti5422
    @meyeti5422 ปีที่แล้ว

    ranges

  • @АлександрИнженер-д4б
    @АлександрИнженер-д4б ปีที่แล้ว

    Норм боб

  • @thatGeorgeR
    @thatGeorgeR ปีที่แล้ว

    Why naming tuples "records"? To confuse users of other languages? You go C# way in naming things and this is not something good.

    • @joranmulderij
      @joranmulderij ปีที่แล้ว

      Because they are not tuples

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

    More garbage,
    Why don't people like keeping stuff simple and clean.

  • @markonovakovic3838
    @markonovakovic3838 ปีที่แล้ว

    as F# lover I can say that some of this is pretty ugly.... but am happy that it is coming. in case am using Dart (I hope not honestly) by the time 3.0 comes along I would definitely be happy about it. this is definitely couple of years too late tho

  • @jeroboam4486
    @jeroboam4486 ปีที่แล้ว +2

    Very good presentation, however I'm saddened that Dart is falling in the same trap than C#: over burdening the language with syntactic sugar, functional elements etc to 1) appease the 5% of language snobs that demand these features and 2) justify the Dart team salaries.
    Dart isn't my main language so I don't code frequently in it. It started as a very simple language that wasn't getting in my way. But every time I come back to it more useless stuff has been added. Sometimes I spend more time thinking about the language than my code.
    More isn't better.

    • @baggern
      @baggern ปีที่แล้ว +3

      lmao cope

    • @xmanreturn
      @xmanreturn ปีที่แล้ว

      If it isn't your main language why do you care
      I think the feature added will be useful for sure

    • @jeroboam4486
      @jeroboam4486 ปีที่แล้ว +1

      @@xmanreturn The fact it's not my main language doesn't mean I don't use it. And it's quite confusing when I do use it.

  • @user-sl7oc7tg4t
    @user-sl7oc7tg4t ปีที่แล้ว +1

    Cool! Thanks for your job!
    w.r.t. for loop over Map.entries, I think it makes more simple and intuitive to just yield Record (key, value) than MapEntry.
    Anyway, can't wait for Dart 3.0 on stable channel!

    • @m00ni
      @m00ni ปีที่แล้ว +2

      Ideally, yes, but that would require a potentially breaking change to the Map interface, which is harder. We have ideas on how to make this even nicer.

    • @user-sl7oc7tg4t
      @user-sl7oc7tg4t ปีที่แล้ว

      @@m00ni In my opinion, there are two possibilities; add a new getter 'records' to Map or MapEntry inherits Record (K, V),
      but the former would be duplicated method, while the latter, I don't know whether it returns (key, value) by inheriting.
      I'm looking forward to your ideas on next announcement!!

  • @GeorgeNoiseless
    @GeorgeNoiseless ปีที่แล้ว

    YES, finally. Thank You!
    It never ceases to amaze me how close Dart is to Python in many respects. For me personally that is a massive positive.
    Getting sidetracked a bit further Python even has a GUI library (widget wrapper) that seems to borrow somewhat from Flutter -- PySimpleGUI.