https://kotlinlang.org logo
Title
l

lutz

11/24/2020, 2:42 AM
Coworker just asked this:
I'm looking for learning resources as an experienced PHP developer trying to understand the subtleties of working with the JVM.  For example, PHP has essentially no concept of multithreading and asynchronous programming, while it seems pretty important to JVM development.  Does anyone have suggestions?
They are just starting to use kotlin on the backend and ran into some performance issues w/their impl of coroutines. Any recommendations?
a

asad.awadia

11/24/2020, 3:28 AM
Spend some time learning the vertx framework and reading its documentation
Also why use coroutines when threading is misunderstood. I consider coroutines to be learned and used after understanding threading
Also https://www.swoole.co.uk php's async framework
a

Alex Nordlund

11/24/2020, 10:12 AM
I guess it depends very heavily on what you're doing, most PHP applications serve mutliple users and if you're using something like spring you'll probably be handling multiple users in the same way
a

asad.awadia

11/24/2020, 3:33 PM
PHP uses processes, Spring uses threads, to serve multiple users
l

lutz

11/24/2020, 6:44 PM
Thanks for the recommendations. They are migrating from a monolith php stack to kotlin microservices. On one of the microservices they started to use coroutines instead of reactive. Lots of performance issues so they ended up removing all the coroutine code. They are trying to learn more about async programming in general before going down that route again (if they do). I'm in android land and very happy with coroutines, so it's interesting to me to see them have so many issues with it.
a

asad.awadia

11/24/2020, 6:46 PM
You can give them my contact if they want to chat about async - I do a lot of that stuff
m

Matteo Mirk

11/25/2020, 8:33 AM
coroutines are a tool, and like every tool it can be misused: your team need to study on the subject to become effective
n

nicholasnet

11/25/2020, 4:59 PM
@lutz I came from PHP land too. Rather than diving into threading and coroutine immediately I would suggest to explore the differences of language first. If individuals is using any framework in PHP, then see how same can be done in Java/Kotlin land using some framework of his or her choice. Then dive into threading and other stuff.
1
e

edrd

11/25/2020, 5:01 PM
Maybe performance issues were caused by blocking code inside coroutines. Coroutines are not threads and blocking code degrades performance significantly. They may want to add some checker, such as https://github.com/reactor/BlockHound
👍 2
l

lutz

11/25/2020, 5:24 PM
Yes - there was definitely
runBlocking
code that got removed. Do you have any docs I can send them about this issue:
Coroutines are not threads and blocking code degrades performance significantly.
a

asad.awadia

11/25/2020, 5:26 PM
Coroutines are syntactic sugar over callbacks - just remember that
c

christophsturm

11/26/2020, 9:46 AM
vert.x is really not the obvious choice here. have them join the #coroutines channel here and ask for help for specific problems. maybe try to come up with small isolated samples for problems.
👍 1
j

Jukka Siivonen

11/26/2020, 2:14 PM
Doesn't it depend on what kind of system you are building in a first place? For basic web applications there is no need to be reactive and use any async/coroutines bells and whistles but understand threads first
It feels that there's some kind of hype around async/reactive paradigm which makes ppl dive in to the deep end straight away even if they shouldn't need to
:this-is-fine: 2