Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Wednesday, 25 May 2011

Soda: a document editor

Hello! I’ve been working on a thing! It’s called Soda, and it’s a document editor. It’s sort of like Google Docs, only a bit simpler and, well, different. The most important difference is the way you create documents: rather than do it visually, you write them in a sort of code.

Now I realise this doesn’t sound terribly brilliant, but there’s a reason for it. When you type stuff using a WYSIWYG editor, it’s often difficult to maintain consistent formatting across a complex document. The ideal way to do it is to use some sort of style system – Word 2007 has those nice big style buttons if you have enough screen space, while LibreOffice has a handy Styles pallete/list thing.

However, neither of them really encourage the user to make use of these facilities, which I think is a shame, albeit understandable from a historical perspective. The ‘apply formatting to a selection of characters’ style of editing was laid down in The Beginning, and it’s probably far too late to do anything about it now. Still, I made Soda anyway, because it’s something I want to use (I wrote this blog post with it).

Anyway, the idea is you use various ‘control characters’ to apply semantic styling to blocks of text. For example, rather than say “make this text bold, size 22 and centred”, you instead say “make this text a level 1 heading”. In other words, you apply meaning to sections of text, and then you can control how all text with that meaning appears throughout the document (well, you can’t control it yet, as I’ve not actually implemented a style editing interface, but there is going to be one).

Caveat Emptor

Soda is not finished. It probably never will be, completely – there’ll always be something to add or something to fix. In its current state it’s quite usable, and I’ve tried to make sure the main part of it, the editor, has no glaring bugs.

That said, there’s still plenty to do before I’d be comfortable with declaring it fit for general use. Here are some things I have in mind at the moment:

  • Making registration/sign-in easier. I’ve been experimenting with OAuth login and it’s really just a question of putting the code in place, after which you’ll be able to sign in using Facebook, Twitter etc.

  • Smooth off the rough edges. At the moment, when you leave the editor with unsaved changes, there’s no warning/confirmation. Likewise for deleting documents.

  • Editor and preview preferences are not saved.

  • Needs a Markdown formatting guide.

This isn’t a comprehensive list, obviously, but these are the priority things. Like I said, none of them are really show-stopping problems, but they’re definitely obstacles which shouldn’t be there.

So yeah, if you want to poke around with it, feel free. It’d be good to get some feedback, too, as it’s hard to know what kinds of issues users may encounter when approaching it fresh.

Oh yeah and I know it’s silly, and I really do keep meaning to do something about it, but after logging in you need to click the ‘Your saved documents’ link at the top to create a new document. Once I’ve put the OAuth stuff in place, you’ll be redirected to that page after signing in or registering.

http://soda.heroku.com/

Saturday, 26 March 2011

Vim to HTML

I just discovered a feature of Vim that I'm not entirely sure is useful, but it's certainly interesting:

:TOhtml

It outputs the current file as HTML, including syntax highlighting! To see what I mean, this is the output when run on the main JavaScript file for my piXY application. Set your browser's monospace font to Consolas and what you'll see is pretty much exactly what I see in MacVim (as seen in the screenshot in the previous post).

Sunday, 31 October 2010

Ostensibly Here

ALERT: this post is about programming and stuff, so if you're not interested, best skip it! That said, I'd love it if you had a look at the new forum I'm working on and had a play. If it breaks, please let me know :D

Hello!

Gosh it's been a while, hasn't it? There's a good reason for that, however, and it does sort of involve WoW. Or rather, it involves a distinct lack of WoW: I haven't played since I broke my Windows 7 install by messing up the installation process of Ubuntu, about two months ago (I told it to put the bootloader on my external drive. Don't ask). Anyway, in lieu of WoW-playing, I have been doing something to break out of the rut of career mediocrity I've been in for years: I have been learning how to make web-based programs. That is, how to write in Javascript, Python and Ruby, how to run servers, and all (well, some) about the stuff that holds it all together.

Said the client to the server

Javascript, as it happens, is a really nice language. Apparently it gets a lot of stick for being a toy, but I feel it's more like a surprisingly versatile yet lightweight tool. The best part is, pretty much every desktop and laptop computer comes with the tools necessary to begin with Javascript: a text editor and a web browser. Of course, the real power comes when you can communicate with and store data on a server, as then you can split an application into two parts: the server-side which does all the data-retrieval, and the client-side which does all the presentation and interaction.

A common framework for developing the server-side web applications is MVC – Model, View, Controller. This is all well and good for presenting mostly static pages that the user doesn't interact with much, but when you involve Javascript on the client side more than for a few nice effects, you can start offloading a lot more of the page rendering to the client. Rather than sending fully-formed HTML from the server, you can just send the relevant data (in JSON format, ideally) and have the client set up the HTML on the fly. Until fairly recently this wasn't a practical way to do things, as browser incompatibilities and slow Javascript performance meant the DOM manipulation required just wasn't practical. However, efforts by Google, Mozilla and Opera to vastly improve their Javascript engines, combined with the emergence of Javascript frameworks like jQuery and Prototype, has resulted in a new style of developing large, complex web applications.

Enter Andy, stage left

It was into this environment that I entered more or less in ignorance. Ten years ago I'd done some programming for a while in Delphi, writing some handy little utilities like a font browser (sadly no longer available since the host it was on closed down). However, writing Windows desktop software is really quite different to writing for the web. For one thing, the applications tend to be more monolithic and closed – all compiled up into one neat .exe file. Web apps on the other hand are invariably run directly from source code, albeit often minified, and can easily pull their various parts from different servers around the web; they feel looser and more open to write.

On Javascript

Speaking of 'loose and open', that's generally how I see Javascript. It's a very easygoing language, due in large part to its loose typing. It's that and the fact that functions are first-class object that really make Javascript so nice to use. You almost never have to declare the type of a variable, and a function definition (which itself can be a variable) has a list of parameters that doesn't specify their type:

var add = function(a, b) {
    return a + b;
}

The thing about that function is that its parameters don't even have to be numbers:

var foobar = add("foo", "bar"), // foobar = "foobar"
    forty_two = add(40, 2);     // forty_two = 42

Or how about:

var arbitrary = function(a, b, func) {
    a *= 2;
    b *= 1.5;
    return func(a, b);
};

var number1 = 64,
    number2 = 99,
    number3 = arbitrary(number1, number2, add);

alert(number3);

There's just so much I could write here, about objects, closures, AJAX, jQuery and so on, but it'd get kinda boring I reckon, so I'll move one.

The future's bright

But it's Ruby-coloured, at least for me. It took a lot of prompting and hinting and suggesting, but my brother finally persuaded me to dive into all this stuff, and after a nice chat with his boss I've begun to focus my attention on Rails, pretty much just because it apparently has better (i.e. more) job prospects than the language and framework I initially chose, Python and Pylons.

Job prospects is what I need, as I'm currently working fixing computers, which, while not boring, is hardly challenging. One of the things I love about programming is solving problems, and there is an endless supply of those. There's always something new to learn, to try and understand, and maybe even eventually to teach others about.

I feel with programming I can do something more directly useful to people than just being a cog in a black box machine that takes in broken computers and spits out working ones. That's a large part of the motivation for writing my forum – I want to do something that people will use and appreciate. The idea was born of dissatisfaction with the way most existing forum software works: too many page loads, cumbersome to navigate and slow to use. Another part of the motivation, of course, is so that I have something to show to prospective employers, as it's not like I have x years of commercial programming experience. From what I've heard and read, though, I stand a good chance of getting hired based on what I know and can do, rather than how long I've been doing it.

So, here's to hoping for an improvement in my general state of affairs! Who knows, maybe one day I'll even come back and have a pop at ol' Deathwing.