A page for beginners to add to SWI-Prolog internet site

What do you think about it ??? … and a question to Jan …

To help new users, i would find useful to add a dedicated page to the SWI prolog website with examples that could fit adding a menu Tutorials/Beginners/Examples

Different interesting ressources:

… and there are for sure many other good links at disposal. Ideally it would be better to have a list of the different examples titles with direct links to their pages.

I am sure that many of us have plenty of interesting pages to share and to my point of view the best way to learn is on a “try and retry” approach understanding concrete examples. Making things simple make people enjoy it and want to learn more. An old principle says that if an 8 y/o child can’t understand what you say then you didn’t explain it correctly :slight_smile:

PS: The good approach for an example is that it must fit a web page otherwise beginners feel it to be too long (on that Github is not for beginners …). It is the same as a principle which says that videos on a topic to explain must be 1 to 2 minutes max to be seen entirely by a maximum of people otherwise you lose readers.

This already exists, in a fashion. Have you seen the code examples under some of the predicates, like length/2, csv_read_file/3, append/3?

Those live in their own repo. The readme there explains how it works and why it exists.

I did contribute some examples, but I have been slacking since (even though I have more good ideas) :frowning:

My approach is to make small self-contained examples based on use-cases that I have encountered.

The biggest hurdle (after laziness) is to find the balance: how generic/specific? does it enlighten? is it too big/small? how much to explain? and so on.

Is your idea something along the same lines? I wouldn’t mind trying to make good examples based on requests here on the list, I struggle knowing what needs explaining and how useful an example is to anyone who has not encountered my very specific use case.

Examples at the bottom or predicates pages are “2 lines” style = a great way to illustrate a predicate BUT not what i name examples to learn playing with, meaning an applied real use (i-e your "). Moreover as i mentionned GitHub is not either done for beginners.

= both ways are needed

Think about students discovering Prolog the same way students in the 80s learnt BASIC on a TRS-80 though some others were still using one line or page editors on terminals … or the way people now work with web sites leaving a page if they don’t get it within one second and mainly just look at the front page of each site vs direct access picking the other ones as they navigate according to their interests or social life.

The main problem of skilled users and especially Prolog programmers due to their academic background, is that they consider beginners like already half skilled users . If you want an example just look at the comment on this page about the parenthesis lacking.

Anne Ogborn made a cool cartoon (of which i don’t remember the link) but the thing to understand is that the way students learn programming now has nothing to do with the traditionnal way … the same way my daughter was always telling her 3 years older brother that he was “has-been” being on Facebook though now adolescents use Instagram … If they don’t feel attracted they go elsewhere and there are many sociology studies about generations behavior huge changes and their impact on personal as well as professional choices etc.

The thing to keep in mind is that if you lose young generations then you make products die … and young people mrore than ever want to have fun and internet made people want things to be “instant”.

And i totally agree on your “examples based on use-cases that I have encountered”.

I think to make Prolog mainstream its important to show examples of real-world development problems that are solved wtih Prolog.

The origin of Prolog in academia hinders in this sense adoption since examples are mostly puzzles and toy problems – they don’t deal with real world issues such as persistence, concurrency, scalability and the like.

SWI-Prolog has wonderful facilities for real world problem solving and these should be high-lighted and systematically explained for beginners who seek to become professional programmers.

Where should Prolog be positioned to provide its most value?

Dan

1 Like

I think that it is important to make the difference in between beginners / intermediate / skilled / experts and for now the Prolog documentation in general is (to my point of view) lacking a beginners vision though it is what makes future intermediate and higher level users.

As i mentionned, beginners (i mean real beginers) need 2 things apart from installing Prolog :

  • concrete examples on predicates use as they no more want to lose time understand theory
  • small programs to look at to understand how it works on a try / retry approach.

Depending on the length of examples Boris “real life examples” fit into one of those 2 categories, but also in higher level use cases. Maybe examples also need to be ranked in between beginner / intermediate / skilled / expert ? (In a previous life i designed a system whose content was dynamically generated depending on keys.)

It’s also why i pointed out in other discourse subjects questions at an intermediate level like :

  • DDE is no more a way to request Excel data, then what can i do ?
  • grabbing data with Xpath is no more efficient due to Ajax, how do i pick-up a file from a web page ?
  • if i get a CSV with colums that i don’t need how do i 1/ find my columns 2/ integrate them etc. ?
    etc.
  • how can i create some kind of database the Prolog way
    etc.

To my point of view teaching Prolog is also lacking 2 points in terms of structuring a dev environement:

  • how do i structure my local folders (including how do i make a dev / integration / production)
  • how do i integrate Prolog simply with GitHub.

Those are just questions, but at the end it leads to how can the community grow embracing beginners and students to make it look fun (as skilled users feel it) and not as a ghetto or an old 80’s story as most students think compared to Javascript, Python etc.

To my point of view Prolog could be a real mainstream language which means not considering it with preconcieved ideas, as a smart glue or a system focused on some specific use.

What makes adoption is the fact that people practice, get at ease and feel efficient. To give you another anecdote from real life, years ago i needed a quick integration of a database that was announced as taking 1 week to be developped … as i knew the logic of what needed to be done and I was quite skilled under Excel … i did the same in less than 2 hours … and i’m sure that many of you have tons of similar experiences using Prolog …

The nice thing with Prolog is that it valorizes rules which means knowledge and its modelization …

I think the key question is what is the underlying motivation for a beginner to get into Prolog.

If it is writing glue code probably Python is a better choice (time investment, given its popularity).

If it is to become a professional developer, then any of the imperative languages of the day are a better time investment.

In my case it was productivity and declarative exploration of a significant problem – and the possibility to potentially turn my explorations into production code given facilities such as unit testing, concurrency, FFI, web server readiness (websockets, REST API), and others.

To be frank with you and think the way my children do, i don’t care about what is the motivation … what matters is that the first try be the one that catches attention and make the beginner want to know more … as they are used to say things must be cool.

Said differently as far as curiosity can be turned into a a beginner having fun using it leading to ways for its own use then you have won.

Each case is different what matters is that people at the end feel that it fits to their needs. Also why i talk about a “mainstream” and not “focused” preconceived stuff.

When i was a young child i created a computing club with more than 100 members. Our oldest member was over 90 y/o and was going to lessons i was doing about BASIC because he wanted to learn English …

1 Like

Absolutely …

Being curious about Prolog can be very fulfilling indeed and for all ages – perhaps even for the younger given the minimal syntax and the declarative nature of the program …

Dan

This is a good starting point for an example. If I knew what is your desired data structure at the end, I can try to make a self-contained example out of it. The other missing piece is the content of the CSV; is weather.csv in the example here: csv_read_file/3 good enough for that purpose?

To complement: being cool means having funny easy to understand examples that make you feel at ease and say of course, that’s obvious … and that is all the nice thing with Prolog which is a language based on rules …

Some examples from A feature upgrade that would be useful for csv_read_file/3 - Request For Comments - SWI-Prolog

In what i name “2 lines demo” = get the list of the CSV colums names.

In a more complete example : give the columns names (or column numbers) you want to extract and get a table only with those columns.

I think the best way forward is to use explore the use of swish …

https://swish.swi-prolog.org/

Its all web based, no install, and examples can be encoded and annotated.

What if we as a community contribute small examples into a shared swish notebook

Dan

Yup … i was thinking about adding a comment to the page SWI Prolog Getting Started saying that another way to start is to directly use SWISH even before installing SWI Prolog :slight_smile:

The thing i like in Simply Logical is the SWISH integration that makes example be directly usable … same as Microsoft C# lessons = you read, you try it online or copy it to your own installation, and you immediately see it running … no theory … direct practice.

Sure but what is the “table” that you want? A list of row(...)?

This is basically the difficulty of examples, everyone agrees it is nice to have them, but it is not at all easy to make good examples.

To my point of view for beginners it is basical of basical so yes …

For a “2 lines” example = get the colums names with a result in the style headers(‘col name 1’, ‘cole name 2’, "cole name’)

For a more oomplete example with an extracted table = should be close to doing csv_read_file but delivering the rows that you decided to filter
it can even be used the same way as a row example doing the same but just on the current row

As far as i understood, the idea at the end of the intiial post with Jan as well as yourself was that things need to be simple and easy to understand rather than complexifying the existing predicates.

I think it makes sense to have that page starting with a couple of pointers to alternative starting points. I doubt there is one such point. It all depends on your background and aim. Some people want to learn the language. Others may want to know how the system can help them solve their problem. Everyone needs some basics on the syntax and program structure. Afterwards things may get very different depending on your goals. SWISH is great for learning the language, but rather useless for most tasks that require interacting with the environment.

1 Like

Hello Jan, As the internal text is yours, maybe you could add a 3rd way (apart from Linux and Windows) in the getting started linking to SWISH so that it be better valorized ? have SWI Prolog logo on the top left and SWISH logo on the top right so that i be more natural to click on ?

1 Like

All text is on GitHub. The manual comes from GitHub - SWI-Prolog/swipl-devel: SWI-Prolog Main development repository (the main repo), where static text lives in the man directory and the rest is generated from the PlDoc comments in Prolog source files. The static web pages except for the manual come from GitHub - SWI-Prolog/plweb-www: Submodule of plweb.git that contains the (wiki) web-pages

Pull requests are welcome. Before submitting large pull request, try something small. Small requests are quickly created by you and reviewed by me. Big changes that change the style too much and/or contain too many “not really correct” statements are typically rejected.

That said, the manual is not the place to start for beginners. It is not a tutorial and as far as I’m concerned it should not become one. It can point at tutorial material. Possibly the “Get Started” landing page should be a page on the static website that points at SWISH, LPN, Simply Logical, the current page, etc.?

1 Like

Thx i didn’t know the text of the manual itself could be updated from GitHub. I’ll have a look at it.

Also the examples that are currently in the manual. I pasted the link higher in the thread.

1 Like

It is not immediately. The PR needs to be approved and the actual website update happens with the next development release. Typically every 2 weeks. Can be earlier on serious issues or later due to lack urgency and new features.