Course:CPSC312-2023/NotesApplication2

From UBC Wiki

What is the problem?

Sometimes writing on paper can be a hassle. We have created a convenient and versatile notes application that allows users to quickly and efficiently jot down their thoughts and/or take detailed class notes – all in the terminal.

Our goal was to determine whether Prolog is suitable for building user focused apps that involve user management, a database, and an API-like structure. More specifically, we were looking to see if we could replicate the features and user experience of popular notes apps (ex. Apple Notes) within the terminal, all while structuring the codebase in a way which separates the code (as it would in large projects) between the client-side, server-side, and database logic. By trying to replicate how real, production level apps are made, we would be able to test if Prolog is suitable for such tasks.

What is the something extra?

Our main key feature is the web app. We have built an entire functioning web app using Prolog an connected it to the backend which uses a SQLite database. On top of this we were able to add:

User management: users can create an account, login, and store all their notes within that account -- using cookies to manage auth on the frontend

Note stats: users can get the word count and most frequently used words in the note

What did we learn from doing this?

We learned that prolog is a very realistic option for creating a functional notes application. Building a notes app with many features, creating a web app, integrating it with an actual database, and replicating the structure of large scale apps was definitely possible and quite intuitive to do in Prolog. However, it was not amazing at any one part which would not make it a top choice for a production level notes app.

We were able to create a web app but using the http libraries for which Prolog has built-in support. This made is relatively easy to run the web server, create the handlers, create the HTML web pages, and handle cookies. This was much easier to do than in Haskell and is proof that Prolog might be a better choice if building a web app is a priority. However, we would not say that Prolog is something that can be used to build production level frontend applications when comparing it to something like React. This is because of the lack of library support which makes it difficult to build more advanced applications (ex. dynamic state management).

On the backend, Prolog was relatively easy to setup and use. The database connection was quite seamless using the prosqlite package. However, due to the lack of type safety it was easier to run into type related bugs that weren't caught by the compiler as they would in Haskell. This made it more challenging to deal with the conversion between the Prolog code and the database objects than it was in Haskell. For this reason, Haskell might be a better option to use on the backend.

Although we were able to complete most of the core features that would be included in a notes app, given some more time, we would definitely want to extend our app (which shouldn't be too difficult due to the organized structure of the code). Some more features we would like to support include password-protected notes, folders, tags for notes, export to PDF/.txt file, and more. Given what we have learned about Prolog, we are confident that these features could all be added to the app.

Overall, we conclude that Prolog definitely could be used to build end-to-end applications (frontend and backend) however, it may not be an ideal choice for doing so. Although it could handle large scale projects like this (i.e. Notes app), on the frontend using something like React would be much more convenient and on the backend using a language with more type safety would be easier to work with based on our findings.

Submission

https://github.com/KavpreetGrewal/prolog-notes-app