Hello, I'm new to Kotlin but not programming and ...
# getting-started
u
Hello, I'm new to Kotlin but not programming and was curius what is the best framework for Web development (Backend only) and what kind of database is mostly used with Kotlin? And looking at Kotlin it seems a switch statement is now called "When" why is that? Any tips on how to reduce CPU and memory usage in intelij?
r
when
is an expression whereas
switch
is not. It can also be used with arbitrary cases and is not restricted by type. Essentially, it’s completely different from switch-case while still providing all the functionality that we get from switch-case. https://kotlinlang.org/docs/control-flow.html#when-expression
e
(Java 17 added
switch
expressions, but that was much later than Kotlin's
when
)
🙏 1
the rest of your questions are pretty subjective
for backend frameworks, look for yourself in https://kotlinlang.org/docs/server-overview.html, #server, #ktor, #micronaut, #spring, #vertx, etc.
r
yeah, and since java interop works pretty well, just use whatever db tech you were using for java and you’ll be fine
e
for databases, https://www.ktorm.org/ https://github.com/JetBrains/Exposed and #squarelibraries's https://github.com/cashapp/sqldelight all have Kotlin integration
👍 1
but yes, general JVM technology integrates pretty well
e.g. Quarkus isn't designed around Kotlin, but it works fine https://quarkus.io/guides/kotlin
u
Thanks for all the help, but i have one question related to the libraries aswell. I normaly don't want to download a template from like Spring and get started using a bunch of premade code i want it to be like other languages where you import the libraries and code how you want it yourself why does both Java and Kotlin use this approach? i feel like it's getting to mutch boilerplate/blotated.
e
you can set everything up yourself without templates, you just need to understand more of it first.
r
a lot of the boilerplate in these libraries are actually for reducing the amount of boilerplate needed to do the same thing
c
In general, the “project generators” from Spring, Ktor, etc. are great for folks that aren’t deeply familiar with both the language and the ecosystem. You will really struggle to get everything working project if you don’t first understand the Kotlin language, and the specifics of the frameworks you’re using. So these project generators give you a way to just get started immediately, which helps you focus on the learning the language and the framework. Ultimately, they are just tools. You’re more than welcome to create your projects from scratch, but it’s not recommended unless you already know what you’re doing.
e
with Ktor, you can get started with just an
embeddedServer
in code. but that is only for one particular use case; for others, you may need different configurations
u
I see, i will take a look at these libaries and try to understand how they are builtup, i have used c# for quite many years and i assume from the look of it Java and Kotlin isn't mutch different.
r
Bold of you to assume 😂 😉
u
heh i better get started then 🙂
I never used Java or Kotlin, but this Year i decided to move away from c# to learn something new and hopefully familliar, so we will see.
r
It can feel familiar. I used c# a lot in college, but not a ton since
e
Kotlin was designed as a JVM language first, with good Java interop, which leads to some different design choices than C#
for example, Java bytecode is compatible all the way back to 1.0, whereas C# 2.0 did a compatibility break when they added generics. so that works differently