I wrote this article for the RiveScript Community Wiki, but am reposting it here for visibility.
I've been noticing more and more lately that people are using RiveScript to power Facebook Messenger chatbots, which adds a whole lot of complexity that RiveScript wasn't ready for. This article explains why RiveScript was designed the way that it is, what it's doing to support modern chatbots, and recommendations for how to design a modern chatbot.
This is something I wanted to rant about for a while: event loops in programming.
This post is specifically talking about programming languages that don't have their own built-in async model, and instead left it up to the community to create their own event loop modules instead. And how most of those modules don't get along well with the others.
Over the last couple months I've been slowly working on rewriting RiveScript in yet another programming language: Google's Go language! It's also my first project in Go, which is what tends to be the case (rewriting RiveScript in Java and Python were my first projects in those languages, too).
But this is the last time I'm going to be rewriting RiveScript from scratch.
For some historical background, the first RiveScript implementation was written in Perl, and I designed it to be one big monolithic file (
RiveScript.pm), because then I could tell noobs that they can update to a new version of RiveScript in their bots by just dropping in a new file to replace the old one, and avoid overwhelming them with the complexity of doing a CPAN installation (especially if they're generally new to Perl as well, and all they really wanna do is just run a chatbot.)
I've just spent pretty much the whole day redoing the website for RiveScript.com, and I think it looks pretty nice.
RiveScript.com was the final website on my server that was still running on my legacy PerlSiikir CMS, and it's been on my to-do list for a while to get it migrated over to my new Python CMS, Rophako like what Kirsle.net is currently running on. The old Perl code was clunky and ugly and memory-leaky, and now I'll be at ease if I ever need to migrate to a new web server, as my Python web apps are extremely quick to get up-and-running, whereas it was an hours-long ordeal to get PerlSiikir to run.
So, the bulk of the work actually needed for RiveScript.com was purely front-end. I revamped the whole web design to use Twitter Bootstrap and make it look all hip and edgy like how all the other small software project websites are these days.
Besides the programming language on the back-end, I had other reasons for why I wanted to simplify RiveScript.com: I don't have the motivation or energy to do as much with that site as I did previously.
I used to run a YaBB Forum on RiveScript.com, but it wasn't extremely active and it was getting hit by too many spam bots, so several months ago I shut that down and linked to the RiveScript forum at Chatbots.org.
More recently I had programmed a chatbot hosting service that was on RiveScript.com, but that wasn't very popular either. I know nobody was using it because it had been broken for months and I hadn't heard any complaints. ;) A couple months ago I sunsetted that feature by turning off new site registrations and removing some references to the feature. And now that's officially gone! If you actually had a bot hosted there, contact me and I can get you your bot's reply files back.
So, the new site is simple and minimalistic and is just about the RiveScript language itself. It was an ordeal rewriting all of the pages from scratch (well, most of them) but now that it's done, the site should be very low-maintenance for me.
And, the front-end pages for the new site are also open source, FWIW.
In an older blog post I mentioned getting Alicebot Program V, a Perl implementation of an Alice AIML bot, up and running on a modern version of Perl, but I didn't go into any details on what I actually did to get this to work (which wasn't very nice of me ;) ).
Unfortunately for me I also didn't even write down any notes for myself, so I had to figure it out again, myself, from scratch. Which I decided to do, only this time I wrote down some notes, and published a new, updated version of Program V which you can check out on GitHub -- or for the lazy, get a zipped release of Program V 0.09.
This blog post is about what I needed to do to get Program V up and running, some of which is also outlined in
UpdateNotes.md on the GitHub repo.
Front (click for bigger picture)
Back (click for bigger picture)
Zoom-in on back.
If you want one it's $20 at cafepress.com/rivescript.
With this I eventually plan on creating some RiveScript-enhanced Android apps, like a "personal assistant" chatbot that can talk out loud and listen to you using Android's text/speech converter libraries.
On my many attempts to learn C++ I never actually made anything useful that wasn't a tutorial-like program (with the exception being a single-threaded CyanChat library I was working on but never completed). So this time I decided to just skip the tutorial b/s and dive right in to making a RiveScript C++ library, and Google things as I run into them.
I knew about C++ strings (who doesn't?) which are a big improvement over what C has, but I newly discovered vectors (dynamic resizable arrays) and maps (associative arrays) and among these three, it covers all the basic data types I'm used to in Perl.
I hit a roadblock though when it came to constructing the large data structure that the Perl RiveScript module makes and which I'm familiar with, but looking into C++'s
struct solved that pretty quickly.
All this attention to RiveScript lately, though, made me remember the point about how the Perl RiveScript module (the only feature-complete implementation of RiveScript to date) is released under the GNU General Public License, which would demand that any application that uses it also be released under open source.
I was thinking of re-licensing RiveScript under a more open license to see if it could drive up usage of it for non-GPL projects. I was considering something like the LGPL, Apache or BSD license. But, I think I have a better idea!
At work I was using ExtJS for a while and I saw how their licensing scheme works: they dual-license their code; the GPL licensed version is free to use, but being GPL code it demands that your entire application be made open source. They then have a commercial license that allows you to use their library in a non-open application, for a fee.
I think this may be the better way to go. For the open source folks who use RiveScript today nothing changes, but if somebody wants to create a commercial application with RiveScript they wouldn't be able to use the GPL-licensed version. After watching all the news about SmarterChild and its parent company (Colloquis, now owned by Microsoft) over the past decade, with their chatterbot patent and their commercial SDK, giving out free code that can be used in a commercial closed-source product doesn't seem like a very smart move. ;)
The chatterbot patent now owned by Microsoft is groundless anyway, because the Net::AIM module on CPAN released in 1999 ships with an example script for an AIM chatterbot which pre-dates ActiveBuddy's inception in 2000. ActiveBuddy's claim that they invented the AIM chatterbot falls in the face of prior art.
The Android OS project, for example, opted to release the core Android components under the Apache license, rather than the GNU General Public License (GPL) which is usually popular with open source GNU/Linux software.
Using the Apache license was a strategic move for Google, because the Apache license is less restrictive than the GPL; with the GPL, any software you write that incorporates GPL code must also be released, in its entirety, under the GPL license. Just by using GPL code in your application, your whole application must be made open source under the same terms as the GPL'd code you borrowed for it.
To put this in perspective, let's imaging a hypothetical story in which Adobe decides to add a new image format into Photoshop, and they use some code for this image format which is released under the GPL license. Because Photoshop is using GPL'd code--even though they're using only a tiny bit in comparison to the rest of Photoshop's code--Adobe would be forced to release Photoshop in its entirety under the GPL license; they would have to provide all of its source code to its users, and you could therefore just download it and compile your own Photoshop from source code.
Proprietary software companies like Adobe of course wouldn't like this, so they don't generally like to use GPL-licensed code in their products; the GPL is considered viral because it "infects" the entire application and forces it all to become open source just because it is. The GPL is a "copyleft" license.
Android's code is released under the Apache license instead because, that way, individual vendors can make their own modifications and additions to the base Android code, and add proprietary features to keep an edge over their competition. If their contributions to the Android core was forced to be made open source, as the GPL would require, they would be less inclined to spend time and money developing their new features in the first place, because their competitors could easily just take their code for themselves in their own Android devices.
So what does this all mean for RiveScript?
RiveScript has always been released under the GNU General Public License, which would be great if RiveScript was, itself, a complete software application. It isn't. RiveScript is just a library, a Perl module, and it doesn't do anything until you write an actual Perl application that loads the module.
So if somebody wanted to create and sell a closed source "desktop assistant" type application, with a pretty GUI and an animated face and it could speak to you out loud and understand you when you speak to it out loud, and it simply wanted to use my RiveScript module for the artificial intelligence part... they wouldn't be able to release it as a closed source product. The GPL license governing the RiveScript library would force their entire application to be made open source.
This obviously isn't ideal; and so, usually, libraries are released under the GNU Lesser General Public License, which is an ideal license to be used for software libraries.
Under the LGPL, an application would be allowed to use my RiveScript library and still be, overall, a closed source application. The only restriction would be if they wanted to modify RiveScript itself, to add new features to it or extend its functionality in any way; if they touch my RiveScript module itself, their changes would have to be released to the public as open source. But, it wouldn't touch the rest of their product at all; they could still keep their overall product closed source and sell it if they wanted to.
So, I'm thinking I should relicense RiveScript and maybe see if that will help drive more developers to use it in their projects. The LGPL though isn't particularly ideal for a Perl module though since the license deals a lot with terminology like "linking" which only applies to C/C++ code. But maybe the old tried-and-true Artistic License that Perl itself is released under would do just as well.
I'll work out the details later but expect RiveScript 1.22 to be licensed more openly; or, at the very least, dual-licensed to be used in both open and closed source projects.