6 ms·
Is someone working on a more modern syntax to Prolog? like how ReasonML is for OCaml but for Prolog
by iddan 5y ago
Is someone working on a more modern syntax to Prolog? like how ReasonML is for OCaml but for Prolog
- xvilka 5y agoReasonML is not a modern syntax for OCaml, it's just JavaScript-like syntax. Nothing modern about it. Notably, latest OCaml versions have more modern syntax - some additional sugar, shorter monadic binding syntaxes, upcoming special syntax for effects, and many other small things that compound in overall better experience.
- agumonkey 5y agoWhat would you wish to see changed ?
- horsh1 5y agoLess repetitions. Instead of roo(X, W) :- zut(X, Z), pum(Z, Y), tos(Y, W) we could write something like roo/2 :- zut . pum . tos
- triska 5y agoYou can do this with definite clause grammars (DCGs), which are available in virtually all Prolog systems: roo --> zut, pum, tos. Note the use of (-->)/2 to define a grammar rule. Use phrase/3 to invoke the DCG. DCGs are currently being drafted for inclusion in the Prolog ISO standard: https://www.complang.tuwien.ac.at/ulrich/iso-prolog/#dcg https://www.complang.tuwien.ac.at/ulrich/iso-prolog/#dcg
- capableweb 5y agoI think you have to specify a bit more what "modern" means in terms of language design. Most languages have a C-like syntax today, which is very old, but I don't think you're thinking about "age" but rather something like features we use in newly created languages? The only reason I could see ReasonML being called "modern" compared to OCaml would be because of the C-like syntax, but that syntax is very old and would be the opposite of "modern" considering age only.
- sidkshatriya 5y agoThe main issue with Prolog is not its syntax. Like scheme/lisp the syntax is dead simple once you get the hang of it. The main issues are: - The language is untyped. In some ways you get more power because it it untyped but then it becomes more difficult to build/understand/maintain/refactor larger programs - Debugging the language is quite difficult. There are some really interesting videos/resources at the "Power of Prolog" [1] that give you tips on how to debug. IIRC many of those tips only apply to "pure" Prolog (a certain class of Prolog programs that don't do things like modify global state etc). Essentially you can keep making your Prolog goals more and more general to home into the bug. But to answer your question, I am not aware of any "ReasonML" equivalent of Prolog. ReasonML just differs on the "surface" level with OCaml. The internal type system, compilation pipeline etc. is all OCaml. ReasonML as a project makes sense for the OCaml ecosystem because OCaml is typed language and has a sophisticated syntax. Prolog's syntax is SUPER simple. So its not really possible to have too much of a different take on syntax when it comes to Prolog. In Prolog essentially we have Head :- Body This could become transformed to: if Body then Head In other words, there is not much room for syntax innovation as there existed in OCaml when ReasonML came out as alternate (surface) syntax. You have other languages like Mercury which try to be a typed version of Prolog. They are significantly different languages in their own right so I wouldn't classify them in the "ReasonML" equivalent category. [1] https://www.metalevel.at/prolog https://www.metalevel.at/prolog by Triska (I highly recommend this resource)
- HelloNurse 5y agoIf Prolog syntax is too basic to be innovated, is there something useful and complex that could be described with new syntax? Examples in other languages include adding classes and objects to Pascal with a handful of keywords or adding lambda functions to C++ and to Java with recycled punctuation.
- dragonwriter 5y ago> If Prolog syntax is too basic to be innovated, is there something useful and complex that could be described with new syntax? You could add a couple of communication primitives and have Erlang. But...it’s been done.
- tannhaeuser 5y agoProlog at the syntactic level is just terms, with the facility to create your own DSLs using custom operators/precedences, or the option to use just functional syntax. Doesn't get any more minimal than that. Minimalist syntax is rather the strong point of Prolog, and also that it's ISO-standardized and you've got a wealth of Prolog systems to to run your code on. Though realistically, the many SWIism that crept into common packages prevent portability across Prolog code bases (excessive use of directives, non-standard core predicates, large base packages and the dreaded package system itself not helping portability, syntax extensions).
- pjmlp 5y agoReasonML is OCaml for JavaScript devs, I never had any issues with the syntax that actually happens to be 20 years younger than C, and about the same age as Java/JavaScript.
- infradig 5y agoYou might look at Picat. It's a Prolog twist I really admire.
- ford_o 5y agoIt has already been done. Look at Curry.