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
j

jw

03/23/2018, 1:54 PM
they're complimentary not competition
👍 3
j

Jonathan

03/23/2018, 1:56 PM
What can Rx solve that Coroutines cannot?
j

jw

03/23/2018, 1:56 PM
multi-value cold push
also that question really makes no sense
j

jw

03/23/2018, 1:57 PM
RxJava is an abstraction
j

Jonathan

03/23/2018, 1:57 PM
cold stream are planned feature.
j

jw

03/23/2018, 1:57 PM
i'm aware as evidenced by my participation in that thread
j

Jonathan

03/23/2018, 1:58 PM
indeed^^
j

jw

03/23/2018, 1:59 PM
RxJava basically contains a tiny implementation of coroutines and there's no reason that a version of RxJava couldn't be built on top of Kotlin coroutines to great benefit
j

Jonathan

03/23/2018, 2:00 PM
But once kotlinx.coroutines will have cold stream. What use case would be answered by rxJava only?
j

jw

03/23/2018, 2:01 PM
its operator collection
☝️ 2
l

louiscad

03/23/2018, 2:03 PM
Its operator collection can also be added to kotlinx.coroutines, right ?
j

Jonathan

03/23/2018, 2:04 PM
kotlinx.coroutines has even, if smaller an operator collection too. And RxJava operators are anyway not usable with kotlin channels, so the rx operator collection doesn't help if you use coroutines.
j

jw

03/23/2018, 2:04 PM
sure. then we've just reinvented RxJava thus proving they're complimentary concepts and not competing and we can stop these silly questions from being asked over and over
j

Jonathan

03/23/2018, 2:06 PM
I think it is an interesting question. And it must be answered before going for coroutines. And if the answer is "they are complimentary" this is okay, but then the question becomes: "How do they complement each other? For what task should I chose one or the other?"
j

jw

03/23/2018, 2:08 PM
When most people talk about coroutines or RxJava they don't actually care about the implementation of the library they care about the programming style that it affords
Thus, most people lauding RxJava don't care about the fact that they use RxJava they care about its API abstraction. They don't care about the fact that it's manually built on threads running loopers encapsulated in Schedulers and would happily switch to the exact same API built on threads and loopers encapsulated in CoroutineContexts
👍 1
Coroutines are just callback hell if you lack the compiler magic that does the bytecode transformation just like RxJava is callback hell if you lack the higher-level API around it
Believe me, I welcome our new coroutine overloads and look forward to a cold stream abstraction so I can drop my final RxJava usage and switch to RxKotlinCoroutineHeaven instead
j

Jonathan

03/23/2018, 2:16 PM
Okay. I agree with everything you said. But, to me, it means that they do compete. Otherwise, for what task would you still use Rx?
My question is genuine interest. I'd like to know if we should still use Rx for some specific task.
c

Caleb Allen

03/23/2018, 3:12 PM
@Jonathan I've been experimenting with a library that gives the user an API similar to Rx, but with an under the hood implementation using Coroutines to enable concurrent data flows. The implementation to enable concurrent reactive programming using coroutines is an order of magnitude simpler than trying to manage that with threads https://github.com/caleb-allen/Konko-Flow
j

Jonathan

03/23/2018, 3:21 PM
@Caleb Allen Yes. I'm aware that it is possible to recreate an "rx-like" library based on coroutines. There is another similar project too, if you're interested: https://github.com/pull-vert/reactivity. But why would I need such library? What use-case does it solve better than plain coroutines with kotlinx.coroutines?
j

jw

03/23/2018, 3:28 PM
Oh we're linking Rx coroutine libraries? https://github.com/JakeWharton/Reagent/
we have already enumerated what it solves
multi-value cold push sources
c

Caleb Allen

03/23/2018, 3:29 PM
My use case/experiment has been using rx-like operations to wrap these operations into easy to use dispatchers that take care of concurrency for me.
ie scaling up coroutines when we know that an operation is stateless and associative, and scaling them down when we know an operation is stateful
a

acando86

03/23/2018, 3:37 PM
Rx & coroutines operates at a different level of abstraction IMO, they provide different ways of reasoning about the code, and they just partially overlap each other. First, I’d say Rx is not primarily concerned with concurrency. Hold on, of course it has built-in tools to handle concurrency and asynchronous behaviours, but that’s not the main/only reason to use Rx. Rx is more about reasoning in terms of streams. Rx is more about expressing and representing the business logic of your application in terms of manipulation and combination of these streams (usecases becomes actually observable transformers). I would consider more appropriate to compare Rx to something like say FRP (Rx intentionally is NOT by construction a realisation of FRP in the sense of the Elliott’s FRP work) or compare it to a more traditional, imperative, state machines. Rx is more about “monadic” chainability, push-based patterns, etc and it’s highly influenced by concepts borrowed from functional programming and category theory. Then, As a matter of fact, Rx also has another degree of freedom, namely the Scheduler, an interesting abstraction on top of threads, and people can exploit this degree of freedom to achieve asynchronous behaviour. I guess (but I’ve never tried myself) there is nothing that in principle prevents someone to write a Rx scheduler on top of coroutines and power the whole Rx infrastructure with coroutines. CSP/channels etc that kotlin implements on top of coroutines are not a replacements for monadic composition, they are a model to reason about concurrent behaviour (as they are actors)
j

Jonathan

03/23/2018, 4:08 PM
Kotlin Sequences and coroutines channels allow to reason in term of streams. Business logic can be express as manipulation and combination of theses streams. Coroutine dispatchers allow same abstraction as Rx schedulers. I know there are differences. But, I'm not aware of a concrete use-case for which Rx would help more than sequences or coroutines. If you know one, please share it, I'm genuinely interested.
j

jw

03/23/2018, 4:09 PM
multi-value cold push sources. neither channels nor sequences can model this
j

Jonathan

03/23/2018, 4:20 PM
Ok, so you'r answer is "as soon as kotlinx.coroutines will provide cold stream, as they are planning to, there won't be such use-case."?
j

jw

03/23/2018, 4:21 PM
well except for the lack of operators that will be available and need to be rewritten
we're replaying the same conversation as above
Rx's value is its API, not its implementation
💯 1
j

Jonathan

03/23/2018, 4:38 PM
Yes but I cannot use rx operators with coroutines channels anyway. And if I miss an operator with channels it is usually very easy and straight forward to implement it myself. So bottom line, if I have kotlin coroutines, I don't need rx.
j

jw

03/23/2018, 4:39 PM
you seem to be conflating rx with RxJava
there is nothing library-specific about Rx's API
j

Jonathan

03/23/2018, 4:42 PM
Yes, indeed I'm conflating them, sorry for that. Every time I said "rx" I meant "RxJava"
j

jw

03/23/2018, 4:43 PM
Then I agree with you! Once we have that, you shouldn't need to use the library unless you're interoperating with something that requires it.
a

alucard

03/23/2018, 7:50 PM
I know my question was a bit polemic. But I had problems in porting some Rx code to coroutines, such as setting a piece of code to react to bluetooth data only when that the remote device send them.
With Rx it is trivial: just crating a flowable an sharing these data with other observables, but with coroutines, I was complicated
l

louiscad

03/24/2018, 10:52 AM
@alucard Was it Bluetooth Classic or Bluetooth Low Energy?
a

alucard

03/25/2018, 2:04 PM
Classic Bt
i

iex

03/25/2018, 6:55 PM
channels?