It's almost been two weeks since I open-sourced the web site and I haven't even written a post about it, so... here's a summary of things:
- The new home page is alright. I didn't like the thoughts list being the front page, so I just made a small about page or something.
- Layout, style, and usability improvements turned out pretty well, I think. Some notable improvements are the table of contents feature on each page, bigger line spacing, and a wider column. I also added tags/categories again, but I'm still pretty confident that Google does it better.
- Updated projects and demos pages seem better as well. I pretty much just reorganized everything and updated the formatting a little bit.
- A links page to archive all sorts of interesting articles I find.
- An archive page that just lists all of my post headlines by category. Seems pretty alright.
- Flask is awesome. I transitioned to it from my own framework and I'm blown away by how easy and powerful it was. The development server that comes packaged inside is phenomenal amnd makes development tremendously easy. Switching between web site projects is vastly easier than mucking with all the Apache configuration files.
- nginx and gunicorn are awesome as well, and I'm really enjoying them a lot more than with Apache and mod_wsgi. Everything seems much clearer now and I feel like I have a stronger grasp on what's actually happening; whether that's because I've got more experience in general or these are actually easier tools to use is anyone's guess. Probably a combination of both.
- Linode is magnitudes better than GoDaddy in terms of VPS hosting. Not only is it cheaper, but the dashboard and management web site is less cluttered and easier to navigate. Everything seems much more transparent, and I have more control over the server itself (eg picking my own distro from any possibility rather than a list of two or three). I subscribed for it a few months ago and haven't looked back. I even got a free upgrade, which is something GoDaddy never did in four years. Overall, the company just seems less scummy as well.
- Delicious is okay. It gives me a quick way to bookmark links I enjoy, tag them, and then export them to a page on this site. It's nothing spectacular and I've encountered some small nuisances, but it works most of the time.
- GitLab is awesome. I'm not using it for this site, but it's definitely a better option than paying for private repositories from GitHub. Honestly, I think it's better than GitHub in a lot of areas.
After about a week's worth of effort, I've finally got a functioning version of soofw based on a Python and mod_wsgi. I wrote my own framework system to get a better understanding of the web environment for Python, but I'm not entirely confident it's the best solution for my needs. Earlier today I finished importing all of the legacy posts to the new system and flipped the switch to transition from PHP to Python.
Overall, it was an enjoyable experience. It felt pretty satisfying every time I got a piece to click into place. Python made it easy and quick to implement all of the features of the previous version plus some new ones. I wrote the new system with the eventual goal of open-sourcing it on GitHub, but at the moment it's a little... messy. I'd like to spend some time with it clean it up and get a chance to see where it misses the mark. I can already tell that it's a much more powerful and flexible setup than my old PHP, so I'm pretty hopeful.
When I first started writing the code, I decided I didn't want to use a(n) SQL database anymore. They're too clunky for such a simple project. I didn't want to use an awkward (and probably insecure) admin system every time I wanted to publish a new post, and I definitely didn't want to write that admin system. I also didn't want to use a standard MySQL admin system like phpMyAdmin and its ilk, because they're ugly and hard to use. Using a database system also comes with some other barriers, like migrating between a production and testing server. It annoyed me.
As a result, I decided to use a filesystem based "database". Within the application directory I have a posts directory, and inside of that posts directory I have a list of plaintext files. A script reads the directory and generates a post listing. Each post file contains some Markdown-formatted source text and some meta properties like publish date and title. From there, the view decides which posts to display and fills a buffer with rendered templates, which the WSGI app returns as the page content.
First, yes, I know that most Python web frameworks come with their own database management system. Yes, I know that databases are much faster than a filesystem set up. Yes, I know that I can't query the filesystem and find posts matching a certain tag, date range, etc. But I also don't need any of that. I did away with tags a while ago; Google does it better anyway. I only have 40-something posts, so the speed a non-issue. I even tested it with 1000 posts and the read times were negligible. As for the management system, I'm much more comfortable using a terminal to manage my posts. I can clone the site's Git repository to my computer, write a new post and preview it locally, and then commit and push back to the site to publish. I'm not missing out on any features, either, because I have the full power of the Linux shell to help me out. I can search my posts with
grep and write them with Vim. I don't have to deal with a bad web editor or funky search syntax. At the moment, I'm much more content with the flexibility of a filesystem database than a standard one. I also don't have to store my database credentials in my source files anymore, either.
No more PHP
Where to start... PHP sucks. There's dozens of posts defending it, and some of them have a lot of great points. It does have a really low barrier to entry, and that's the primary reason that I learned it. It was easy. I could make dynamic, templated web sites in a matter of minutes, and it took away all of the pain of updating all my HTML files whenever I made a design change. It was great at the time, but now I can't stand it. I can't stand looking at my old code and seeing
foreach($array as $key=>$val) anymore. The
$ variable prefix makes code incredibly hard to read, and I still don't even understand the
as...=> syntax. There's even more weird stuff in there, like the infamous
T_PAAMAYIM_NEKUDOTAYIM error messages and function case-insensitivity (
MAX(...) is the same as
mAx(...)). Variables are case-sensitive, however. It's just functions that don't matter. Why? I don't know. If you're interested in a more thorough write up, I suggest you read eevee's post.
I was mostly just sick of writing
<code>...</code> every time I wanted to highlight something in monospaced font. HTML tags are pretty verbose, and when you're trying to get thoughts out of your head it can be a pain in the ass to spend an extra 13 (17 with shift!) keystrokes on formatting. Markdown, as stated in its design philosophy, is easy to read and easy to write. It's such a natural system for formatting, and it has a whole host of features I didn't even know existed until I actually checked John Gruber's official documentation. I never want to go back to writing my posts in HTML. Miserable.
Oh god. I can write my posts in Vim now, and I don't even have to
cat the file, copy it, and then paste it into MySQL. This is easily my favorite feature of the new system. Paired with Markdown formatting, I've made it orders of magnitude easier to write my posts.
I can do this now that I won't expose any possible security holes like the database credentials, schema, server, etc. Huzzah! Beyond that, Steve Losh was a heavy influence on this decision, so I'm just going to redirect you to his article instead.
Not much to say here, but my last directory structure was bad. I mean it. Insecure, horribly unorganized, unmaintainable, and straight up bad. I've reorganized and toyed with my Apache configuration to create a much more rigid organization.
Kinda? It's much easier to get my site running on a new machine when it's not tied to a database server. All I need to do is install the dependencies and set up the Apache config files. Lovely!
Maintainability, Readability, Writeability
My code is so much easier to maintain, read, and write now. Python has made my life so much easier than it was with PHP. The post database is also much more accessible and maintainable as well, so that's a giant bonus.
Again, simplifying my life. I write posts in plaintext on a local copy of the site and then push them to the server when I want to publish. It's simple.
I can store my posts in version control now! If I accidentally
rm posts/* I can just restore them through Git. Paired with the improved directory structure, this feature is even better. The former structure made it possible but not easy (I still used it, however), so I'm excited for this.
That's it... I think. If you have any suggestions or comments, please feel free to contact me via email! Thanks for reading.
I've always been really interested in learning Python. Its clean syntax and use of whitespace to delimit code blocks has always been very appealing, and the incredible amount of positive feedback I've seen about it is impressive. I've dabbled with it a few times, but never enough dabbling to solidify its semantics in my head. I even tried porting this web site over to Django once, but I ended up losing motivation because of the brand new learning curve (like Vim's, it was intimidatingly steep). Recently, however, I decided to make a terminal-based to do list and plunged right into it with Python. In the very beginning I was having difficulty handling the command line arguments properly, so I was tempted to switch to a more familiar language like PHP. In spite of PHP's calling, I knew I'd never learn Python if I just kept quitting in favor of a more familiar language, so I stuck with it.
Man am I glad with that decision. After getting the arguments sorted out and actually getting into the logic of the system, I was blown away with how simple and expressive Python's syntax is. It's amazing how concise and readable everything is and how easy it is to create beautiful, easy-to-read code. Control structures are concise, formatting is simple, and complicated operations are reduced to simple expressions. Tasks that are cumbersome in other languages are made trivially easy with Python. For example, checking if the string
"Whose cookie is that?" (stored in the variable
bigstring) contains the substring
"cookie" done in multiple languages:
It's not even a contest on which language is the most compact and readable. Of course, this form of succinct syntax, along with its whitespace-delimited code blocks, can be a source of confusion for people more familiar with other languages. For me, and I would imagine most people, especially those new to programming, this type of syntax is easy to pick up on and assimilate into. This was also one of my first real experiences with Git, pushing me even further out of my comfort zone. I'd been using Subversion for almost a year and was pretty content with how it had turned out for me, but I couldn't ignore all the Git + GitHub hype going on in the internets. Another satisfying decision, as Git is incredibly powerful. I'm not nearly experienced enough to describe all its advantages, but a quick Google search should explain it fairly well.
My command-line to do list
In an effort to improve my personal task management / organization and my Python, I've been writing a command-line based to do list. I based it heavily on todo.txt and Steve Losh's t, but with my own little twists and ideas built into it. It's my first real experiment with both Python and git/github, so I'm learning as I go and hopefully making a usable product for people other than myself. You can check out all of the details over at the github repo and even fork it or something funny like that.