Discourse

The design of Discourse, as I mentioned previously, shows that a great deal of attention was spent on small things. When I added a footer to the pages of my copy of Discourse, the in-browser HTML editor automatically added an ending </a> tag following the <a> tag that I had entered. If I want to update just a single field, rather than the entire set of fields on the update-configuration page, I can do that by clicking on a check box.

It's great to see a Web application that isn't only nice for users, but also nice for administrators. By clicking on a check box, you can back up your database automatically on a regular basis. If you want, you also can enter an Amazon S3 bucket name to which your backup will be delivered. The list of thoughtful features, such as these, goes on and on.

And then, of course, you start to use Discourse for discussions and discover all the little things that they added in order to improve the user experience. For example, you cannot enter titles or postings that are too short, and Discourse automatically fixes topic titles that are in all caps. If you reference someone with the @username syntax, his or her personal interactions menu will glow, indicating that there is something to which he or she should respond. And if the user isn't logged in, or doesn't come to the site within a specified time, he or she will receive e-mail, indicating the reference. This provides a great balance between keeping things on the Web and keeping people involved by e-mailing them and inviting them back.

There are lots of other things, some big and some little, which add to the user experience. One of my favorites, as someone who opens many tabs and sometimes forgets what is in each one, is that Discourse keeps track of my writing even if I use multiple tabs. I don't have to worry that opening the same page in one tab will somehow stomp on the posting I already started in another one. That sort of attention to detail, and an understanding of how people actually use the Web with modern browsers, is quite impressive.

Technical Underpinnings

From a user's perspective, Discourse is piece of software. It is easy for regular users, forum owners and moderators alike to configure and use it. But Discourse also is a well-written piece of software, designed for maintainability and long-term growth. Looking at the way it was built can help inform your own work, as you try to create increasingly interesting Web applications. That's because Discourse seems to have been built using most of the latest ideas in the Web application world.

For example, although Web applications traditionally did most things on the server, sending complete HTML pages to the user's browser, that is no longer the case. JavaScript is playing an increasingly vital and dominant role in modern Web applications, and Discourse goes all out on this front, using the open-source framework Ember.js, which aims to make it easy to write sophisticated applications in the browser.

Thus, in nearly every case in Discourse, requesting a URL doesn't result in a complete page of HTML being sent to your browser. Rather, you'll often get a page of HTML without any content. A second, separate request, initiated by Ember, then will request the data that should fill in that page. So, a page refresh often will result in an HTML request followed by a JSON request. If you click on a button or link, however, you're likely not to cause a full page refresh, but rather an Ember action, which will result in an Ajax call to the server, followed by JavaScript-driven changes to the DOM. But as far as the browser is concerned, you have remained on the same page the whole time.

Interviews with Atwood indicate how much he cares about performance, and that is pervasive throughout the site. Although Ruby on Rails has long allowed you to turn an object into JSON with a simple "render json" call, it turns out (and is documented in the Discourse source code) that this is 20% slower than invoking the JSON conversion method on your own. Most applications likely never have noticed this problem, but Discourse, in trying to be speedy, has identified, benchmarked, improved and then documented such issues. In addition, administrators of a Discourse forum automatically have it run with rack-mini-profiler, a Ruby-compatible version of a famous JavaScript plugin that measures the loading speed of the page and of the various Ajax calls executed from within it.

Conclusion

If you need a Web-based forum or are thinking of starting an on-line community, I would argue that you should use Discourse. Despite the early version number, it is stable and useful, and it automatically alerts you when there is a new version to retrieve.

Perhaps the most striking part of Discourse is its attention to details regarding user design. In the open-source world, we're used to thinking in so-called practical terms, often saying that aesthetics aren't necessary, or at least that they can come after correct technical solutions. Discourse is, in many ways, proving the opposite—that you can start off with a relatively limited feature set, but so long as you consider what users want, not what technical functionality you want, your product will succeed.

Indeed, if there is an important lesson I have learned through the years, it's that people aren't interested in functionality, but rather in what they need to make their business, school or home more productive. Features are only important so far as they fix a pressing need.

Bottom line, I encourage you to run, not walk, and try Discourse. Whether you use it on a site, or just read the code to learn how Ruby and Ember can work together, I expect you will get a lot out of it.

Resources

The Discourse home page is http://discourse.org. Aside from some documentation and background, the site offers a live Discourse site, so you can see it, play with it and understand what is involved. If you want to download the code, however, you will need to clone from https://github.com/discourse/discourse.

Discourse is written in a combination of Ruby on Rails, Ember.js, PostgreSQL and Sidekiq, which relies on Redis.

Jeff Atwood's blog is at http://codinghorror.com. Two good interviews with him about Discourse are from the Ruby Rogues and the Thoughtbot podcast.

______________________

Reuven M. Lerner, Linux Journal Senior Columnist, a longtime Web developer, consultant and trainer, is completing his PhD in learning sciences at Northwestern University.