Rock the JVM
Rock the JVM
  • Видео 172
  • Просмотров 1 499 524
Testing Functional Kotlin with the Raise DSL: How to Use JUnit, Kotest, MockK, AssertJ and Mockito
blog post: blog.rockthejvm.com/testing-raise/
Advanced Kotlin course: rockthejvm.com/p/advanced-kotlin
In this video we'll learn how to integrate popular Kotlin testing libraries (Kotlin Test, Kotest, MockK, Mockito, AssertJ and others) with code written in a functional style with the Arrow library and the Raise DSL.
Timeline:
0:00 Intro & setup
3:00 TDD with Arrow, Raise and AssertJ
12:17 Kotest and Fake Objects
20:08 Mocks with MockK and Mockito
Related videos:
Functional error handling in Kotlin, part 2 - Either & Raise: ruclips.net/video/C0B44WBJJmY/видео.html
Follow Rock the JVM on:
LinkedIn: linkedin.com/company/rockthejvm
Twitter: rockthejvm
Blog: Blog: blog.rockthejvm.com
----------...
Просмотров: 638

Видео

Automatic Dependency Injection in Scala - Just the Type System!
Просмотров 3 тыс.Месяц назад
GitHub: github.com/scala/scala3/blob/main/tests/run/Providers.scala Learn ZIO: rockthejvm.com/p/zio In this video we will demonstrate a technique for automatic dependency injection in pure Scala with no other libraries or frameworks. Here, instances are passed automatically just by the structure of the types in question, without relying on macros, annotations, reflection or any runtime behavior...
A Remote Code Execution System with Apache Pekko & Scala
Просмотров 2,2 тыс.Месяц назад
Article: blog.rockthejvm.com/remote-code-execution-engine/ GitHub: github.com/ghurtchu/braindrill/ Learn Pekko: rockthejvm.com/p/the-akka-bundle In this video we will demonstrate the features of Apache Pekko (the open source version of Akka) with a small project: a distributed remote code execution system, where a client sends a piece of code as text to be executed, and our system returns the o...
The Power of Recursion - How To Think Code Clearly
Просмотров 2,6 тыс.2 месяца назад
Scala Data Structures and Algorithms course based on functional programming and recursion: rockthejvm.com/p/scala-functional-programming-interview-practice This video is beginner-friendly. If you're a senior developer, you might want to send this video to your junior engineers getting started with Scala or functional programming (in any language). In this video we discuss recursion not so much ...
Kotlin Scope Functions for Expressiveness: let, run, with, apply
Просмотров 1,6 тыс.3 месяца назад
Complete Kotlin course: rockthejvm.com/p/kotlin-essentials In this video, we'll learn about Kotlin scope functions: let, run, with, apply. Kotlin scope functions are useful to increase mental clarity and flow for chained computations, especially when combined with other functional programming primitives. However, scope functions are not the most intuitive, especially when you come to Kotlin fro...
htmx, ScalaTags and ZIO HTTP - Single-Page Web Applications in Scala
Просмотров 2,9 тыс.3 месяца назад
GitHub: github.com/rockthejvm/scalatags-htmx-demo ZIO course: rockthejvm.com/p/zio This video is a demonstration of a small web application written in Scala, called Neon Pages: a catalogue of contacts where you can add, edit, remove and bulk-edit data with instant feedback and persistence. The application is written in Scala with - ScalaTags with server-side rendering (SSR) - htmx for custom HT...
Scala PostgreSQL Integration With Skunk
Просмотров 2,2 тыс.4 месяца назад
blog post: blog.rockthejvm.com/skunk-complete-guide/ Full Stack Scala course: rockthejvm.com/p/typelevel-rite-of-passage This video will show you how to seamlessly interact with a PostgreSQL database from Scala with the Skunk library, and how to perform CRUD operations in a type-safe way. Timeline: 0:00 Intro 1:32 Setting up Skunk and Domain 3:31 Setting up Postgres and Config 8:02 Creating and...
Kotlin Tutorial - Kotlin at Light Speed, Part 5 - Functional Programming in Kotlin
Просмотров 2,8 тыс.5 месяцев назад
blog post: blog.rockthejvm.com/kotlin-flows Complete Kotlin course: rockthejvm.com/p/kotlin-essentials This is a long-form practical introduction to Kotlin Flows, a reactive data structure that can emit values in an asynchronous, non-blocking fashion. This video will teach you how to build Kotlin Flows, how to manage their lifecycle, what to do in case your flows get empty or throw errors, how ...
Generative Art in Scala, No AI Required
Просмотров 2,6 тыс.5 месяцев назад
GitHub repo: github.com/rockthejvm/scalar-2024-artistic-scala This video is a demo of particle physics-based algorithmic art in Scala, rendered on an HTML canvas by Scala.js. You'll get some cool effects (artistic, maybe?) that would be hard to describe to an AI. You'll learn the more graphical benefits of functional programming productivity, as well as some techniques that you may not encounte...
Hands-on Kotlin Tutorial - Kotlin at Light Speed, Part 6 - Nullables, Special Methods, Extensions
Просмотров 6786 месяцев назад
Kotlin at Light Speed is a jam-packed online Kotlin course/Kotlin tutorial series. Written form: blog.rockthejvm.com/big-kotlin-tutorial/ Complete Kotlin course: rockthejvm.com/p/kotlin-essentials In this video: syntactic and structural "niceties" that make Kotlin programming fun, intuitive, easy to read and understand, and safe from bugs and crashes. We talk about nullables, special methods an...
Hands-on Kotlin Tutorial - Kotlin at Light Speed, Part 5 - Functional Programming in Kotlin
Просмотров 1,2 тыс.6 месяцев назад
Kotlin at Light Speed is a jam-packed online Kotlin course/Kotlin tutorial series. Complete Kotlin course: rockthejvm.com/p/kotlin-essentials Written form: blog.rockthejvm.com/big-kotlin-tutorial/ In this video: what functional programming is and why it's useful, how we can define function values in Kotlin (along with various syntax sugars), as well as practical applications of FP with transfor...
Hands-on Kotlin Tutorial - Kotlin at Light Speed, Part 4 - Collections Standard Library
Просмотров 6276 месяцев назад
Kotlin at Light Speed is a jam-packed online Kotlin course/Kotlin tutorial series. Written form: blog.rockthejvm.com/big-kotlin-tutorial/ Complete Kotlin course: rockthejvm.com/p/kotlin-essentials In this video: an overview of the most popular collections in the Kotlin standard library, and when you should use each. Get the full course here: rockthejvm.com/p/kotlin-at-light-speed The full compl...
Hands-on Kotlin Tutorial - Kotlin at Light Speed, Part 3 - Object-Oriented Programming in Kotlin
Просмотров 1,2 тыс.6 месяцев назад
Kotlin at Light Speed is a jam-packed online Kotlin course/Kotlin tutorial series. Written form: blog.rockthejvm.com/big-kotlin-tutorial/ Complete Kotlin course: rockthejvm.com/p/kotlin-essential In this video: how to structure your code in terms of classes, instances, properties and methods. We describe various features of OOP in Kotlin, including abstract classes and interfaces and the Kotlin...
Hands-on Kotlin Tutorial - Kotlin at Light Speed, Part 2: Syntax, Expressions, Control Flow
Просмотров 1,3 тыс.6 месяцев назад
Kotlin at Light Speed is a jam-packed online Kotlin course/Kotlin tutorial series. In this video: values, types, expressions, if/when structures, looping, and functions. Written form: blog.rockthejvm.com/big-kotlin-tutorial/ Complete Kotlin course: rockthejvm.com/p/kotlin-essentials Get the full course with video downloads here: rockthejvm.com/p/kotlin-at-light-speed The full complete code: git...
Hands-on Kotlin Tutorial - Kotlin at Light Speed, Part 1: Getting started
Просмотров 2,7 тыс.6 месяцев назад
Kotlin at Light Speed is a jam-packed online Kotlin course/Kotlin tutorial series. Written form: blog.rockthejvm.com/big-kotlin-tutorial/ Complete Kotlin course: rockthejvm.com/p/kotlin-essentials In this video: why Kotlin is useful, why you should learn Kotlin, and how to get started writing your first Kotlin code. Get the full course here: rockthejvm.com/p/kotlin-at-light-speed The full compl...
Kotlin Type Classes - a Practical Pattern to Organize Your Code
Просмотров 2,6 тыс.7 месяцев назад
Kotlin Type Classes - a Practical Pattern to Organize Your Code
How to Write Full-Stack Scala Applications - Typelevel
Просмотров 6 тыс.7 месяцев назад
How to Write Full-Stack Scala Applications - Typelevel
ZIO Rite of Passage: A Full-Stack Scala Project-Based Course with ZIO
Просмотров 1,5 тыс.9 месяцев назад
ZIO Rite of Passage: A Full-Stack Scala Project-Based Course with ZIO
A Load Balancer in Scala with Cats Effect and Http4s
Просмотров 4,3 тыс.10 месяцев назад
A Load Balancer in Scala with Cats Effect and Http4s
Microservices and gRPC in Scala with FS2 and Scalapb
Просмотров 3,5 тыс.11 месяцев назад
Microservices and gRPC in Scala with FS2 and Scalapb
Functional Error Handling in Kotlin, Part 3 - the Raise DSL
Просмотров 2,1 тыс.11 месяцев назад
Functional Error Handling in Kotlin, Part 3 - the Raise DSL
OAuth Authentication in Scala with Http4s
Просмотров 2,6 тыс.Год назад
OAuth Authentication in Scala with Http4s
Kotlin Context Receivers - How to Use, Why, and Best Practice
Просмотров 4,6 тыс.Год назад
Kotlin Context Receivers - How to Use, Why, and Best Practice
Functional Error Handling In Kotlin: Either and Result
Просмотров 5 тыс.Год назад
Functional Error Handling In Kotlin: Either and Result
HTTP Authentication in Scala with Http4s: Passwords, Digests, Sessions, JWTs
Просмотров 3,5 тыс.Год назад
HTTP Authentication in Scala with Http4s: Passwords, Digests, Sessions, JWTs
Functional Error Handling in Kotlin, Nullables and Options
Просмотров 3,2 тыс.Год назад
Functional Error Handling in Kotlin, Nullables and Options
Scala Server Security with Http4s: CORS and CSRF
Просмотров 1,9 тыс.Год назад
Scala Server Security with Http4s: CORS and CSRF
Full Stack Scala 3 with the Typelevel Stack - a Conference Talk
Просмотров 3,9 тыс.Год назад
Full Stack Scala 3 with the Typelevel Stack - a Conference Talk
Java Virtual Threads - How Virtual Threads Work, Scheduling, Cooperation and More
Просмотров 10 тыс.Год назад
Java Virtual Threads - How Virtual Threads Work, Scheduling, Cooperation and More
The Typelevel Rite of Passage: A Full-Stack Scala 3 Project-Based Course
Просмотров 3,7 тыс.Год назад
The Typelevel Rite of Passage: A Full-Stack Scala 3 Project-Based Course

Комментарии

  • @NITISHBHARDWAJONE
    @NITISHBHARDWAJONE 5 часов назад

    What an excellent tutorial ! Can only come from a person who understands CS fundamental in depth .

  • @screwgogleplus7105
    @screwgogleplus7105 9 дней назад

    Hey, I have noticed Kotlin videos on the channel are a thing recently and I am just curious if this signifies the decline of Scala popularity while Kotlin is growing? Or maybe you want to keep the channel open to a wider audience? Or maybe there are not many Scala libraries/topics that you want to present currently? Just curious?

    • @rockthejvm
      @rockthejvm 9 дней назад

      I'm just teaching what I know, and will definitely have more Scala on the channel

  • @blademoose8169
    @blademoose8169 14 дней назад

    Hello Daniel, I've recently found your videos and they've been a blast to go through so thanks for the effort put in. While watching the video I came up with different implementations for the < and <= traits, are there issues I'm not seeing atm? I've tested for every combination with the type aliases from 0 to 5 object < { given succLt[A <: Nat]: <[A, Succ[A]] = new <[A, Succ[A]] {} given chainedLt[A <: Nat, B <: Nat](using lt: <[A, B]): <[A, Succ[B]] = new <[A, Succ[B]] {} } object <= { given eq[A <: Nat]: <=[A, A] = new <=[A, A] {} given succLte[A <: Nat]: <=[A, Succ[A]] = new <=[A, Succ[A]] {} given chainedLte[A <: Nat, B <: Nat](using lt: <=[A, B]): <=[A, Succ[B]] = new <=[A, Succ[B]] {} }

    • @rockthejvm
      @rockthejvm 12 дней назад

      Seems legit - just different axioms

  • @orlandocastellanos9263
    @orlandocastellanos9263 15 дней назад

    Can we use spark with kotlin?

    • @rockthejvm
      @rockthejvm 12 дней назад

      Yes, with the Java API - but completely unrelated to the video, no?

  • @galberger8415
    @galberger8415 24 дня назад

    I love Scala, I really do. But at the risk of sounding like a hater - this solves an issue that nobody had a problem with. I have a mere 6 years of Scala under my belt and so far the companies I know that use Scala in production either do not use its full power OR (and worse) shifting away from it. It is hard enough to find a good Scala programmer, let alone an advanced one, so please, let's stop making things more complex. And to top it all, if I did understand the explanation well, it is not available in Scala 2 due to the lack of type matching which makes this feature a major block for most of the industry.

  • @user-uf4lf2bp8t
    @user-uf4lf2bp8t 25 дней назад

    I mainly write rust, but scala, being arguably more open to different paradigms than rust, does functional programming so well. I really hope ergonomic HKT's will be added to rust one day.

  • @user-lx7jn9gy6q
    @user-lx7jn9gy6q 26 дней назад

    Implicits in general should be used VERY sparingly. This works here but when you’re reading older code and they use them, it almost always turns out to not be worth it.

  • @Schwannism
    @Schwannism 26 дней назад

    Unfortunately GROUP BY is not covered.

  • @tuxjumale4197
    @tuxjumale4197 28 дней назад

    t.b.h. this all looks to me like just a good theoretical exercise, but in my daily work I wouldn't choose neither this nor ZIO-layers over the good old macwire "lazy val userSubscription = wire[UserSubscription]". And even if not relying on the macwire - then still I would rather wire everything manually "lazy val userSubscription = UserSubscription(userService, db)", than having to write those unnecessary layers/providers/etc

  • @sulikszabolcs
    @sulikszabolcs 28 дней назад

    In my practice writing the wiring logic is the smallest possible problem. And the compiler helps me by checking the *explicit* types in the constructors. I don't see the benefit of the extra compiletime magic to get the same results. Generally I don't see the benefit of any magic at all.

  • @Rockyzach88
    @Rockyzach88 29 дней назад

    _Looks at Scala history page_ : "Scala was designed to be a better Java" Me: Oh sweet! I'm going to learn a new language. Me after the video: :O

  • @pawesado8782
    @pawesado8782 29 дней назад

    Comparing types using match types can run you into a problems. Personally I think it is an anti pattern. It's because of disjointness checks which is required to advance to remaining cases. With simple types - everything works well, but problems arise when you want to match against covariant/contravariant generics, or match types. Consider example below: type IsSame[A,B] =A match case B => true case _ => false summon[IsSame[Option[Int],Option[String]] =:= false] It doesn't compile The worst thing is that everything seems to be fine until you start using some more sophisticated types

  • @darrenkim8301
    @darrenkim8301 Месяц назад

    It was very helpful for me understaing Auto DI using pure scala3. Thank you!

  • @SalimOfShadow
    @SalimOfShadow Месяц назад

    Really well explained! Loved this!

  • @danielmachadovasconcelos877
    @danielmachadovasconcelos877 Месяц назад

    Oh my God! There is so much boiler code to compose two operations. Inserting into a database and sending an email should not require much complexity.

  • @hrizony7847
    @hrizony7847 Месяц назад

    Thank you. But I am a little confused. 15:11 why it’s not blocking. When you call the method you still need to wait the result from another thread right? Forgive my dumbness, I really don’t understand the difference between it and Async non blocking here 4:57.

  • @perodactyl490
    @perodactyl490 Месяц назад

    This is exactly what I needed to get started! Thanks so much.

  • @DavidePavan
    @DavidePavan Месяц назад

    Finally, an example of using type-level programming in Scala. The simplicity and elegance are impressive. Having worked for years with Java and Spring, I appreciated doing dependency injection explicitly when using Scala. Therefore, I don't think I would use this technique in my own project, but I would be very interested in seeing more examples of how to leverage this technique.

  • @iteospace
    @iteospace Месяц назад

    I wrote the same thing in 3 simpler and cleaner in C#

  • @DoctorPiss1
    @DoctorPiss1 Месяц назад

    What you can do with the Scala 3 compiler is amazing. I have mixed feelings about this kind of automated dependency injection. I do like that it can result in a lot less code written by the programmer but every time I have worked with something like this I have had to spend a lot of time figuring out all of the magic that is going on under the hood. I do like that this solution is built with plain Scala. No macros or reflection. Interesting stuff

  • @alanliu6126
    @alanliu6126 Месяц назад

    Excuse me, how to benchmark scala apps, could it be used in production?

  • @mastapegs
    @mastapegs Месяц назад

    This was a fantastic view into abstract Scala programming. Brings me back to Haskell. I love how clean you presented your examples.

  • @EmilioRodo
    @EmilioRodo Месяц назад

    As interesting as the mechanism is, I'm still not groking how is this or Zlayer more ergonomic that simply instantiating one's dependencies and wiring them via constructor injection. Both approaches require boilerplate in the companion object (and therefore a dependency on the di library). Could you elaborate on that? I am legit terrified I'm being an old man shouting at the clouds here, I'd love to understand this!😂

    • @rockthejvm
      @rockthejvm Месяц назад

      You don't have to manually build your instances, you don't care where they come from, you don't need to keep track of which piece requires which instance

    • @EmilioRodo
      @EmilioRodo Месяц назад

      ​@@rockthejvmhow would it work if you had several instances of the same type (different implementations of the same interface)? Assuming that you need to control which implementation is passed where

  • @butcherless
    @butcherless Месяц назад

    Odersky is doing a magnificent job and I have no doubt that he will make the language disappear. However, it is always comforting to learn by watching Daniel's videos.

  • @MrDejvidkit
    @MrDejvidkit Месяц назад

    This is a very nice trick, and I love it. It could be useful for simple programs, which is really nice. I would use this in subsets of a bigger project, but I like the ZIO approach much better because it has more advanced and feature-rich options, like repeatability, configurations, etc., which the compile-time constructor can't work with. At least, I think so. Also, this has no error handling, which is something I really love with Zio-type. Safe error handling is really important in big projects.

  • @miguelqueiroga2737
    @miguelqueiroga2737 Месяц назад

    Th best explanation I've seen on the subject. Great content!

  • @MrDejvidkit
    @MrDejvidkit Месяц назад

    Yeey new Scala video, finally :)

  • @hubstrangers3450
    @hubstrangers3450 Месяц назад

    Thank you....could you kindly provide the transcript for the above video, need to read to support your thoughts....thx

  • @jay-hinddoston8364
    @jay-hinddoston8364 Месяц назад

    Need to try this but its awesome

  • @haroonalishah1940
    @haroonalishah1940 Месяц назад

    From simple DI to complex, extra code ZIODI, NO THANK YOU.

  • @sabita1225
    @sabita1225 Месяц назад

    really great and simple explainer easy to understand.. big thanks

  • @brieuckaisin7742
    @brieuckaisin7742 Месяц назад

    This is BRILLIANT, thanks! Tuples as heterogeneous lists and match types are real game changers in Scala 3!

  • @MrMikeJones1477
    @MrMikeJones1477 Месяц назад

    Is there a public RFC for this feature?

  • @abelgerli
    @abelgerli Месяц назад

    Ok TLP is needed .. to support it, but not to use it. So i am able to use it without wearing a real black belt 😊

  • @chiquiflautro
    @chiquiflautro Месяц назад

    wouldn't it work also with multiple implicits rather than a single using clause with a provider of a tuple

  • @chiquiflautro
    @chiquiflautro Месяц назад

    I was actually thinking of trying to implement something like this the other day. Nice to see you doing a video about it and Oderdky coming up with it

  • @HelloForeignWorld
    @HelloForeignWorld Месяц назад

    A couple of potential issues come to my mind: 1. Config loading based on some condition - e.g. loading different config file based on environment variable or some CLI argument, which will not be possible if the dependencies are resolved entirely on the type level. Usually you have your config as a very first dependency which is fed in the services. 2. Disposing of resources (e.g. acquire and release) is not under our control. 3. Using fresh instance of a layer (e.g. to avoid global uniqueness for a particular layer) To be honest all of the above issues might very well be solvable and this could be a good lightweight DI approach. I really like the clever type level programming and that you managed to mention "Odersky" and "ZIO" in a single video 🙂 Thank you for sharing this interesting idea!

  • @Thomas-yh6nx
    @Thomas-yh6nx Месяц назад

    No magic, I like it!

    • @sulikszabolcs
      @sulikszabolcs 28 дней назад

      Except the extra traits, types, the implicit mechanism and the scala.compiletime package. Other than that, nothing, really.

  • @flatmapper
    @flatmapper Месяц назад

    Can we do DI without frameworks?

    • @HelloForeignWorld
      @HelloForeignWorld Месяц назад

      it all depends on the level of ergonomics you are ready to sacrifice :D

  • @yiannig7347
    @yiannig7347 Месяц назад

    need a big cup of coffee and go over this, but it looks cool

  • @rockthejvm
    @rockthejvm Месяц назад

    Please write your impressions of this approach in the comments! If you like it, it's not impossible that it may become a core Scala library or module.

  • @bishbashboshjt
    @bishbashboshjt Месяц назад

    I’d be interested to see conditional dependency injection like Zio layers support - might be possible with an auxiliary data structure that’s indexed like a tuple but the element can be optional/error type

  • @KamtoEddy
    @KamtoEddy Месяц назад

    coming from TypeScript, this is awesome!

  • @wuhaoecho
    @wuhaoecho Месяц назад

    I come back to this video from fasthtml. :) It was invented in scala too.

  • @anastasiiazu
    @anastasiiazu Месяц назад

    Coming from Scala coding, it pains me that people use for loops for iterations instead of mapping 😂

  • @sashibhushanarajput1194
    @sashibhushanarajput1194 Месяц назад

    I guess when you said iterations is heavily discouraged in Scala it would have helped to give the reason why, otherwise nice video

  • @vash47
    @vash47 Месяц назад

    Great video. I feel more comfortable now reading query plans. It's still tough!

  • @vipulpatel-il9nb
    @vipulpatel-il9nb Месяц назад

    Masterfully explained !!!

  • @DujoBenja
    @DujoBenja Месяц назад

    I'm working on refactoring a huge application and switching from Play framework to Zio. I have migrated the services and all I have to do is run the application. I have a problem that I cannot provide more than 512 Zlayers, is there any practical solution for my case? It doesn't make sense that I can't provide ZLayer as much as I want?

  • @eduardabramovich1216
    @eduardabramovich1216 Месяц назад

    quick question, if i want to learn scala native, is it the same as scala? can i do it with this tutorial? or there are some specific resources to do so? Thanks in advance!

    • @rockthejvm
      @rockthejvm Месяц назад

      Scala Native has the same language rules as Scala for the JVM :D