Joseph Cooney reminds us that, in January 2005, 37signals went live with a product they built in 579 lines of code:
You read that right, not 60,000 or 600,000 but instead a commercial project written in less than 600 lines of Ruby code. When I first saw this number I was incredulous -- I've written stored procedures that are longer than that. My current project has more lines of configuration than that. I've even written console apps in notepad, and compiled from the command line with more lines than that, because I thought they were so small they didn't need a whole .sln and .proj file, and yet here is 37signals going live with a product that is just 579 lines of Ruby.
As noted in the Rails blog, the original product launch was covered on Ruby language creator Matz' blog in his native Japanese. Surprisingly, the relevant facts are still readable:
Of course, a simple lines of code number isn't the entire story-- they actually built the entire Rails framework first to support building small apps like ta-da list. None of the required Rails framework code, nor any of the the necessary stylesheets, JavaScript, HTML, and so forth, are included in that number. Still, I agree with Joseph: it's an impressive achievement, and it can lead to some interesting thought experiments:
I have a few interesting product ideas from time to time. What is the absolute minimum amount of code I could write that would make those ideas work? If I'm prepared to operate within the constraints of the platform (whatever that is) how much effort would that save me? How many more "interesting ideas" could I turn into working products if I was prepared to follow these constraints? How many more cool/useful things could you build if you promised yourself that each one would only be 600 lines of code?
What can you build in 600 lines of code? Think of it as an exercise in minimalism. Does your preferred language or environment allow you the freedom to create something interesting and useful with that constraint in place?
Here, let me post my 600 lines of code in the comments to your post!
And you thought the FizzBuzz post was bad :)
BradC on January 24, 2008 3:35 PMFizzBuzz in 600 lines or less... Kinda like "Hello World!" in less than one line of code. (In other words... don't bother, please.)
Good food for thought on writing concise and useful code. The key here is also NOT to turn in it into an exersize in obfuscation.
Thanks for this little tidbit!
John Baughman on January 24, 2008 3:54 PMMaybe I'll go through some C app I've got, and remove the newline character from all lines that don't start with #.
Then again, maybe not.
Joshua on January 24, 2008 4:01 PMWhat can't i write in one line of code and a little bit of insanity and an overused scrollbar?
Darren Kopp on January 24, 2008 4:12 PMwith 600 line of code,
I can wipe out your hard drive
and fill it with useless junk
Isn't that a lot for 600 line only ?
Frankly, if the point is to discuss which
programmer langage is more concise than other,
I would have expected a more instructive article.
And no, Ruby on Rail doesn't look yet attrictive to me.
Well, I wrote a small webapp in PHP-SQLite for the library i work in that manages the entire movie loan process in less than 400 lines, XHTML+CSS included. Ok, it's far from those web-two-dot-zero features, but it does the job... :)
I remember someone writing a demo reversi game in ASP where the user played against the computer. I believe it was about 142 lines of total code HTML and VBscript.
Lee on January 24, 2008 4:28 PMI'm sure Larry Wall could have written that in 600 characters of Perl
maeghith on January 24, 2008 4:31 PM#include "WordKiller.hpp"
int main()
{
WordKiller theApp(;
return theApp.run();
};
600 lines of Ruby? Try something ten times as good as Word, in just 6 lines of C++ (or 2, if you remove unnecessary breaks.)
Oh, yes, the WordKiller.dll "framework" will be a little larger, but what the hey. Noone else ever considers the "framework" size when harping on about their one-liners, so I
More seriously, here's what I can write in 600 lines of legitimate code: a product that 50 thousand other developers could duplicate in a weekend. I could "write a product" but building a business would require something more, and not just in terms of code size.
If you have 579 lines of code plus a great deal more code that you're discreetly ignoring, then you might have something non-trivial.
Bob on January 24, 2008 4:32 PMoops, I forgot I was referring to the 37 signals product.
And to add: XDDDDD
maeghith on January 24, 2008 4:33 PMI once wrote a (horizontal) star scroller in 19 bytes. Switch to mode 13h, create random stars and make a loop that moves them. In 19 bytes. I'm still so proud of that :)
J. Stoever on January 24, 2008 4:38 PMHeh - I be it could be done as a APL one-liner - but no one would be able to read it, and figure it out
KG2V on January 24, 2008 4:44 PMIs something they don't charge for considered commercial? It's a fairly trivial program, like Bob pointed out, one a competent programmer could probably code in around a weekend. (http://railsrumble.com/)
It is certainly nice that something useful can be created in this time frame, though.
Brennan on January 24, 2008 4:50 PMAs a user of BaseCamp, I've delt with the short comings -- such as no Spell Check or HTML edit view. But all-in-all, for the basic $10 a month plan it is worth the money.
Me on January 24, 2008 4:51 PMAs a rails developer, I would like to say that that is 600 lines of code they actually wrote. A frozen rails 2.0.2 has 171,098 lines of code. Just didn't want to have anyone misled.
blazes816 on January 24, 2008 5:01 PMI don't know about writing less than 600 lines of code but I'm sure this should serve as good example to application and framework developers that writing short and clear code shall be possible. How many APIs have we used that required us to do so much for so little (hello Java ;) ) ? How many applications were bloated with thousands of lines of code that could be reduced to half the count just by cutting on patterns and fancy "we'll make it reusable because someone might think of wishing to reuse it" code ?
Alex on January 24, 2008 5:05 PM
Tell me, does javascript count as loc? I can't read chinese, so it's hard to tell if it's just lines of ruby? Anyone care to translate?
I watched Joe Stagner write an AJAX todo list in 20min. What can you write in 20 min? http://download.microsoft.com/download/0/f/6/0f651a0f-6f2b-4497-b061-e1b2825e22e0/MSAJAX-ToDoList.wmv
Apparently all I can write in 20 min is a useless blog comment.
Here is PhotoShop in 7 lines of code.
#include "Photoshop.h"
int main(int argc, char **argv)
{
Photoshop *app = new Photoshop();
app->Run();
return EXIT_SUCCESS;
}
www.bigbadjim.info:6060 has less than 600 lines of code. It is not complete, but what it is works.
I was not trying to be terse.
jim on January 24, 2008 5:34 PMI would have to say that some of the most impressive code in terms of size to functionality are Steve Gibson's Window's programs written in assembly. http://www.grc.com/smgassembly.htm
If you have an old Windows machine, this was the most amazing screen saver program, in < 200K! http://www.grc.com/chroma.htm
@Darren we'll you can't write anything in Python for sure :)
Anyways one practice I do have is to write any module for a larger app to have less than 500 lines. It's not that hard but whenever I see a module that has more lines than that I reanalyze and break it into smaller more focused sub-modules
BoredGuyAtWork on January 24, 2008 5:48 PMI wrote a python and pygame-based blackjack GUI game in just over 600 lines of code... I'm entering it in a contest, then I'm gonna open source it and release it.
Allan on January 24, 2008 5:52 PMSince I'm fluent in Japanese, I'll translate for those that are wondering what the post says:
"
Well its a cooperative TODO application. Haven't used one myself, but I've been hearing lately that they can be very useful.
However what's really interesting is that this web app was written in Ruby On Rails, and it's just 579 lines long.
Maybe I should learn some Rails too.
"
My friend built a multi-million dollar web app in 2,000 lines of ruby code (including unit tests). Makes me feel kinda of ashamed of my passion in C#.
I hope BOO become more popular.
buddydvd on January 24, 2008 5:57 PM@mehdi
dd can do that for you in 1 line
darko on January 24, 2008 6:06 PMI think conciseness is important, but how about another constraint to this thought experiment?
Challenge:
After writing your 600 lines of code, you come up with something additional that the code should do. Then, hand it off to a fellow programmer and have them add it successfully without your help.
If you can do that, _and_ you don't fuse your brain into a smoldering bio-mass in the process, I think you just rose to the rank of Sensei-Coder :)
Thomas Borzecki on January 24, 2008 6:10 PMI am proud of www.bigbadjim.info:6060. I have worked almost five hours on it. It is an exercise in keeping things simple. It has 504 lines of code so far, and does work.
It would be a todo list if I put "TODO" in big type at the top
jim on January 24, 2008 6:18 PMI've written an entire program loader in far less. I used to work on a machine which required me to fit functions into 728 bytes of code. It was 6502 assembly, and those two pieces of information should tell you what machines I was using, and where I was borrowing memory to put the code in.
Grant Johnson on January 24, 2008 6:20 PMXMonad, a window manager, was at one point less than 600 lines of haskell. Now it's around 1000, I think.
mgsloan on January 24, 2008 6:23 PMRemember HyperCard? I wrote a lot of HyperCard applications in less that a hundred lines of code: Payroll systems, accounting systems, inventory, games, demos, etc. I started using Hypercard as a application prototyping tool, but the apps came out so nicely, I simply used the prototype as the program. Whole applications could be written in a couple of days.
My favorite was called "Stack2Text" which would dump a Hypercard stack into text script that could recreate the entire HyperCard stack again. It was a way to transfer HyperCard stacks over text only BBS systems.
HyperCard was the primary reason why people upgraded their Macs to 4Mg of memory (Remember that this is in the days most PCs still had only 640K). Hypercard needed a full Meg of memory to work.
Apple lost interest in Hypercard almost the day they released it. Hypercard languished for years. It never got much further than bitmapped black and white graphics.
David W. on January 24, 2008 6:34 PMi wrote a php script to take info from the URL that was submitted by my friends WiFi app, to draw out a graph in a PNG image. the script is only about 250 lines
phil on January 24, 2008 6:37 PMI build my new website using Django (python framework) in 632 lines of code, with 674 lines of html templates. This doesn't include the hacked javascript I used, nor the settings files. Pretty good though, and it's getting full of features.
Dan on January 24, 2008 6:51 PMI wrote a weather service provider (http://forecaster.ws) in about 100 lines, and a blogging tool (http://www.subwindow.com) in about 60.
600 lines is kind of a lot =)
Erik Peterson on January 24, 2008 6:52 PMThe (Python) code for DecentURL.com was about 350 lines when I first launched it. It stabilized at about 500 lines after I'd added a few features. Now I've added some "premium services", but it's still only 900 lines.
Ben Hoyt on January 24, 2008 6:53 PMI wrote a python web application that measures a given URL from various geographic locations using an accelerated path and a non-accelerated one and presents the difference using a Flash UI all done in roughly 360 lines of code. Its useful for my sales folks to demontsrate the value of a an Application Delivery Netwotk.
Paddy on January 24, 2008 6:58 PMusing MySuperAwesomePrewrittenFramework;
public class TadaList
{
myFramework.Scaffold();
}
This is why I'm not impressed at all with rails and line count. When you move 90% of the functionality into the MVC engine, all you really need to do is whip up a handful of views and a few controllers.
Sure, MVC is a nice architecture, but rails didn't even MVC, they just made it popular.
BTW, you could create Tadalist almost entirely in ASPX markup without writing a line of code, doesn't mean you should.
Jonathan Holland on January 24, 2008 6:58 PMeven == event.
@Other Pythons Users,
I love python, don't use it everyday, but my comment about you can't do it in Python to Darren, was that you can't write an app in one absurdly long one line of Code when using Python, which I think is a good feature as it forces code to be reasonably readable.
And in the one line code camp, I would hope that all real Javascript apps out there would be compressed into a single horrible loooooong line of code, so they don't waste my bandwidth. I guess that means it's necesarry to write a useful app in 1 line of JavaScript code :)
nitpick: event==invent
BG on January 24, 2008 7:26 PMI wrote a Weewar notifier in AutoIt in ~250 lines of code. I tried writing it in c# but I gave up after about 2000 lines of code and over 18kb of different source files.
Craig Woodward on January 24, 2008 7:27 PMThis 256 byte intro (yes BYTES) is impressive: http://pouet.net/prod.php?which=3397
A 4KB intro with graphics and music, for example, http://pouet.net/prod.php?which=16373 , is also impressive.
A todo list with a HUGE framework in 600 lines of code? Not so much. I would call it "cute".
If you think 600 lines of code is small, then you clearly are not a perl programmer.
Of course, if we start counting characters (or punctuation) I might be in trouble.
JohnV on January 24, 2008 8:19 PMI just did Conways game of life in just over 200 lines of code: http://www.gumuz.nl/blog/lifegame-2d/
Python with Pyglet, OpenGL (consider those my rails ;)
gumuz on January 24, 2008 8:38 PMRuby on rails is fine for small & simple sites; but when you start adding logic then you have to start coding.
It also makes assumptions about the database that are against convention, ie: naming tables in plural form.
If you want to talk about impressive, how about a raytracer written completely in ONE line of Linq?
http://tirania.org/blog/archive/2007/Nov-16.html
Andrew on January 24, 2008 8:50 PMYep.The Rials looks like a magic in productivity:)But an interesting news: Have you ever tried "web2py" ? In my opinion it's the best pythonic Rials! It's productivity... unimaginable :)
vahid on January 24, 2008 10:11 PMRuby on Rails uses a lot of code generation. Comparing it with other programs written in other languages brings up a lot of questions. Both the verbosity of the language has to be taken into consideration as well as the underlying libraries.
Take for example Java. It's got a lot of libraries that one can use. Making a desktop application would just mean that one has to use the SWING library.
Compare that to Common Lisp. Common Lisp can do the same thing that Java does, and probably even more, but are the libraries that one can use, or does one have to write everything?
One can even write a desktop application Brainf*ck, but the understanding the source code would probably require omniscience.
I assume we're not talking about 'tricks' where you're just running external code, plugging together existing components, or having 8000 char+ lines.
So, given that:
Full applications? No.
Incredibly useful utilities? Absolutely.
Gadgets / Widgets / Plugins? Sure
Depends on what your definition of an application is I suppose.
Total lines of code is, and has always been, a poor measure of effort required. Sure, they might have legitimately only needed to bang out 579 lines - but if it took them longer to get to that point, it all becomes redundant.
That said, I'm all for expending less effort for more productivity, and if they're getting great results through rails - good on 'em!
Will Hughes on January 24, 2008 11:01 PMYou can do some really cool user interface stuff in C#.NET with WPF and Expression Blend (XAML user interface descriptions). Do all the data binding of .NET objects to XAML elements. Using other .NET 3.5 frameworks like WCF, you could probably create a networked photo sharing application in less than 100 lines of C# code.
There's a lot to be said for well-designed, productive frameworks and environments that don't make you reinvent the wheel every time you need a GUI app or a web app or a data structure or whatever.
Do not count lines of code.
This is not a programming language issue, but its about the available libraries that support it.
It is obvious, you know it, but you do not mention it. Why?
"you can't write an app in one absurdly long one line of Code when using Python"
Of course you can:
exec "absurdly long one\nline with embedded\nnewlines"
Pythoneer on January 24, 2008 11:34 PMi could solve fizzbuzz.
Scott Elkin on January 24, 2008 11:38 PMI'm not that impressed really...
You could do single, double and circular single and circular double linked list implementations in under 100 lines of standard c99 so you'd have at least 500 lines of space left to use them. That's a whole lot of possibilities, I bet it includes tetris! and many more puzzle games.
Now imagine what you could do with 600 lines of c# or objective-c, the sky is the limit!
The little detail that it's a web app makes it sound a bit more impressive, but then, that's exactly what Ruby was designed for.
So no... not really impressed.
kris on January 24, 2008 11:41 PMThat seems to be more stupid than your last blog entry with telephone screening. LoC does not count anything. If you use just 3 lines of code you can include ie in excel and start to browse. But who needs this? In less than 100 lines you can write a simple recursive Towers of Hanoi in assembler. You can also use Datasets, datagridviews and a lot of build in .net functionallity to produce with a few own lines a search engine for ebay items which could filter the results. (even with a small bid agent). If you reduce it to this standard functionallity, all of your phone questions are totally irrelevent.
If you use languages like prolog, lisp, (f#) you can do other things in 600 LoC than you can do with .net 3.5 and c#.
In c++ you can put a lot of things in an one liner. But you can forget that you understand quickly what that code does a year after coding.
So do you really want a lot of rather useless apps which are hard to maintain?
offler on January 25, 2008 12:09 AMWell, _I_ was impressed (although clearly in a minority)....looks like it's put-up-or-shut-up time for lots of coding horror readers.
JosephCooney on January 25, 2008 12:11 AM"None of the required Rails framework code, nor any of the the necessary stylesheets, JavaScript, HTML, and so forth, are included in that number."
So this game: http://blog.beef.de/2008/01/16/html-game/ is written in ZERO lines of code. Top this Rails :-)
Peace
-stephan
It seems like most of the commentators just don't understand the point here. Or they won't.
It's not about removing linefeeds or call everything a framework and just count the 'application kicker'. It's about making an idea into a usable solution within a short ammount of time (and cost), and then making a business out of it.
How many frameworks like 'wordkiller' or 'photoshop' will you find out there? How many business ideas can you realize with such a framework?
Vegar on January 25, 2008 12:25 AMHere's my urlopen(.pl) :)
It checks if there's an URL in the clipboard, and if it finds one, it automatically opens it in your favorite browser.
It's far from perfect (URL-regex should be more strict etc), but works for me. Actually I wrote this extra-quickly "on demand" for a friend.
Way under 600 lines! (Although I don't know if that is a fair comparison as it's Perl) ;)
my $browser = "iceweasel";
my $clipboard_cmd = "/usr/bin/xclip -o";
my $delay = "2";
my $last_opened = "";
my $last_clip = "";
my $clip;
while (1) {
$clip = `$clipboard_cmd`;
$clip =~ s/\n/\ /g; # - Substitute newlines with space.
$clip = $clip . " "; # - Add space to $clip, to match
# exact selections too.
if ($clip ne $last_clip) { # - If this clip haven't been checked before.
$last_clip = $clip;
$clip =~ m/(http\:\/\/.*?)\ .*/i; # - Find URL and if it's not
if ($1 && $1 ne $last_opened) { # the one used last, open it.
system($browser, $1);
$last_opened = $1;
}
}
sleep($delay);
}
oh my god, and it looks extra-terrible without indentation :)
Samuli on January 25, 2008 12:34 AMSteve "If you have an old Windows machine, this was the most amazing screen saver program, in < 200K! http://www.grc.com/chroma.htm"
Check out farbrausch who developed some amazing 64k stuff.
This was their first.
http://www.pouet.net/prod.php?which=1221
650 lines of code is great to get a bussiness idea out.
I dont think I'd be able to translate an idea into that very quickly.
Dan,
I took a look at your site <a href="http://www.shuttercal.com">http://www.shuttercal.com</a>, but I couldn't find a page that tells what the site is useful for.
A site where I first need to sign up in order figure out what I can do with it, is not a site I would want to waste my time on. And I think a lot of other people agree with me on that.
I believe the "Learn More" button should return an 'about' page. "With shuttercal.com you can shut up callers! It has ..." (Yes I did figure out it's not about shutting up callers)
sobani on January 25, 2008 12:42 AMHey Jeff, thanks again for your Coding Horror.
I think most people are missing the point here. It's not a matter of LOC, but what can you do with less effort... and not needing complex code to achieve results.
Yuri on January 25, 2008 12:54 AMXForms is quite good for writing short web applications. If I remove the empty lines, inline instances, comments and some static XHTML, I'm down to 487 lines for a data entry system currently in production. This features adding, editing, and removing data in three forms separated into tabs, validation against other XML files (with helps, hints, and alerts), file upload / deletion, navigation between data items and a collapsible log displaying all the entered items with the current one highlighted.
Victor on January 25, 2008 1:01 AMI felt the need to help you, because you are so right and because many of the people who commented didn't get it. See the full post here: http://my.opera.com/alex_boly/blog/2008/01/25/writing-less-code-is-good-for-your
Briefly the idea is:
The more lines of code your software has, the greater the number of bugs.
The more lines of code your software has, the longer it takes to solve one bug.
So writing less code helps you write good software.
Who said this code wasn't complex though? It could be 579 lines of code that are all 1000 characters long!
Honestly.. who cares how many lines of code an application is? As long as it fufills it's requirements and it's easy to maintain, that's all that matters. Not some c0ck-measuring contest to see how small you can get the source files!
James on January 25, 2008 1:13 AMWell, not sure if it counts, but if I'd persevered it COULD have become a commercial application:
I wrote my own (VERY clunky!) word processor in Z80 assembly language for the TRS-80 in about 1980, I guess. It must have been in less than 16K bytes, probably quite a bit less, because that's all the memory my computer had. But it worked pretty well - I wrote most of a novel on it.
I remember the TRS-80 had a chess program that fitted into less than 4K of memory. Played pretty bad chess, but it did work.
David on January 25, 2008 1:23 AMThe creators of the darkbasic language (thegamecreators.com) regularly hold a competition where the entries have to form a working 3d computer game within 20 lines of code. Due to the level of functionality you can achieve with such a high level command set, this is not only feasable, but results in some great games.
However, due to each command being of such a high level of functionality, each takes a long time to execute. I think many programmers don't think about the execution complexity due to being so focused on the uncompiled code and how that looks.
It is a great practice to avoid using 20 lines instead of the 5 you actually need. I recently rewrote a class method at work and removed 50% of its code. This lobotomised code not only fixed the problem, but ran faster (no surprise there). That said, if the system had been properly designed at the beginning, that class would never have been needed.
Measure twice, cut once.
"Honestly.. who cares how many lines of code an application is? As long as it fufills it's requirements and it's easy to maintain, that's all that matters. Not some c0ck-measuring contest to see how small you can get the source files!"
Exactly!
All the "Oh boy, someone wrote a 600 liner which represents does cool. I should drop what I'm doing and do what that guy's using!" moaning... some people should simply take a step back and think about what they're doing. Hint: programming isn't about typing text in an editor.
People are too focussed on operating tools (e.g. a language, editor, ide). The tool isn't important, it's what you do with them and more importantly WHY you're using these tools.
The more of these same-themed blogposts are posted on this blog, the less motivated I am to read them.
Frans Bouma on January 25, 2008 1:29 AM@Bob (and others stressing out that its a framework with lots more lines than 600):
The point is that the whole framework does not have to be written again in order to do the 600 lines app (and you could do others too). Yes, they did have a big hand in creating Rails. That's not the point. Using the framework they created, they made a commercially viable application in extremely few lines, proving out a theory of application in the process.
Reminds me of when I used to write web apps without the benefit of Grails. I could spend ages trying to show a concept works using the old method of slog-slog-slog-slog.
The weeks/months of time to prove a complicated web driven concept have shortened down to a few hours in most (if not all) cases.
Thats not the point either though.
Brandon on January 25, 2008 1:41 AMUnfortunately my Perl can be quite verbose.
Regarding the framework: do you count those lines too? Even my biggest Delphi projects are dwarfed by the VCL they rely on. My final year project at uni was a simple voxel renderer. The core of it was approximately 100 lines, but to even produce an output I needed hundreds of lines to write to a bmp file.
John Ferguson on January 25, 2008 1:54 AMI've just published an internal Excel app with 832 lines of VBA code.
I think that's not bad, even though it could probably be done in less.
GUI Junkie on January 25, 2008 2:06 AMIm pretty sure that with 600 lines of code I can do some Hello World.
Almost sure!
Caxaria on January 25, 2008 3:55 AMPah, using frameworks and libraries is cheating.
Heck, I made a fullscreen Polish flag in DEBUG.COM in 19 *bytes*. Beat that, 37signals!
Mark on January 25, 2008 3:58 AMPfffstsss.. I can write an full featured webshop with ERP system integration in 2 lines:
system = FullFeaturedWebShopWithERPIntegration(:webenabled => true)
system.processRequest(CGIRequest::instance)
yeah - its THAT simple and ONLY 2 farging lines people... ;-)
Lars Borup Jensen on January 25, 2008 4:09 AMWhy not 666 lines of code ? /sarcasm :)
TrXtR, yeah farbrausch(www.farbrausch.de) are cool, check out the debris demo from 2007: http://pouet.net/prod.php?which=30244.
Anyway, what 37signals has done is smart and elegant, but not very impressive. But the goal was ofcause to show how elegant the rails framework is. As always use(+create) the right tool for the job.
As a programmer you should be more impressed with the algorithms and impress the boss, costumer, etc. with the programming statements.
/P
Peter Palludan on January 25, 2008 4:28 AM"Pfffstsss.. I can write an full featured webshop with ERP system integration in 2 lines:
system = FullFeaturedWebShopWithERPIntegration(:webenabled => true)
system.processRequest(CGIRequest::instance)"
And what else can you do with that? Nothing. People have done a wide range of things with RoR, one of these being a Todo list in 600 lines. It's a demonstration of the completeness and flexibility of RoR.
That said, it might only be 600 lines but it misses out a lot:
http://rifers.org/blogs/gbevin/2005/3/18/blabla_tada_in_java
Back in the 90s there was a competition to write the nibbles (snake) game in a minimalistic way. I was somewhere 48 bytes as I remember, the winner was somewhere 37 bytes. that was a pure assembly fun.
n' on January 25, 2008 5:05 AMI remember the days when part of the programmer's job was to write code that was as efficient as possible simply due to memory restrictions. The days leading to 2G memory and TByte harddrives have nurtured a generation of lazy and inefficient programmers.
PaulG. on January 25, 2008 5:06 AMHey Now Jeff,
Make everyone think 600 line what could we do. I like the screen shot too, I never knew I could read Japanese until today.
Coding Horror Fan,
Catto
I can build Hello World in under 600 lines of code
Billkamm on January 25, 2008 5:52 AMYeah, but...it's just Ta-Da List.
Not to crack on Ta-Da List; it's cool, but it's basically just a little thing that manipulates checkboxes, isn't it?
Evan on January 25, 2008 5:53 AMhmm, how would you make a _solid_ computer game in that much code? it seems to me that without a _lot_ of pre-existing code (frameworks, libraries, etc.), that's going to take much more effort.
dilbert on January 25, 2008 5:55 AM"600 Lines"
If it's only lines of code that were typed by a developer not including the framework, configuration and generated code then 600 seems a lot, there are ways of producing functioning code without little if any "lines of code".
I've been hearing a lot about Ruby On Rails lately, mostly FUD. I also read an amusing article about Rails developers calling themselves "rock star coders" and creating that online persona. I'm tempted to learn Ruby On Rails but I've heard that it is "the rails way or the highway" and it forces you to design the database to meet its requirements and does not allow any SQL hacks to solve problems. It sounds like one of those frameworks that promises to save you time until you need to do something slightly unconventional and then you need elaborate hacks. Even ASP.NET is guilty of that but it is flexible enough to meet most needs.
Robert S. Robbins on January 25, 2008 5:59 AMThis would have been about 6 years ago, but I wrote a boggle solver in Delphi that I remember being only a few hundred lines. Even had some primitive hacked-up OCR so you could use it to cheat at the online games. :-)
And to whomever mentioned HyperCard, I remember that! That was actually my introduction to programming, way back in elementary school. To most of the kids, it was just a slide show, but once I started digging in I realized that there was a whole world in there. It's really too bad that Apple let it stagnate - I can't think of any better way to get someone interested in programming.
Aaron G on January 25, 2008 6:04 AMI recently picked up RoR, and let me tell you the installation alone was a pain in the ass. It is definitely quick as far as development time goes, but seems to be more of a fast solution for designers with little knowledge of programming.
It is interesting if nothing else, and definitely worth taking a look at.
Matt on January 25, 2008 6:16 AMRobert, that's exactly right. Ta-Da List is the quintessential ROR app: a trivial solution to a non-problem, built mainly *because they can*.
Don't misunderstand me, folks, I've got nothing against Ruby as a language or Rails as a framework. It doesn't seem as interesting or promising as, say, ECMAScript, but hey, to each his own. My point is just that if the "rock star programmers" want the rest of the world to take them seriously, they're going to have to put on an actual rock concert someday instead of just farting around in the garage.
Please, prove me wrong, rock stars. Show me a ROR app that's more than just a thin wrapper around a 3-table database. Show me one that solves a real problem, with a non-trivial solution that wouldn't be easier to cobble together with a pen and a pad of paper. Otherwise, I really don't care how few lines of code it took, it's just another mutation of Perl Golf.
Aaron G on January 25, 2008 6:26 AMI'm with KG2V on this one. The old joke is that someone who really knew what they were doing could write an entire OS in one line of APL.
Mostly this points out what a crappy metric "Lines of code" is when comparing different languages. Since I don't know all that much about Ruby, other than that it is a fairly high-level language, the assumption is going to be that the application was sticking to things that could be naturally expressed in Ruby (or its libraries) easily.
So no, not horribly impressed.
T.E.D. on January 25, 2008 6:41 AMYou can actually use semicolons in Python to put multiple lines on one line like this:
print 'Line 1'; print 'Line 2'; print 'Line 3'; print 'Put as many lines as you want separated by semicolons!'
I've tested this and it works.
Valdemar on January 25, 2008 6:51 AM80Micro (a magazine for the TRS-80 from days-gone-by) had a couple of 'One Liner' basic contests. Write a one line program, 254 bytes (less two for the line number and space) was the goal.
I believe there were hundreds of excellent programs submitted. I wrote a one line text adventure (very simple!) and a downhill skiing game, and had bytes left over.
No loading a huge library, only running in the constraints of the programming language as it came (no external libraries) or anything.
Now, I know that is not the point of this post. The point, that many have overlooked or become obsessed with proving wrong, was:
WHAT KIND OF APPLICATIONS AND HOW MANY COULD YOU CRANK OUT WITH A COMPLETE FRAMEWORK AT YOUR DISPOSAL?
Sorry for the AOL-speak, but sometimes you have to yell to be heard over the chest-thumping...
Frankly, with frameworks like the CodeIgniter PHP framework, things DO get really easy.
rustyvz on January 25, 2008 7:02 AMI wrote a weblog application with rss and atom feeds in 430 lines of code (including CSS) running on Django. Though it was my first django app and I likely could add some functionality and still do it in less code now.
rev_matt_y on January 25, 2008 7:17 AMHere is a page of 'one-liners' written in Carl Sassenrath's (AmigaOS kernel dude) REBOL language:
http://www.rebol.com/oneliners.html
It's amazing how much you can get out of a single line of code when hundreds/thousands/millions of _other_ lines of code are being executed.
Zip on January 25, 2008 7:47 AMFuck Ruby.
Yes, you can program everything in 8 lines.
As long as they're websites. As long as you're only doing things supported by framework widgets.
Remember your magpie developer post? Sometimes I think you forget.
N on January 25, 2008 8:00 AMJust ask Microsoft. You can write a useful application without any code at all.
Ryan Clare on January 25, 2008 8:10 AMJust for fun we wrote http://lessmemories.com in 7 hours in 300 lines of code. In another 5 hours and 200 lines of code, we added the browser linkbar button and AIM integration (http://lessmemories.com/tools).
Steven Bristol on January 25, 2008 8:15 AMi'm not particularly impressed for 600 lines of code. i imagine most of them come from the necessity of displaying the thing on a web page.
it seems to do some trivial data stuff... as a non web application written in VB6 or C++ this could be tiny. even with php and mysql generating html, i would wonder where 600 lines of code could come from... but i could imagine it growing that large. pages of php code always seem to come out twice as big as i initially expect... all the browser support and workarounds etc... bloats any website out. i'm sure i must be missing the point as these blog posts are most normally spot on.
concatenating lines of code is not cool though... its 'cheating' and its ugly and horrible to read. :)
the semi-colon delimits the end of the line as far as the language grammar and compiler cares. just because mutliple lines of code are mapped to one line number in the source file... doesn't make it one line of code. it just means you fit multiple lines of code on one line of a text file...
Jheriko on January 25, 2008 8:27 AMBasic/VB provides colon ":" because it foolishly gives meaning to a whitespace character (return). Its the same principle though.
Jheriko on January 25, 2008 8:29 AMI think Steve Jobs loaned 37signals his reality distortion field.
Travis Johnson on January 25, 2008 8:30 AMThe rebol scripting language is pretty darn good for writing useful programs in few LOC. Here's a simple image viewer with a GUI written in 30 lines. http://www.flippingsweet.com/viewer.html
Here are some more examples:
Online Forum
http://www.rebol.com/docs/cgi-bbs.html
Play a List of MP3's
http://www.rebol.com/docs/quick-start5.html
Web Thumbnail Gallery Creator
http://www.rebol.net/cookbook/recipes/0040.html
Server Monitor w/ GUI
http://www.rebol.net/cookbook/recipes/0061.html
Tiny Web Server
http://www.rebol.net/cookbook/recipes/0057.html
The URL-Open Perl script posted above would be 4 or 5 lines of code.
Edoc on January 25, 2008 8:32 AMbtw, a tool i made whilst bored at work: 262 lines of code. pops up a window which lists every window on the screen and lets you force one to be on top (except office windows for some bizarre microsoft reason no doubt). and its c++ which is notoriously verbose and includes all the extra space and comments i use to make it a bit more legible. compiled with dmc with two command line switched... no extras needed beyond the dlls that ship with windows.
three comments in a row... i need to cut back. :)
Jheriko on January 25, 2008 8:36 AMI do embedded programming. One of the chips I worked on had 512 _bytes_ of Flash and 24 _bytes_ of RAM. (Not k - 512 or 24 _bytes_ )
In 100 lines, I've written VHF transmitter code that's used all over the world.
oops, must leave sick kid.
themagni on January 25, 2008 8:48 AM"Honestly.. who cares how many lines of code an application is? As long as it fufills it's requirements and it's easy to maintain, that's all that matters"
I'd echo that!
Programs that are too short approach obfuscation and are not maintainable. Programs that are too long tend not to be maintainable because they tend to have a lot of waste.
There is something special about code that is simple (not necessarily short), easy to maintain, easy to learn, and solves the most complex requirements.
I was reading your blog article "Getting the Interview Phone Screen Right" and really like the part about searching code for phone numbers and seeing what the solution would be. The simplest solution was doing a web search. That's 0 lines of code and solves the problem!
Dave Parslow on January 25, 2008 9:02 AMUseless junk.
Thomas on January 25, 2008 9:05 AMI wrote palacehotel in 24,496 LOC. It has:
- a gmail-like feature complete webmail
- agenda (ala GTD)
- calendaring (underway)
- contacts management
all this including the backend and a wonderful web 2.0 GUI
it's fast (both at the client and server -side), in contrary to Ror and uses completely scalable technologies (spring/hibernate)
It's concise because I've used state-of-the-art time-savers: AndroMDA and OpenLaszlo. And thanks to groovy, the development process is a breeze.
It's more than the 600 LOCs of ta-da list but it's also *much* more than ta-da list.
Usually you're posts are quite good. This one throws out a flippant, retarded statement. I know you must be doing this to get everyone chatting becaue I know you know BETTER! What about code that is generated? That's still lines of code that needs to be maintained.
Come on Jeff, you're much better to know that it possible. Since you code a lot in C#, I assume you've seen your share of Microsoft Demos where the guy develops entire databound websites with just dragging and dropping ASP.NET webcontrols. Would this count as writing software without any lines of code? Afterall, the dev isn't really writing code. The framework is just wiring things up. I see no difference between this and what the 37Signals is declaring.
As with Ruby on Rails, like almost any other framework, if what you want to do differs from how they do it, it's great pain. All the AJAXy/JavaScript code generation by Rails is pretty rigid with what you can do without writing a lot of your own. Essentially, they created a 600 line application with a framework they they custom built to the exact specs for that 600 line application.
I guess once the marketing hype is on your side, you can get away with saying anything. The real size of TADA is Rails Framework + Tada code.
I write all my programs in Notepad on one line. Word wrap is for pansies. Take that 37signals!
CynicalTyler on January 25, 2008 9:26 AMin f# you can write even more powerful applications with just One line of code.
do main
The framework is probably doing most of the work so 600 lines is not a big feat.
Some programmers cram as much code as possible in a single line or statement. The code becomes hard to read and maintain. Hard to debug or use breakpoints because a single statement is doing several tasks in one line.
The fact should be the number of statements, not number of lines. I can put several statements in one line separated by ;'s. (in C#)
Abdu on January 25, 2008 9:45 AMSigh... Another cheap Ruby plug
CptBongue on January 25, 2008 9:55 AMBack in the 1960's during the early days of computers, programmers, etc.
They had something called bumming.
Where someone would create some kind of app, then another person would try to write it in smaller number of lines of code.
I only know this because of Steven Levy's book Hackers, which describes the history of Hackers in the early generation of computers.
I think this si something we should bring to the software/web industry, as a way to create better, more solid, reliable code.
Instead so much code is called proprietary, it makes much harder for us to learn and share, and thereby improve the whole industry.
Craig M. Rosenblum on January 25, 2008 10:03 AMALL my projects start out being 600 lines of code or smaller... :) 3 months later they are 60000 lines. tadalist will be the same way soon... wait for it.... wait for it....
Tony on January 25, 2008 10:10 AMAll this over the to-do list?
wow... underwhelmed
With Dreamweaver and phpmyAdmin, I wouldn't have to "write" one line of code, this can all be done without any hand coding, with the built in features of both applications. Wouldn't take more than two, three hours either, probably less.
Kaosweaver on January 25, 2008 10:25 AMIn my data strutures class I had to wrote a telphone book app in C using console interface and saving things in a dynamic list. It took about 300 lines of code (maybe less, I do not remember). Still, at least 30% of those were interface code. If it was 1995 and I had polished the program a little more I could sell it as a custom program for someone.
What I'm saying is that interface code (even with all the frameworks around) are still a lot more lines than "business" code, but still, interface code is somewhat repetitive and "dumb" code (code that is not either clever or hard to do, like making a click event in a button that validates a date which is in a text box).
Hoffmann on January 25, 2008 10:46 AMHum, well... With Ant, Batik and some XLST transformations, I did a a full featured homepage generator in 4Ko. XSLT is not exactly friendly but together with Ant it allows to do some nice multi-staged code generators.
Alex on January 25, 2008 10:48 AM"If we wish to count lines of code, we should not regard them as lines produced but as lines spent."
- Edsger Dijkstra
Rick Liddle on January 25, 2008 10:52 AMA real application in 600 lines of code? Bah, this will be easy!
Just let me start a new Visual C++ MFC application here... running the app wizard now. Ok, it's ready. Let's do a quick code count to start things off...
What the *#$#@ - 650 lines of code already??
OK, let's try the .NET C# Windows Forms app wizard...
Mark R. on January 25, 2008 11:12 AMA lot of commenters are missing the point here. Sure, the app is only 600 lines of code if you don't count the framework. So what? You didn't write the framework. Anyway, Jeff is just using it as an example for his thoughtful question of the day.
Not that I have a thoughtful answer, but I think I get the question.
A. Lloyd Flanagan on January 25, 2008 11:45 AMOkay, I think I get it. This article is related to this one from last month:
http://www.codinghorror.com/blog/archives/001025.html
I don't think 37Signals set out to write < 600 LOC program any more than Steve Yegge set out to write a > 500,000 LOC one.
But it's a useful feedback mechanism. If LOC count is growing constantly you're probably doing something wrong. If it's staying in the range of the size of a program you would write from scratch in a weekend you're probably doing something right.
Patrick
As of this writing, TechZe.us (http://techze.us) has 430 LoC (as above, not including template and library).
TechZeus on January 25, 2008 12:22 PM[Do'h. Stupid HTML stripper...]
Okay, I think I get it. This article is related to this one from last month:
http://www.codinghorror.com/blog/archives/001025.html
I don't think 37Signals set out to write a < 600 LOC program any more than Steve Yegge set out to write a > 500,000 LOC one.
But it's a useful feedback mechanism. If LOC count is growing constantly you're probably doing something wrong. If it's staying in the range of the size of a program you would write from scratch in a weekend you're probably doing something right.
Patrick
I think LoC is a really bad measurement of programming effort. Granted, its very tempting to say either "WOW!! Look at how many lines of code I put into this one project! Isn't that impressive!" or "Look at how few LoC I have, aren't I skilled at writing succinct code!". In reality, how impressive either a large or little number of LoC is depends greatly on exactly what you're program does and also which lines you are counting (only what you (you're team) wrote, the entire project, your project and all dependencies that u used, etc.). I think a better judge of at how well written a program is would be:
1. efficiency of the code (does it run well enough that all users never have to sit and with).
2. Size of program (how much space it takes up on the hard drive). Granted this is very subjective (i.e. a program that uses .NET framework 3 will be smaller than one that re-invents all the data structures it uses).
3. Usefulness. This is my most important point: how useful is the program to the user? Does it do everything they expect it to do without breaking, and is there anything a user could expect of it that it does not do?
Thats my 2 cents.
Mike on January 25, 2008 12:50 PMI wrote a solunar tables calculator that performs astronomical calculations to return sun rise/set/transit, moon rise/set/transit/underfoot times, moon phase, major and minor solunar periods and some other cool stuff. The php version fits in about 700 lines including commments. The c version fits in about 800 including comments.
Doug on January 25, 2008 2:14 PMMaking it a goal to limit an application to a specific number of lines of code is, by definition, a coding horror!
Josh Stodola on January 25, 2008 2:31 PMPlease consider pointing to software that can count "lines of code" for different languages esp. PHP
Kishore Balakrishnan on January 25, 2008 2:41 PMI remember when they used to have 1K programming contests. Your source code had to be 1K or less. Some people did some pretty creative things.
guess it sorta depends on what language your talking. 600 lines of assembly barely buys you anything. someday we're all gonna be out of a job because any monkey can build software by snapping legos together :-(
jminadeo on January 25, 2008 3:29 PMto be fair ive written quite a lot of lil apps here and there that do very useful things in under 600 lines of code - to be honest though, 600 is quite a lot and is a dependant and language and style
fusi on January 25, 2008 4:05 PM#include "masterlib.h"
int main(void)
{
/* some functions defined in "masterlib.h", dont forget to link it */
stop_the_wars_in_the_world();
find_cure_for_cancer();
end_poverty();
make_justice();
/* TODO: maybe call adjust_my_bank_account(); after these... */
return EXIT_SUCCESS;
}
Yeah, Ill have to pile on with the other Perl-heads. I have written a lot of programs with less than 500 lines of code. And many of them did more than just make a to-do list. Is't a to-do list kind of a CompSci 201 homework example?
But I do like their fancy-dancy fading highlight bars and super big Myopia fontface on that site.
Chubber on January 25, 2008 6:10 PMIn college a friend and I would have friendly competitions to see who could write a C program to accomplish some simple task in the fewest characters. We'd then get together and compare our results and work together or further winnowing the character count.
Here's one of our results:
main(){int a=256,i,p[a],k;for(i=0;i<a;p[i++]=1); for(i=2;i<a;i++)if(p[i]){printf("%d ",i); for(k=i*2;k<a;k+=i)p[k]=0;}}
I don't recall what this does. But I invite anyone to compile it and give it a whirl.
Hmm.. I could easily build a bot in python that writes Jeff Atwood blog articles very convincingly. Oh wait--six *hundred* lines? Well! I guess I could build ten bots!
from random import choice
article = ''
while len(article) < 1000:
article += choice(choice(randomDevBlogQuotes()),choice(randomImages()),choice(linksToMyOwnArticles))
The task list in OfficeZilla.com with group sharing (private and shared tasks), add, edit, delete with a little sloppy code duplication (need to get in and make it nice) plus html is 729 lines. I have not updated it in several years now, not sure what these guys are getting so excited about there 600 lines. It just isn't a big deal.
George SCott on January 25, 2008 8:50 PMNo program stays at 600 lines.
The requirements are increasing, you have to add feature after feature to stay competitive.
And after a long time of growth of the feature-list, another company starts with an nearly featureless 600-lines programm, "which is so easy to use". And the circle starts from the beginning.
Add:
A simple account-withdrawal-method has more than 600 lines. Simpler solutions are exactly that: Simple, but simple-minded.
The world is complex out there, if you want to target reality, you have to consider some more things.
Great software only looks simple from the outside. To count lines for measuring quality was never a good idea for itself.
600 lines in Ruby must have like 60 lines of end's. So I guess it'd be 540 lines in Python.
x386 on January 25, 2008 11:04 PM600 lines to make a co-operative todo list? I only used 300 in php (html and everything). It is a bit of a mess, but it works for what it was made for.
(of course there is a sql class and a user class to control things, but since that stuff wasn't counted in the ruby entry, I'm not counting it in here either)
Thomas Winsnes on January 25, 2008 11:48 PMWith Oracle Application Express (http://apex.oracle.com) you can build applications similar to Tadalist with ZERO lines of code...
OraDude on January 25, 2008 11:55 PMI think I've only written one item that was more than 600 lines (most are under 300). Granted, I'm mostly writing quick apps in PHP or bash scripts, but they've saved hundreds of hours of production time in my company over the last few years. The most is 260 lines of PHP that took less than a day to write and cut a 200-hour task down to 50 hours.
The one app I wrote that was over 600 lines? 5000 lines. A full-featured scheduling database that tied into the company's business systems and provided reporting. And what happened to it? It was considered a "prototype" and the code handed to someone else to reconstruct.
In the time it took me to spec, write, and debug that "prototype" I probably could have saved the company a few thousand more hours.
Capri on January 26, 2008 6:29 AMI wrote something similar a couple of weeks ago: http://simpable.com/software/1000-loc/
I agree with some of the other comments that the world is complex, but I also think that too many developers worry about all the edge cases and potential options instead of focusing on the big picture.
Scott Watermasysk on January 26, 2008 8:07 AMAaron G - http://wiki.rubyonrails.org/rails/pages/OpenSourceProjects << A few of those are non-trivial.
"Fuck Ruby."
No, "Fuck RoR."
article += choice(choice(randomDevBlogQuotes()),choice(randomImages()),choice(linksToMyOwnArticles))
should probable be
article += choice([choice(randomDevBlogQuotes()),choice(randomImages()),choice(linksToMyOwnArticles)])
[ICR] on January 26, 2008 8:20 AMMarketing hype.
Since they own both the app and the framework, they can gerrymander the dividing line between them anywhere they want.
WilliamV on January 26, 2008 9:21 AMHi Jeff,
Does it have to be a commercial application?
Thanks,
Jay
Puhh, 600 lines is not really much. Last two apps I wrote were a small blog software (3000 LOC, far away from finished), and a library asset managment tool (12000 LOC), both web based... most reports I write at wor have more than 600 LOC...
derhans on January 26, 2008 3:31 PMThe NHaml view engine (now part of MVCContrib) scrapes in at 572 :-)
Andrew Peters on January 26, 2008 4:10 PM"they actually built the entire Rails framework first"
I believe that's actually false - Rails was extracted from Basecamp, and I *think* Basecamp came before Ta-Da List.
The philosophy of build the app first, then extract the framework was actually a point of ferocious contention when Rails first arrived. The whole argument against every other framework in the universe was due to the Rails opinion that building a framework first is putting the cart before the horse.
Giles Bowkett on January 26, 2008 6:16 PMThin, is one of the fastest ruby web server and is 687 LOC. It's also very flexible.
http://code.macournoyer.com/thin/
The trick is to use good libraries I think. Choosing the good ones is often the toughest part of a project.
macournoyer on January 26, 2008 8:01 PMA lot of my PHP/MySQL web page / database things clock in well below 600 LOC. I wrote a power attack calculator for D&D, that spits out graphs and everything, in about 600 LOC.
wkerney on January 27, 2008 2:12 AMWhy is 600 lines of code so impressive? For that matter, why do so many programmers concern themselves with raw metrics, without having something reasonably consistent to *compare* them to? Ignoring the debate about whether or not this qualifies as "code", here's two lines of "code" from my DOS 5/Windows 3.11 (yes, they're still alive!) boot partition:
> @echo off
> win
Those two lines of code suddenly turn my computer into a GUI complete with useful (and not so useful) things like full applications, games, utilities, image editors, scientific calculators, etc. Much more than a simple collaborative "ToDo" app, and with 1/300th the "code." And, it's all done within the limits of old and severely out-dated 16-bit operating systems.
Point is, metrics like lines of code are skewed and useless. With most "modern" high level languages, you can do a *lot* with only a few lines of code by leveraging *millions* of lines of code you did *not* write. And that is not always a good thing, either; The underlying code may bloat your application with extra code to test for certain cases and conditions, handle more than one task, etc, that may not ever even exist within your own application.
But the code is still there. So your 600 lines of code could be 6 megs of disk space for the executables, libraries, and other support files, while my 12000 lines of code doing the same thing in another language could fit everything in under 1/2 a meg.
In conclusion, before the phrase "600 lines of code" impresses me, tell me two other related facts: 1. How much space does the final assembly (executables, libraries, and support files) take on disk? In RAM? And 2. If your competitors were to write a similar application, using the same languages and tools, would their number of lines of code be significantly different? What if they could do it in 400 lines of code, and still add features you did not?
Joe Hacker on January 27, 2008 3:24 AMEdoc wrote:
"The URL-Open Perl script posted above would be 4 or 5 lines of code."
Depends! You could write it all in one line, but then it might not be very readable. In some languages, it doesn't make sense to ask for less than 600 lines of code, if you don't specify, how long the lines may be.
I would write Samuli's example "urlopen" abose like this in REBOL:
delay: 2
last_clip: ""
forever [
if clip: find read clipboard:// "http://" [
clip: first parse clip none
if clip <> last_clip [
browse clip
last_clip: clip
]
]
wait delay
]
It works! Get REBOL and try it our yourself!
John Niclasen on January 27, 2008 4:00 AMMy Ruby OpenGL based logfile visualizer (glTail) came in at 608 LOC in version 0.01, but I think my initial working prototype was at ~300 lines.
I wrote my hAtom based blog[1] including all logic, templates, and styles in 161 lines of Ruby code[2] using Sinatra[3], a framework written in 120K.
[1]: http://journal.redflavor.com
[2]: http://redflavor.com/reprise.rb
[3]: http://sinatra.rubyforge.org
@buddydvd - I'm curious, what is the multi-million dollar rails app built in less than 2k LoC?
To the "LoC doesn't matter contingent" -- assuming perfectly readable & optimized code, does 600 lines of code vs 5,000 lines of code make a difference, if both do exactly the same thing?
How about 10k lines vs. 100k?
Do you really, honestly believe LoC does not make a difference whatsoever?
Even some of the most "complicated" Web 2.0 apps like Twitter will not have a high LoC in rails (python too, probably). I'd hazard to guess Twitter's LoC-count is less than 20k. 30k, absolute tops.
For 150+ model domain applications (i.e. where rails might not necessarily shine), sure you could be dealing with 50k+ LoC in rails. But then it'd probably be 150k+ LoC in Java. :) (not flaming, just speculation based on my own experience)
Shanti Braford on January 27, 2008 1:18 PMA group of vigilantes--calling themselves Anonymous, or Anon--are escalating their attacks against the Church of Scientology in what they consider to be Internet censorship by issuing new video challenges. In one video posted to YouTube, Anonymous addresses the many news organizations covering the war, stating that the group has been watching. While the individuals behind the effort generally support the coverage, they also severely fault the media.
"We find it interesting that you did not mention the other objections in your news reporting. The stifling and punishment of dissent within the totalitarian organization of Scientology. The numerous, alleged human rights violations. Such as the treatment and events that led to the deaths of victims of the cult such as Lisa McPherson.
This Cult is Nothing but a psychotically driven pyramid scheme.
Why are you, the news media, afraid of discussing these matters? It is your duty to report on these matters.You are failing in your duty."
Lisa McPherson was a member of the Flag Service Organization, a branch of the Church of Scientology, whose death in 1995 remains controversial. Although the Church of Scientology was initially held responsible, felony charges against it were dropped when the medical examiner ruled her death was an accident. A civil suit against the church by McPherson's parents was settled in 2004.
At one point in the video, Anonymous says, perhaps in response to its growing numbers of critics, "this is not religious persecution, but the suppression of a powerful, criminal fascist regime."
A request for comment from the Church of Scientology has not yet been answered.
A person wearing a motorcycle helmet addresses followers of Scientology in a second video.
On Friday, Anonymous also posted on YouTube a second YouTube video to the Church of Scientology, this time addressed to its many followers.
"Your religious beliefs are not wrong, like any other religion, and they are yours to keep. However beliefs should not come at a price. Not from your wallet or compromising your thoughts.
Those who have left feel a new life, a rebirth into true freedom. You can join them if you wish. You may not believe us. We ask of you one thing: Make up your own mind. That is a sentence of more profound meaning for you now than at any other time in your life."
Both videos continue a trend in using a computer-generated voice over stylized video. A Web site called Project Chanology continues to detail present and future actions by Anonymous and others.
Anonymous on January 27, 2008 10:11 PMMuch agreed with William V. and I'll QFT: "Marketing hype. Since they own both the app and the framework, they can gerrymander the dividing line between them anywhere they want."
Quite obvious to me as well which means it should be even more obvious to someone like Jeff. Maybe a lazy Friday post, who knows...
The LoC "my language is better than yours" debate rages on in the blogosphere with absolutely no relevance in the 9-5 world. I've worked on projects from Perl to ASP to C++ from a few thousand to a few million lines and not once did the discussion of LoC come up at the office.
Success of a technical project rarely relies on terse, tight code as it does a host of other variables - most completely non-technical in nature. If a worse Ruby programmer wrote it in 950 lines would his project be more or less successful? What if he had the idea a year earlier. See?
Rob S. on January 27, 2008 11:17 PMJohn Niclasen: You're exactly right.
I'd rather make a program to be ~20 lines of understandable code than 1-4 lines of crap.
Perl actually needs to be written quite verbosely for that code to be readable and easy/possible to maintain (and still this magical 600 LoC limit is enough for a lot of functionality).
I've personally already written enough Perl-programs that after few weeks I no longer have no idea what they do and how :)
Edoc: Although one *can* write Perl-programs in very little amount of lines, it doesn't mean that one *should*. Self-documenting style isn't always the shortest. And I think same goes for REBOL, although I have no REBOL experience.
Samuli on January 28, 2008 2:21 AMOf course the fewer lines code the better. But the code should not become unreadable nor unmaintainable, so shorter is not always better. Also it is not wise to shorten variable names into cryptic looking abbreviations.
Don on January 28, 2008 2:31 AMI wrote the prototype of ditaa (http://ditaa.sf.net) in Perl, and it was 563 lines of code. It was fully functional but not as feature-rich as the java version. In terms of external libraries, it only used the GD library for generating the actual image files. Code available on request ;-)
Stathis Sideris on January 28, 2008 4:54 AMI'm a cobol programmer, I can barely make it to the procedure division in under 600 lines....
Cory Alspach on January 28, 2008 5:44 AMWhy does LOC really matter if you abstract everything out into your framework?
You could adjust the question to:
Not counting re-usable code, what can you write in 600 LOC?
Tom von Schwerdtner on January 28, 2008 6:51 AMIt boggles the mind that *EVERYTIME* I visit this blog (at least once a week), 80% of the commenters *completely* miss the point of the post they're commenting on ! They rush to the bottom of the page to lecture Jeff about how *HE* doesn't understand the issues that he's writing about, ignoring those who write to endorse and/or expand on Jeff's perspective. That's not to say that I agree w/ his (Jeff's) conclusions/assertions/opinions every time, but as in the case of this blog entry, I *understand* what he's getting at: what's *your* favorite *little* programming gem, either one that you've personally written that you're proud of or one that someone else has written that's impressed you ?
The central point has *nothing* to do w/ the framework-of-the-week, Ruby, RoR, hi-level vs. lo-level libraries, your fav language vs. my fav language, the validity of LoC as a programming productivity metric, or frameworks-in-general.
BTW, keep up the good work, Jeff....
The Jetman on January 28, 2008 8:42 AM@Samuli @Niclasen
I agree. I'm also against the use of non-obvious coding styles.
Niclasen-- at the time of reading Samuli's Open-URL my quick prototype was:
bar: none
forever [
foo: trim read clipboard://
if all [foo <> bar "http://" = copy/part foo 7][browse to-URL foo]
bar: form foo
wait 2
]
Which is pretty close to yours.
Edoc on January 28, 2008 9:15 AM[walter brennan]
Dag nab it! You young whippersnappers don't know the meaning of code! When I was your age we didn't have no scroll bars, and no perl or Ruby-on-rails neither. We was real programmers!
[/walter brennan]
look at this super clean X11 implementation:
int main( )
{
system("startx");
}
mr_hugo on January 28, 2008 3:53 PM(1) Wow, my schoolmates (including Guy Steele) and I were proud of what we could accomplish in a FORTRAN IV subset on the high school's 8KB IBM 1130. Some of the commenters above accomplished much on far less.
(2) I commented on the post about Logo
( http://www.codinghorror.com/blog/archives/001026.html
DAKra on December 30, 2007 07:32 PM
) about functions I wrote to create 10 technical drawings for a project. That totaled 280 lines of logo, including blank lines between functions and some comments.
(3) re life in 200 lines: gumuz on January 24, 2008 08:38 PM above:
34 years ago, I did life in the 1130's FORTRAN IV subset. It was toroidal Life. It ran very slowly. I knew that the system handled 2D arrays much more slowly than 1D array, so I unrolled the m x m 2D array with its references to A(I,J+1) etc to references to a 1D array V(M*(I-1)+J+1), with the M*(I-1) calculated outside the inner loop. It ran 3 times as fast. That was about a page of code.
Later, I saw humor in the idea of running a cellular automaton in spreadsheet cells. I did it with circular reference formulae but without using macros, except to reset to your original pattern. It still works in the current Lotus 123, but not in Excel. See
http://www.angelfire.com/nj4/dakra137/Life/LIFEL1A.TXT
http://www.angelfire.com/nj4/dakra137/Life/LIFEL1A.WKS
http://www.angelfire.com/nj4/dakra137/Life/LIFEL1A.XLS
A 10 by 10 toroidal world has 200 formulae.
I guess that would be analogous to 200 lines of code.
Oh, I've written many things in less than 600 lines of code. That's about how much code you can fit in one LSL script anyway - after that you hit the 16k limit and have to break your code in two scripts. ;)
A pretty advanced LSL vehicle script has around 800 lines of code. Auto-updater much like Java Webstart can be done in 100-200 lines. My current project, which flies you to the skybox it creates somewhere in the sky, scanning objects in the vicinity to ensure you're alone, has some 500 lines broken in 5 scripts. My other project, HUD display fetching some stats from the web and other sources, and doing some calculations, has around 450 lines.
A lot of fun for a programmer in Second Life. ;)
Domchi on January 29, 2008 12:47 AMTrouble is, as a few have pointed out, frameworks, libraries, etc. account for so much of the bloat that "600 lines or less" begs the question, "Of what?"
I did put together a little Amazon Web Service, designed to accompany mobile phones (and which is available on my site, via the link below), in under 200 lines -- but again, so much underlying stuff's powering it (.NET Web Services, Amazon Web Services, the .NET Framework, etc.) that it doesn't seem quite fair to say it's "only 173 lines long." All told, it's probably using several hundred thousand lines.
But at least I didn't have to write them!
Chris Nunciato on January 29, 2008 11:25 AMhttp://noise.youchill.com/?p=14
220 lines of ESP2 DSP assembler code that forms a fully functional realtime 24 bit/44Khz stereo audio pitch shifter. It is an emulation of the popular Eventide Harmonizer, authored by MAA in 1996. It shipped as one of the stock algorithms on the Ensoniq DP/PRO Digital processor.
If no fancy user interface is required, 600 codes were enough to make your program do many things, but if you are expecting something that will interract with a user and do custom actions, then I don't think 600 will do anything smart enough to be considered as something useful.
Holy shit, its Beef Supreme! Is this whole post a complete joke? How cannot be!
Throwspoop on January 31, 2008 11:22 PM600? Hah! How about Tetris in 50? (Click my name for the link).
Sjoerd Verweij on February 1, 2008 3:05 PMI just finished a multithreaded, all-purpose, I/O blocking server daemon in Lisp that runs essentially as a state machine -- the idea was to just be able to hand it a set of commands and a port and let it go.
Just under 300 lines. Doesn't need any external libraries except for trivial-gray-streams. Flexi-streams if you need 'em.
In line with the efficiency->utility theme of this post: it has a lot of uses -- for me, anyway. Fr' example, now I can implement a server for most any protocol just by writing up the relevant commands and then passing them to the module. Need new features? Add 'em to the list!
Basically, it's a way for me never to have to deal with sockets again.
Adam on February 2, 2008 12:53 AMPlease, the fact that you can throw a whole application in a library much less a framework so the question becomes how big are the extras are? The post seemed like a filler for me... had some really good posts earlier ... like the non-open Apple blog. Tried to read everyone no matter what!!!
Jim on February 5, 2008 8:19 AMIt's too difficult to write something without using any other library. As Jeff said "a simple line of code number isn't the entire story", I think we can limit the lines of function, class, library, etc...
Catherine Sea on February 15, 2008 6:18 PMi wrote this http://www.sfaturiculinare.ro in about 1000 lines, with user profile and all that. but with the framework behind ... well ... it's just not the same
mad on February 27, 2008 3:49 AMIsn't ROR a framework and not a programming language?
I'm pretty sure that the rails framework has several thousand, of not tens of thousands of lines of code. You have to have that code for it to work at all.
Jestep on March 7, 2008 2:25 PMI built http://puzzelation.com using 233 lines of Perl, and the modules CGI, DBI, HTML::Template, List::Util and HTML::Entities - but I'm sure all told that comes out to over 600 lines.
Luke on March 7, 2008 8:09 PMI wrote an app that I use frequently. It stores my userid and password information for varous sites in an encrypted format. In order to use the program you have to use a visual login - hit four points, within ten pixels, in proper order. If successful the data is displayed unencrypted. The login can be changed, items may be added or deleted from the list, etc. All this in 207 lines of VB .NET.
kj on April 7, 2008 12:02 PMSweet!
Ginger LaBelle-Brown on April 16, 2008 10:08 PMComon man, i think i dont even remember if i wrote an email less than 600 lines lately.
Nawaz Ali on May 30, 2008 2:37 AMI don't think it's relevant what you can do with x number of lines.
All it says is that the more you can do, the more someone did the work for you before.
Did I forgot to say that I don't like frameworks. Sorry.
janedoe on June 9, 2008 9:15 PMI wrote a Mandelbrot set plotter using C++ and OpenGL in 350 lines. It can make pretty pictures.
Troxy18 on August 22, 2008 8:08 PM1st stage bootloader for FAT-formatted disks. Less than 450 lines of asm.
Anonymous on September 22, 2008 2:27 AMSpanish verb conjugator in Perl in about 6000 LOC.
Mito on September 22, 2008 2:30 AMOops, 600 LOC, not 6000 LOC for the conjugator.
Mito on September 22, 2008 2:31 AM1st stage hootloader for FAT-formatted disks is actually 189 lines of 8086 asm.
John Metcalf on September 30, 2008 11:38 AMimport gen
gen()
Graphical random number generator program in 2 lines of python. Think you need to be a bit more specific about the whole >600 thing.
Mute on October 19, 2008 5:38 PMscrapper bot and find-sale logic for atgaragesale.com have less than 600 lines of code. site is functional with those only, but index and post-sale logic could probably be reduced to fit into that number too.
there is a database with lots of zip/cities data (40k+ rows). does that count? :)
lazar on March 19, 2009 8:15 AM| Content (c) 2009 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved. |