minimalism

minimalism

minimalist staircase... looks really dangerous

I am a minimalist at heart, I like simple things with clean lines and no clutter. This is one of the reasons I love my new iMac, its just a beautiful magic floating screen filled with win. Minimalism is more than just an artistic movement or an ironically expensive interior design style. Programming is by its nature minimalistic, we programmers (as I have said before) are a lazy bunch. No one wants to type the same code over and over again, so we came up with functions, and then classes, and then inheritance, and frameworks, and aspect oriented programming, and so on and so forth. We want to reduce the amount of work that we as the developer has to do.

Here is a simple windows program that pops up a hello world screen using Visual C++

// GT_HelloWorldWin32.cpp
// compile with: /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS /c

#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>

// Global variables
static TCHAR szWindowClass[] = _T("win32app");
static TCHAR szTitle[] = _T("Win32 Guided Tour Application");

HINSTANCE hInst;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
    wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName   = NULL;
    wcex.lpszClassName  = szWindowClass;
    wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));

    if (!RegisterClassEx(&wcex)) {
        MessageBox(NULL, _T("Call to RegisterClassEx failed!"), _T("Win32 Guided Tour"), NULL);
        return 1;
    }

    hInst = hInstance; // Store instance handle in our global variable

    HWND hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 100, NULL, NULL, hInstance, NULL);

    if (!hWnd) {
        MessageBox(NULL, _T("Call to CreateWindow failed!"), _T("Win32 Guided Tour"), NULL);
        return 1;
    }

    ShowWindow(hWnd, nCmdShow);
    UpdateWindow(hWnd);

    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return (int) msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
    PAINTSTRUCT ps;
    HDC hdc;
    TCHAR greeting[] = _T("Hello, World!");
    switch (message) {
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        TextOut(hdc, 5, 5, greeting, _tcslen(greeting));
        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
        break;
    }
    return 0;
}

Holy Shit! This is after I stipped all the comments, removed whitespace, and reformatted to 1TB. But here is how much code you need to do something similar in C++ leveraging Qt

#include <QtGui>
 
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QLabel label("Hello, world!");
    label.show();
    return app.exec();
}

This is great news for the developer, we can accomplish the same result with much less code. We are now much more productive and so we have freed up some precious developer time that we can spend on something else. Our code is much smaller, much more minimalist now, which is good because we are lazy. This ends up being a dual edged sword because there is now the temptation to start coding up more features, because they are so easy to implement now. We have made our code more minimalist but in doing so have enabled developers to make their applications feature bloated and anything but minimalist.

Jeff Atwood wrote a post yesterday, Responsible Open Source Code Parenting, in which he asserts that John Gruber is being a negligent open source parent.

I don’t mean this as a personal criticism. John’s a fantastic writer and Markdown has a (mostly) solid specification, with a strong vision statement. But the fact that there has been no improvement whatsoever to the specification or reference implementation for five years is … kind of a problem.

The question I had, and still have is why. I wrote this comment on Hacker News yesterday regarding this post

The idea that since markdown hasn’t done anything in years its somehow being stewarded improperly is a bit foolish. Look at Gruber’s vision statement, he wanted to make an easy-to-read easy-to-write markup.

He did it, it is done, it’s called markdown. If Atwood had his way Gruber would have spent the last 5 years filling it up with features and today we would be reading a post about how Markdown went from slim and sleek to fat and bloated.

Gruber set out to do something, then he did it, now it’s done. It’s a minimalist approach. Atwood would have rather he spent the last 5 years allowing for “open source collaboration” that would help in “moving forward and maturing” Markdown. To what ends?

It is easy to add feature after feature to something with the belief that you are somehow adding value, but the whole world doesn’t think this way. Let’s illuminate this with an example.

Apple Remote Windows MCE Remote
apple remote

There are 7 buttons

mce remote

The technical term is an assload of buttons

That’s how the Apple Remote is intended to look, it’s not lacking buttons because they haven’t gotten around to putting some more on, they intentionally kept it simple. Now I’m not trying to argue that one remote is superior to the other, I prefer the Apple Remote, but the important word there is prefer. Atwood makes the mistake of thinking since something hasn’t changed in 5 years its a problem. What if Gruber did the cost-benefit analysis of the new features for the last 5 years and decided that it just didn’t need anything else.

People have asked me if I’m going to use Disqus and although I tried it for a bit I decided to just use the simple built-in commenting system. Disqus was all kinds of bells and whistles, it is (in my opinion, which since it’s my blog is the only one that counts ;) ) ugly, and it’s benefit doesn’t outweigh it’s cost in my opinion. By the time I took out all the stuff that made Disqus feel bloated to me I realized I basically had the simple built-in comments, just hosted by a third party, so I abandoned it.

There is a cost to every feature you throw into your software, the cost is added complexity. I have decided that complexity better come with some gain for the user, otherwise I won’t add widgets and gadgets and features just to add them.

Tags:

12 comments

  1. Jeff Atwood is not saying that Markdown misses important features. When he says that it has not evolved, he means that although time has showed us there are better ways to do the same thing, Markdown has not evolved to reflect this.

    Jeff gave us some examples of bugs annoying several people according to the mailing lists. He’s not talking about adding more features or making the syntax more difficult.

    Autolinking would be even more simple…

  2. Options aren’t in of themselves an evil aesthetic. In fact options that only appeared when you looked for them would be at least as good as a minimalistic approach (although harder to develop).

    Alas, your minimalistic removal of Disqus has torn my comments here from friendfeed (and potentially other sites). The additional navigation from my comments were a breadcrumb to others to come visit. And now it’s only a faint memory.

    The comment system served the commenter at least as much as the blog host, it was the glue. This is one more blog where my comments will be cut off from my easy documentation, and searching.

    The extreme of minimalism is nothing.

  3. Perhaps Atwood does want a lot of new features to be added, but he plainly lists some obvious issues that should be fixed. The idea that you think fixing bugs equates to making Markdown fat and bloated is foolish too.

  4. I am somewhat in the middle on the Markdown topic.

    However, I do think your assertions are a bit off.

    There is a big difference in fixing bugs and adding features. Most of what Atwood is asking for is to address the bugs and usability issues.

    Look at your Apple remote example. That was not the first version of the Apple remote. Sure the first one worked, but it had some inherent usability problems which were addressed in later versions.

    Of course, unlike Apple, Gruber isn’t selling anything which is why I am kind of in the middle. I love Markdown and would love to see it blossom, so I am in the end very biased towards progress.

  5. I would like to clear up a misconception, I am not against fixing bugs, this is why I didn’t mention anything about it. Atwood’s desire to fix bugs is fine by me. The thing is that fixing bugs does not require a 5 year long open source effort, it requires a couple of patches.

    When Atwood says that there should be an open source effort to move forward and mature Markdown, it would start with bugfixes but no way is it going to end with them.

  6. Hey, it’s Daniel from Disqus. I feel you on keeping things balanced between feature-ful and bloated.

    So, just wondering, what would be the major things you’d like from Disqus, or any comment system, if you didn’t feel they were bloated?

  7. Regarding your win32 API vs. Qt example – isn’t that an apples to oranges comparison? win32 programming has been deprecated for years now, by things like MFC (shudder) and .NET – you could easily build a UI with a smaller, easier to read block of code if you really wanted to.

  8. A bonsai is maintained with a careful eye, but no one would dare to make the claim it is not minimalist.

  9. The same window-producing code in REBOL:

    view/new layout [label "Hello, world!"]

    (Requires the 800K (not M) rebol script interpreter to make it work).

    Now, that is simplicity!

Leave a comment