As programmers, the number one rule is efficiency. There is creative coding where there is a certain amount of craft involved and it doesn't matter how long we spend creating the program, as long as it looks nice and artsy at the end, we don't care how much time we spend on it.
But real programming is about getting stuff done, and really fast, too. It's also about 'the race against time' to churn out brilliant, elegant code on time, and within budget. So a coder is constantly split/torn between artisan creative coding, and efficient, algorithmic, clinical code that powers the backbone of other apps, and is considered 'mission critical' code that should never have to be touched again in the future and has a great bus factor.
Craft coding is wonderful, and we can come back to it anytime. You can have a Guinness, read the newspaper, and get back to making a DIV spin with SASS/JS. It's not an especially harrowing task, although it does require some rudimentary math to make stuff spin with SIN, and COS. The urge to make cute looking things that are full of win is in all of us.
All nighter type coding is concerned with a higher purpose. It's about infrastructure building. It's about setting up a rig, or environment for great stuff to happen in the future. I brought up the notion of all-nighter code as a race against time. The technology you're working on right now is changing faster than you can type. In some sense, all-nighter coding is coding the future - it is pulling the future towards you.
Craft code is important, as it flexes our muscles for the all nighter. Do you need to convert a PNG file to base64 in two seconds? No problem - you toyed with the CANVAS API one month back; you can draw on that knowledge. Maybe you need to solve a UX problem really quickly? Not an issue - you check your analytics dashboard for the side projects you work on, and can draw some conclusions.
Craft coding is important because we can be serendipitous with code and learn to be explorative. Being able to explore and play with code as if it was some sort of Lego is very important. Craft code is serendipity, whereas all-nighter code is destiny.
If the notion of code-as-destiny sounds too deep and taking things a bit too far, let me remind you that coding is on par with literacy. Being able to read and write is the single most liberating thing a person can do. Imagine that liberation being multiplied several times over with the ability to code. So an all nighter for me is a sacred thing. It's a special place, free of distraction, where I can, literally, plan the next ten years of my life. I don't even need a browser. I simply start coding out ideas, and then later refactor them into something more beautiful in the browser.
If you're looking for examples of this code to pore over to try and garner the inner workings of my mind, you won't find any. Most of the code I've released publicly is not especially interesting, and doesn't concern the all-nighter code I talk about. But if you need an idea of the type of programs I'm talking about I can give you many:
Custom TODO lists / Bucket lists, with built-in algorithms to detect which items deserve more priority, and which items are frequently ignored and therefore will never be achieved.
Twitter neural networks & social graphs. Ways to heatmap twitter and find who is most interesting. Who is your Twitter crush, and what that means :)
Lots of Twitter bots. Autorepliers / favoriting bots / Positive sentiment gathering / Keyword spying
Bespoke 'whiteboard' system where you can dump any thought which is text based, and even 'draw' around it, as you would an IRL whiteboard, to draw conclusions, brainstorm and create 'lightbulb' / eureka moments.
Those are just a few. Currently I'm working on a design manifesto to deal with the ever increasing problem of how to design a bloody website in this day and age without somebody creating a Tumblr website which lambasts your design decisions.