How can to achieve lots of code?
Damien Katz - Damien Katz - October 29, 2012I get mail.
hello damien
I read about you from a book on erlang.
Your couchdb application is really a rave.
please can you help me out ,i’ve got questions only a working programmer can answer.
i’m shooting now:
i’ve been programming in java for over 3 years
i know all about the syntax and so on but recently i ran a code counter on my apps and
the code sizes were dismal. 2-3kcommercial popular apps have code sizes in the 100 of thousands.
so tell me- for you and what you know of other developers how long does it take to write those large applications ( i.e over 30k lines of code)
what does it take to write large applications - i.e move from the small code size to really large code sizes?
thank you.
Never try to make your project big. Functionality is an asset, code is a liability. What does that mean? I love this Bill Gates quote:
Measuring programming progress by lines of code is like measuring aircraft building progress by weight.
More code than necessary will bloat your app binaries, causing larger downloads and more disk space, use more memory, and slow down execution with more frequent cache misses. It can make it harder to understand, harder to debug, and will typically have more flaws.
CouchDB, when we hit 1.0, was less than 20k lines of production code, not including dependencies. This included a storage engine (crash tolerant, highly concurrent MVCC with pauseless compactor), language agnostic map/reduce materialized indexing engine (also crash tolerant highly concurrent MVCC with pauseless compactor), master/master replication with conflict management, HTTP API with security model, and simple JS application server.
The small size is partly because it was written in Erlang, which generally requires 1/5 or less code of the equivalent in C or C++, and also because the original codebase was mostly written by one person (me), giving the design a level of coherency and simplicity that is harder to accomplish—but still very possible—in teams.
Test are different. Lines of code are more of an asset in tests. More tests (generally) means more reliable production code, helps document code functionality that can’t get out of sync the way comments and design docs can (which is worse than no documentation) and doesn’t slow down or bloat the compiled output. There are caveats to this, but generally more code in tests is a good thing.
Also you can go overboard with trying to make code short (CouchDB has some WTFs from terseness that are my fault). But generally you should try to make code compact and modular, with clear variable and function names. Early code should be verbose enough to be understandable by those who will work on it, and no more. You should never strive for lots of code, instead you want reliable, understandable, easily modifiable code. Sometimes that requires a lot of code. And sometimes—often for performance reasons—the code must be hard to understand to accomplish the project goals.
But often with careful thought and planning, you can make simple, elegant, efficient, high quality code that is easy to understand. That should be your goal.
Categories: Blogs Damien Katz
Erlang on Twitter
» kirikaza (Kirikaza): RT @LogaRhythm: “If you don’t perform experiments before designing a new system, your entire new system will be an experiment” Mike William…
» digitalBush (Josh Bush): Lost a couple of hours figuring this one out “erl -pa ebin” needs to be “erl -pa ../{app}/ebin” if you want code:priv_dir/1 to work. #erlang
» buzzamzn (アマゾンに関する情報を発信中♪): 楽天市場:Learn You Some Erlang for Great Good!-【電子ブック版】 http://t.co/Ot4LPkbgw7 #amazon #アマゾン #相互フォロー
» rvalyi (Raphaël Valyi): @matrixise j’avais bidouillé un peu de Erlang récemment, pas trop mon truc, mais là avec la Syntaxe de Ruby/team Plataformatec, ça motive…
» imarshut (MarsHut): #Calling #Ruby #Functions http://t.co/79x1tBhoc9 ErlPort (library to connect Erlang to Ruby) 1.0.0alpha released
» fogelmania (Raphael Fogel): Alexander Fok, System Architect @ooVoo will have a talk at the #Erlang track of #DevconTLV http://t.co/GRA0Q2zny7 Welcone to TLV, Alexander!
» robertoaloi (Roberto Aloi): @mariofusco Wouldn’t it be simpler switching to #erlang? ;-)
» guillaumepotier (Guillaume POTIER): @francois2metz du coup tu vas recruter une armée de full stack ? Tu ne veux pas qques spécialistes Erlang ?
» oker1 (Zsolt Takács): Mochi Labs - statebox, an eventually consistent data model for Erlang (and Riak) http://t.co/tWhlCDGtBz
» HumphreyStamper (Humphrey Stamper): Wage reduction the trim erlang only http://t.co/6qTcEyl3Sk tactician in contemplation of organism leap http://t.co/1CWvIAjBNU
Statistics
Number of aggregated posts: 10658
Most recent article: June 13, 2013
Latest comments
» Moraru on This is Why You Spent All that Time Learning to Program: It is true that computer science was a pain in the back at time that i’ve had to learn it…
» Commercial hand dryers on Couchbase Meetup at new HQ: Buy online from here where you will get so much of variety in Commercial hand dryers for people. If you…
» Fort McMurray Homes on Motivated Reasoning and Erlang vs Python vs Node: I don’t really understand why this post is motivational? I don’t even see a post, just a title. Fort McMurray…