Course:CPSC312-2021/ProGraph

From UBC Wiki

Authors: Reg McDonald, Kyle Da Silva, Julian Mentasti

What is the problem?

We would like to determine whether Prolog would make a good language for building a domain specific language (DSL). To test this, we are going to create a DSL that enables people to easily create graphs in a declarative manner. As well, our program will provide a series of predicates that can be used to ask questions about the graphs that users make.

What is the something extra?

As an interesting addition, we will add the capability for our program generate a visualization though GraphViz of any graph defined in our DSL.

What did we learn from doing this?

In this project we investigated whether Prolog would be a good language for DSL parsing and graph problems. During the time we spent on our project, we were able to develop our application to support all of the features that we wanted to have.

We felt that Prolog was very good for finding results, or validating inputs. To this end, Prolog was a capable language for parsing DSLs. By only needing to state true facts, the developer only needs to focus on correct inputs, and does not need to spend time programming logic to handle malformed DSL inputs. By structuring our DSL using JSON, the Prolog JSON library made parsing a breeze. One con that we experienced was in building helpful error messages when a DSL was malformed; in this respect, we feel that imperative languages perform better.

For graph problems, Prolog was very good at finding cycles, paths and other properties. However, Prolog's syntax made certain graph problems more difficult to write than they would have been in imperative languages; this was particularly true for predicates that needed to generate results.

We went from finding it challenging to debug prolog but its tracing functionality ended up being quite useful.

Overall, we were happy with Prolog and the results of our project. We would recommend Prolog for parsing DSLs, but recommend using caution when deciding to move forward with using Prolog for graph problems.

Links to code etc

https://github.com/reggiemcdonald/ProGraph