Kotlin for Typescript developers

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 มิ.ย. 2024
  • Subscribe
    / @tom-delalande
    This video is meant for Typescript developer interested in Kotlin. I cover the syntax, tooling and create a general project. If you're on the fence about trying Kotlin, I hope that this can be helpful.
    Thank you so much for taking the time to watch
    Github:
    github.com/tom-delalande/lear...
    Twitter:
    / tomdelalande_
    Discord
    / discord
    Twitch:
    / tomdelalande
    Timestamps
    0:00 - Agenda
    0:32 - Advantages
    1:32 - Syntax
    3:28 - Code Editor
    4:22 - Build & Dependency Management
    6:47 - Web Server
    9:07 - Outro
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @nanonkay5669
    @nanonkay5669 3 หลายเดือนก่อน +17

    Gradle is the single biggest turn off for using any JVM language. I wish it was much much simpler

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

      But think about the amount of dependencies you need in js land compare to kotlin land, the one single thing I hate js the most is the amount of dependency you need to get some simple things to work which is insane

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

      @@lucasteo5015 the number of js dependencies might be high, but managing them is pretty easy and convenient, with most projects already having everything configured for you. With npm, it's just a matter of running install, update or remove in the cli and you're good to go. But with Gradle, it's almost manual. You have to know your way around the Gradle file, what section means what, what plugin has a dependency to another dependency to make it work etc. That experience was painful for me during the time I was teaching myself Android dev and I don't miss that at all

    • @Amejonah
      @Amejonah 3 หลายเดือนก่อน +6

      > I wish it was much much simpler
      Gradle is simple enough if you don't do anything with the build. Alternatively, look up the extension "amper" by Jetbrains: it is a YAML file and is very shrimple.

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

      @@Amejonah will try it out

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

      You could use Bazel

  • @AlexAvance
    @AlexAvance 3 หลายเดือนก่อน +7

    There is a kotlin language server that has been put together by the community and is added to mason (a LS downloader plugin for nvim). I use ktlint for formatting too, and the pair is not quite as robust as intellij, but I've started using it recently and it's pretty good.

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

      Could you share your config please?
      Also, are you using any helper to call Gradle tasks?

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

      Maybe it’s time for me to try it again!

  • @devatrii
    @devatrii 3 หลายเดือนก่อน +6

    I've been using kotlin for almost 2 years now it's my most favourite language.. i found myself losing some brain cells when using TS.

  • @_modiX
    @_modiX 3 หลายเดือนก่อน +5

    The beauty of Kotlin is that you have the most straight-forward easy-as-JS language for the most used consumer OS in the world to compile natively for ..., Android. And the tooling allows you to really do anything you want with Kotlin. The sad part about Kotlin is the tightness towards JetBrains and what not, and the world falls apart out of their walled garden. So many people (incl. me) fail to attempt to work on an Android project within NeoVim for instance (other than editing a bit here and there). The whole thing can get so massively complex that it causes mobile development to have such bad reputation. I really just get frustrated with it that I end up opening Android Studio eventually. Same story as with Xcode and iOS. The way we built our mobile systems shall be more secure and consumer friendly, but also way too complex and inaccessible for the free-minded.

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

      There's an option to pass IntelliJ into NeoVIM

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

      Intellij Idea is open source though so

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

      Yes, this is terrible. Worked on it in the past, and it was not a pleasant experience. Why should I need that bunch of stuff in a songle damn folder

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

      @@Serizon_ Just because it's open-source doesn't make it a good product. It's an IDE, massively bloated to make your life easier, until you want to free yourself from it. Android build steps are insanely complex that Android Studio is like a forbidding fruit. You eat it and be happy, until you want to get off your IDE addiction and there are many reasons to do so, battery drainage while being on the go being one of it. "An idiot admires complexity, a genius admires simplicity" ~ Terry Davis.

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

    absolutely lovely video
    i liked how you likened a lot of kotlin's language features to their js counterpart (like ktor or maven being counterparts of express or npm)

  • @Bruno-bh8dm
    @Bruno-bh8dm 3 หลายเดือนก่อน

    Very cool and clear video. Thank you, Tom! I'm really looking forward to do something with Kotlin!

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

    I can't change my editor :( I will wait lsp and meybe then try it, kotlin looks pretty

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

    Yet another banger

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

    clean and concise video

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

    Kotlin is a nice language, especially from the point of view of syntax. But I feel like it takes a lot of configuration to run it (properly) outside of Jet Brain's IDE(s) and to use it for anything other than android development. If the tooling (for editors other than IntelliJ) was improved it would be make for a great alternative to JS, taking into account the fact that there's already a lot of languages (other than TS) that can do that pretty well.

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

    Imo, you should have gone in-depth into typescript interfaces because there's no direct equivalent in Kotlin (i.e. differences between nominal and structural typing), and if it were, I would say actual Kotlin interfaces are the closest to it and not data classes.
    With Kotlin interfaces you can pretty much do almost the same thing as TypeScript interfaces. You can have classes implement those interfaces, but you can also have objects do the same:
    ```
    interface Foo {
    val prop: Int
    }
    val instance = object : Foo {
    override val prop: Int = 1
    }
    ```
    Another critique is that, imo, the equivalent of an object in TypeScript (it's not as usual to call it a map other than by people coming from other languages, specially since there's an actual map class already) is an object in Kotlin (above example also works here). The closest thing to Kotlin's maps in TypeScript is the class Map (which is basically a LinkedHashMap since it preserves insertion order)

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

    How does the interop with java work? Is it possible to convert an existing java program into kotlin? Do Java packages run the same? Is springboot available?

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

      Kotlin compiles to jvm bytecode like java, so java code doesn't even know its calling kotlin code. It just works. Some kotlin specific features like coroutines get jumbled up or even inaccessible if you want to call them from java code, so you usually need to keep that in mind if you are developing with the express purpose of consuming from java. As for using java code in kotlin, everything will work out of the box. Kotlin will even take care of things like calling getters/setters in the background for you.
      IntelliJ and Android Studio have a java to kotlin converter built in, and it will even suggest converting java code to kotlin if you try to paste java code into a kotlin file. Usually the generated code isn't the most idiomatic but it will work. You don't really get some of the major benefits of kotlin if you convert with this, and its better to just write your own idiomatic kotlin to replace old java when you need to (since, remember, your old java code will still work perfectly fine).
      Since Kotlin and java compile to jvm bytecode, they are run the same on the jvm. When interoping with java on the jvm, there isn't a new runtime, just a new frontend language.
      Spring boot is available for kotlin! There is one quirk in that kotlin makes classes final by default, while spring needs open classes. You can either manually make all your classes open or you can use the "allopen" compiler plugin created specifically for this issue.

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

    Ok I might be learning kotlin for android development

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

    what are your thoughts on sqldelight? It lets you write sql queries manually and will generate kotlin accessors for them.

    • @tom-delalande
      @tom-delalande  3 หลายเดือนก่อน

      I’ve never heard of it. But I enjoy writing SQL directly. The biggest performance bottleneck comes from interacting with the DB so I try and keep as much control as I can there.

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

      @@tom-delalande the neat feature of sql delight is you write raw sql and the generated bit is a nice kotlin api that saves writing the raw strings and inserting things via index

    • @tom-delalande
      @tom-delalande  3 หลายเดือนก่อน

      I misread sorry. That does sound very interesting. I’ll look into it

  • @seanknowles9985
    @seanknowles9985 24 วันที่ผ่านมา

    Union types in kotlin?

  • @saiphaneeshk.h.5482
    @saiphaneeshk.h.5482 3 หลายเดือนก่อน +3

    Kotlin for backend?
    Thought only java is used.

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

      While very reductive (and somewhat wrong), you can think of Kotlin as Java with sugar syntax. Also, Java is definitely not the only language for backend. Other popular ones off the top of my head: JavaScript/TypeScript (node), Go, python, rust, php. You also have ruby with ruby on rails, though it has lost a lot of popularity

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

      Kotlin was initially created as an alternative JVM language, hence for the same use cases as Java. One shouldn't be surprised that Kotlin is used for the backend and supported by the most popular Java frameworks.

    • @saiphaneeshk.h.5482
      @saiphaneeshk.h.5482 3 หลายเดือนก่อน

      @AntonArhipov yeah, I knew that kotlin was introduced to replace java and they are inter-operable. But it kicked off in the android world. I had no idea that it was used in the backend too.
      But are there any projects which is using kotlin for backend? And is it interoperable with Java in backend too?

    • @saiphaneeshk.h.5482
      @saiphaneeshk.h.5482 3 หลายเดือนก่อน

      @lengors7327 had a doubt, what problem did the ruby solve?
      Like the other framework has a special need, like for computation Java, concurrency go, more IOs node, CMS php, blazingly fast rust, and did Python solve any particular situational problem?

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

      @@saiphaneeshk.h.5482 Sure! Spring, Micronaut, Quarkus - are all Java frameworks, and they all work with Kotlin thanks to interoperability. On Kotlin's website, there's a page with references to big companies using Kotlin for the backend, including Atlassian, Netflix, Amazon, N26, Intuit, etc. I have seen many banks actually use Kotlin for backend development. Thanks to interoperability with Java, it is possible to use virtually any Java libraries and frameworks with Kotlin. Kotlin was intended to be used on the server in the first place, long before it kicked off in Android.

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

    Once you're deep enough into Typescript, every type system feels like a step down unfortunately. The only one that feels comparable is Zig's which doesn't have a language server that can properly represent it yet.
    I think to me the most amazing Typescript-ey thing is being able to take an existing type and do weird things to it, like making every key in a map have a prefix, or transforming all child types to a new type based on the input value... the flexibility is insane, which is just to allow for the type system to model all the weird stuff in the javascript library ecosystem, but makes using it so fun. Stepping away from it in any direction is a bit painful.

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

      Flexible yes. Robust? I personally think Typescript's type system is not as robust as good nominal type systems like Kotlin's or Rust's. And that's understandable - typescript ultimately needs to be built on top of a dynamic language and a structural type system is best for that.

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

      @@balen7555 Yeah, Typescript's is definitely not super mathmatically solid. I think the thing I've realized is I really like how Typescript's types are super concrete, where everything ultimately boils down to an object of fields, a tuple or an array, which can be constructed from that type with proper auto-complete tooling - so it says "yes, and" a lot, vs. a lot of type systems like C++ templates, haskell just have a LOT of creative (and obscure) ways to say "no". When I'm trying to get stuff done, having the type system work to help me instead of finding weird ways to block me is a huge productivity bonus.
      Granted, with Github Copilot, the 'yes, and' tooling is brought back, so it might actually help make those really obtuse type systems a lot more palitable - that's the only reason I'm able to make steady progress with zig

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

    Lol, I would rather use GoLang

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

    I think golang is better than kotlin