From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id CF0E27FFA1 for ; Mon, 7 Mar 2016 15:55:05 +0100 (CET) IronPort-PHdr: 9a23:1rE6yxfa3/0ms9X3Kfe5sgetlGMj4u6mDksu8pMizoh2WeGdxc+4YB7h7PlgxGXEQZ/co6odzbGG7OawACdevN6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDtvc2KKFsVzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IeezAcq85Vb1VCig9eyBwvZWz9Er1dhaU/nYXTkkRlxNJBUCFsEC7Dd/NtX7Trep8wynSFML/V689XXz25qhiUgDhjH5WaGMR/2Tei8g2h6Ve9lbplhtjyoucSoiPMv1vNvfMes8TQGBIRMBWRgROB4q9a80ECO9XbshCqIyovUYCrF2xHwiqDu71xRdHg3b32esx1OFyQkn9wAU8EodW4zzvp9LvOfJXDLm4 Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=rudi.grinberg@gmail.com; spf=Pass smtp.mailfrom=rudi.grinberg@gmail.com; spf=None smtp.helo=postmaster@mail-io0-f179.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of rudi.grinberg@gmail.com) identity=pra; client-ip=209.85.223.179; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rudi.grinberg@gmail.com"; x-sender="rudi.grinberg@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of rudi.grinberg@gmail.com designates 209.85.223.179 as permitted sender) identity=mailfrom; client-ip=209.85.223.179; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rudi.grinberg@gmail.com"; x-sender="rudi.grinberg@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-io0-f179.google.com) identity=helo; client-ip=209.85.223.179; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rudi.grinberg@gmail.com"; x-sender="postmaster@mail-io0-f179.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AROAATld1WlbPfVdFdgm6BHl4PgXWJT5x/gU4qkXwhhBWBWQKBKTsRAQEBAQEBAQEQAQEBAQcLCwkhL4ItghUBAQMBEhEdARsSCwEDAQsGBQsaHQICIQIRAQUBChIGARISAg6HagEDCggOoj+BMT4xizaBaoJXhRwKGScDClGDdgEBAQEBAQEBAQEBAQEBAQEBAQEBAQ8BBQoEhASGQoI9gUxeglOBOgWGHAyHfIkGhWOGFYF1gi6GbYVfhwyGCy+BDw8ngXgqChQIgWZMAYk8AQEB X-IPAS-Result: A0AROAATld1WlbPfVdFdgm6BHl4PgXWJT5x/gU4qkXwhhBWBWQKBKTsRAQEBAQEBAQEQAQEBAQcLCwkhL4ItghUBAQMBEhEdARsSCwEDAQsGBQsaHQICIQIRAQUBChIGARISAg6HagEDCggOoj+BMT4xizaBaoJXhRwKGScDClGDdgEBAQEBAQEBAQEBAQEBAQEBAQEBAQ8BBQoEhASGQoI9gUxeglOBOgWGHAyHfIkGhWOGFYF1gi6GbYVfhwyGCy+BDw8ngXgqChQIgWZMAYk8AQEB X-IronPort-AV: E=Sophos;i="5.22,551,1449529200"; d="scan'208,217";a="206393018" Received: from mail-io0-f179.google.com ([209.85.223.179]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 07 Mar 2016 15:55:04 +0100 Received: by mail-io0-f179.google.com with SMTP id m184so133618062iof.1 for ; Mon, 07 Mar 2016 06:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version; bh=8Vu0QkM8mXB1r8kmVWduW44MH/nlPUBJqjBvhaUBaKs=; b=zsaxO1ILj1VOuD/uAhg1zsUx1XC6OtnbtS+2u5FtISxVHrd/Pb93lwGMEX8OriNbjp cOqk659Kl/a8SMPGYUfvfNRLWfy1tI2TsWMsw/VQdvLurowcA1GRYGANdcP6YR12OUAz MvffJpHUO+d2WClxZ+8b012jDTPTxin/tYaqL3+cry/SBpKf+0AnGqS1IkrNwHEKg0oP iBeUdI39zBLbfx+yLFwi4aPDX7U3yUdG2EoiVuxkJCVmyJyjnS2ayc1g8eIXLWLXwagy 0UwikctWMbt5zDWwjP5zbfmipc3OhUDw8zqEwNZBfGDo44SpgoU76VHM0b8xs6XmRjEZ 0HYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version; bh=8Vu0QkM8mXB1r8kmVWduW44MH/nlPUBJqjBvhaUBaKs=; b=PqSoCxRn+h3xZdOwXL74l/h4sm964qpwkp4zjXMVZ7oFfbHLoda8dyddEy2cOmeTH0 OvRWFwmHPGcuT8TLB4YQoQfxS5OVAVMlbGThXL55GEgAbB0fS90rzYExLzHFjpYOx5iC 73DdJD99wOgvxMDAebAQuUu4tPOuCQYyk60CSKe4RBQiRQrhhgpQT3VgcfGeWbLEM/07 Ym2pCo+vy9EDEJw8KweyIdVjmiVXwQ5aALhWUvrk5QZmqObsnrXjP3yOYw0pPYLrEc9O kHDflaAPqVg1lMbQPL927R1krcP1gVAvCBZVvHr2ArFZK/h+l9Vjkr0nNcnE4AEpMNNu 1m4Q== X-Gm-Message-State: AD7BkJKjIv11KGyg8KOlrtbH5DQZ7UMTJGlTuqZZHhfxdfXv1Ac75zRzpClXHXj5ufM8pA== X-Received: by 10.107.11.162 with SMTP id 34mr15066362iol.165.1457362503347; Mon, 07 Mar 2016 06:55:03 -0800 (PST) Received: from Rudis-MacBook-Pro.local (24-246-56-85.cable.teksavvy.com. [24.246.56.85]) by smtp.gmail.com with ESMTPSA id s101sm257908ioe.24.2016.03.07.06.55.01 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Mar 2016 06:55:01 -0800 (PST) Date: Mon, 7 Mar 2016 09:55:00 -0500 From: rudi.grinberg@gmail.com To: Ashish Agarwal , Yotam Barnoy Cc: Simon Cruanes , Malcolm Matalka , Ocaml Mailing List Message-ID: In-Reply-To: References: <86oaaqahc1.fsf@gmail.com> <20160307090859.GF30630@nunchakus.loria.fr> X-Mailer: Airmail Beta (353) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="56dd9644_3aca9b5b_177e8" Subject: Re: [Caml-list] Question about Lwt/Async --56dd9644_3aca9b5b_177e8 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Since my post was mentioned, I thought I=E2=80=99d chime in. I=E2=80=99ve used both libraries and I=E2=80=99ve found little practical di= fference between the two. I think porting a codebase from Lwt to Async (and= vice versa) is mostly mechanical work. While I still prefer Async=E2=80=99s interface a little more but I think th= e two main points in my blog post still stand. If portability and maximum i= nteroperability with the community are important to you then the decision i= s already made in my eyes. On March 7, 2016 at 9:26:41 AM, Ashish Agarwal (agarwal1975@gmail.com) wrot= e: >=C2=A0Also, what happens to general utility functions that aren't rewritte= n for Async/Lwt -- as far as I can tell, being in non-monadic code, they wi= ll always starve other threads, since they cannot yield to another Async/Lw= t 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 tha= n 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/20= 14/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 bare= ly used package on opam both as 1. A lot of code is not on opam. >=C2=A0Is there an existing compatibility library functorized over the inte= rsection 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. However, we have quite a few projects that needed this abs= traction, so duplicating this code in each repo seemed wrong. Thus we devel= oped future, which was recently released in opam. On Mon, Mar 7, 2016 at 9:06 AM, Yotam Barnoy wrote: Is there an existing compatibility library functorized over the intersectio= n of Async and Lwt? That would make being compatible with both much easier. On Mon, Mar 7, 2016 at 4:08 AM, Simon Cruanes = 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 =3D 'a and (>>=3D) x f =3D 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 =C3=A9crit : > Yotam Barnoy 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 f= or > > 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/L= wt > > 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 w= ell > > 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. S= ome > > 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.=C2=A0 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.=C2=A0 For example, I usually try to separ= ate > parsing of a network protocol from the reading and writing of the bytes. > > -- > Caml-list mailing list.=C2=A0 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=C2=A0 7D8D 4AC0 1D08 49A= A 62B6 --56dd9644_3aca9b5b_177e8 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =
Since my post was mentioned, I thought I=E2=80=99d= chime in.

I=E2=80=99ve used both libraries and I=E2=80=99ve found little practica= l 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=E2=80=99s i= nterface a little more but I think the two main points in my blog post stil= l 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). Ther= e 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. However, we have quite a few projects that needed this abstraction, so duplicating this code in each repo seemed wrong. Thus we developed futur= e, 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 =3D 'a
and (>>=3D) x f =3D 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 =C3=A9crit :
> 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/oca= ml_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


= --56dd9644_3aca9b5b_177e8--