Where can I learn advanced Kotlin from?

I’ve been a Java developer for many years, and I thought it was to right time to start learning Kotlin.

I found a ton of videos explaining the basics for people who moved from Java to Kotlin, and I was shocked by how impressive this language was.

However, there was a lot of topics, some of which I might not even know about, that are pretty advanced and even if I got the overall idea on how to use them, I want to learn them more in depth.

And I couldn’t find a book/PDF/Videos that explains advanced topics throughout, and shows all the great things Kotlin provides.

Can anyone recommend one that is somewhat close to what I’m looking for?

submitted by /u/argaman123
[link] [comments]

Continue Reading Where can I learn advanced Kotlin from?

What’s new in KMM? đŸ€” Find out from the comfort of your couch! đŸ€© In this video, Kate will give you an overview of the most interesting KMM ecosystem highlights since the technology went Alpha in August of 2020. 🚀

submitted by /u/Anisim_1
[link] [comments]

Continue Reading What’s new in KMM? đŸ€” Find out from the comfort of your couch! đŸ€© In this video, Kate will give you an overview of the most interesting KMM ecosystem highlights since the technology went Alpha in August of 2020. 🚀

Special for developers interested in the field of Android

As a continuation of the educational course to explain Android using Kotlin language on the YouTube platform under the title:

Tutorials for Android by Kotlin

The link for the Playlist:
https://www.youtube.com/playlist?list=PLsfs9DojDVqO5a2I_7tXYxqZ_6k94Op4r

2 short videos have been uploaded to explain the first and second parts of “Kotlin Overview and SetOnClickListener by 3 Different Ways”

Android – Kotlin – Overview and SetOnClickListener by 3 Different Ways – Part01 – Explanation

https://www.youtube.com/watch?v=mU-Q7OVh4f4&list=PLsfs9DojDVqO5a2I_7tXYxqZ_6k94Op4r&index=5

Android – Kotlin – Overview and SetOnClickListener by 3 Different Ways – Part02 – Explanation

https://www.youtube.com/watch?v=lTKFb842veQ&list=PLsfs9DojDVqO5a2I_7tXYxqZ_6k94Op4r&index=6

The Playlist will cover the following topics:

* Designing and developing Android mobile native application using Kotlin.

* Create dynamic lists with RecyclerView.

* Android Jetpack Navigation and View Binding.

* SQL database and SQLite (Room).

* Background processing, multi-threading, and Coroutines.

* Android Jetpack Lifecycles, LiveData, and ViewModel.

* Architecture Design Pattern using MVVM.

* Working with remote data via HTTP/HTTPS protocols using RESTful API.

* Data serialization JSON and XML using network framework Retrofit2.

* Dependency injection using Koin.

More videos will be uploaded later (God willing, a video will be uploaded every 3 or 4 days)

I hope it helps.

#Android #Kotlin

submitted by /u/AhmedTawfik32
[link] [comments]

Continue Reading Special for developers interested in the field of Android

How to build a GraphQL Gateway with Spring Boot and Kotlin

With Spring Boot + Kotlin + Coroutines + GraphQL-java-kickstart, you can build a GraphQL Gateway with a minimum of boilerplate.

Up and Running

The code is available here:

jmfayard/spring-playground

Run the server like this:

git clone https://github.com/jmfayard/spring-playground
cd spring-playground/graphql-gateway
./gradlew bootRun

Open GraphiQL at http://localhost:8080/

Animal facts

With this project up and running, you can fetch animal facts using a GraphQL Query.

Enter this query:

query {
dog {
fact
length
latency
}
cat {
fact
length
latency
}
}

Run the query, and you will see something like this:

If you are new to the GraphQL, read this introduction from @methodcoder, I will wait.

https://medium.com/media/63ea00cc1e27ec6be082d27c75f797cc/href

Cat facts and dog facts

Where do the animal facts come from?

The server knows about two REST APIs.

The first one is about cat facts:

$ http get https://catfact.ninja/fact
{
"fact": "Isaac Newton invented the cat flap. Newton was experimenting in a pitch-black room. Spithead, one of his cats, kept opening the door and wrecking his experiment. The cat flap kept both Newton and Spithead happy.",
"length": 211
}

And the second one is about dog facts:

$ http get https://some-random-api.ml/facts/dog
{
"fact": "A large breed dog's resting heart beats between 60 and 100 times per minute, and a small dog breed's heart beats between 100-140. Comparatively, a resting human heart beats 60-100 times per minute."
}

By building a simple gateway, we take on complexity so that the front-end developers have one less thing to worry about:

  • We take care of calling the multiple endpoints and combining them, becoming a backend-for-frontend.
  • We offer a nice GraphQL schema to the front-end(s).
  • We normalize the response format — dog facts have no length attribute, but we can compute it!
  • We can potentially reduce the total response time. Without the gateway, the front-end would do two round-trips of let say 300 ms, so 600ms. With the gateway, there is one round-trip of 300 ms and two round-trips between the gateway and the facts server. If those are located on the same network, those could be done in 10 ms each, for a total of 320 ms.

So, how do we build that gateway?

Dependencies

If you start a new project from scratch via https://start.spring.io/, you will need to add those dependencies:

  • Spring Webflux
  • GraphQL-java
  • GraphQL-java-kickstart libraries

Use the source Luke

Note that I’m using gradle refreshVersions to make it easy to keep the project up-to-date. Therefore, the versions are not defined in the build.gradle files, they are centralized in the versions.properties file. RefreshVersions is bootstrapped like this in settings.gradle.kts:

https://medium.com/media/dbf2e6d4c43feb33b55a03a17f3d2745/href

GraphQL-schema first

GraphQL-java-kickstart uses a schema-first approach.

We first define our schema in resources/graphql/schema.grqphqls :

https://medium.com/media/1291e72dbc48136069a2020704b51c0d/href

Then, we tell Spring where our GraphQLSchema comes from:

https://medium.com/media/b38095cf5b3757ebd8e33dc5602da64a/href

Spring wants at least a GraphQLQueryResolver, the class responsible for implementing GraphQL queries.

We will define one, but keep it empty for now:

@Component
class AnimalsQueryResolver() : GraphQLQueryResolver {

}

GraphQLQueryResolver

If we start our application with ./gradlew bootRun, we will see it fail fast with this error message:

FieldResolverError: No method or field found as defined in schema graphql/schema.graphqls:2 
with any of the following signatures
(with or without one of [interface graphql.schema.DataFetchingEnvironment] as the last argument),
in priority order:
  dev.jmfayard.factsdemo.AnimalsQueryResolver.cat()
dev.jmfayard.factsdemo.AnimalsQueryResolver.getCat()
dev.jmfayard.factsdemo.AnimalsQueryResolver.cat

The schema, which is the single source of truth, requires something to implement a cat query, but we didn’t have that in the code.

To make Spring happy, we make sure our Query Resolver has the same shape as the GraphQL schema:

https://medium.com/media/0d2edf3a38f5a0fd7dcea24a01eba212/href

Notice that you can directly define a suspending function, without any additional boilerplate, to implement the query.

Run again ./gradlew bootRun and now Spring starts!

We go one step further by forwarding the calls to an AnimalsRepository:

https://medium.com/media/9ee243fede53ce85853e83574d996465/href

How do we implement this repository? We need an HTTP client.

Suspending HTTP calls with ktor-client

We could have used the built-in reactive WebClient that Spring provides, but I wanted to use ktor-client to keep things as simple as possible.

First, we have to add the dependencies for ktor, http and kotlinx-serialization, then configure our client.

See the commit Configure ktor-client, okhttp & kotlinx.serialization

The most interesting part is here:

https://medium.com/media/e7cdcf169aae2a925e61c6317d10900e/href

Simple or non-blocking: why not both?

When I see the code above, I am reminded that I love coroutines.

We get to write code in a simple, direct style like in the old days when we were writing blocking code in a one-thread-per-request model.

Here it’s essential to write non-blocking code: the gateway spends most of its time waiting for the two other servers to answer.

Code written using some kind of promise or reactive streams is therefore clearly more efficient than blocking code.

But those require you to “think in reactive streams” and make your code looks different indeed.

With coroutines, we get the efficiency and our code is as simple as it gets.

Resilience via a Circuit Breaker

We have a gateway, but it’s a bad gateway.

More precisely, it’s as bad as the worst of the servers it depends on to do its job.

If one server throws an error systematically or gets v e r y s l o w, our gateway follows blindly.

We don’t want the same error to reoccur constantly, and we want to handle the error quickly without waiting for the TCP timeout.

We can make our gateway more resilient by using a circuit breaker.

Resilience4j provides such a circuit breaker implementation.

We first add and configure the library.

See the commit: add a circuit breaker powered by resilience4j.

The usage is as simple as it gets:

https://medium.com/media/a85ff23fcfeea577b3a619daf5817efa/href

I want to learn more

See spring-playground/graphql-gateway

jmfayard/spring-playground

The talk that inspired this article: KotlinFest2019「Future of Jira Software powered by Kotlin」 #kotlinfest — YouTube

https://medium.com/media/79fe002f558d781672934e302da05b1a/href

Documentation of the libraries used in this project:

Another approach: Creating a Reactive GraphQL Server with Spring Boot and Kotlin

If you want to contact me, there is a standing invitation at https://jmfayard.dev/contact/.

Click 👏 to say “thanks!” and help others find this article.

To be up-to-date with great news on Kt. Academy, subscribe to the newsletter, observe Twitter and follow us on Medium.

If you need a Kotlin workshop, check how we can help you: kt.academy.


How to build a GraphQL Gateway with Spring Boot and Kotlin was originally published in Kt. Academy on Medium, where people are continuing the conversation by highlighting and responding to this story.

Continue Reading How to build a GraphQL Gateway with Spring Boot and Kotlin

Calling All Kotlin Programmers! Take Part in Kotlin Heroes: Episode 7 Coding Contest

If you’ve been thinking of new ways to level up your Kotlin coding skills, programming competitions are a great way to do so.

Starting from June 22, you can polish your Kotlin skills and practice solving algorithmic problems in a dedicated practice round on the Codeforces platform. On June 29, the real challenge begins – take part in Kotlin Heroes: Episode 7, and compete to win prizes!

I like a challenge, sign me up!


Even if you’ve never participated in programming contests before, we encourage you to give it a try. This is a great opportunity to test your limits and improve your coding.

The tasks of this episode are thought-provoking, fun, and designed to suit programmers of all levels. And everyone has a chance to win prizes!

It’s easy to take part

  1. Register on the Codeforces platform.
  2. Register for the Kotlin Heroes: Episode 7 contest. 
  3. Mark your calendar: June 29, 2021, at 14:35 UTC.
  4. Show up at the appointed time and enjoy the competitive spirit!

Take Part in Kotlin Heroes!


How to prepare

Enroll in the practice round with open solutions, which starts on June 22, 2021, at 13:35 UTC and lasts for a week. In this round, all solutions are open and you can see hints if you get stuck. 

Refresh your knowledge of Kotlin and learn more about competitive programming:

Contest rules

  • The contest features a set of up to 10 problems that range from simple ones, designed to be solvable by anyone, to hard ones, to make it more interesting. You are only allowed to use Kotlin to solve these problems. You have 2 hours and 30 minutes to complete the tasks. You move up the leaderboard by finding the most efficient solutions to the problems in the shortest time possible.

Prizes

  • The top three winners will receive prizes of $512, $256, and $128, respectively. 
  • The top 50 contestants will win an exclusive Kotlin Heroes t-shirt and Kotlin stickers. 
  • Every competitor who solves at least one problem is entered into a drawing for one of the 50 exclusive Kotlin Heroes t-shirts.

I like a challenge, sign me up!


Good luck and enjoy Kotlin!

Continue Reading Calling All Kotlin Programmers! Take Part in Kotlin Heroes: Episode 7 Coding Contest

End of content

No more pages to load