https://kotlinlang.org logo
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
benchmarks
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
confetti
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
lincheck
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by
Title
u

4ntoine

03/08/2019, 12:23 PM
Hey, guys. We’re going to reconsider our system design. Can you point some C++ vs. Kotlin comparisons, benchmarks? Probably including some project management aspects like “coding time” (amount of time required to implement the same functionality), developers costs (average salary), learning curve, etc. Thanks in advance
c

Czar

03/08/2019, 12:43 PM
It's like comparing tractors to pickup trucks. Yeah, both are machines, and both can tow things, but they're very different beasts. Which is best for your project depends on your project and resources available to you (as in developers).
1
u

4ntoine

03/08/2019, 12:46 PM
Both agree and disagree. From TPM’s point of view it’s just ecosystem that helps solve some technical task. Not sure that are too different as you mentioned. For example Kotlin/Native can compile kotlin code into binaries (not JVM bytecode) so they are pretty comparable
What i’m trying to do is to find measurable advantages over C++ ecosystem
m

Mike

03/08/2019, 12:46 PM
If you do find a study like this, the entire programming community would want to see it. Unless you’re willing to hire two teams, give them the exact same assignment and complete isolation, there’s no way to know… No two projects are exactly the same. No two teams are exactly the same. Too many variables.
👆 1
For performance, I’m sure you can find comparisons between C++ and Java/JVM. Kotlin compiles to Java bytecode, so that should be sufficient. For team development time, good luck. For average salaries, there are several resources for looking at salaries. If you’re lucky, someone will have gathered this, and might be willing to share…
u

4ntoine

03/08/2019, 12:48 PM
Yeah, i can clearly see your point. However if it’s possible at all i’d like to learn existing findings to demonstrate reasonable advantages of Kotlin ecosystem
I believe every TPM have to do it before investing into some solution if choosing between C++ and Kotlin
and probably other solutions
m

Mike

03/08/2019, 12:50 PM
C++ and Kotlin are very different, so I doubt there are too many teams choosing between the 2. If they’re already C++, they’ll likely stick as it’s always expensive to change languages. Kotlin will mostly come from Android dev and existing JVM teams. If you’re truly starting from scratch, then I can completely see where you’re coming from. But a lot of decisions are more ‘gut feel’, or ‘emotional’ because of a lack of objective measures and studies.
u

4ntoine

03/08/2019, 12:53 PM
I think i can share some details on our current system design. It’s JS wrapped into C++ (and embedded V8), wrapped into Java (over JNI) and used in Android. We can see clear limits of such approach because of disk footprint (V8 size) and memory consumption (too small opportunities for improvements in JS). So i’d say we start from scratch but having some experience in domain and technical implementation (language agnostic). So we’re really choosing between rewriting everything in C++ or Kotlin (and we’re taking into account possibility to compile to binary with Kotlin/Native and to JVM bytecode with Kotlin JVM)
c

Czar

03/08/2019, 12:57 PM
I see now why you believe Kotlin has advantages here. I think the main one is removing all that indirection you've specified. The problem though is that your team will have to learn a new technology, which is always a drag on the project. It may be advantages long-term, but I doubt that you'll feel any benefit short-term. Or just get another team which is Java/Kotlin from the start.
m

Mike

03/08/2019, 12:58 PM
Wow! That’s quite the tech stack there. If the end target is Android, why not just Kotlin? Or is the code too shared and performance is that critical? Doesn’t sound like you have a typical problem space that you’re dealing with. If you’re targeting Android, Kotlin (IMO) is a much better choice than Java. And especially if you also have iOS as Swift and Kotlin are more similar then Swift and Java. And what Alexander said.
u

4ntoine

03/08/2019, 1:03 PM
it’s performance and memory-critical. We have lot’s os strings and most likely migrating to some memory-efficient data structures like trie (probably even marisa trie). Also as Alexander mentioned, we’e like to get rid of that wrappers chain because it causes lot’s of troubles: it’s 3 languages, different set of skills, tools and peoples working on it. The target goal is to use it in both large C++ code (Chromium fork) and android apps (as library).
Yeah, we will need people - for both C++ and Kotlin. So learning curve and hiring possibilities also matters
Also it would be good to suggest me some videos on experts opinions on the subject, like

https://www.youtube.com/watch?v=Pz-4co8IaI8&list=LLmdEPb5geNqn_WSbq7J6FPw&index=43&t=0s

👍 1
(who bets to Java if choosing between C++ and Java)
m

Mike

03/08/2019, 1:13 PM
I don’t have experience with performance/memory critical apps. Everything I’ve read tends to indicate the JVM can be very good at this, but like all things, may require some tweaking and full understanding of the library data structures etc. As far as language, I strongly lean to Kotlin. I was doing some Java, and although it’s a great language, it still felt like death by a thousand cuts in comparison to writing/reading Kotlin code. And the teams I’m working with feel the same way.
u

4ntoine

03/08/2019, 1:16 PM
Thanks for your feedback, Mike! I personally enjoy Kotlin too. However in order to prove to my TPM that Kotlin is better than C++ in terms of language syntax i think we should demonstrate some measurable advantage, not just words
That’s why i’m looking for some articles, findings, comparisons, etc
m

Mike

03/08/2019, 1:22 PM
As I said, unfortunately too many decisions are made by gut feel because objective studies/measures that are actually valuable are very tough to find/do. I don’t have anything concrete because I’ve never had the opportunity to do A/B comparison as that’s obviously significantly more expensive than just choosing one, even if it’s a little bit worse. I suspect the bottom-line is more about the team, what they’re comfortable with, and what they’re willing to learn. Any change of language will have a cost associated with it, and is likely quite hard to recoup the costs on… We’re all still waiting for the perfect language 😉
💯 1
u

4ntoine

03/08/2019, 1:24 PM
Right 😀 Thanks! However, anyone - feel free to share anything helpful here
d

dalexander

03/08/2019, 1:25 PM
My experience limited experience with C++ is that people choose for “performance” dogmatic rather than pragmatic reasons-- they typically have no benchmarks, they just think they know it’s going to be necessary ahead of time. I think, depending on the problem you are trying to solve, you may be able to demonstrate that the performance between C++ and Kotlin is not significantly different with a small prototype or something to that effect. Although depending on the role of Javascript in the project you might still have problems because you’d probably be stuck running it through a WebView or something on Android.
u

4ntoine

03/08/2019, 1:28 PM
Thanks for your input on that, Derek. Yeah, good point with small prototype. I’ve already started with prototype on Kotlin and i was able to do it really fast, though i’m not C++ expert (J2ee background instead). You’re right aobut Android, but we solved it with embedding of V8 and added huge paint as binary V8 required wich adds 15mb to the app
d

dalexander

03/08/2019, 1:34 PM
Ouch at the binary V8. I’ve been on another project which embedded the Rhino JS engine for our javascript-scripting needs, which is about 1MB in size, but it impacts startup time, and Rhino was very slow because it couldn’t use a JIT on Android.
c

Czar

03/08/2019, 1:42 PM
I would start with these: https://yosefk.com/c++fqa/ 🙂 C++ is very easy to get wrong, Kotlin much less so.
👍 1
Kotlin is demonstrably more consistent, easier to learn and better designed (although the latter is arguable). If we are comparing languages. Eco-system is whole another matter. Kotlin eco-system is not very mature, that said it piggy backs on JVM one which is one of the most mature eco-systems out there. On the other hand Kotlin native is not ready for prime time, IMHO.
u

4ntoine

03/08/2019, 1:47 PM
Yeah, agree completely. But i’d say it’s our feelings and overall impression and it’s pretty difficult to prove that to TPM. I’d really appreciate some experts opinions or measurable comparisons. However even “mature” C++ vs “still experimental” K/M already shows the difference 😉
k

Kris Wong

03/08/2019, 2:01 PM
i. and others in my org, have spent time looking at Kotlin Multiplatform vs. C++ for cross platform development
I've found both to be satisfactory from a purely language and productivity perspective, as there are good tools for C++ for autogenerating necessary bindings.
The real issue, IMO, comes from finding 3rd party libraries that can be easily consumed on iOS and Android, because you end up having to cross compile with 2 different toolchains and multiple ABIs
u

4ntoine

03/08/2019, 2:04 PM
agree, libraries matter too
k

Kris Wong

03/08/2019, 2:04 PM
with Kotlin/native you've already got some useful tools that are supported (Ktor, kotlinx.serialization). But the Kotlin common stdlib is smaller than the Koitlin JVM stdlib
i see significant momentum behind Kotlin Multiplatform, though. The project is just in its infancy.
u

4ntoine

03/08/2019, 2:05 PM
what makes you think so? BTW do you mean Kotlin/Native compiler pr K/Multiplatform as approach in general?
k

Kris Wong

03/08/2019, 2:06 PM
Jetbrains is investing heavily there. There were a number of multiplatform talks at KotlinConf (and also the year before)
you can easily see they want Kotlin to be used everywhere
Google is the other major member of the Kotlin Foundation, and they're also pursuing multiplatform (Flutter)
also, I've heard we're using Duktape as a lightweight embedded JS engine
IIRC, they said it's around 1 MB
u

4ntoine

03/08/2019, 2:10 PM
yeah, we’ve tried Ducktape and it really suxx in terms of memory consumption (~4 times worse in our use case)
k

Kris Wong

03/08/2019, 2:11 PM
Gotcha
In my mind it's not an either/or proposition. We intend to use the right framework for any given project.
u

4ntoine

03/08/2019, 2:15 PM
@Kris Wong Can you please explain why you think K/M (or K/N) is not mature enough?
k

Kris Wong

03/08/2019, 2:15 PM
Well, it's still experimental for one
It's not even released
There's less documentation and online conversation about issues and what not, because a lot of people are just getting started with it
r

rook

03/08/2019, 3:10 PM
IMO, it’s important to understand what experimental means in this context. Experimental does not indicate instability or unreadiness for “prime time”. I’m just going off the historical example of coroutines here, so forgive me if this is an incorrect conclusion. Experimental simply means that the API might have breaking changes in the future. As long as the benefits outweigh the risk of eating that potential cost, it’s a viable solution (and maybe even preferred).
I haven’t touched C++ in around 5 years, so I’m a touch unfamiliar with what’s available, but you might look at model constructs and standard extensions that would massively simplify current patterns in your existing code base. A really good (but Java-focused) example of this, would be Jake Wharton’s various intro-to-kotlin style talks he was giving non-stop about a year or two ago.
Here’s an example of a shorter one:

https://www.youtube.com/watch?v=0sPzDwS55wM

💯 1
t

Terry Gruenewald

03/08/2019, 6:47 PM
Hi @4ntoine This is a well timed discussion as I am also looking into considering Kotlin for replacing a C++ project for support of multiple platforms (web/Windows desktop). It seems like a great language, but it seems like this would be an "all in" approach, and I would like to setup small "experiments" in order to learn from mistakes and "fail fast" if need me. Does anyone know of a way to ease Kotlin development in with C++ for developing a C++ native library used by Windows applications?
k

Kris Wong

03/08/2019, 6:52 PM
Kotlin/Native integrates nicely with C. Unfortunately not C++.
but you can easily develop independent modules in whatever language you like and bring them together into one app
to clarify my first statement, you can reference a C library from Kotlin code, but not C++. You can use a Kotlin library compiled with Kotlin/Native from either C or C++.
👍 1
s

serebit

03/08/2019, 6:56 PM
Is C++ interop planned?
t

Terry Gruenewald

03/08/2019, 6:59 PM
Thanks, @Kris Wong for that insight. So if compiling with Kotlin Native, I would have access to C standard libraries? That would provide a limited form of experimentation. I am also considering using Haxe since, in theory, that would allow me to generate C++ code that could compile with my existing C++ library. If there is a way to do something similar in Kotlin, that would make a nice POC as well.
k

Kris Wong

03/08/2019, 7:02 PM
certainly. that's the main point of Kotlin/Native
u

4ntoine

03/08/2019, 7:07 PM
@Terry Gruenewald Yeah, my intention was also to do some poc projects. We will also need to use kotlin compiled code from C++. Afaik Kotlin and C++ interop for some reason isn’t supported (correct me) Objective-C glue layer isn’t desired for us. @Kris Wong any examples of accessing of compiled kotlin code from C++?
👍 1
k

Kris Wong

03/08/2019, 7:09 PM
it compiles to C headers/binary. you can easily use C from C++.
u

4ntoine

03/08/2019, 7:10 PM
@Kris Wong Could you please explain it or reference to some sample code/project?
t

Terry Gruenewald

03/08/2019, 8:01 PM
Thanks @Kris Wong
🍻 1
u

4ntoine

03/09/2019, 3:53 AM
@Kris Wong I haven’t found any project example written in C++ using Kotlin code. I guess Kotlin code should be compiled to static or shared library with K/N and then reused in C++ project. However it’s unclear how to use it in C++ project. I believe it can expose only C interface, not C++ (correct me) and that’s disappointing disadvantage again. Any examples are still appreciated.
k

Kris Wong

03/09/2019, 4:13 PM
you are correct