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 8355A7FA5E for ; Fri, 21 Apr 2017 18:05:00 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=yotambarnoy@gmail.com; spf=Pass smtp.mailfrom=yotambarnoy@gmail.com; spf=None smtp.helo=postmaster@mail-qk0-f176.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yotambarnoy@gmail.com) identity=pra; client-ip=209.85.220.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of yotambarnoy@gmail.com designates 209.85.220.176 as permitted sender) identity=mailfrom; client-ip=209.85.220.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; 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-qk0-f176.google.com) identity=helo; client-ip=209.85.220.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="postmaster@mail-qk0-f176.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3ApdnbLRxZ+zob2GPXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?1OwQIJqq85mqBkHD//Il1AaPBtSHraocw8Pt8InYEVQa5piAtH1QOLdtbDQizf?= =?us-ascii?q?ssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1?= =?us-ascii?q?JuPoEYLOksi7ze6/9pncb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-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CNAAAWLfpYhrDcVdFcHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBgn6CGAeDYIoVkWiJDoxWgg+GJAKEBAc/GAEBAQEBAQEBAQEBEgE?= =?us-ascii?q?BAQgLCwgoL4IzIgGCQAECAyMEGQEbEQwBAwwGBQsDCgICJgICIgERAQUBHAYTF?= =?us-ascii?q?IlvAQMVnQ4/jAWBbBgFARyDCQWDVgoZJw1WgxABAQEBAQUBAQEBARsCBhJ5hUi?= =?us-ascii?q?Edoddgl8FiTOIKotkjXKFFIIZjz6SURQfgRUfgT4mHSBZGIRCDxAMgX8kNYk2A?= =?us-ascii?q?QEB?= X-IPAS-Result: =?us-ascii?q?A0CNAAAWLfpYhrDcVdFcHAEBBAEBCgEBFwEBBAEBCgEBgn6?= =?us-ascii?q?CGAeDYIoVkWiJDoxWgg+GJAKEBAc/GAEBAQEBAQEBAQEBEgEBAQgLCwgoL4IzI?= =?us-ascii?q?gGCQAECAyMEGQEbEQwBAwwGBQsDCgICJgICIgERAQUBHAYTFIlvAQMVnQ4/jAW?= =?us-ascii?q?BbBgFARyDCQWDVgoZJw1WgxABAQEBAQUBAQEBARsCBhJ5hUiEdoddgl8FiTOIK?= =?us-ascii?q?otkjXKFFIIZjz6SURQfgRUfgT4mHSBZGIRCDxAMgX8kNYk2AQEB?= X-IronPort-AV: E=Sophos;i="5.37,230,1488841200"; d="scan'208";a="221116463" Received: from mail-qk0-f176.google.com ([209.85.220.176]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 21 Apr 2017 18:04:59 +0200 Received: by mail-qk0-f176.google.com with SMTP id d80so10658882qke.3 for ; Fri, 21 Apr 2017 09:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=T8z5WNrYKXdjq/0TC3ZpgmyrQG0itSmBfO3pB77njM0=; b=Sw8EhKG8T3TUcNzRkhsrDhAqsa3IehmX8uDGX2yyjs530dIuS2gyRBVEwhy4XyFYVr rg9zNdxEEcylJlrr/5PWcYrb5ZAWkVozzA+iikVaMzZUyeMKxz4DK5t3c+71G2BAS64W GR71L2dnzWys1RDF811G0s5eP1suLSIbJLP0Ww2VVTmMjJLK0bftPpws1wqMc5Tq+/mh EJ2cAEu8WEH5aH2RJnHu5STbuDHQukNevkEdMGv9rA0s5Gev3xGpfe8ef1pEvmliMwB5 wvZylS3eqooXZR3Kn/rv3fi4c+6rlWTFZtAYwEoSS+UaAtaTBvQP30+6/Z7+a5PzrDvH Ep4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=T8z5WNrYKXdjq/0TC3ZpgmyrQG0itSmBfO3pB77njM0=; b=r70p51YiqvhRaqadkYgJGoIgmXWJpWmzhoUJdfVstfKKqNI9QUvteyzcBWcVk3n20y t3TaeJObVC7bLUR/lT1AhWQj7ZsLSXe0kIBeFw0cwBY2Ht2P3TvFH0jBwCFe8Bhe0iZ8 1QLC5/F93ceXEc0qXD1UH0xseBzQAyrbzMRDNwm+rzx1z15HbOpQMYv9eLigSdtcTBK9 zI4+eDdhuLdDAWhWxEmhOFjU/IvV3Gh3LK1vcyi7qNGQoRQmXuj8D/sOigYJ9PuyjiwT xwny5l/GPVs/TlvipoOgtQjxeWaOklBS9G4NOakgHBwB12fgFFhbrPrpo9HVWwOp80PZ YOlQ== X-Gm-Message-State: AN3rC/69xRbk5pQxLxQA28a/yb7TazNeZah2XVkc/o7wWg8YSROQXoH7 0I6pvYxb78zY3BN3PNxjoAhFdMZntw== X-Received: by 10.55.217.71 with SMTP id u68mr12919099qki.272.1492790697873; Fri, 21 Apr 2017 09:04:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.181.74 with HTTP; Fri, 21 Apr 2017 09:04:37 -0700 (PDT) In-Reply-To: <58FA282A021A076200390603_0_57023@msllnjpmsgsv06> References: <58FA282A021A076200390603_0_57023@msllnjpmsgsv06> From: Yotam Barnoy Date: Fri, 21 Apr 2017 12:04:37 -0400 Message-ID: To: Hongbo Zhang Cc: Ocaml Mailing List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] PPX is harmful to our community in the long term My 2 cents: I personally think we did PPX wrong. PPX should have used the syntax as its starting point for full backwards compatibility. Currently, the PPX cycle is OCaml: { syntax -> AST -> serialized AST } -> PPX: {serialized AST -> AST -> PPX modification -> serialized AST} -> OCaml: {serialized AST -> AST -> ... } Exposing the AST is the cause of the problem you mention. If instead, every PPX extension had a particular OCaml compiler's syntax parser and syntax printer integrated into it, and the PPX cycle was: PPX: { syntax -> AST -> PPX modification -> syntax } -> compiler: { syntax -> AST -> ...} We would have far fewer issues with PPX plugins, since they would be as backwards-compatible as the syntax. I think this mistake happened because everyone was trying to move away from camlp4's complexity, and we didn't notice that the problem with camlp4 wasn't the approach, but rather the fact that it wasn't making use of the same code as the compiler and therefore required its own heavy learning-curve and parallel maintenance to keep up with the compiler. To be fair though, camlp4 came before the age of OCaml on github, opam, and the associated easy code/library sharing. The only issue I can see with this idea of improving PPX is that the PPX-generated syntax wouldn't have the original source locations. We'd need an annotation that indicated the original source locations (perhaps row and column offsets) when a PPX translated to modified syntax and printed it out, so that the compiler's errors would have proper locations relative to the original source. -Yotam On Fri, Apr 21, 2017 at 11:41 AM, Hongbo Zhang (BLOOMBERG/ 731 LEX) wrote: > Dear OCaml developers: > Given that bitten by PPX from time to time, finally, I think it is a time to > spend two hours sharing my experience with PPX and why you(the OCaml library > developer) should avoid PPX as much as you can. > > Here is a story I just experienced this morning, I tried to install a > package from opam, and it complained my compiler is too old - 4.02.3, to be > honest, 4.02.3 is still a pretty modern OCaml compiler, even debian stable > still stays on 4.01. Anyway, I switched to 4.04.1, after half an hour, it > failed to compile again, complaning about some ppx error message. This is > not my first time experience, and finally it made me to write an essay about > why PPX is harmful. > PPX is a compiler plugin, it imposes a very large compiler surface API to > your library, and we don't have any backward compatibility guarantee from > the compiler, which means your library will only work against a specific > compiler. Even worse, OCaml is an elegant but small community, we don't have > too many maintainers for a library, if you have a library which relies on > PPX (the dependency chain could be really really huge, for example, > ppx_metaquot depends on typing environment, you can find lots of stories > about node_modules in Node community), it will probably not work against > next version of OCaml compiler, and it will be a huge maintenance overhead > for other people to pick it up. > > OCaml is already a very expressive language, probably more expressive than > any other mainstream language, (Go, Java, C/C++, etc), it is fine to write > some boilerplate code, or we can cut PPX as a dev dependency, after your > PPXed your code, check in the generated source code(via -dsource), so it > will not bring dependency to end users. > There are some valid use cases of PPX, for example, in BuckleScript or > JS_of_OCaml, we want to customize OCaml language a bit for external FFI, or > if you have a very large team, and committed effort to maintain your PPX. > Happy hacking in OCaml without PPX, Thanks -- Hongbo > >