Q1: Is Prolog suitable for web apps?
Prolog is a general programming language and there is nothing in the language that prevents such usage. Prolog as a language shares many good properties (like immutability) with functional languages.
There is a nice writeup Can I replace a LAMP stack with SWI-Prolog?.
Q2: Why isn't html//1 used for generating HTML?
The DCG predicate html//1 was used in the original blog application. There were 3 reasons why it did not work well:
- it is overly verbose for HTML that mainly consists of static parts and couple of placeholders that are filled with data;
- attempt to abstract away template parts into separate modules makes it even more verbose;
- HTML authoring tools do not work with Prolog syntax;
- it cannot be used for rendering other text formats than HTML (although this is less relevant for web apps).
Q3: Why isn't http_handler/3 used for routing?
The http_handler/3 predicate uses static path terms. If you want to extract parts of path, you have to do it manually. Handlers for different HTTP methods require manual checking for the method. In conclusion, you need to implement your own dispatch logic on top of it.
Q4: Why are unicode symbols in source scrambled in HTML output?
You need to add directive
:- encoding(utf8). into your source files that contain unicode strings and atoms. The directive is
Q5: How to export data?
bc_data_comment:bc_export_comments(+Filename). A Markdown
file is exported for every entry with a JSON file describing the entry metadata. Comments are exported into one JSON file.
Q6: Why was direct usage of http_unix_daemon removed?
module is very Unix-specific and refuses to load on Windows. There are some developers on Windows and supporting them required a fragile shim
which did not support most of the options. The solution was to replace it with a more generic code for parsing command-line arguments. The new
code also supports options from the
settings.db file. It is recommended to use a process manager (upstart, systemd, supervisord) for
production on Linux. However, the http_unix_daemon can still be used with a custom main file.