caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] PPX is harmful to our community in the long term
Date: Fri, 21 Apr 2017 18:43:55 +0200	[thread overview]
Message-ID: <a55f2860-73f7-c091-a27d-784f37b5ca58@gerd-stolpmann.de> (raw)
In-Reply-To: <CAN6ygOn_UTcrwjXpZKSLOq6sHRupWZAT47=SEijL6z2BzuWg6g@mail.gmail.com>

So far I understand, with "syntax" you really mean syntax-as-string.

I think most often the AST changes by adding more fields or more AST 
nodes. Wouldn't the situation already improve a lot if we switched to 
record variants for the AST types? (Besides that the compiler would get 
way more readable.) New fields wouldn't be a big problem anymore because 
they are looked up by name and not by position.

Gerd


On 21.04.17 18:04, Yotam Barnoy wrote:
> 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)
> <hzhang295@bloomberg.net> 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
>>
>>


  reply	other threads:[~2017-04-21 16:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-21 15:41 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2017-04-21 16:04 ` Yotam Barnoy
2017-04-21 16:43   ` Gerd Stolpmann [this message]
2017-04-21 17:11   ` Alain Frisch
2017-04-21 18:28     ` Jeremie Dimino
2017-04-21 16:55 ` Francois BERENGER
2017-04-21 19:11 ` Yaron Minsky
2017-04-21 19:22 ` Emilio Jesús Gallego Arias
2017-04-21 19:23 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2017-04-21 21:17 ` Fabrice Le Fessant
2017-04-28 11:07   ` Olaf Hering
2017-04-28 13:04     ` Anil Madhavapeddy
2017-04-28 14:50       ` Yaron Minsky
2017-04-28 14:55         ` Jacques Carette
2017-05-11  9:37           ` Jeremie Dimino
2017-04-21 21:48 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2017-04-21 23:10 ` Emilio Jesús Gallego Arias
2017-04-22 12:49   ` Serge Sivkov
2017-04-22 14:47 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2017-04-22 19:47 ` Robert Muller
2017-04-23  1:30   ` Yaron Minsky
2017-04-23  0:06 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2017-04-23  1:25 ` Yaron Minsky

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=a55f2860-73f7-c091-a27d-784f37b5ca58@gerd-stolpmann.de \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    /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).