This post is the result of reading through and following the LOLCODE Specification 1.2 ("smoking the manual", right?), and writing and executing my code on

My "hello world" was going to be a . I like it because it nicely illustrates the basics of a language - variables, operators, looping, conditionals, and the likes.

As far as naming goes, the specification allows for a wide variety, so I decided to go PascalCase all the way, so as to ease up the reading a bit - otherwise the language is a bit harsh on the eyes, to say the least.

I'm curious about how idiomatic my code is - this is my very first and probably last program. Did I overlook language constructs that would help readability? How's naming? Indentation? Any issues?

HAI 1.2

    I HAS A Fizz ITZ 3
    I HAS A Buzz ITZ 5

    IM IN YR FrootLoopz UPPIN YR Frootz TIL BOTH SAEM Frootz AN 100 
      BTW Frootz runs 0 through 99

      I HAS A Froot ITZ SUM OF Frootz AN 1
        BTW Froot will run 1 through 100

      O RLY?
        YA RLY
          Froot R "FizzBuzz"
        NO WAI
          BOTH SAEM 0 AN MOD OF Froot AN Fizz
          O RLY?
            YA RLY
              Froot R "Fizz"
            NO WAI
              BOTH SAEM 0 AN MOD OF Froot AN Buzz
              O RLY?
                YA RLY
                  Froot R "Buzz"

      VISIBLE Froot

    IM OUTTA YR FrootLoopz


  • 46
    I was expecting CHEEZE and BURGER, not FizzBuzz. – h.j.k. Aug 29 '14 at 6:01
  • 30
    A serious code review about code written in a joke language? And asking about the idiomaticity of said code? Sometimes I wonder about this place. – fluffy Aug 30 '14 at 3:17
  • 4
    @fluffy I'm starting to wonder too, and we have a meta question about the matter. – Simon Forsberg Aug 30 '14 at 20:05
up vote 61 down vote accepted

I like how you have declared the Fizz and Buzz 'constants'. It makes the code more readable.

The comments are useful too, though, for consistency, the second comment should be changed from:

BTW Froot will run 1 through 100


BTW Froot runs 1 through 100

The idea of generating Froot from Frootz is also good, because it reduces the computations later in the code.

I only wish you used a better name than Frootz because it conflicts with Froot. The similarity is.... uncanny.

I would suggest the name Loopz:

I HAS A Loopz ITZ SUM OF Frootz AN 1

This will reduce the ambiguity, and improve the readability and maintainability.

Finally, it is good that you put the Fizz modulo check before the Buzz check because that improves performance. Many people put buzz first, but that means the modulo-5 check happens, and that fails more often than the modulo-3 check, so people who do the Buzz-loop first tend to do about 20% more conditional checks.

All in all, for a first go, I am very impressed with your result. I can't wait until you implement a interpreter in . Till then!

  • 18
    It is oddly appropriate for you to answer this question given your name. – user22048 Aug 29 '14 at 23:02
  • 3
    Tough decision here, I'm giving you the checkmark on this one.. but I'm surprised nobody mentioned that I'm doing 3*5 at every iteration, could have used a I HAS A FizzBuzz ITZ PRODUKT OF Fizz AN Buzz outside the loop. – Mathieu Guindon Aug 30 '14 at 13:15
  • I had to check and make sure that fim++ still didn't exist. Whew. Safe for another year. – RubberDuck Dec 15 '16 at 10:43
  • @RubberDuck What is fim++? – caird coinheringaahing Apr 27 '17 at 21:17
  • @user00001 Dear Princess Celestia... – RubberDuck Apr 27 '17 at 21:45

I really can't believe I'm reviewing right now...

  • The specification does allow for variables to be any case, but all existing documentation uses lower case for variables. So, lowercase variables would be more idiomatic, but I'd go with camelCase for readability.
  • Frootloopz is creative and idiomatic, but Froot is meaningless beyond it's relation to Frootloopz. Loopz would still be idiomatic and counter would be more meaningful.
  • As @Pimgd noted, you can reduce the nesting by putting O RLY?, YA RLY on a single line.
  • The code both calculates and prints. LOLCODE supports functions. I would use it to separate the concerns. Particularly since this is an exercise in learning the language.

A function is demarked with the opening keyword HOW IZ I and the closing keyword IF U SAY SO. The syntax is as follows:

HOW IZ I <function name> [YR <argument1> [AN YR <argument2> …]]
     <code block>


You've gone with a structure like this:

    YA RLY
        Froot R "Buzz"

I don't really like it. It has an extra indentation level. Instead, I'd opt to do this:

    Froot R "Buzz"

You do get multiple statements on one line, but I'd see the IZ WIN (== true for those who are LOLCODE-inexperienced) as a part of the if statement.

Indentation - Comments

  I HAS A Froot ITZ SUM OF Frootz AN 1
    BTW Froot will run 1 through 100

Why is this comment indented? I think it should be like so

  I HAS A Froot ITZ SUM OF Frootz AN 1
  BTW Froot will run 1 through 100

Because there's no indentation level by variable assignment.

Magic numbers

100 should be a constant with a name that describes its meaning. Something like FIZZBUZZLIMIT or MAXFIZZBUZZNUMBR. Or even STAHP... but that might be less descriptive than the other names.

  • 6
    What else would you call the number 100? HUN? – RubberDuck Aug 29 '14 at 14:31
  • 4
    @RubberDuck Limit, MaxLines, Amount... It's not about the value, it's about the context. That 100 could be 1000 or 250 or 1337. When do you want FizzBuzz to stop? – Pimgd Aug 29 '14 at 14:53
  • 4
    Just making sure you weren't suggesting this. – RubberDuck Aug 29 '14 at 14:55
  • 19
    I would humbly suggest the variable name STAHP – MikeTheLiar Aug 29 '14 at 18:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.