Everything you need to know about Kotlin 2.0 🟣

Поділитися
Вставка
  • Опубліковано 11 гру 2024

КОМЕНТАРІ • 113

  • @joshdoesitall
    @joshdoesitall 6 місяців тому +284

    Kotlin 2 before GTA6 is crazy

    • @curizic
      @curizic 6 місяців тому +33

      I suspect there will be Kotlin 3 before GTA 6

    • @gregandark8571
      @gregandark8571 4 місяці тому +1

      @@curizic Maybe even Kotlin 4.0 before GTA 6.

  • @Cypressious
    @Cypressious 6 місяців тому +51

    Most of the new language features you showed were previews of changes that are potentially coming in future versions. They are not available in 2.0.

    •  5 місяців тому +3

      Indeed, most of these were not mentioned in the release notes. We already moved our Android project to K2 and if the destructuring expressions really worked like that, our code wouldn't have compiled in the first place, but we saw none of that.

    • @patrykkowalski8355
      @patrykkowalski8355 5 місяців тому +5

      true, seems like typical click bait

  • @mahiainti678
    @mahiainti678 6 місяців тому +3

    3:37 fyi the correct term is "destructuring" not destructing. Destructing an object usually refers to freeing its memory, what we are doing here is very different. On the other note a lot of cool features especially better smartcast

  • @jackeblan
    @jackeblan 6 місяців тому +49

    I love the backing field😮

    • @Henderson101
      @Henderson101 6 місяців тому +2

      Coming from C#, this is kind of like a readonly property:
      private sting x; //is mutable
      public string X => x; // is immutable
      (or you can do, which makes an implicit private backing field int he generated IL, but in your code, you just use X)
      public X {get; private set;}
      (Or if you like old school)
      private string x;
      public string X
      {
      get => x;
      private set => x = value;
      }

  • @universe8989
    @universe8989 6 місяців тому +4

    Loved the guarded condition!

  • @MaggicBones
    @MaggicBones 6 місяців тому +6

    Thank you so much Stev !

  • @guai9632
    @guai9632 6 місяців тому +3

    hope we'll have union & intersection types everywhere one day

  • @Anonymous-jb7xx
    @Anonymous-jb7xx 6 місяців тому +3

    It's not "destructing", it's "destructuring". And triple quote strings are called "raw strings".
    Overall the changes seem rather underwhelming, there's no new features to functional programming for example (Kotlin's strongest point).

  • @WDGKuurama
    @WDGKuurama 6 місяців тому +21

    Kotlin having error types before C# is crazy. Can't wait for real C# Unions.

    • @this-is-bioman
      @this-is-bioman 6 місяців тому

      Kotlin is already lightyears ahead of C# and remember my words... it'll compile to .net some day 😁

    • @thmo_
      @thmo_ 6 місяців тому +6

      Kotlin is fairly younger I think, Microsoft has to worry about lots of compatibility things to introduce features like that.
      Take a look at the latest breaking changes in C#13; accessing the backing field in auto properties was held back for nearly two years just because the keyword „field“ might break existing code and needs to be refactored. So I guess Microsoft is dealing with other issues than Jetbrains is adding new language features.

  • @jam4l
    @jam4l 6 місяців тому +4

    Great summary, thanks.

  • @stijndcl
    @stijndcl 6 місяців тому +5

    Do these new union types for errors open the door to explicit errors/errors as values instead of using `throw`?

  • @vibovitold
    @vibovitold 6 місяців тому +2

    I can't find any info on these error objects (6:59). Is it documented or announced somewhere? Could this be only a part of the internal API?

    • @StevdzaSan
      @StevdzaSan  6 місяців тому +1

      They are yet to be released, they just announced it on a Kotlin conf. You can watch the video from the conference itself, google it.

    • @vibovitold
      @vibovitold 6 місяців тому

      @@StevdzaSan got it! Thanks

  • @Noor_alden
    @Noor_alden 6 місяців тому +3

    thank u for the great content ❤

  • @futsuchinpo9892
    @futsuchinpo9892 6 місяців тому +1

    i didnt even know there is kotlin 2.0
    thanks man

  • @DARKcarlos1
    @DARKcarlos1 6 місяців тому +2

    awesome content Stefan... are you going to update your Kotlin masterclass course with this subject?

    • @StevdzaSan
      @StevdzaSan  6 місяців тому +1

      Yep I'll add a few new lectures in the following period.

  • @vadimn6393
    @vadimn6393 3 місяці тому

    when i wrote:
    dataarg class Config (val Arg1: Int = 1)
    i get the error:
    Syntax error: Expecting a top level declaration
    (without dataarg - all ok)
    IntelliJ IDEA 2024.2
    Kotlin compiler version: 1.9.25
    Language version: 2.0

  • @pakkerto
    @pakkerto 3 місяці тому

    why multiplatform kotlin template error when android studio is set to kotlin 2.0?

  • @shahriarzaman4715
    @shahriarzaman4715 6 місяців тому

    1:47 I can't find dataarg!! even kotlin playground 2.0.0 not compiling !! How to use?

  • @jtsdeals
    @jtsdeals 6 місяців тому

    I'm getting "Explicit backing fields are not supported in FE 1.0" when I try the live data example you gave?
    Here's what Gemni says:
    In Kotlin 2.0.0, backing fields are not supported in the frontend (FE) 1.0. This means that you cannot access or modify the backing field of a property directly.
    There are a few reasons for this change. First, backing fields are not necessary in Kotlin. The compiler automatically generates getters and setters for properties, so you don't need to worry about creating them yourself. Second, backing fields can be a source of bugs. If you accidentally modify the backing field directly, you can easily break your code.

  • @rhen4610
    @rhen4610 6 місяців тому

    Loveee the backing field update

  • @ashwin_mahajan
    @ashwin_mahajan 6 місяців тому

    Thanks for the video, san

  • @DamjanDimitrioski
    @DamjanDimitrioski 5 місяців тому

    Is the dataarg close to a trait in a php class?

  • @xitize
    @xitize 2 місяці тому

    Thanks 👍

  • @TerenceKearns
    @TerenceKearns Місяць тому

    When will your Kotlin masterclass be v2?

  • @Ezrael2k5
    @Ezrael2k5 6 місяців тому +1

    Hey @Stevdza-San,
    I have migrated my project to Kotlin 2.0, how I can use the BackingFields now, when I'm trying to use it, I got this error: Explicit backing field declarations are not supported in FE 1.0

    • @StevdzaSan
      @StevdzaSan  6 місяців тому

      Kotlin 2.0(RC1) introduced explicit backing fields as far as I know.

  • @supercurioTube
    @supercurioTube 6 місяців тому +1

    Wow these are great additions!
    I've never encountered the type issues fixed however.
    I didn't really get the extensible data arguments tho, I'll have to look into it more. It makes me wonder if it means passing an object as argument instead of having real function arguments, therefore what would be the performance drawbacks (GC pressure)

    • @vibovitold
      @vibovitold 6 місяців тому +1

      It should have been rather easy to implement it as a zero cost abstraction (similar to value classes or inline functions). The best way to find out - other than by looking up the docs - is decompiling the bytecode to Java to see how it's resolved under the hood... (I like doing it that way because it's more instructive)

    • @supercurioTube
      @supercurioTube 6 місяців тому

      @@vibovitold good point, I hope so too.
      In a way it is almost odd that this new concept is a "class" but I guess it avoids introducing a completely new thing in the language and its tooling.

  • @Virus00000000000001
    @Virus00000000000001 6 місяців тому

    Thats huge stuff. Thanks

  • @vengateshm2122
    @vengateshm2122 6 місяців тому +1

    Well compiled video.

  • @thirstypooch
    @thirstypooch 5 місяців тому

    thanks for this

  • @esquilo_atomico
    @esquilo_atomico 6 місяців тому +1

    love smartcasts

  • @juanherrera9521
    @juanherrera9521 6 місяців тому

    i cant find any documentation about union types??

  • @abdkak4119
    @abdkak4119 6 місяців тому

    I think the best addition is regarding livedata

  • @randypenajimenez3893
    @randypenajimenez3893 6 місяців тому +5

    Good choice on taking the goods from C#

  • @bO-sb7el
    @bO-sb7el 6 місяців тому

    where is static extensions? ((

  • @LokendraBohara-s3u
    @LokendraBohara-s3u 6 місяців тому

    how to use dataarg class ?

  • @ayushrai3266
    @ayushrai3266 6 місяців тому

    please guide us to learn some topics like Notification channels , work managers and foreground services , please sir its a request

    • @StevdzaSan
      @StevdzaSan  6 місяців тому

      I already have a tutorial series about Notifications and Work Manager. Also you can check my Stopwatch tutorial to learn more about Foreground service.

    • @ayushrai3266
      @ayushrai3266 6 місяців тому

      Ok sir Thanks ❤
      Btw your tutorial of remote Mediator+ pagination is well explained ❤(That Boruto App With Ktor backend Course on udemy )

  • @haseeb776
    @haseeb776 4 місяці тому

    I want to uplift my career as native android developer. I have beginner level expertise over 1.5 year. Please suggest any relevant certification that may help me to grow in market.

    • @StevdzaSan
      @StevdzaSan  4 місяці тому

      @@haseeb776 Send me a message on Instagram.

  • @rodrigob
    @rodrigob 6 місяців тому +2

    Nice summary! Thanks for the video. A small english correction, "more cleaner" is considered a grammatical error. One should simply say "cleaner" or maybe "even cleaner".

  • @forresthopkinsa
    @forresthopkinsa 6 місяців тому

    Destructuring YEEEAAAAAA

  • @aa3352-m9w
    @aa3352-m9w 4 місяці тому

    Thanks

  • @techxyz5475
    @techxyz5475 6 місяців тому +1

    Major Change

  • @maousama168
    @maousama168 6 місяців тому

    wowww K2 is amazing, I hope my laptop can run new android studio version + emulator.

  • @krtirtho
    @krtirtho 6 місяців тому +1

    dataarg❌
    Dat aarg✅

  • @VinyJones2
    @VinyJones2 5 місяців тому

    🤩

  • @lover1301
    @lover1301 3 місяці тому

    Prepare for the language of the future.

  • @gorudonu
    @gorudonu 6 місяців тому +5

    this is what I needed, more keywords and making language more complicated /s

    • @StevdzaSan
      @StevdzaSan  6 місяців тому

      No worries, buddy, I'll simplify it for you when the time comes 😎🙌

    • @vibovitold
      @vibovitold 6 місяців тому +1

      Nobody forces you to use them, or even to upgrade to 2.0.
      Besides, a lot of these changes actually simplify things (such as more intuitive smart casting).

  • @allanandliftedhands2669
    @allanandliftedhands2669 6 місяців тому

    Kotlin all the way

  • @devatrii
    @devatrii 6 місяців тому

    ❤❤

  • @johnathanrhoades7751
    @johnathanrhoades7751 6 місяців тому

    I want dataargs in all my oop languages

  • @techxyz5475
    @techxyz5475 6 місяців тому

    👌

  • @bananasba
    @bananasba 6 місяців тому

    feels like C# clone

    • @desertfish74
      @desertfish74 5 місяців тому

      It’s the other way around really, c# is hastily adopting all sorts of syntax from more modern languages

    • @FilipCordas
      @FilipCordas 5 місяців тому

      @@desertfish74 C# is stealing from f# Kotlin is stealing from c# it's a circle of life.

  • @khumokwezimashapa2245
    @khumokwezimashapa2245 6 місяців тому

    GOATlin 🗣🗣🗣

  • @sorousheskandary-l7q
    @sorousheskandary-l7q Місяць тому

    Hi, There a lot of countries that aren't connect to global banking system, It'll be nice if you put your crypto wallet address for those donations

  • @this-is-bioman
    @this-is-bioman 6 місяців тому

    The new destructing constraint is insane! Why would they do this? I hope they'll loosen it soon enough.

    • @khanhuynh.social
      @khanhuynh.social 6 місяців тому +1

      i have same consideration with you, cause after migrate to 2.0, we may get error compilcation.

  • @ayushverma2166
    @ayushverma2166 6 місяців тому

    #1

  • @letmebe_pro
    @letmebe_pro 6 місяців тому +10

    Every new upgrade - > Kotlin less intuituve/readable. Java is easier in syntax

    • @StevdzaSan
      @StevdzaSan  6 місяців тому +1

      Why do you think that?

    • @letmebe_pro
      @letmebe_pro 6 місяців тому +5

      @@StevdzaSan You can do so many things in one line of code in Kotlin, but... If you read such code, you must do a lot of effort to understand a sense of this oneliner. I think in this matter Java is more readable although you often must write more lines of code.

    • @StevdzaSan
      @StevdzaSan  6 місяців тому +1

      @letmebe_pro I don't think that Kotlin is less readable. However, you do need to learn its syntax to properly understand it. But once you do, it's a whole different story 🚀

    • @DielsonSales
      @DielsonSales 6 місяців тому +2

      I think the point is the more clutter is added to a language, the harder it becomes for beginners to learn it. This seems to be a common complaint nowadays with languages such as Kotlin, Swift and Rust. I guess the problem is at what point do we say it’s “enough”? This is why we see answers such as Go, which was made to be the exact opposite in terms of complexity, and why some people praise C to this day for being a small enough language despite its drawbacks.

    • @neneodonkor
      @neneodonkor 6 місяців тому

      ​DielsonSales I think they add more features because they see beginners flocking other languages...

  • @revs87
    @revs87 6 місяців тому

    Elvis op, Aligator op and now Butth*le o.

  • @Daniel_Zhu_a6f
    @Daniel_Zhu_a6f 5 місяців тому

    i'd say, none of these features are actually useful. wasn't it their selling point that you can write modern procedural code, while maintaining full java compatibility? shouldn't they be cutting off oop capabilities, not adding new weird stuff? (i really don't get what prevented people from doing "dataargs" before v2.0, this trick has existed since structs were invented)

  • @ashwin372
    @ashwin372 6 місяців тому

    isn't kotlin a Java clone

    • @vibovitold
      @vibovitold 6 місяців тому +3

      No, it isn't, although if this video (even if you hadn't known anything about Kotlin before) didn't help you realize that, I doubt any comment will

    • @ibrahimanimasahun9431
      @ibrahimanimasahun9431 6 місяців тому

      lmao! wth

    • @yurowitz
      @yurowitz 6 місяців тому +1

      I wouldnt say clome but its heavily inspired by it and could pretty much replace it anywhere. Its also backward compatible

    • @vibovitold
      @vibovitold 6 місяців тому

      @@yurowitzit's interoperable with Java. not "backwards compatible".
      Java isn't its previous version, it's still under development, they are alternatives of eachother and interoperability works in both directions.
      its syntax is clearly different from Java - much more similar to other more modern languages such as Swift.
      it's a JVM language of course - but so is eg. Scala

  • @csmac3144a
    @csmac3144a 6 місяців тому

    None of this will matter in a few years. Languages only need to be usable by AI code writers, not humans. Humans will become experts at creating requirements and specifications for new systems. Code will be almost entirely generated and tested by AI.

    • @desertfish74
      @desertfish74 5 місяців тому +1

      Lol

    • @zweitekonto9654
      @zweitekonto9654 5 місяців тому

      And who do you think will code this "AI" to code? Oh its humans? Oh damn so we need to learn to programme anyway?

    • @Asgoritolin
      @Asgoritolin 5 місяців тому +2

      You will still need to understand the programming language to debug AI code, you can't be 100% reliant on them.
      Not to mention that the AI learns based on examples. If examples are not provided anymore it will start to stagnate.
      Also, what if I want to program for fun?

    • @csmac3144a
      @csmac3144a 5 місяців тому

      @@Asgoritolin We're using synthetic data to pre-train models already. I've generated millions of lines of code purely through models. We've developed an agentic swarm that uses TDD to create code, UX test frameworks to verify against requirements, etc. It's not yet 100% hands off, but it's just a matter of time. The generated artifacts -- plus some RLHF -- will serve to both train future models and inform test-time inference. Certainly there will be a role for developers, and you definitely can code for fun the same way people are still hacking on Z80 boards today for fun.

    • @Asgoritolin
      @Asgoritolin 5 місяців тому +1

      @@csmac3144a So your plan is to just trust the AI. And when it fails, just debug it with AI?
      Idk man. Being 100% reliant on it is just ridiculous. Someone has to manually supervise it at the end. Not to mention that, even if you create synthetic samples, you still need to know that programming language to make them.
      Remember that programming is in everything and therefore can have direct consecuences on people's lives. No system is 100% reliable and that's where software engineers come in.

  • @timandersen8030
    @timandersen8030 6 місяців тому

    Kotlin is terrible. Swift is better.

    • @tharakhgormaniad9820
      @tharakhgormaniad9820 6 місяців тому +2

      i hope you are joking

    • @henrik908
      @henrik908 6 місяців тому +10

      Source - Trust me bro

    • @randypenajimenez3893
      @randypenajimenez3893 6 місяців тому +2

      Says a guy that has never touch Kotlin

    • @AmirHosseinFZ
      @AmirHosseinFZ 6 місяців тому

      🤡 🤡

    • @vibovitold
      @vibovitold 6 місяців тому +1

      The easy part is behind you - we've got a catchy headline.
      Now it would be a good time to substantiate this claim with some observations and examples. Although I suspect the easy part may be the only part :)