From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: On DSLs Date: Tue, 26 Nov 2019 10:51:31 +0100 Message-ID: <877e3narto.fsf_-_@gnu.org> References: <87mudrxvs8.fsf@ambrevar.xyz> <87mudd59ho.fsf@gnu.org> <877e4glyc3.fsf@ambrevar.xyz> <87v9rxx8ri.fsf@gnu.org> <87d0e4oy51.fsf@ambrevar.xyz> <878sop6icq.fsf@gnu.org> <87d0drscng.fsf@gnu.org> <87mucm4iyp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:55063) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZXVP-0007o1-0y for guix-devel@gnu.org; Tue, 26 Nov 2019 04:51:36 -0500 In-Reply-To: (Konrad Hinsen's message of "Mon, 25 Nov 2019 12:06:16 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Konrad Hinsen Cc: guix-devel@gnu.org Hello, Konrad Hinsen skribis: >> What do we disagree on, actually? :-) > > This: > >>> 2. Power users will always write code in powerful languages that exceed >>> what less advanced users can deal with. And since power users are not >>> necessarily benevolent, this creates a trust issue for the less >>> advanced ones. >> >> Good point. I tend to (naively?) view it the other way around: that it >> gives people an incentive to try and write actual code rather than mere >> declarations. > > I'd say we should encourage people to write declarations as much as > possible and resort to executable code only when declarations become > too messy. As a corollary, we should support most configuration-style > use cases with suitable declarative forms, much like these: > >> The goal for Guix was to have the =E2=80=98package=E2=80=99 and =E2=80= =98operating-system=E2=80=99 >> forms, for instance, look exactly like what you=E2=80=99d write in JSON = etc., >> only with a different syntax. I agree. > For better illustration, I'll try to rewrite my own manifests in the > way I'd like to be able to write them. That's probably more useful > than theory (a tough statement to make for a theoretician ;-) Agreed! > The main reason why I want to see more declarative style is: > >>> The problem with powerful formal languages (read: Turing-complete) is >>> not writing, but (1) debugging and (2) reading. >> >> Yes and no. Guile has a debugger, whereas XML/JSON/YAML don=E2=80=99t. = As for >> reading, it=E2=80=99s subjective, but I don=E2=80=99t think a full-blown= language is >> necessarily harder to read. > > It's harder to read because you need to understand the language's > execution model if there is one. YAML etc. don't, there is nothing > but literals. Which is also why they don't need a debugger. That=E2=80=99s not true. In some cases, people write something that=E2=80= =99s actually code (in YAML, in JSON, etc.) and there=E2=80=99s an interpreter running it. There=E2=80=99s usually no tooling coming with that interpreter, in particu= lar no debugger, error reporting may not be optimal either, and the semantics may be ill-defined (I=E2=80=99m getting close to Greenspun=E2=80= =99s tenth rule :-)). It=E2=80=99s just that it=E2=80=99s not presented that way, but= that=E2=80=99s what it is. IOW, I think you can have a declarative _style_ in a full-blown language, like: (define coreutils (package (name "coreutils") ;; =E2=80=A6 )) And you can have =E2=80=9Carbitrary code=E2=80=9D in things that are presen= ted as =E2=80=9Cpure declarations=E2=80=9D or not-a-programming-language. For an example, see =E2=80=98eval-cabal=E2=80=99 in (guix import cabal), which evaluates Cabal = =E2=80=9Cthings=E2=80=9D (code or not?). Or see the =E2=80=98syntax-rules=E2=80=99 =E2=80=9Cdeclara= tions=E2=80=9D. This is just to say that we should not conflate the style and the language. I think what we care about is supporting a declarative style, and making it expressive enough that people don=E2=80=99t feel the need to resort to complicated code. >> (define lst (list 1 2 3)) >> >> lst =3D [1, 2, 3] > > Fine. But then a power user comes along and writes > > (define lst (cons* 1 2 '(3))) > > That may be bad style, but as a reader I have to be able to deal with it > nevertheless. And bad style may in fact serve to obfuscate evil > intentions. I agree, but I think that this is hardly avoidable. Sure, a pet DSL will initially have nothing but =E2=80=98list=E2=80=99 so the problem won= =E2=80=99t exist. But sooner or later, it=E2=80=99ll get =E2=80=98cons*=E2=80=99 as well. Thanks, Ludo=E2=80=99.