caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ivan Gotovchits <ivg@ieee.org>
To: rudi.grinberg@gmail.com
Cc: Ashish Agarwal <agarwal1975@gmail.com>,
	Yotam Barnoy <yotambarnoy@gmail.com>,
	 Simon Cruanes <simon.cruanes.2007@m4x.org>,
	Malcolm Matalka <mmatalka@gmail.com>,
	 Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Question about Lwt/Async
Date: Mon, 7 Mar 2016 09:59:36 -0500	[thread overview]
Message-ID: <CALdWJ+y0Nf4EvZygKYDH7nCPqkE3PShb537hjRB=yqDZKBwwjA@mail.gmail.com> (raw)
In-Reply-To: <etPan.56dd9644.734c0340.177e8@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 6257 bytes --]

> While I still prefer Async’s interface

Me too, that's why we created an [overlay][1] over Lwt, that provides an
interface in the style of Core library.
I'm currently working on releasing this library to opam.

[1]: https://github.com/BinaryAnalysisPlatform/core-lwt

On Mon, Mar 7, 2016 at 9:55 AM, <rudi.grinberg@gmail.com> wrote:

> Since my post was mentioned, I thought I’d chime in.
>
> I’ve used both libraries and I’ve found little practical difference
> between the two. I think porting a codebase from Lwt to Async (and vice
> versa) is mostly mechanical work.
>
> While I still prefer Async’s interface a little more but I think the two
> main points in my blog post still stand. If portability and maximum
> interoperability with the community are important to you then the decision
> is already made in my eyes.
>
> On March 7, 2016 at 9:26:41 AM, Ashish Agarwal (agarwal1975@gmail.com)
> wrote:
>
> > Also, what happens to general utility functions that aren't rewritten
> for Async/Lwt -- as far as I can tell, being in non-monadic code, they will
> always starve other threads, since they cannot yield to another Async/Lwt
> thread.
>
> There is Lwt_preemptive.detach and Async's In_thread.run to get around
> this.
>
>
> > It seems that Lwt is more popular in the community outside JaneStreet
> than Async (if only by looking at its reverse dependencies on
> opam.ocaml.org). There has been posts about this, for instance
> http://rgrinberg.com/blog/2014/12/11/abandoning-async/ .
>
> I'd be wary of drawing conclusions from one blog post and even from opam.
> I think the answer is: both are used a lot. Also depends on what you mean
> by "a user". It's not too useful to count Jane Street's packages and one
> barely used package on opam both as 1. A lot of code is not on opam.
>
>
> > Is there an existing compatibility library functorized over the
> intersection of Async and Lwt? That would make being compatible with both
> much easier.
>
> Most people provide this internally for each of their projects, e.g. Cohttp's
> IO signature
> <https://github.com/mirage/ocaml-cohttp/blob/master/lib/s.mli>. However,
> we have quite a few projects that needed this abstraction, so duplicating
> this code in each repo seemed wrong. Thus we developed future
> <https://github.com/solvuu/future>, which was recently released in opam.
>
>
>
> On Mon, Mar 7, 2016 at 9:06 AM, Yotam Barnoy <yotambarnoy@gmail.com>
> wrote:
>
>> Is there an existing compatibility library functorized over the
>> intersection of Async and Lwt? That would make being compatible with both
>> much easier.
>>
>> On Mon, Mar 7, 2016 at 4:08 AM, Simon Cruanes <simon.cruanes.2007@m4x.org
>> > wrote:
>>
>>> Hi,
>>>
>>> It seems that Lwt is more popular in the community
>>> outside JaneStreet than Async (if only by looking at its reverse
>>> dependencies on opam.ocaml.org). There has been posts about this, for
>>> instance http://rgrinberg.com/blog/2014/12/11/abandoning-async/ .
>>> However, if you're writing a library, it is good taste (if possible) to
>>> parametrize you code over an "IO" monad that will be easy to instantiate
>>> with either Async or Lwt (or the trivial blocking monad where 'a t = 'a
>>> and (>>=) x f = f x) along with the required IO primitives.
>>>
>>> Regarding general utility functions, if they do not perform IO or depend
>>> on (blocking) IO they can be used directly with Async/Lwt (unless they
>>> really take a very long time to complete).
>>>
>>> Le Mon, 07 Mar 2016, Malcolm Matalka a écrit :
>>> > Yotam Barnoy <yotambarnoy@gmail.com> writes:
>>> > > Hi all
>>> > >
>>> > > I'm thinking about my next project in OCaml, and I'm wondering how
>>> many
>>> > > users of OCaml currently use Lwt or Async regularly.
>>> > >
>>> > > One of the advantages of OCaml over Haskell (which I'm not crazy
>>> about) is
>>> > > the fact that you don't have to constantly be stuck inside a monad.
>>> > > However, once you want to use these user-level threading libraries,
>>> you're
>>> > > essentially tied to a monad. It also means that the usage of any
>>> other
>>> > > monad from Lwt/Async code is out -- OCaml doesn't have the monad
>>> > > transformer infrastructure to layer monads easily as far as I can
>>> tell (am
>>> > > I wrong?). I mean, even in Haskell using Monad Transformers is a
>>> pain (IMO).
>>> > >
>>> > > Also, what happens to general utility functions that aren't
>>> rewritten for
>>> > > Async/Lwt -- as far as I can tell, being in non-monadic code, they
>>> will
>>> > > always starve other threads, since they cannot yield to another
>>> Async/Lwt
>>> > > thread. Is this perception correct? If so, this seems to imply that
>>> you
>>> > > either write your code to cooperate within these frameworks and
>>> suffer the
>>> > > monad, or don't, and make it near-impossible for Lwt/Async users to
>>> make
>>> > > use of your code.
>>> > >
>>> > > I would like to get an idea of the usage level of these libraries,
>>> as well
>>> > > as the burden of writing compatible code, any difficulties etc.
>>> Also, I'd
>>> > > like to get a sense of the domains that benefit from these
>>> libraries. Some
>>> > > domains (such as gaming) traditionally involve a continuous main
>>> loop, and
>>> > > would thus only suffer from the additional overhead of queuing in
>>> these
>>> > > libraries.
>>> > >
>>> > > -Yotam
>>> >
>>> > I mostly use Async.  However, I think most usage of Lwt or Async
>>> > requires doing as little as possible in these frameworks and using them
>>> > to orchestrate other functions.  For example, I usually try to separate
>>> > parsing of a network protocol from the reading and writing of the
>>> bytes.
>>> >
>>> > --
>>> > Caml-list mailing list.  Subscription management and archives:
>>> > https://sympa.inria.fr/sympa/arc/caml-list
>>> > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>>> > Bug reports: http://caml.inria.fr/bin/caml-bugs
>>>
>>>
>>> --
>>> Simon Cruanes
>>>
>>> http://weusepgp.info/
>>> key 49AA62B6, fingerprint 949F EB87 8F06 59C6 D7D3  7D8D 4AC0 1D08 49AA
>>> 62B6
>>>
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 9525 bytes --]

  reply	other threads:[~2016-03-07 14:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07  1:38 Yotam Barnoy
2016-03-07  7:16 ` Malcolm Matalka
2016-03-07  9:08   ` Simon Cruanes
2016-03-07 14:06     ` Yotam Barnoy
2016-03-07 14:25       ` Ashish Agarwal
2016-03-07 14:55         ` rudi.grinberg
2016-03-07 14:59           ` Ivan Gotovchits [this message]
2016-03-07 15:05             ` Ivan Gotovchits
2016-03-08  6:55         ` Milan Stanojević
2016-03-08 10:54           ` Jeremie Dimino
2016-03-07 15:16 ` Jesper Louis Andersen
2016-03-07 17:03   ` Yaron Minsky
2016-03-07 18:16     ` Malcolm Matalka
2016-03-07 18:41       ` Yaron Minsky
2016-03-07 20:06         ` Malcolm Matalka
2016-03-07 21:54           ` Yotam Barnoy
2016-03-08  6:56             ` Malcolm Matalka
2016-03-08  7:46               ` Adrien Nader
2016-03-08 11:04               ` Jeremie Dimino
2016-03-08 12:47                 ` Yaron Minsky
2016-03-08 13:03                   ` Jeremie Dimino
2016-03-09  7:35                     ` Malcolm Matalka
2016-03-09 10:23                       ` Gerd Stolpmann
2016-03-09 14:37                         ` Malcolm Matalka
2016-03-09 17:27                           ` Gerd Stolpmann
2016-03-08  9:41     ` Francois Berenger
2016-03-11 13:21     ` François Bobot
2016-03-11 15:22       ` Yaron Minsky
2016-03-11 16:15         ` François Bobot
2016-03-11 17:49           ` Yaron Minsky
2016-03-08  5:59 ` Milan Stanojević

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALdWJ+y0Nf4EvZygKYDH7nCPqkE3PShb537hjRB=yqDZKBwwjA@mail.gmail.com' \
    --to=ivg@ieee.org \
    --cc=agarwal1975@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=mmatalka@gmail.com \
    --cc=rudi.grinberg@gmail.com \
    --cc=simon.cruanes.2007@m4x.org \
    --cc=yotambarnoy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).