Slashdot Mirror


Simpler "Hello World" Demonstrated In C

An anonymous reader writes "Wondering where all that bloat comes from, causing even the classic 'Hello world' to weigh in at 11 KB? An MIT programmer decided to make a Linux C program so simple, she could explain every byte of the assembly. She found that gcc was including libc even when you don't ask for it. The blog shows how to compile a much simpler 'Hello world,' using no libraries at all. This takes me back to the days of programming bare-metal on DOS!"

33 of 582 comments (clear)

  1. Missing the point by textstring · · Score: 5, Funny

    Interesting, but she does sort of sidestep the whole 'Hello World!' part of a hello world program.

    1. Re:Missing the point by Anonymous Coward · · Score: 1, Funny

      I once tried to make the elf my bitch. The GM (and oddly other players weren't too amused.

  2. Re:Hello World by Megaweapon · · Score: 5, Funny

    FYI, Steve Jobs came up with the idea for the "Hello World" app.

    He also holds the design patent on the touch wheel interface for it.

    --
    I'm sure "SlashdotMedia" will improve on all the wonders that Dice Holdings blessed us all with
  3. I can code that app in... by putaro · · Score: 5, Funny

    45 bytes, huh? I can do it in....

    #!/bin/sh
    exit 42

    18 bytes and it's portable across all Unices. Maybe the assembler version is faster, though?

    1. Re:I can code that app in... by larry+bagina · · Score: 4, Funny

      White pythons are generally 5-8 inches. It's a popular misconception that blacks have larger pythons. In reality, the average black python is slightly smaller than the average white python, but there's much more size variation. Asian pythons are smaller. And then there are some unfortunate guys with a micro python thats only 1-2 inches.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

  4. YES!!!! FINALLY by commodoresloat · · Score: 5, Funny

    Thank God we have finally crossed this hurdle. The baffling complexity of helloworld.c is no longer an obstacle to world domination.

    I think we can now finally say once and for all that 2010 will be the year of Linux on the desktop.

    1. Re:YES!!!! FINALLY by Anonymous Coward · · Score: 1, Funny

      No it won't. Do not be foolishly optimistic. Until videogames are readily available on Linux (and I mean commercial games like Call of Duty), no general consumer would be compelled to use Linux on Desktop (may not apply for netbooks).

    2. Re:YES!!!! FINALLY by Aphoxema · · Score: 2, Funny

      Thank God we have finally crossed this hurdle. The baffling complexity of helloworld.c is no longer an obstacle to world domination.

      I think we can now finally say once and for all that 2010 will be the year of Linux on the desktop.

      No it won't. Do not be foolishly optimistic. Until videogames are readily available on Linux (and I mean commercial games like Call of Duty), no general consumer would be compelled to use Linux on Desktop (may not apply for netbooks).

      *sigh*

      --
      "Most people, I think, don't even know what a rootkit is, so why should they care about it?"
  5. Stoner code. by geekmux · · Score: 3, Funny

    OK, when I first read this, I thought to myself, "now why in the hell would anyone care to do this?"

    Then it dawned on me. One stoned programmer said to another....Yeah, that's probably how it went down. Both now, and back in 1979, when you could still smoke in the Data Center...

  6. any torrent links? by SethJohnson · · Score: 1, Funny

    Waiting for someone to crack this new hello world code and post it on bittorrent. Any links appreciated.

    Seth

  7. Sell your Seagate shares *now* ... by Anonymous Coward · · Score: 1, Funny

    ... and pile up on 64x8 TTL Proms!

  8. Re:Hello World by thegrassyknowl · · Score: 5, Funny

    No Steve Jobs designed "iHello World", which is actually one byte larger than the standard hello world app, but he's litigating against everyone who creates "Hello World" since 100% of it is quite obviously a subset of "iHello World".

    --
    I drink to make other people interesting!
  9. Re:Hello World by Anonymous Coward · · Score: 1, Funny

    FYI, Steve Jobs came up with the idea for the "Hello World" app.

    He also holds the design patent on the touch wheel interface for it.

    His was a variant that was tradmarkable. "iHello iWorld". Sadly it being an executable file means it to won't run on an iphone.

  10. Re:11k Is Too Big? by VocationalZero · · Score: 2, Funny

    It's just a 20th-century digital processing appliance.

    Mine is a 21st-century appliance, thank you very much!

  11. Re:11k Is Too Big? by Zouden · · Score: 4, Funny

    Get away from the idea of Gigahertz desktops and $1000 laptops and join the real computer revolution!

    You're right! I'm going to throw my laptop out the windows right now! Reading slashdot will be so much more fun on a computer smaller than a sunflower seed.

    --
    "A week in the lab saves an hour in the library"
  12. That's exactly it by Anonymous Coward · · Score: 4, Funny

    Guy reminds me of an old joke.

    What's the difference between a bitch and a whore?

    A whore fucks everyone. A bitch fucks everyone but you.

  13. Let the lawn derby begin by ClosedSource · · Score: 3, Funny

    One of the earliest processors I used had only 256 bits of RAM (Yes, that's right 256 B I T S of memory)

  14. Re:BTDT by Anonymous Coward · · Score: 1, Funny

    Why do you hate women so much? Is it out of self loathing that you had to become one?

  15. Re:11k Is Too Big? by Anonymous Coward · · Score: 1, Funny

    Hahaha, wtf? That was actually an apt car analogy.

    Now, get off my lawn!

  16. Re:Old news is VERY OLD by Anonymous Coward · · Score: 1, Funny

    That's just the Lords of Cobol being pissed that the Lords of Fortran did it first.

  17. Re:Not a C program by Anonymous Coward · · Score: 1, Funny

    Step four, leave out step four to save time.

  18. Re:BTDT by guyminuslife · · Score: 5, Funny

    The fact that people would even still use C at all for anything anywhere ever shocks me.

    I started writing device drivers in Ruby, and have never looked back.

    In order to get Ruby to run on my system, I run it in an interpreter. The interpreter is written in Java, which is a much faster language and therefore more suitable as an interpreter.

    The JVM on my system is written in C#. I know that C# is comparable to Java in terms of efficiency, but since this is a Windows machine, I figure it's "closer to the metal."

    The implementation of the .NET framework on my computer (and the Windows operating system itself) is written in Ruby. Since I already have a Ruby interpreter on my system, this presents no problems.

    --
    I don't believe in time. It's a grand conspiracy designed to sell watches.
  19. Re:BTDT by guyminuslife · · Score: 2, Funny

    I remember those. We used to have to carry them around in the snow, uphill both ways. ;-)

    --
    I don't believe in time. It's a grand conspiracy designed to sell watches.
  20. Re:11k Is Too Big? by mwvdlee · · Score: 2, Funny

    Indeed.
    At 11kB each, my 1TB harddrive would only fit some 97 million programs.

    --
    Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
  21. And so he should! by TheVelvetFlamebait · · Score: 2, Funny

    "Hello World" uses over 90% of his "iHello World" work. You would be hard pressed to make a fair use argument here. ;-)

    --
    You know, there is a difference between trolling and pointing out the flaws in your reasoning. Just saying.
  22. Re:Old news is VERY OLD by ta+bu+shi+da+yu · · Score: 2, Funny

    ... and I read it in 2002. On slashdot.

    --
    XML is like violence. If it doesn't solve the problem, use more.
  23. Re:11k Is Too Big? by tomtomtom777 · · Score: 2, Funny

    One of the earliest machines I learned programming on only had 256 bytes of memory.

    You lucky bastard.

    My parents could never afford such computer. I had to learn programming on a computer with only 1 bit of memory (Yes that's right: 1 B I T of memory!)

    Those were the days. And you tell the kids these stories and they won't believe you...

  24. Re:11k Is Too Big? by Tim+C · · Score: 4, Funny

    My God, are you saying that people should use the right tools and techniques for the job at hand, rather than applying the same limited ones to every problem they come across?

  25. Re:BTDT by dzfoo · · Score: 4, Funny

    I have a suggestion: If you write your JVM in Visual Basic instead of C#, it'll be portable, since most old microcomputers included BASIC in ROM. And, of course, .NET already brings Visual Basic.NET!

          -dZ.

    --
    Carol vs. Ghost
    ...Can you save Christmas?
  26. Re:11k Is Too Big? by fyngyrz · · Score: 2, Funny

    Now, get off my lawn!

    ...he can't, he didn't include libc. The thing won't actually move, it just runs. :)

    --
    I've fallen off your lawn, and I can't get up.
  27. Re:29 bytes ! Beat that !!! by Anonymous Coward · · Score: 2, Funny

    But you're including that bloated library DOS. Much better to bypass all that cruft and just use the hardware directly. Also, why write the whole string. The user will just have to know that 'h' stands for hello world. It's a training issue!

    mov ax,0b800h
    mov ds,ax
    xor di,di
    mov byte ptr[di],'h'
    ret

  28. Re:How about 28 bytes?! by Anonymous Coward · · Score: 2, Funny

    Why did you put it in your porn folder?

  29. Re:11k Is Too Big? by Alari · · Score: 2, Funny

    Nope! Now, hand me that pickaxe, I need to dig myself a memory upgrade.

    http://df.magmawiki.com/index.php/Computing

    --
    I use Windows... like a two dollar wh.. why don't I just go ahead and not finish that sentence.