So, now we're doing it old school as I set off into chapter 1 of Prolog properly. It is sparking a few memories of the old computer science degree, but only vaguely, so it still feels pretty new to me.
Whilst I enjoyed a bunch of the fun examples in previous chapters, here I felt that I had to change some americanisms, velveeta, jolt, soda, twinkie & desert became cheddar, coke, drink, cake & pudding. Plus, flavour and colouring have a 'u' in them. I can't help it, I'm a bit of a grammar and spelling nazi sometimes :)
Anyways, on to the tech stuff, it has some impressiveness, but so far seems less like a programming language and more like a logic calculator as you have to use it within the boundaries of it's runtime interface. I dunno if we'll find out ways to do other work around crafting a UI, or to harness it as a logic engine within a different language for some polygottism, but I currently can't see how I could fit it into anything that I do.
One of the samples was to write a map colouring tool that could give combinations of colours to use so that adjacent states were different colours. The code had rules different(Mississippi, Alabama) and different(Alabama, Mississippi) but all other pairing are only listed once. The rule different was declared in both directions, so I think that this was a bit of a typo, although not really a bug as it is just duplicating a rule. I also found that the definition of the colouring method was overly verbose with the definition having the full state names and the calling code having the exact same. The rest of the rules about what has to be different were tied intimately to the given selection of states though, so a more generic method wouldn't really be right, it just felt like it wasn't really very DRY.
As usual, the chapter finished with a bit of homework, a few quick googling tasks so that we could get a few resources, and a couple of simple apps to write. (Is apps the right word for Prolog code? I'm not sure, knowledge systems maybe...) These were nice and simple to churn out without needing to resort to leaning on any of the resources that we needed to google for. First up was a list of books and their authors with a query to find all books by a single author. Following that was a list of musicians, their instruments, and the genres that they play. We were asked to write a query so we could find all guitarists, and that was it. The genre part was ignored completely, so I made my query a little more complicated so that I could find all musos based on their instrument, or all people playing a certain genre, or a combination thereof. And due to the way that Prolog works you could also find all instruments and genres that a musician plays. As we all know, Mr Eddie Van Halen is both the world's greatest guitarist and a fine keyboard player too ;)
As mentioned, from what I've seen so far, I can't imagine how Prolog can be used anywhere other than in Prolog, which feels limiting. But the code came nice and easy without all the road blocks that Io put in my way, so I'm quite enjoying it so far and looking forward to seeing if it will be more useful than I can currently grok. I found the writing of this chapter less inspiring than others though. Bruce Tate's writing kept me interested through the dark days of Io, but the language is holding together the Prolog for me. Hopefully that is just me being racist to a chapter that has more Americanised examples than the earlier ones, and not a sign that a little way into the book he started to get bored or complacent and let the quality drop. Lets see what awaits in day 2...