ocsigen / lwt

OCaml promises and concurrent I/O
https://ocsigen.org/lwt
MIT License
709 stars 173 forks source link

Lwt 4.0.0 breaking changes notice #453

Closed aantron closed 6 years ago

aantron commented 7 years ago

Lwt 4.0.0 will be released towards the end of 2017 in March 2018 with minor breaking changes to packaging, and perhaps several APIs. Hopefully, there will be less breakage than in 3.0.0.

The current release, 3.1.0, prepares to delete some modules. Another planned release, 3.2.0, will schedule additional breaking changes for 4.0.0. A comment will be added to this issue when 3.2.0 is released, with details and instructions about those additional plans.



ELLIOTTCABLE commented 7 years ago

Hi! Random new-OCaml-learner here, coming from the JavaScript/Node world.

Just came by to say this careful, premeditated handling of breaking changes is extremely heartening, and makes me 10x more excited to join the OCaml community.

Keep up the good work! <3

aantron commented 7 years ago

Well, thanks :)

aantron commented 6 years ago

Here are additional breaking changes, also planned for the future 4.0.0, announced and prepared by the recent 3.2.0 release. To give proper time to adapt, 4.0.0 will be released in three months, around March 2018.

Each breaking change is detailed below, with instructions on how to prepare for it. I will cc the maintainers of affected opam packages after 3.2.0 becomes installable. I've listed the names of opam packages potentially affected under each notice. See if your package is in the lists.

The scheduled breaking changes are still proposals. If you think anything below is a really bad idea, please don't hesitate to object or otherwise comment :) The three-month window is for adaptation and discussion :)




























aantron commented 6 years ago

cc @agarwal @akabe @andersfugmann @andrenth @andrewray @anyakichi @Armael @avsm @balat @c-cube @copy @cyberhuman @darioteixeira @delamonpansie @diml @djs55 @dominicjprice @domsj @dsheets @edwintorok @emillon @essdotteedot @fdopen @fxfactorial @gaborigloi @gildor478 @gregtatcam @haesbaert @hannesm @hhugo @ivg @johnelse @jrochel @kayceesrk @Leonidas-from-XIV @lindig @MassD @mato @metadave @mfp @mseri @msimon

aantron commented 6 years ago

cc @nojb @pqwy @pveber @rgrinberg @ryanslade @samoht @seliopou @smondet @talex5 @toolslive @vasilisp @vbmithr @vouillon @vzaliva @xvw @yallop @ygrek @yomimono @zoggy @zshipko

aantron commented 6 years ago

Please see the above comment, with instructions on how to adapt to future changes in Lwt 4.0.0, which will be made in three months. Mostly, adapting will involve adding new dependencies to opam files, due to changed packaging of Lwt helper libraries.

gildor478 commented 6 years ago

@aantron can you list the affected packages?

What command do you use to estimate what packages are impacted by this change?

Is this something like:

$> opam list --depends-on lwt
aantron commented 6 years ago

@gildor478 The affected packages for what? Each specific change lists the affected packages under the description already. Are you referring to something else?

The command is

opam list --unavailable --depends-on lwt --depopts --recursive --short
gildor478 commented 6 years ago

@aantron Thanks. The list of affected packages by breaking changes is perfect.

I have received first the comment where I was CCed and I was wondering how to act on it. It looked like a long list of sorted names. You may want to improve the CC message with something like

@gildor478 for debian-formats, @mfp for sqlexpr, @agarwal for biocaml, [...]

This can help people to know what they should change.

Anyway, thanks. I'll change ocaml-debian-formats accordingly.

aantron commented 6 years ago

Thanks. I'll probably have to do that for the next time we have breaking changes.

aantron commented 6 years ago

The Lwt.bind change will most likely not happen. Please see https://discuss.ocaml.org/t/1337/13 for details. Hopefully, this makes maintenance easier for everyone, and thanks for all feedback :)

rneswold commented 6 years ago

That's a shame. Sounds like this change would have made bind behave consistently and correctly. Plus, bumping the major version implies API changes that may not be backward-compatible. If people are worried, they can continue to use the 3.2.x branch until they've tested thoroughly against 4.0.x. After all, OPAM reports available versions all the way back to 2.3.2 so 3.2.x isn't going away soon.

ivg commented 6 years ago

That's a shame. Sounds like this change would have made bind behave consistently and correctly. Plus, bumping the major version implies API changes that may not be backward-compatible. If people are worried, they can continue to use the 3.2.x branch until they've tested thoroughly against 4.0.x. After all, OPAM reports available versions all the way back to 2.3.2 so 3.2.x isn't going away soon.

The majority of big projects, that are serious stakeholders of Lwt, will then may choose to continue to use Lwt 3.x, that will eventually lead to a nasty schism, like gnome 2.x vs gnome 3.x, etc. This will, in the best case scenario, double the support burden, and, in the worst one will make many packages uninstallable, or create yet another branch in the already too complex "which async library to use" decision tree. Given that in the real life, the noted problem with the bind semantics, is not often observable (if at all), I don't think that we should make this step.

Also, I would suggest everyone to refrain yourself from using exceptions together with Lwt (or any other async computations) and use variants to denote failed computations. Under such model, the bind function has perfectly fine and sound semantics.

aantron commented 6 years ago

We may still be able to make the Lwt.bind change, but with more preparation, to make it easier for users to adapt. For example, we could add a testing mode to Lwt that randomizes the deferral strategy to help discover mistaken assumptions about it.

However, I'm not sure what the ultimate value of this would be, given it's still work for users, it can't be flagged statically, and the semantic problem is not a problem for users in practice.

All the semantic problem means is for developers of Lwt, we have to do extra work when editing any core Lwt API, to ensure that it interacts safely with bind. But we almost never change the core Lwt API anyway. Fixing Lwt.bind would make it possible to analyze its behavior in isolation from other APIs, which is worthwhile, but probably not worth breaking all users for.

I agree strongly with @ivg about avoiding exceptions. Reflecting a lot on experience with Lwt and JS promises, my overall opinion is that rejections and asynchronous exceptions are both pretty ill-conceived mechanisms, almost as poor as cancelation. While it would be nice if these things worked well, because exceptions need to go somewhere and we don't want to handle them manually each time, each actual design that I've seen or come up with so far seems to produce undesirable consequences.

As @ivg points out, even though Lwt supports rejection, a user that is aware of its problems is likely to be using explicit error handling, in which case the Lwt.bind problem "accidentally" becomes irrelevant.

Lwt_result can help with this.

copy commented 6 years ago

Async provides an Eager_deferred module that can be opened to shadow bind and friends with their eager (lwt-like) versions. Maybe a similar solution could be provided by lwt to opt-in for safe monads. That is assuming it is possible to have both styles of promises in the same process and the implementation complexity is reasonable.

aantron commented 6 years ago

We could eventually do that. It should be very easy to get both styles of API exposed. The changes from #500 support this.

aantron commented 6 years ago

Closing this, as 4.0.0 is now merged into opam (ocaml/opam-repository#11708). See also the main announcement on Discourse.

Further discussion, questions, etc., are welcome, of course :)

vog commented 6 years ago

Great work! However, the documentation and tutorials should reflect the new project structure as well, especially with regard to lwt.ppx versus lwt_ppx.

aantron commented 6 years ago

@vog thanks for catching and reporting it! I (think I) fixed all remaining lwt.ppx in 0a1863d just now. The docs site is a bit behind on picking up Lwt changes. That is being tracked in #576 for now.