Author Topic: How many lines of code does it take to change a lightbulb?  (Read 7449 times)

zybork

  • Posts: 400
  • Turrets: +68/-72
How many lines of code does it take to change a lightbulb?
« on: August 22, 2010, 06:47:24 pm »
I guess you all know that “what does it take to change a lightbulb”-thought experiment, used to characterize how a trivial task is to be done. Here is the same for programming languages, how many lines of code of a certain programming language does it take to “change a lightbulb”?

How many lines of code does it take to change a lightbulb?

%

How many lines of C does it take to change a lightbulb?

Many. It'll also take some time to write and debug the code, but once you're done, the program will run really really fast.

%

How many lines of C++ does it take to change a lightbulb?

A few less than you would need in plain C, also the binary will have double the size and half the speed while executing, *but* you can use objects in C++, which you do not have in C.

%

How many lines of PERL does it take to change a lightbulb?

Maybe only one or two, but if you want to be able to understand what you've written ever again, better use twenty, or fifteen, or twentyfive, for there is more than one way to do it.

%

How many lines of Python does it take to change a lightbulb?

Including the usual comments, ten. Always. Everywhere. No matter if you want it or not.

%

How many lines of a natural language does it take to change a lightbulb?

You don't need just lines, you need a book - a manual. That's why they invented machines, computers and programming languages in the first place.

%

How many lines of Java does it take to change a lightbulb?

This is not the question, the question is: How much memory will the code consume after you've had the application up and running for a few minutes.

%

How many lines of HTML does it take to change a lightbulb?

You can't solve this problem with HTML, for HTML is static, so it is not possible to change anything. Instead use PHP or Javascript or CGI or PSP or ASP or Java or ...

%

How many lines of PHP does it take to change a lightbulb?

Besides that you will have to set up a web-server with mod_php and databases, not so many at first. After some bugfixes and rewrites to make the code cleaner, who can tell...?

%

How many lines of Javascript does it take to change a lightbulb?

Hm, this depends on which browser you want to use to run your code in, but listen to my advice and better include your favourite 200K-library to do it, or else you will go crazy making that stuff crossbrowser.

%

How many lines of FORTRAN does it take to change a lightbulb?

I don't know, ask that guy from the other department who is to retire next week, maybe he knows.

%

How many lines of Assembler does it take to change a lightbulb?

A lot, and some time develop the procedure. But the change afterwards is lighteningly fast and the lightbulb fits perfectly. Of course, if you change the lightbulb to a different brand, you have to redo the procedure completely from scratch.

%

How many lines of Pascal does it take to change a lightbulb?

Many, and you will have to do a lot of additional typing for the language is very verbose *but* the code, once finished, will be great for learners to understand the algorithm of changing lightbulbs, for Pascal is used for teaching purposes and not for any real work.

%

How many lines of Brainfuck does it take to change a lightbulb?

Isn't the question rather, how many angels can dance on a needle's tip?

%

How many lines of Postscript does it take to change a lightbulb?

A lot and it will be a pain in the ass to do it, but that's not the point, the point is that I guess you didn't even know Postscript is a real programming language you can write real code in, did you?

%

How many lines of Visual Basic does it take to change a lightbulb?

You do not write, you drag, drop and click - you will have to enter a few words of code from time to time tough. However, if you're done with your code, it will only run on one platform which means that you will need to install a few gigabytes for the operating system and then again 200 megabytes for the framework Visual Basic requires to run, but isn't it great that you can see the blinken lights?

%

How many lines in a Unix-shell does it take to change a lightbulb?

Maybe only one, this is, the one to call the binary that does the actual change, which of course implies that you need to have that binary installed.

%

How many lines of the ideal programming language does it take to change a lightbulb?

None. In an ideal programming language, lightbulbs do not break. Too bad we're talking only theory here.
« Last Edit: August 22, 2010, 08:57:55 pm by zybork »
I have retired from Tremulous. Definetely. If you play a game just because it has become a habit, but u'r only feeling like a kindergarten teacher - well, maybe I am just getting too old (hell, I was a teenager when DukeNukem3D was *new*) - it's probably not a bad idea to just let it be. And I do.

Don't take this personally. Have fun, guys.

superspirality

  • Guest
Re: How many lines of code does it take to change a lightbulb?
« Reply #1 on: August 22, 2010, 08:17:27 pm »
Hah, nice one. ;)

Crava_Loft

  • Guest
Re: How many lines of code does it take to change a lightbulb?
« Reply #2 on: August 22, 2010, 11:52:27 pm »
you wouldn't change a lightbulb by coding

Demolution

  • Posts: 1198
  • Turrets: +157/-64
Re: How many lines of code does it take to change a lightbulb?
« Reply #3 on: August 23, 2010, 01:26:09 am »
you wouldn't change a lightbulb by coding

You wouldn't even try!

Clan [AC] - For all your air conditioning needs please visit: http://s1.zetaboards.com/AC_NoS/index/
my brain > your brain.
and i am VERY stupid.

SlackerLinux

  • Spam Killer
  • *
  • Posts: 555
  • Turrets: +41/-62
Re: How many lines of code does it take to change a lightbulb?
« Reply #4 on: August 23, 2010, 03:33:24 am »
Code: [Select]
HAI
CAN HAS STDIO?
CAN HAS LIGHTBULB?
I HAS A OLDLIGHTBULB
BTW Unscrewing Lightbulb
IM IN YR LOOP
UNSCREWLIGHT OLDLIGHTBULB
IZ LIGHTBULBCONNECTED LIEK FALSE
  YARLY
    KTHX
IM OUTTA YR LOOP
I HAS A LIGHTBULB
BTW screwing Lightbulb
IM IN YR LOOP
SCREWLIGHT LIGHTBULB
IZ LIGHTBULBCONNECTED LIEK TRUE
  YARLY
    KTHX
IM OUTTA YR LOOP
U SEEZ "Lightbulb Replaced!!11!!"
KTHXBYE

LOLCODE Example prob room for improvements(like no loops and assume that screwlight does it till its out/in)
« Last Edit: August 23, 2010, 03:38:59 am by SlackerLinux »
Slackware64 13.1
SlackersQVM/

Jack Bauer

  • Posts: 200
  • Turrets: +6/-10
Re: How many lines of code does it take to change a lightbulb?
« Reply #5 on: August 23, 2010, 05:33:15 am »
Code: [Select]
HAI
CAN HAS STDIO?
CAN HAS LIGHTBULB?
I HAS A OLDLIGHTBULB
BTW Unscrewing Lightbulb
IM IN YR LOOP
UNSCREWLIGHT OLDLIGHTBULB
IZ LIGHTBULBCONNECTED LIEK FALSE
  YARLY
    KTHX
IM OUTTA YR LOOP
I HAS A LIGHTBULB
BTW screwing Lightbulb
IM IN YR LOOP
SCREWLIGHT LIGHTBULB
IZ LIGHTBULBCONNECTED LIEK TRUE
  YARLY
    KTHX
IM OUTTA YR LOOP
U SEEZ "Lightbulb Replaced!!11!!"
KTHXBYE

LOLCODE Example prob room for improvements(like no loops and assume that screwlight does it till its out/in)
Isnt that Ruby?
"Las guns are a woman's weapon. That's why they're called 'Las' guns!"
"In My Opinion", eg "IMO you should have googled it instead of asking"

Aelita

  • Posts: 742
  • Turrets: +147/-34
Re: How many lines of code does it take to change a lightbulb?
« Reply #6 on: August 23, 2010, 01:39:30 pm »
Ruby is far worse.

superspirality

  • Guest
Re: How many lines of code does it take to change a lightbulb?
« Reply #7 on: August 24, 2010, 02:20:48 pm »

zybork

  • Posts: 400
  • Turrets: +68/-72
Re: How many lines of code does it take to change a lightbulb?
« Reply #8 on: August 24, 2010, 05:31:30 pm »
Reminds me, I don't have Ruby in my list. How many lines of Ruby would it take to change a lightbuild, and why? Is it really only an “improved perl”?
I have retired from Tremulous. Definetely. If you play a game just because it has become a habit, but u'r only feeling like a kindergarten teacher - well, maybe I am just getting too old (hell, I was a teenager when DukeNukem3D was *new*) - it's probably not a bad idea to just let it be. And I do.

Don't take this personally. Have fun, guys.

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: How many lines of code does it take to change a lightbulb?
« Reply #9 on: August 24, 2010, 05:36:12 pm »
How many lines of Haskell does it take to change a lightbulb ?

You cannot change the lightbulb, you must create a new world with a different lightbulb in it.

Aelita

  • Posts: 742
  • Turrets: +147/-34
Re: How many lines of code does it take to change a lightbulb?
« Reply #10 on: August 24, 2010, 06:23:40 pm »
Reminds me, I don't have Ruby in my list. How many lines of Ruby would it take to change a lightbuild, and why? Is it really only an “improved perl”?

It's more like a bastardized perl clone with downs.

Jack Bauer

  • Posts: 200
  • Turrets: +6/-10
Re: How many lines of code does it take to change a lightbulb?
« Reply #11 on: August 24, 2010, 06:55:29 pm »
Reminds me, I don't have Ruby in my list. How many lines of Ruby would it take to change a lightbuild, and why? Is it really only an “improved perl”?

It's more like a bastardized perl clone with downs.
Just added a new word to my vocabulary.
"Las guns are a woman's weapon. That's why they're called 'Las' guns!"
"In My Opinion", eg "IMO you should have googled it instead of asking"

CreatureofHell

  • Posts: 2422
  • Turrets: +430/-126
    • Tremtopia
Re: How many lines of code does it take to change a lightbulb?
« Reply #12 on: August 24, 2010, 10:22:14 pm »
Reminds me, I don't have Ruby in my list. How many lines of Ruby would it take to change a lightbuild, and why? Is it really only an “improved perl”?

It's more like a bastardized perl clone with downs.
Just added a new word to my vocabulary.

That's what these forums are for.  ::)
{NoS}StalKer
Quote
<Timbo> posting on the trem forums rarely results in anything good

zybork

  • Posts: 400
  • Turrets: +68/-72
Re: How many lines of code does it take to change a lightbulb?
« Reply #13 on: August 25, 2010, 12:19:16 am »
How many lines of Haskell does it take to change a lightbulb ?

You cannot change the lightbulb, you must create a new world with a different lightbulb in it.


 :D

Thanks for this one  :)  Officially implemented in my list :)
I have retired from Tremulous. Definetely. If you play a game just because it has become a habit, but u'r only feeling like a kindergarten teacher - well, maybe I am just getting too old (hell, I was a teenager when DukeNukem3D was *new*) - it's probably not a bad idea to just let it be. And I do.

Don't take this personally. Have fun, guys.

Samurai.mac

  • Posts: 317
  • Turrets: +18/-17
Re: How many lines of code does it take to change a lightbulb?
« Reply #14 on: August 26, 2010, 10:48:33 pm »
Code: [Select]
void main()
{
       int lightSocket;
       int bulbBlown;
       int lightBulb[2];
       lightBulb[0] = old;
       lightBulb[1] = new;

       if (bulbBlown == 1)
       {
              lightSocket = lightBulb[0];
       }
       else
       {
              lightSocket = lightBulb[1];
       }

       if (lightSocket == lightBulb[0]
       {
              lightSocket = lightBulb[1];
       }
}