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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 8CFF07FFA1 for ; Mon, 7 Mar 2016 15:59:41 +0100 (CET) IronPort-PHdr: 9a23:jLt1hRYophibNh1wxnQzOiD/LSx+4OfEezUN459isYplN5qZpcuybnLW6fgltlLVR4KTs6sC0LqJ9fC5EjJQqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh7/0q8SYPVUArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIZoGJ/3dKUgTLFeEC9ucyVsvJWq5i/4UBCX63AAfmITmxtOS0iZvVCpFqv25zHnuus71zObO8f7V78cVjGr7qMtQxjt2wkdMDts0X/ejIRfi75cvhmhpgBki9rVfo69Nfdzc+XaZ9xMFjkJZdpYSyEUWtD0VIAIFedUeLsBog== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=ivg@ieee.org; spf=Pass smtp.mailfrom=ivg@ieee.org; spf=None smtp.helo=postmaster@mail-lb0-f180.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of ivg@ieee.org) identity=pra; client-ip=209.85.217.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of ivg@ieee.org designates 209.85.217.180 as permitted sender) identity=mailfrom; client-ip=209.85.217.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-lb0-f180.google.com) identity=helo; client-ip=209.85.217.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="postmaster@mail-lb0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0D4AQDMlt1WlbTZVdFdgm6BHm0GqgsqkXwXAQmFbgKBIgc7EQEBAQEBAQEBEAEBAQEHCwsJIS+CLYIUAQEBAwESER0BASwLAQQLCwsNDR0CAiEBEgEFAQoSGRICDodrAwoIDqJFgTE+MYpPZ4RBAQSFYgMKhEcBAQEBAQEEAQEBAQEBAQEBAQEPBgqGDYQ9gj2BTF6CGzgTgSeGIQyHfIkGhWOGFYF1gi6MTIcMhgsRHoEPDyeCIgoUCIFmHi4BiTwBAQE X-IPAS-Result: A0D4AQDMlt1WlbTZVdFdgm6BHm0GqgsqkXwXAQmFbgKBIgc7EQEBAQEBAQEBEAEBAQEHCwsJIS+CLYIUAQEBAwESER0BASwLAQQLCwsNDR0CAiEBEgEFAQoSGRICDodrAwoIDqJFgTE+MYpPZ4RBAQSFYgMKhEcBAQEBAQEEAQEBAQEBAQEBAQEPBgqGDYQ9gj2BTF6CGzgTgSeGIQyHfIkGhWOGFYF1gi6MTIcMhgsRHoEPDyeCIgoUCIFmHi4BiTwBAQE X-IronPort-AV: E=Sophos;i="5.22,551,1449529200"; d="scan'208,217";a="167462390" Received: from mail-lb0-f180.google.com ([209.85.217.180]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 07 Mar 2016 15:59:39 +0100 Received: by mail-lb0-f180.google.com with SMTP id bc4so133058958lbc.2 for ; Mon, 07 Mar 2016 06:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=dcL99+Gv5mOvio9BKNY3BOa8PYTEZt2I2QIxuCFplIU=; b=vJFFcO374T1zejMprNpifyhRTBemkri65xs8YtKC2nWQ7z4qeZeXBzK5Q8wfnL2z0u pbGUpPPYBRzY2qqjo697RUq8Hca/ndAL14KYIL+V9k/TSgPnWtPmL62gWvm19K25fX+7 BSbWLQoAM1t4neUq31eSN9/REo5EXMndEq2ndR+JBaPrbqBagkc/Vzd09LjonMtDZUE7 LOMsBmCJEKX1I9hSsZ0Z6Vxo0RyvPQb9J10RIq5vocvkgAEBre/fjUz9oWkp2EG6iB9/ Gx7nMmpwr43sY9xFm6FqCJDjdHCTjSKiiJ3NR+qO8fkmdRmWqY03TNJ5kgiAUo4kACls zXaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=dcL99+Gv5mOvio9BKNY3BOa8PYTEZt2I2QIxuCFplIU=; b=lJDf/7yMj/q3h1KSVK2FBga3JVMotEF9gFy1V4tl0Qyc+p+rtA9CfsIrVpRvlh9QzK ifsw620Xdphf7pm5yPcdqPn3hFSfcaRwF/uNv+2dOCY3rMek2HV8mW6b1f94liMwmaNH uer9QP8EOWEVR1k2s4Cw5mvDz7xtzaZBteyfZtvw1c3LtQkGnw2kbJtOQAGLSeXulbMf 4UJN8iLyeRqOxMeWlLovVN4WQnNhfWr5YN0xKwiU14nJsQyKntiWHAaM2Q0eeY1f+mMK JSYH/xLi0HdPTeksYbqPMSLlPj7dkq9sLItCojJs6pVbtQJbo66Nt52Q8wcAE7SIWY8/ 1oXQ== X-Gm-Message-State: AD7BkJKa8RmyPTqLi3Sq50a71LWK56vQuqitOvgMaOCD29MX9ze/vkwLs+O7lI/O4QLB1tNbw5RWZ3UMWy9elSBm MIME-Version: 1.0 X-Received: by 10.112.139.202 with SMTP id ra10mr895495lbb.41.1457362776191; Mon, 07 Mar 2016 06:59:36 -0800 (PST) Received: by 10.114.180.161 with HTTP; Mon, 7 Mar 2016 06:59:36 -0800 (PST) In-Reply-To: References: <86oaaqahc1.fsf@gmail.com> <20160307090859.GF30630@nunchakus.loria.fr> Date: Mon, 7 Mar 2016 09:59:36 -0500 Message-ID: From: Ivan Gotovchits To: rudi.grinberg@gmail.com Cc: Ashish Agarwal , Yotam Barnoy , Simon Cruanes , Malcolm Matalka , Ocaml Mailing List Content-Type: multipart/alternative; boundary=001a11c23888959ad0052d76b661 Subject: Re: [Caml-list] Question about Lwt/Async --001a11c23888959ad0052d76b661 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > While I still prefer Async=E2=80=99s 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, wrote: > 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 = 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 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 wi= ll > 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. Coht= tp'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 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 >> 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 > > 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 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 th= em >>> > to orchestrate other functions. For example, I usually try to separa= te >>> > 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 >>> >> >> > --001a11c23888959ad0052d76b661 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
> While I still prefer Async=E2=80=99s interface

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


On Mon= , Mar 7, 2016 at 9:55 AM, <rudi.grinberg@gmail.com> w= rote:
Since my post was mentioned, I thought I= =E2=80=99d chime in.

I=E2=80=99ve used both libraries and I=E2=80=99v= e found little practical difference between the two. I think porting a code= base from Lwt to Async (and vice versa) is mostly mechanical work.

Wh= ile I still prefer Async=E2=80=99s interface a little more but I think the = two main points in my blog post still stand. If portability and maximum int= eroperability 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:

>=C2=A0Also, 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.oc= aml.org). There has been posts about this, for instance http://rgrinberg.com/blog/2014/12/11/aba= ndoning-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 Ja= ne Street's packages and one barely 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 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 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 =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.=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 separate
> 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 49AA 62B6



--001a11c23888959ad0052d76b661--