David Turnbull is the author of the Meteor Tips blog, a regular source of tips, tricks, and tutorials for the Meteor JavaScript framework. He's currently hard at work on a screencast series for beginning developers to get started with Meteor.

David's articles

  1. WordPress vs. Jekyll: Why You Might Want to Switch

    I’ve been using WordPress for the last eight years or so and, along the way, it’s been a good companion. But it’s far from perfect. Over the last four years, while running a high-traffic blog about video games, I struggled with a range of problems, like:

    • My blog loading slowly.
    • My blog crashing during peak periods.
    • My blog becoming infected with malware.

    It’s not like I didn’t prepare for these things. I installed W3 Total Cache, setup a content delivery network, upgraded the hosting, installed a number of security plugins, and did all of the “best practices” stuff.

    Did these things help? Sure, but it was never enough, so when I shut down the site and no longer needed one of WordPress’ biggest advantages – being able to publish content quickly – I decided to look elsewhere.

    Jekyll, I discovered, was exactly what I needed.

    Introducing, Jekyll

    Jekyll is a static blog generator. This means, instead of installing server-side software that’s built with a language like PHP, you use the command line on your local computer to generate static files (HTML, CSS, etc).

    These files are generated based on:

    • A configuration file.
    • Any templates you want to define.
    • Markdown files for blog posts.

    You then upload the generated files to any web server and, well, that’s your blog. While this might simply sound like a geeky alternative to WordPress, this static approach has a range of real-word advantages over WordPress.

    Let’s talk about them.

    1. WordPress is overkill.

    These days, WordPress is basically a content management framework. It can do just about everything and, if that’s what you’re looking for, then stick with it. I haven’t got a vendetta against WordPress. It’s great software. It’s just evolved beyond its roots and beyond what I (and many other people) need.

    Jekyll, by comparison, is just a blogging platform. To some, this focus will be limiting, but if you only want to run a blog, then:

    1. Jekyll has everything you need and nothing that you don’t. You won’t be bogged down in options and insignifcant choices, but you also won’t lack the features you need most.
    2. The writing experience is unparalleled. Because your content is built with Markdown files, you can use whatever text editor you prefer. Personally, I use Sublime Text, but any other option is fine. Your preference wins.
    3. There’s less chance of anything breaking. This is partly because of Jekyll’s small scope allowing for a considerable amount of polish, but also because you’re not dealing with finnicky server-side software.

    The “best” tool will always depend on the context but, increasingly, I think a simpler platform like Jekyll is worthy of being considered first.

  2. 6 Ways to Turn Sublime Text Into the Perfect Blogging Tool

    Sublime Text is a popular code editor but, after spending a few months with it, I realised something: it’s also an excellent tool for blogging. Not just an excellent blogging tool for a code editor, an excellent tool for blogging period. These days, I write all of my posts in Sublime Text – including this one – and, as you’ll soon see, there’s nothing else quite like it.

    Here I’ll share the most important tips for blogging in Sublime Text and, along the way, the benefits will become clear.

    Let’s begin.

    1. Write with Markdown

    Sublime Text is a text editor, not a rich text editor. This means writing with a formatting language like Markdown will get you the most bang for your buck. If you’re not sold on the idea of Markdown, consider these benefits:

    • Your files are portable between platforms. You might use Sublime Text on your computer, for instance, but you can just as easily switch to Editorial on the iPad.
    • It’s much easier to backup your work. Save every file into Dropbox and instantly have an archive of your posts. Combine this with Arq and Glacier and you’ll have more backups than you could ever possibly need.
    • You’re not locked into any format. Converting from Markdown to HTML is easy, as is converting from practically any other format. There is no “safer” format for your words.

    Then, of course, there are all of the benefits associated specifically with Sublime Text, and those are what we’ll cover now.

    2. Install These Packages

    By itself, Sublime Text has a ton of features that’ll come in handy when working with words – far more than I could hope to cover here — but there’s also a vibrant ecosystem of third-party packages that take it to a whole other level. Here’s the few that I’ve found the most helpful:

    • Markdown Editing adds the bext syntax highlighting to Markdown files I’ve ever seen – yes, even better than dedicated writing apps like Byword. It also simplifies the interface by removing line numbers, etc.
    • SmartMarkdown adds a range of other usefulf features, like the ability to fold headlines (which is great for larger documents) and create Markdown lists more easily (by automatically creating the bullet points).
    • WordCount adds word functionality to the Sublime Text status bar. It isn’t an inherently remarkable package but, either way, it works well.

    But these are still just the tip of the iceberg. There are thousands of packages available, many of which are specific to writers.

  3. 7 Reasons to Develop Your Next Web App with Meteor

    When I first learned about the Meteor JavaScript framework, I saw someone write, “Meteor is to Node.js as Rails is to Ruby,” and I think that’s a good comparison. A few years ago, Rails was the hot new thing on the web, sprinkling some useful “magic” through the development process to make programming on the web more approachable and pleasant. Out of the countless new frameworks that have spawned as of late though, none have made me feel the way Rails did as much as Meteor — a framework that you should seriously consider using for your coming projects. Here’s a few reasons why.

    1. Your applications are real-time by default.

    Lately, companies like Twitter and Facebook have been moving toward a real-time web. It’s inevitable that, sooner than you probably expect, users will expect web applications to work near-instantaneously. I imagine there’s already users who wince whenever a separate page load is required for simple tasks like changing settings and logging out.

    The problem is, creating real-time web applications is tricky. Or at least, it was. Meteor has real-time built into its core though. When the database is updated, the data in your templates is updated. When a user clicks a button or submits a form, the action occurs immediately. In the vast majority of cases, this doesn’t even require any extra effort. You build a web application as you normally would and, out of the box, it just happens to be real-time.

    A while back, the folks at Meteor released a screencast to demonstrate these real-time features, and it’s very much worth a watch, but there’s a range of production applications that do an even better job of showing off the Meteor difference:

    These are just a small sample, too.

    2. You can develop with just one language.

    One of the frustrating parts of being a web developer is the need to wear a variety of hats. You need to think about the front-end, the back-end, and the database, and then there’s another million details that squeeze out the last inch of your mental capacity. Meteor simplifies this process by shrinking the scope of what you need to consider, allowing you to build and manage the front-end, the back-end, and the database with nothing but JavaScript.

    This, for instance, is how we create a “collection” — the equivalent of an SQL table – in Meteor:

    [js]
    BlogPosts = new Meteor.collection(‘posts’);
    [/js]

    So, we can create a collection with a familiar syntax, but also manipulate a collection with a familiar syntax. Here’s how we insert data:

    [js]
    BlogPosts.insert({
    title: ‘Hello World’,
    content: ‘This is the content.’,
    published: true
    });
    [/js]

    There’s another benefit to writing an entire application with one language. One line of code can run on both the client and the sever and do different things in either environment. Here’s why this matters:

    When the statement to create a collection runs on the server it, predictably enough, creates a collection. But when that same statement runs on the client (which it will do by default), it creates a purely local collection within the user’s browser. The user then interfacts with the local collection directly, which is why the data on their screen can change instantaneously, while the local and server-side collections are seamlessly synced in the background.

    This doesn’t require any special treatment. You write one line of code and are provided with a boat-load of functionality in addition to being able to use a familiar syntax throughout the development cycle.

    3. You can save a lot of time with smart packages.

    Let’s say you want to create a user accounts system within a Meteor project. How might you approach it? If your first thought was, “Well, I’d create a collection for the user’s data,” then you’re already thinking too hard.

    In Meteor, this is how we create an accounts system: