Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

[P]
Code Humor Challenge

By Milo Minderbender in Technology
Tue Jun 01, 2004 at 01:21:10 PM EST
Tags: Humour (all tags)
Humour

The goal is to get a humorous piece of code into a production environment. Any kind of humor is acceptable...anything that might make a future developer smile. The code must actually be used by the application.


Qualifying Examples I've Seen

StaleBreadcrumbException

I've only ever truly succeeded once. One of my previous employers had a class called Breadcrumbs to maintain a navigation trail at the top of the web page. They also had a StaleRecordException for when the user tried to modify a database record that another user had modified since the record was loaded. The navigation breadcrumbs had a certain lifetime before they expired. If you tried to read the breadcrumb information after they had expired, I added a StaleBreadcrumbException.

Royal Food Taster

This is the only open source example that I know of. I won't get into how the technology works, but in the Prevayler project, to maintain data consistency, there is a need to run each transaction on a copy of the system first to make sure it succeeds. This is done by instantiating a RoyalFoodTaster.

Close, but no cigar

McNugget

One of my previous employers had, for historical reasons, the requirement that all class names be prefixed with "Mc" (McUser, McCheckbox, etc.). I created the class McNugget, complete with methods like McNugget.dip(McNugget.BBQ_SAUCE). Unfortunately, I was unable to incorporate this into the telecommunications billing software the company was writing. It did, however, stay in the version control system long after I left the company.

The Last Resort

I worked on some software for a travel agency once with classes like Booking and Hotel and Resort. I did my best to find an algorithmic requirement to get the last object from a list of resorts, but I never could incorporate a getLastResort() or isLastResort() method.

Honorable Mentions

I include these because they are funny. However, because the humor is entirely based on complete programmer ineptitude and not on a clever pun, they really don't qualify for the Code Humor Challenge.

Integer Wrapper

The following is actually in production use in a nationwide travel agency chain. Every computer in every franchise location is running this code. Note the rare, but proper, use of the final modifier. (There were rumors of a BooleanWrapper too!)

public class IntWrapper
{
  private final String value;

  public IntWrapper(int value)
  {
    this.value = String.valueOf(value);
  }

  public String getValue()
  {
    return value;
  }
}


Eastern Polish Christmas Tree Notation

Once my team was handed some code written by an outsourcing company. The code had been formatted into "Eastern Polish Christmas Tree Notation" (that's what they called it, anyway). The . was always aligned in the center of the page and everything else surrounded it. This formatting was enforced by the two Polish architects who would reprimand any deviations and were found late at night tabbing their way through normal developer's code to ensure it met their strict guidelines. Again, it's only funny in its idiocy. (This code is no longer in production, unfortunately)

public
DataPair[] getHotelInformation(String hotelId, String informationId)
                                      {
                                        return getHotelInfo("EN", hotelId, informationId);
                                      }

public
DataPair[] getHotelInformation(String lang, String hotelId, String informationId)
                                      {

                           String key = "_HOINF_"+lng+"_"+hotelId+"_"+informationId;
                       DataPair[] tbl = (DataPair[])csh.getObject(key);
                         if(tbl!=null)  return tbl;

                        Connection cn = null;
           OracleCallableStatement cs = null;
                                  try {
                           String qry = " begin HotelServices.getHotelInfo(?, ?, ?, ?, ?); end; ";
                               logger . debug("---"+qry+" "+hotelId+" "+informationId);
                                   cn = DriverManager.getConnection("jdbc:weblogic:pool:oraclePool",null);
                                   cs = (OracleCallableStatement)cn.prepareCall(qry);
                                   cs . registerOutParameter(1,java.sql.Types.INTEGER);
                                   cs . registerOutParameter(2,java.sql.Types.OTHER);
                                   cs . setString(3,hotelId);
                                   cs . setString(4,informationId);
                                   cs . setString(5,lang);
                                   cs . execute();
                              int sta = cs.getInt(1);
                            if(sta!=0)  throw new Exception("status not zero sta="+sta);
                         ResultSet rs = cs.getResultSet(2);
                                  tbl = getDataPairArray(rs);
                               logger . debug("sta="+sta+" key="+key+" cn="+cn);
                                  csh . put(key,tbl);
                                      }
                                 catch(Exception e)
                                      {
                               logger . debug("!!! "+e.toString()+" "+key);
                                      }
                               finally
                                      {
                                  try {
                      if(cs!=null) cs . close();
                      if(cn!=null) cn . close();
                                      }
                                 catch(Exception x)
                                      {
                               logger . debug("!!! "+x.toString()+" "+key);
                               logger . error("!!! "+x.toString());
                                      }
                                      }
                                return tbl;
                                      }


Submissions Welcome

Although my examples are in java (because that's what I do), the challenge applies well to all languages. I'm sure the K5 crowd with its wit and technical expertise can come up with some pretty good ones. Note to you perl people: "cryptic" != "funny".

Disclaimer

The point of this is entertainment only. Although it probably isn't strictly legal to post corporate source code, stupid little stuff like what I've posted isn't letting loose any industry secrets upon which my previous employers' success depends. The really important algorithms probably aren't very funny, anyway.

Sponsors

Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure

Login

Poll
Most entertaining of examples
o StaleBreadcrumbException 12%
o Royal Food Taster 2%
o McNugget 15%
o The Last Resort 2%
o Integer Wrapper 2%
o Eastern Polish Christmas Tree Notation 64%

Votes: 39
Results | Other Polls

Related Links
o Prevayler project
o RoyalFoodT aster
o Also by Milo Minderbender


Display: Sort:
Code Humor Challenge | 241 comments (223 topical, 18 editorial, 0 hidden)
Could you explain the Integer Wrapper joke (2.50 / 6) (#1)
by caek on Tue Jun 01, 2004 at 05:30:56 AM EST

I don't get it! If you want to avoid ruining it for people who are less dumb then perhaps in reply to this comment rather than in the article.

Ignorant of java != dumb (none / 3) (#3)
by Milo Minderbender on Tue Jun 01, 2004 at 05:44:13 AM EST

Java comes with classes to wrap primitives, such as int values. java.lang.Integer, for example. The proper way to convert an int to a String is:

int n = 69;
String s = new Integer(n).toString();

The idea of creating a special class to wrap an int and to store the value inside the wrapper as a String (requiring much more memory) rather than converting it each time you need to read it is absurd.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
For adding int's to arrays... (none / 1) (#5)
by trezor on Tue Jun 01, 2004 at 05:53:44 AM EST

...a int-wrapper is really usefull.

If you want to maintain a dynamic list of integers for what ever reason, a int-wrapper class is actually very usefull.

And for those to lazy to read the manuals (as you might have, I'm way too lazy :), writing a int-wrapper-class is really the fastest solution.


--
Richard Dean Anderson porn? - Now spread the news

[ Parent ]
Not a matter of "reading the manual" (none / 1) (#7)
by Milo Minderbender on Tue Jun 01, 2004 at 05:58:11 AM EST

The two things anyone learning java coming from another OO language (as anyone from your example of writing a wrapper class would be) are:
  • There's no need to delete objects to free up memory
  • All the primitives have wrapper classes
If you know about java.lang.String, you know about java.lang.Integer.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
Actually I didn't (none / 1) (#8)
by trezor on Tue Jun 01, 2004 at 06:07:09 AM EST

I found out after delivering a project with an in use, homemade int-wrapper.

As far as I have gotten the grasp of things it works like this:
String is not a primitive in the same sense as int. A String merely contains a pointer to the location of the actual string, while int contains the actual int. Therefore it cannot be added to lists.

I don't know if you claimed java.lang.String was different from an ordinary String, but just mentioned to it clear the fuzz, if any.

I learned java and OO by experimenting. I never read manuals for programming languages. So I didn't know about point 2, although you could say I should have figured.


--
Richard Dean Anderson porn? - Now spread the news

[ Parent ]
Okay, well... (none / 2) (#10)
by Milo Minderbender on Tue Jun 01, 2004 at 06:31:35 AM EST

I guess you not reading manuals (if you can call a basic java tuturial a manual) places you in the "complete programmer ineptitude" category that I used to describe the IntWrapper.

No, I wasn't saying that String is a primitive, nor that it is different from java.lang.String.

And yes, to maintain a variable list of integers, they need to be objects, not primitives.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
That ineptitude is my friend! (none / 1) (#20)
by trezor on Tue Jun 01, 2004 at 08:34:45 AM EST

I rarely bother learn anything in a proper or time-consuming fashion.

In fact I happen to learn thing Just-in-time, when I need to figure something out. Be it I need a simple one-time purpose perl-script or whatever.

I am, however, extremely good at being inept and getting things done fast. I guess I should feel insulted, but I don't.


--
Richard Dean Anderson porn? - Now spread the news

[ Parent ]
It wasn't an insult (none / 2) (#21)
by Milo Minderbender on Tue Jun 01, 2004 at 08:43:07 AM EST

I suppose there's nothing wrong with valuing getting things done fast over getting things done right, as long as you don't mind the highly trained/skilled people laughing at the awkward way you solved your problem.

The person I laugh most at is myself, looking at code I wrote a year ago before I learned something that I take for granted now as common knowledge.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
Btw (none / 1) (#22)
by trezor on Tue Jun 01, 2004 at 08:46:16 AM EST

I am an electronics engineer specialized in analog circuitry-design. Not a comp.sci-major, so I don't really care if things are done somewhat un-proper.

Im doing stuff to solve problems I want solved, not for a company. And I tolerate dodgy solutions, as long as they work :)


--
Richard Dean Anderson porn? - Now spread the news

[ Parent ]
Seems reasonable to me (none / 0) (#24)
by squigly on Tue Jun 01, 2004 at 09:04:38 AM EST

There's a difference between production code, and a quick and dirty application that has a single purpose.  As long as another user never gets to see the application, your method sounds fine.

[ Parent ]
Distinctions (none / 2) (#32)
by rpresser on Tue Jun 01, 2004 at 09:55:00 AM EST

P.J. Plauger described three different situations where a person can find himself programming. Unfortunately I cannot find the quote, but I will paraphrase:

Programming by accident: A person finds himself with some free time and fools around with programming. Plauger said that such a person should never program anything critical.

Programming by necessity: A person finds himself with a need to be filled, and programs himself out of the box. Plauger said that such a person should never program anything "too large", i.e. larger than he can control.

Programming on purpose: A person decides beforehand that he wants to write programs. Plauger said that such a person should never give away his programming without compensation. (ok, this was before free software had entered public consciousness; but by amending "without compensation" to "without deliberate reason", it still works.)
------------
"In terms of both hyperbolic overreaching and eventual wrongness, the Permanent [Republican] Majority has set a new, and truly difficult to beat, standard." --rusty
[ Parent ]

Ha! (none / 1) (#34)
by Milo Minderbender on Tue Jun 01, 2004 at 10:01:07 AM EST

I guess trezor "finds himself with a need to be filled".

--------------------
This comment is for the good of the syndicate.
[ Parent ]
no it's not, use fastutils [nt] (none / 0) (#102)
by boxed on Wed Jun 02, 2004 at 04:38:19 AM EST



[ Parent ]
Google is having trouble finding fastutils (none / 0) (#104)
by Milo Minderbender on Wed Jun 02, 2004 at 04:45:59 AM EST

Can you elaborate?

--------------------
This comment is for the good of the syndicate.
[ Parent ]
woops, sorry, it's "fastutil" (none / 0) (#108)
by boxed on Wed Jun 02, 2004 at 07:43:30 AM EST

http://fastutil.dsi.unimi.it/

[ Parent ]
What a huge waste of time!! (none / 1) (#111)
by Milo Minderbender on Wed Jun 02, 2004 at 08:22:47 AM EST

Two things that are true:
  1. In the early days the built-in java data structures were crap and you could do well with writing your own.
  2. There is way too much type casting in java.
Number 1 is no longer the case, although I suppose a BidirectionalIterator or a FastHashMap could come in handy now and again. And number 2 is about to be fixed with generics and autoboxing in java 1.5.

I really hope that the fastutil developers generated a lot of that code. I mean, a special class for mapping from float to a boolean? Gross! Casting isn't that bad!

--------------------
This comment is for the good of the syndicate.
[ Parent ]
learn java for fucks sake (none / 0) (#148)
by boxed on Thu Jun 03, 2004 at 05:35:36 AM EST

1.5 removes the CAST not the huge absurd overhead of beating the GC with an ax over the head repeatedly that the primitive type wrappers entail. If you think storing an Integer instead of an int is even CLOSE to the same GC, memory and CPU performance you are sadly mistaken, and if you think 1.5 changes that in any way whatsoever you are again mistaken.

[ Parent ]
So you're telling me... (none / 0) (#153)
by Milo Minderbender on Thu Jun 03, 2004 at 06:59:37 AM EST

...that those fastutil classes that map a float to a boolean aren't just using a java.util.HashMap with float and boolean wrappers? I would look, but that "open source" project has conveniently left those classes out of the src.tar.gz download. Probably from embarassment...

--------------------
This comment is for the good of the syndicate.
[ Parent ]
eh, no (none / 1) (#154)
by boxed on Thu Jun 03, 2004 at 07:05:23 AM EST

It it did that the name would be "slowutil".

[ Parent ]
Fast java (none / 0) (#155)
by Milo Minderbender on Thu Jun 03, 2004 at 07:32:06 AM EST

Thanks for your explanation. That's helped a lot.

Although it doesn't hurt to have these improvement projects, focusing on speed in java is rather silly. Any application where speed is that important should be written in a real compiled language.

It is very sad that java has primitives at all. I think that was a big mistake. We'll probably have to live with it until its successor comes along.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
successor = C#? (none / 0) (#164)
by sab39 on Thu Jun 03, 2004 at 10:40:57 AM EST

C# actually solves the primitives/objects disparity in a clean way and the (as yet publically unreleased, except by Mono) 2.0 version includes generics that eliminate the boxing overhead for collection classes without having to define crazy numbers of custom classes.

As in, new Hashtable<float, bool>() will actually use ints and bools natively without object wrappers.

IMHO, that by itself (even without C#'s other cool features) is enough to qualify it as the "successor to Java". And this is coming from someone who as recently as two years ago was a hard-core Java user who didn't believe Microsoft ever created anything good.
--
"Forty-two" -- Deep Thought
"Quinze" -- Amélie

[ Parent ]

no god dammit, it's SLOW (none / 0) (#166)
by boxed on Thu Jun 03, 2004 at 12:08:20 PM EST

C# does it the way java 1.5 does it (except .net is once again playing catch up): with slow autoboxing. Fastutil is highly optimized very fast collections, not the horribly slow memory raping code that autoboxing and generics produce.

[ Parent ]
C# generics DO NOT BOX (none / 0) (#189)
by sab39 on Fri Jun 04, 2004 at 10:05:32 AM EST

That's not true, C# separately JITs each instantiated generic type, and when the parameter is a value type, it doesn't box.

MSDN arcicle on C# generics

Click on "Generics Benefits" and you'll find the sentences "Because the generic code does not force the boxing and unboxing of value types, or the down casting of reference types, performance is greatly improved. With value types there is typically a 200 percent performance gain".

Please don't make unsupported statements of fact without researching them (if you're sure you're right, it shouldn't be so hard to find a link backing your statement up, right?).

C# did generics right, unlike the horrible hack that Java bastardized onto the language. I already don't use Java very much any more, but even if I did I wouldn't be terribly excited by Java 1.5 (it's basically playing catchup with C# in most areas, except for generics which, as you rightly point out, they implemented as a horrible kludge).

C# 2.0, on the other hand, I'm positively drooling for. Generics done right and python-like iterators and generators in a language that's already the best I've ever used... wow.
--
"Forty-two" -- Deep Thought
"Quinze" -- Amélie

[ Parent ]

java isn't slow (none / 1) (#168)
by boxed on Thu Jun 03, 2004 at 12:12:42 PM EST

Even for lots of silly shit like number crunching java is still comparable to C/C++, and has been for several years now. You really should join us other people in the year 2004.

[ Parent ]
Yeah, fine (none / 0) (#169)
by Milo Minderbender on Thu Jun 03, 2004 at 12:29:34 PM EST

I know that. I've been trying to think of the last time I actually stored a primitive (wrapped, of course) in a map or collection. I'm having trouble. I map strings to objects all the time, and I've obviously got collections of objects all over the place, but never any lists of numbers. Can you think of a use for something as obscure as a float->boolean map? What do you use fastutil for? You seem keen to sell it, so sell it to me!

--------------------
This comment is for the good of the syndicate.
[ Parent ]
hmm? (none / 0) (#215)
by boxed on Mon Jun 07, 2004 at 08:10:25 AM EST

The more obscure ones are clearly generated because of completeness more than someone seeing the need beforehand. I quite often have long->Object and list of longs in SKForum, because the ID of many items are longs.

[ Parent ]
On converting ints to Strings (none / 2) (#6)
by Milo Minderbender on Tue Jun 01, 2004 at 05:53:45 AM EST

Possibly a better way is:

int n = 69;
String s = String.valueOf(n);

This is actually what Integer.toString() uses.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
holy shit, YOU are ignorant (none / 3) (#13)
by boxed on Tue Jun 01, 2004 at 07:20:03 AM EST

Creating a new instance for that? Are you mad? use the static method for crying out loud: String s = Integer.toString(23);

[ Parent ]
Yes, sorry about that. (none / 0) (#14)
by Milo Minderbender on Tue Jun 01, 2004 at 07:21:38 AM EST

I corrected myself in a subsequent comment. I don't do a lot of int->String conversions normally. I let StringBuffer sort it out.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
What about the obvious (none / 1) (#49)
by coljac on Tue Jun 01, 2004 at 01:48:53 PM EST

This may be more inefficient (I think the VM uses a StringBuffer?) but it's a lot cleaner than the IntWrapper:

String s = 69 + "";



---
Whether or not life is discovered there I think Jupiter should be declared an enemy planet. - Jack Handey
[ Parent ]

The VM doesn't use StringBuffer (none / 1) (#51)
by Milo Minderbender on Tue Jun 01, 2004 at 02:20:00 PM EST

I used to think it did, but then I ran a test, appending two strings (I tried it with appending ints too) with the + operator and with StringBuffer, each several thousand times. The + operator was at least 10 times slower. So I guess the VM doesn't use StringBuffer.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
VM and StringBuffer (none / 1) (#69)
by ensignyu on Tue Jun 01, 2004 at 04:58:17 PM EST

That's interesting, because the API docs say:

"The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. String concatenation is implemented through the StringBuffer class and its append method."

Maybe there's additional overhead in there somewhere.

[ Parent ]

Only within a single command (none / 1) (#109)
by ggeens on Wed Jun 02, 2004 at 07:49:21 AM EST

If you write this:

String s = "a" + "b" + "c";

the compiler will translate this into:

String s = new StringBuffer().append("a").append("b").append("c").toString();

If you write:

String s = ""; s += "a"; s += "b"; s += "c";

The resulting byte code will create a new StringBuffer and a new String for each line. So, if you have to append several things together, you will get a performance boost if you create the StringBuffer yourself.


L'enfer, c'est les huîtres.


[ Parent ]
The VM doesn't use StringBuffer (none / 1) (#90)
by ParadisePete on Tue Jun 01, 2004 at 10:35:40 PM EST

The + operator was at least 10 times slower. So I guess the VM doesn't use StringBuffer.

It's not the VM. The compiler will do it for you. I'm guessing it's been a while since you did this. Try it again. You should now get the same byte code for each.

[ Parent ]

I'm sorry, did I say only 10 times slower? (none / 0) (#103)
by Milo Minderbender on Wed Jun 02, 2004 at 04:42:30 AM EST

public class Test
{
  public static void main(String[] args)
  {
      final String toAppend = "WhichIsFaster";
      final int timesToRun = 1000;
      long start; // to avoid miniscule overhead of defining it in-line later
      long end; // to avoid miniscule overhead of defining it in-line later

      System.out.println("*****************************");

      String result = "";
      start = System.currentTimeMillis();
      for (int i = 0; i < timesToRun; i++)
        result += toAppend;
      end = System.currentTimeMillis();
      final long timeWithPlus = end - start;
      System.out.println("Creating a string using + concatenation with " +
                        timesToRun + " copies of '" + toAppend + "' in " +
                        timeWithPlus + " milliseconds.");

      System.out.println("*****************************");

      final StringBuffer buffer = new StringBuffer();
      start = System.currentTimeMillis();
      for (int i = 0; i < timesToRun; i++)
        buffer.append(toAppend);
      result = buffer.toString();
      end = System.currentTimeMillis();
      final long timeWithStringBuffer = end - start;
      System.out.println("Creating a string using StringBuffer with " +
                        timesToRun + " copies of '" + toAppend + "' in " +
                        timeWithStringBuffer + " milliseconds.");

      System.out.println("*****************************");

      final String timesFaster;
      if(timeWithStringBuffer == 0)
        timesFaster = "infinitely";
      else
        timesFaster = Double.toString(timeWithPlus / (double) timeWithStringBuffer) + " times";
      System.out.println("StringBuffer is "+timesFaster+" faster");
  }
}

Produces the output:

*****************************
Creating a string using + concatenation with 1000 copies of 'WhichIsFaster' in 250 milliseconds.
*****************************
Creating a string using StringBuffer with 1000 copies of 'WhichIsFaster' in 0 milliseconds.
*****************************
StringBuffer is infinitely faster


Changing timesToRun to 10,000 results in:

*****************************
Creating a string using + concatenation with 10000 copies of 'WhichIsFaster' in 65859 milliseconds.
*****************************
Creating a string using StringBuffer with 10000 copies of 'WhichIsFaster' in 16 milliseconds.
*****************************
StringBuffer is 4116.1875 times faster


Am I missing something? Is += not the same as StringBuffer.append()?

Let's try integers! That's what got us talking in the first place, right? Changing the line

      final String toAppend = "WhichIsFaster";
to
      final int toAppend = 69;

results in

*****************************
Creating a string using + concateation with 10000 copies of '69' in 3704 milliseconds.
*****************************
Creating a string using StringBuffer with 10000 copies of '69' in 0 milliseconds.
*****************************
StringBuffer is infinitely faster


I got bored waiting for the case where timeWithStringBuffer isn't zero.

Okay...so maybe the slow part of StringBuffer is in the toString() method, actually giving you the string. So I changed the StringBuffer loop to:

      for (int i = 0; i < timesToRun; i++)
      {
        buffer.append(toAppend);
        result = buffer.toString();
      }


Now, at every iteration we have the entire concatenated string available to us. But still:

*****************************
Creating a string using + concatenation with 10000 copies of '69' in 3047 milliseconds.
*****************************
Creating a string using StringBuffer with 10000 copies of '69' in 16 milliseconds.
*****************************
StringBuffer is 190.4375 times faster


Okay, let's give one last shot at explaining this... Perhaps the compiler (or VM) could be constructing a new StringBuffer, doing the append, and calling toString() every time it does a +=... Let's try that!

      start = System.currentTimeMillis();
      for (int i = 0; i < timesToRun; i++)
      {
        final StringBuffer buffer = new StringBuffer();
        buffer.append(toAppend);
        result = buffer.toString();
      }
      end = System.currentTimeMillis();


Drumroll.............. (!)

*****************************
Creating a string using + concatenation with 10000 copies of '69' in 3281 milliseconds.
*****************************
Creating a string using StringBuffer with 10000 copies of '69' in 15 milliseconds.
*****************************
StringBuffer is 218.73333333333332 times faster


Please, by all means, point out to me what I'm doing wrong, and how exactly the + operator is doing string concatenation the same as StringBuffer. Please back it up with data, as I have1. Feel free to make fun of what a slow-ass machine I have at work, too.

------
1 I ran these tests in jdk1.3.1_08 and jdk1.4.2_04 on Windows 2000. Both jdk's produced similar results.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
Problem with last example (none / 2) (#105)
by ensignyu on Wed Jun 02, 2004 at 06:26:01 AM EST

start = System.currentTimeMillis();
for (int i = 0; i < timesToRun; i++)
{
    final StringBuffer buffer = new StringBuffer();
    buffer.append(toAppend);
    result = buffer.toString();
}
end = System.currentTimeMillis();

That should be: new StringBuffer(result)

Otherwise you're appending to nothing each time.

Let's try that now:
**********
Creating a string using + concatenation with 10000 copies of 'WhichIsFaster' in 39249 milliseconds.
*
*********
Creating a string using StringBuffer with 10000 copies of 'WhichIsFaster' in 10287 milliseconds.
***********
StringBuffer is 3.8153980752405947 times faster

Not such a big factor now. This is modified from the original StringBuffer example rather than your int example, but I think the results would be the same.

[ Parent ]

Thanks (none / 0) (#106)
by Milo Minderbender on Wed Jun 02, 2004 at 06:37:01 AM EST

Good point. I now get

*****************************
Creating a string using + concatenation with 10000 copies of '69' in 3094 milliseconds.
*****************************
Creating a string using StringBuffer with 10000 copies of '69' in 2985 milliseconds.
*****************************
StringBuffer is 1.0365159128978225 times faster


So the conclusion is: If you are just concatenating two strings, use +, but if you are doing more than two and efficiency is important, then use StringBuffer and make sure not to instantiate it fresh every time.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
StringBuffer trick (none / 0) (#206)
by danharan on Sat Jun 05, 2004 at 03:24:09 PM EST

And when you instantiate a StringBuffer, you can also specify its initial capacity: StringBuffer(int length)

SB's have an internal buffer array that is made larger every time it overflows, and this is an expensive operation. If you re-run your tests with this in mind, using a StringBuffer should be much faster.

[ Parent ]

OK people congratulations (none / 0) (#135)
by axel on Wed Jun 02, 2004 at 08:03:41 PM EST

You just managed to create a slashdot-like thread and generated like 20 posts discussing some stupid java integer manipulation detail and got down to personal insults. How silly. How boring.

[ Parent ]
Easy answer (none / 1) (#214)
by clambake on Mon Jun 07, 2004 at 05:50:56 AM EST

Very simply, instead of storing the value, and ONLY the value of String.valueOf() in a new class, you could just as easily have just used String.valueOf() method wherever you were using the wrapper previously. It doesn't matter if you knew about the Integer java class or not, that one should have been obvious to anyone.

[ Parent ]
I guess this doesn't count, but... (2.58 / 17) (#4)
by spasticfraggle on Tue Jun 01, 2004 at 05:46:37 AM EST

The Power architecture assembly has an EIEIO instruction (Enforce In-Order Execution of IO).

--
I'm the straw that broke the camel's back!
RCA 1802 had SEX [n/t] (2.60 / 5) (#68)
by epepke on Tue Jun 01, 2004 at 04:49:56 PM EST


The truth may be out there, but lies are inside your head.--Terry Pratchett


[ Parent ]
The x87 has FIST (nt) (2.80 / 5) (#74)
by ksandstr on Tue Jun 01, 2004 at 05:18:18 PM EST



[ Parent ]
8051 has ORL and ANL [nt] (2.83 / 6) (#85)
by ajaxx on Tue Jun 01, 2004 at 08:04:23 PM EST



[ Parent ]
C64 Programmers Ref. Manual (none / 1) (#139)
by LocalH on Wed Jun 02, 2004 at 09:08:38 PM EST

Sprite Expand Y for sprites 0-7: SEXY0 - SEXY7

[ Parent ]
Ditto 6809, 68000 (none / 0) (#219)
by b1t r0t on Mon Jun 07, 2004 at 06:07:00 PM EST

Sign EXtend Still a bit more forced than "SEt X", perhaps. Then there were those of us who hoped that the successor to the Mac SE would follow the same naming conventions as the Mac II series. Unfortunately, Apple named it the "Mac SE/30" instead of the much more interesting "Mac SEx".

-- Indymedia: the fanfiction.net of journalism.
[ Parent ]
I always liked that one. (none / 2) (#140)
by ShawnD on Wed Jun 02, 2004 at 10:01:37 PM EST

EIEIO is in PowerPC too. Too bad none of the other PowerPC opcodes are memorable. Most of them look like jiberish. Hmm want to guess what its original name was going to be? Probably dsync or lsync to go with sync and isync.

BTW The 68HC11 (and probably other 68xx's) has BRN - Branch Never. What a usefull instruction. It even has the destination address as an operand.



[ Parent ]
What about lfsux? (none / 0) (#156)
by derobert on Thu Jun 03, 2004 at 08:21:52 AM EST

Load Floating-Point Single with Update Indexed = lfsux. I'd read that as "life sucks".

[ Parent ]
For neat opcodes, I always liked HCF (none / 0) (#199)
by Bwah on Fri Jun 04, 2004 at 11:46:08 PM EST

Halt and Catch Fire

--
To redesign an infinite ensemble of universes: what terrible responsibility, what arrogance ... It sounds just like the type of thing your average Homo sap would do for a dare. -- Stephen Baxter
[ Parent ]

Branch never (none / 0) (#227)
by squigly on Wed Jun 09, 2004 at 08:21:59 AM EST

Last time I was working on a CPU design, I used a conditional instruction with Less Than, Greater Than and Equals bits.  If all these bits were false, it was a valid instruction, but did nothing.

I added a mnenomic for it for two reasons:  1. I needed the disassembler to output something for the instruction, and 2. It could conceivably be useful for debugging (someone may want to check that the branch behaves correctly when the tests fail for example)

[ Parent ]

merry xmas (2.80 / 5) (#11)
by Highlander on Tue Jun 01, 2004 at 07:16:02 AM EST

I kind of like the xmas tree notation, it looks like maybe an assembler programmer would like it. It would be ok to have an editor that does format code like this, but doing it by hand is a plain waste of time.

This needs a way to show the indentation level, aligning all "{" and "}" along the center is silly. Also, aligning all "." doesn't make sense anymore when you got objects nested deeper than 1 level("my.car.tire.pressure"). Of course you could forbid this and ask people to define a temporary "for readability" :-)

Moderation in moderation is a good thing.

If you ignore usability and everything practical.. (none / 3) (#15)
by Milo Minderbender on Tue Jun 01, 2004 at 07:24:04 AM EST

...it is kind of pretty! :-) I agree.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
Code Formatting (none / 3) (#29)
by Ricochet Rita on Tue Jun 01, 2004 at 09:40:24 AM EST

Strange that they were using man-hours to enforce their bizarre coding convention.
There are programs for this.

Here, we use Jalopy which we've hooked into our Ant compile process.
It frees us from the worry of formatting differences between coding teams.

FABRICATUS DIEM, PVNC!
[ Parent ]

Somehow I doubt... (none / 2) (#31)
by Milo Minderbender on Tue Jun 01, 2004 at 09:52:03 AM EST

Jalapy has a Christmas Tree plugin.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
I could go check... (none / 2) (#35)
by Ricochet Rita on Tue Jun 01, 2004 at 10:06:30 AM EST

but I doubt it too. ;-)

It does have the configurable line-wraps & the option to put braces on their own lines (at the wrapped columns). But aligning the dots? Well...it's open source, so *theoretically* it would be possible to write a template for it.

Not that I'd advocate doing so. Yuck! ;-p

FABRICATUS DIEM, PVNC!
[ Parent ]

Damn that is one sad project. (none / 2) (#54)
by walwyn on Tue Jun 01, 2004 at 02:54:59 PM EST


----
Professor Moriarty - Bugs, Sculpture, Tombs, and Stained Glass
[ Parent ]
whoohoo! (1.07 / 14) (#12)
by ljj on Tue Jun 01, 2004 at 07:17:08 AM EST

technology AND culture!

-1.

--
ljj

Can't beat the... (3.00 / 10) (#17)
by onealone on Tue Jun 01, 2004 at 08:01:14 AM EST

Guru.

Interesting History There (none / 2) (#55)
by ewhac on Tue Jun 01, 2004 at 02:59:24 PM EST

The diagnostic numbers in the Amiga system crash alert originally bore the name Guru Meditation Numbers. Commodore ordered the name changed to something more innocuous, like Software Failure Code or something. Naturally, the Amiga staff were unhappy with the change. But perhaps more unexpectedly, so also were the third-party developers, and notes poured in to Commodore pleading with them to change it back. So they did. The rest is history.

Schwab
---
Editor, A1-AAA AmeriCaptions. Priest, Internet Oracle.
[ Parent ]

a 3 for the joyboard (none / 2) (#83)
by Fuzzwah on Tue Jun 01, 2004 at 07:22:00 PM EST

I really want a joyboard now.

Since the link to the actual screen grab of error message is out of date:

The guru error

--
The best a human can do is to pick a delusion that helps him get through the day. - God's Debris
[ Parent ]

Where I saw the guru (none / 3) (#123)
by rpresser on Wed Jun 02, 2004 at 02:10:32 PM EST

(in addition to my own Amiga, that is):

For many years, the local cable system (once known as TKR, then eaten by TCI, then eaten by AT&T, finally sold to Comcast) used some kind of Amiga system to display the scrolling channel guide/program listings for (analog) cable customers. (Lest We Forget, before digital cable was born, you sometimes had to wait up to two or three minutes to find out what was coming on next on your channel).  Anyway, apparently the software would crash sometimes, and you'd tune to the listings channel and see "Guru Meditation Error". And it would blink about once every three seconds.  Sometimes it would stay there for hours before they rebooted.
------------
"In terms of both hyperbolic overreaching and eventual wrongness, the Permanent [Republican] Majority has set a new, and truly difficult to beat, standard." --rusty
[ Parent ]

Best I ever saw (3.00 / 10) (#23)
by Bjorniac on Tue Jun 01, 2004 at 09:00:33 AM EST

A basic program had the loop: REPEAT .... UNTIL THECOWSCOMEHOME
Freedom for RMG! Join the Jihad...
Nice idea (2.80 / 5) (#26)
by Milo Minderbender on Tue Jun 01, 2004 at 09:19:53 AM EST

In place of

boolean done = false;
while(!done)
{
  // do stuff
  if(something)
    done = true;
}

to avoid using break as some people like to do, you could make your boolean variable more interesting, like

boolean hellFrozenOver = false;
while(!hellFrozenOver)
{
  // do stuff
  if(something)
    hellFrozenOver = true;
}

Thanks.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
Worst... code humor... ever. (2.80 / 5) (#82)
by unDees on Tue Jun 01, 2004 at 07:00:21 PM EST

Not yours -- but a similar one I had loads of fun with at my first job. I inherited a sizable collection of C code where every main.c file had a main() function whose main loop went something like:

while (ETERNITY) {
  //...a few screenfuls of code
}

Other things in the code prompted a check to make sure the author had #define'd ETERNITY to something that actually evaluated to true. Of course, the definition was buried somewhere in a header referenced by a header referenced by a header, but not used by any file except main.c.

And I mean, "ETERNITY?" C'mon, maybe TRUE or something. "While eternity" doesn't even parse to good English....

Looking back, I s'pose it was really all of the other little things in the project that wore me down, and innocent little bits of "humor" like the loop above became the undeserved focus of my frustration.

Your account balance is $0.02; to continue receiving our quality opinions, please remit payment as soon as possible.
[ Parent ]

A few more (none / 2) (#110)
by ggeens on Wed Jun 02, 2004 at 07:58:52 AM EST

In C:

#define ever (;;)

And then:

for ever { /* Do something */ }

I once saw some COBOL code that read REPEAT UNTIL THE_END_OF_THE_WORLD, where THE_END_OF_THE_WORLD was defined as (0=1) or something. (I don't remember the exact syntax.)


L'enfer, c'est les huîtres.


[ Parent ]
Hungarian notation (2.28 / 7) (#27)
by Ricochet Rita on Tue Jun 01, 2004 at 09:31:08 AM EST

seems to be ripe for this sort of thing.

For example, the instance boolean prefix, ib_ (pronounced "I be"), is highly abusable:

ib_functional
ib_dutyful
ib_leever
ib_indyErr

or Local Objects:

lo_fat
lo_nBrau
lo_self(eSteam)

Unfortunately, the code review staff here has no humor & removes the bulk our "creativity."
But it lives on in CVS!

Then at the other end of the spectrum, there's our "test user" database, with 100's of names like:

Ima Pseudonym
Juan Moore-Thyme
Harrison Fondel
Holly Peño
Mike O. Tocksen
Max Illias
Otto E. Rotik
Mona Knight-Rhayt
Auntie D'Loovian
Darron Dew
Ethyl Lynn Glycaul
Ester O'Jhen
Tess Tossterrone
P. Ann Issamo
Claude Balz
etc. etc. etc.

Since this part of the product doesn't ship out, it's largely beneath the reviewers' radar.

FABRICATUS DIEM, PVNC!

Test data (none / 3) (#33)
by Milo Minderbender on Tue Jun 01, 2004 at 09:58:00 AM EST

Yeah, test data is a whole different realm of humorous possibilities. I usually get my test data (and for filling content-less pages) from the Nonsense Generator. Some of that is pretty funny.

As for names, we had a Dr. P Brain in a lot of our use case documents when I worked in the pharmaceutical industry. Almost no one noticed.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
test data is funnier than code (none / 3) (#59)
by Norwegian Blue on Tue Jun 01, 2004 at 03:24:43 PM EST

testdata is suitable for humorous names, but using funny naming in code degrades the code, because it sacrifices explanatory names. So it's mostly restricted to comments. And bad code.

Just to contradict myself, I'm sure funny names can clarify.

int& somebodyKillMe(){
    int ImDeadButIdontKnowItYet =1;
    return &ImDeadButIdontKnowItYet;
}

Maybe it would be a good idea to systematically rename those pesky globals that people can't keep themselves from introducing, to stuff like "g_AnyoneMayGrabMyString"

[ Parent ]

now that is funny (2.50 / 4) (#60)
by Norwegian Blue on Tue Jun 01, 2004 at 03:31:24 PM EST

I wrote & instead of * . Nothing as funny as people being funny not in the way they intended

[ Parent ]
people returning pointers/references to locals (none / 0) (#220)
by polyglot on Mon Jun 07, 2004 at 10:45:55 PM EST

should be taken out and shot!
--
"There is no God and Dirac is his prophet"
     -- Wolfgang Pauli
‮־
[ Parent ]
Stupid (2.42 / 7) (#30)
by guyjin on Tue Jun 01, 2004 at 09:48:02 AM EST

I once had to write an example program for a programming class that would take a few tests (I forget how many, it wasn't arbitrary) and average them for every student in a class. I assigned each student a 'STUdent Personal IDentification' number.

I'm sure someone else came up with the idea before me, though, and that it's floating around in some school grading system somewhere.
-- 散弾銃でおうがいして ください

Check your configurations (2.73 / 23) (#43)
by unixrat on Tue Jun 01, 2004 at 12:03:10 PM EST

While working for a small software company in Duluth, Minnesota, we maintained a small office in downtown, on Superior Street.  There was a small (<500 sq ft.) 'grocery' store near there that stocked various bits of dusty merch.  Every so often we would head down there for some coding fuel.  Between there and the office there was a Chinese restaurant - a rather terrible one IIRC.

While walking toward the Grocery store on a Monday afternoon, we observed two men get out of a pickup, walk up to the doors of the restaurant and try and open it.  It was locked.  They pulled and pulled, but it was obvious to everyone else that the placed was closed.  They started pounding on the doors and doing the cupped-hands-look-in.  They must have been damn hungry.  Anyways, after thirty seconds of futility, one of the kicks the door and yells "What is this, some sort of f*cking Chinese holiday?".  Then they leave.

Every program that we wrote after that had an "FCH" setting in the configuration file.  It was always set to 0 and there was no way to view/modify it through the prog.  If you looked at the config files by hand, it was there, uncommented, sitting all alone.  

If some poor fool would set it to '1', the program would silently quit during startup, never to run again until FCH was set back to '0'.  

and the point of this would be...? [nt] (none / 1) (#63)
by anmo on Tue Jun 01, 2004 at 03:54:18 PM EST



[ Parent ]
Relief from the cubicle doldrums, obviously! (none / 2) (#64)
by Milo Minderbender on Tue Jun 01, 2004 at 03:57:52 PM EST

This is my favorite of the posts so far, along with the guy that got fired for instantiating an instance of FatAss with his boss's name.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
User Unfriendly application (2.00 / 7) (#47)
by Orion Blastar on Tue Jun 01, 2004 at 01:34:25 PM EST

In High School I wrote a User Unfriendly program in Turbo Pascal.

The user was asked to enter a number, if it was not a valid number, the program added 1 to a counter and asked them to enter a number, no letters or symbols, just use the number characters. After 6 tries of this, it displays a message. "Don't you know the difference between a number and a letter? How did you survive in school this far?" and exits the program.

Of course I was forced to take that part out, but it was funny.

The counter was named notanumberentered.

I was told by my teacher that it would make people mad as it insulted them and they may try to break the computer as a result.

A friend of mine wrote a procedure called getthesh*t, which he later renamed to getthejunk. It gathered input from the user.

I did write a coporate ASP app using the variable twiddle in VBScript to keep track of how many times the user clicked on a line of the web page. If it went over 30, it changed the font size, color, and style, 30 more clicks and it went back to normal. Dynamic HTML, got to love it!

In MS-Access, because a certain database had nulls and zeros entered for data they were trying to divide on, I wrote a function named zerotone (zero to one) that if the value was zero or null it was replaced with a 1, otherwise it was the number. I was told for this database that there was no zero values, but the users entered them anyway. Everyone called it zerotone as in zero tone and not zero to one. Division by zero in a query blew the whole thing up, but using zerotone in the denominator prevented that. All zero and null values they wanted as one anyway.
*** Anonymized by intolerant editors at K5 and also IWETHEY who are biased against the mentally ill ***

Mispronounced class (3.00 / 4) (#115)
by sos on Wed Jun 02, 2004 at 10:13:39 AM EST

In one of my company's products we discovered that one of the bottlenecks was our STL's implementation of ostringstream, so I wrote a much faster replacement for it.  Our utility classes were all prefixed with "SL" (derived from our company name) and the replacement class was called "SLOStringStream".  It worked a treat - the class worked much faster, and the bottleneck disappeared from that portion of the code.

It wasn't until much later that I realised everyone read it as "SLOw String Stream" and thought I had named the class sarcastically!

--- My real e-mail address isn't quite scalding.
[ Parent ]

"cryptic" != "funny" (2.91 / 23) (#48)
by coderlemming on Tue Jun 01, 2004 at 01:36:06 PM EST

Note to you perl people: "cryptic" != "funny".

Wait a minute...



#!/usr/bin/perl

if ("cryptic" != "funny") {
  print "Cryptic PERL programs are not funny.\n";
} else {
  print "Cryptic PERL programs are funny.\n";
}






$ perl ./cryptic.pl
Cryptic PERL programs are funny.




--
Go be impersonally used as an organic semen collector!  (porkchop_d_clown)
Now that's funny! (none / 0) (#52)
by Milo Minderbender on Tue Jun 01, 2004 at 02:27:11 PM EST

I don't know perl, which is probably why I think it's cryptic (your example is the clearest perl program I've ever seen). "cryptic" != "funny" is a true expression in java too. The correct string comparison syntax is "cryptic".equals("funny"). Is it similar in perl?

--------------------
This comment is for the good of the syndicate.
[ Parent ]
In perl, "cryptic"==0=="funny" (3.00 / 4) (#57)
by Sacrifice on Tue Jun 01, 2004 at 03:10:42 PM EST

the correct way to compare strings is the operator "eq", or its inverse, "ne" ... == and != coerce their operands to numbers (and if a string isn't a number, its numerical value is 0)

[ Parent ]
You've got it backward (none / 0) (#125)
by p3d0 on Wed Jun 02, 2004 at 04:37:43 PM EST

"cryptic" != "funny" is false in Perl.
--
Patrick Doyle
My comments do not reflect the opinions of my employer.
[ Parent ]
Spoiling the Joke (3.00 / 9) (#53)
by ewhac on Tue Jun 01, 2004 at 02:51:48 PM EST

For those no conversant in Perl, the != operator performs a scalar (numeric) comparison against the two arguments. In a scalar context, non-NULL strings always evaluate to true.

If you want to compare string contents, you have to use the eq operator.

Schwab
---
Editor, A1-AAA AmeriCaptions. Priest, Internet Oracle.
[ Parent ]

Or, in this case, ne <nt> (none / 3) (#71)
by wurp on Tue Jun 01, 2004 at 05:00:04 PM EST


---
Buy my stuff
[ Parent ]
Nitpickery (none / 0) (#137)
by fortytwo on Wed Jun 02, 2004 at 08:31:12 PM EST

Actually, scalar context dosen't determine the type of comparison - scalar just means you're dealing with one thing - one string, one number, one reference [there's also list and hash context, and some others that nobody cares about]. What's actually happening is that == compares its (scalar) arguments numerically, and non-number scalars become 0 when made into numbers (lists become the number of items in the list, and hashes into something weird). 'eq' compares scalars as strings, which would make the more intuitive behavior.

[ Parent ]
Close... (none / 0) (#229)
by vectro on Wed Jun 09, 2004 at 07:35:07 PM EST

Strings are evaluated as 'true' if they are not empty, or 'false' if they are empty.

In this example, 'cryptic' and 'funny' are both 'true'.

“The problem with that definition is just that it's bullshit.” -- localroger
[ Parent ]

Fun. (2.88 / 9) (#50)
by BigZaphod on Tue Jun 01, 2004 at 01:56:38 PM EST

Sticking stuff like that in is what makes programming fun.  Basically, there's two kinds of programming:  1) Programming to solve a problem.  2) Programming to solve someone else's problem.

It is the second kind of programming that is often the least rewarding.  When you're sitting in a cube and adding feature XYZ because marketing thought the flashing bright colors would sell more units, you simply have to do something to break down that nagging sense of futility...

So anyway, where I used to work a friend and I kind of got good at influencing people to have some fun with the code.  It seemed like just about every project we were working on eventually got some code in there someplace that had silly names or comments.  Everyone seemed to enjoy it.  I figure we were doing a public service by bringing some fun to the daily grind.  :-)

There are two big ones that I remember.  I can't give actual code, of course, but I recall some of the specifics anyway.

One instance had us doing some code to clean up some temporaries used in the calculation of something or other.  The data that needed cleaning up was in a list container of some kind.  The list was renamed to death_row and function that cleaned it up and freed the memory was something like TheExecutioner().  (I wish I could remember exactly...)  There were also many fun comments surrounding this code.  I think there was even something about the governor calling during some of the stages of determining what needed to go on death_row vs. what didn't.

The other instance that sticks out was a time my friend and I were going through a bit of a Mr. T phase.  We had this whole class loaded down with methods like PityDaFool( int fool ) and other Mr. T-isims.  That was fun.  The comments were especially rich...

Of course eventually both my friend and I were let go (a few months apart) and they lost one of their most senior developers in that time, too.  Something strange was going on there.  I don't miss it.

"We're all patients, there are no doctors, our meds ran out a long time ago and nobody loves us." - skyknight

Related note: Easter eggs (3.00 / 4) (#79)
by unDees on Tue Jun 01, 2004 at 06:50:35 PM EST

At my first gig, one of my fellow engineers and I shared a penchant for Easter eggs. Not exactly the same as Milo's notion of wackiness buried in the code itself, but fun to do nonetheless. One project used an algorithm so fancy that he decided we needed something to keep us humble. So he put in an obscure key combination that would play a Darth-like .wav file reminding us not to be too proud of the technological terror we'd constructed. Probably a lot funnier to our sleep-deprived brains than it was to anyone else, assuming someone was bored enough to Escape-Meta-Alt-Control-Shift-click the exact right undocumented pixel.

I also remember a project from a more recent job where you could create a new item on a list, rename it to "Who wrote program name?" and be treated with G-rated pictures of the lead developer in drag at the company Halloween party. We only taught that one to customers we liked.

Your account balance is $0.02; to continue receiving our quality opinions, please remit payment as soon as possible.
[ Parent ]

i was fired for this one... (2.76 / 13) (#56)
by the77x42 on Tue Jun 01, 2004 at 03:06:00 PM EST

Classname = FatAss

Public Event FoodInSight()

Public Sub Eat(varFood)
    var_Food = var_Food - 1
End Sub

-------------

Private WithEvents Ralph [my boss's name] As FatAss

Dim var_Food As Variant
Dim bol_FoodVisible As Boolean

var_Food = CONST_EVERYTHING

Private Sub Ralph_FoodInSight()
   While bol_FoodVisible  
      Call Ralph_Eat(var_Food)
      If var_Food = 0 Then bol_FoodVisible = False
   Wend
End Sub


"We're not here to educate. We're here to point and laugh." - creature
"You have some pretty stupid ideas." - indubitable ‮

heh... (none / 2) (#61)
by Run4YourLives on Tue Jun 01, 2004 at 03:46:06 PM EST

I remember entire email threads built along those chucks of code... If I would have had the balls I would have stuck working copies into the code....

Oh well.

It's slightly Japanese, but without all of that fanatical devotion to the workplace. - CheeseburgerBrown
[ Parent ]

funny thing is... (none / 1) (#62)
by the77x42 on Tue Jun 01, 2004 at 03:49:42 PM EST

... it's probably the cleanest code i've ever written :P


"We're not here to educate. We're here to point and laugh." - creature
"You have some pretty stupid ideas." - indubitable ‮

[ Parent ]
God Save VB! (none / 1) (#107)
by pinkcress on Wed Jun 02, 2004 at 06:54:44 AM EST



---
damnit all these 'facts' getting in the way of my writing - turmeric
[ Parent ]
Printer on Fire (2.86 / 15) (#58)
by arcade on Tue Jun 01, 2004 at 03:20:44 PM EST

I posted this as 'editorial' earlier by mistake, this time it should come out as topical, with a bunch of more info added.

In the nice little file

/usr/src/linux/drivers/char/lp.c:

in the linux kernel, you find the following gem of a code fragment:

 } else if (!(status & LP_PERRORP)) {
 if (last != LP_PERRORP) {
 last = LP_PERRORP;
 printk(KERN_INFO "lp%d on fire\n", minor);
 }

"Printer on fire" is one of the classical unix error messages - with a good history to add.

Jesse Pollard explained it on usenet once (I quote, in full):

"

As I understand it, this message is related to a parallel port (input only style) status code - ready, online, check.

The "check" signal might have had a slightly different name, but it was a "unknown error".

The fire message came from the old drum printers. These had the alphabet on a 3 inch diameter steel drum, one ring of the alphabet for each colum.

Over this would run a ribbon, about 24 inches in width, and 10 feet long. This assembly was all mounted on a door to give access to the paper, and
the print hammers.

The print hammers are all mounted on a fixed base of the printer body, with the fanfold paper running over it.

The drum rotated about 1200 to 2400 RPM. Faster for higher speed printers.

What happens is that the ribbon gets worn and tends to slide toward the side of the printer that is printed on the most (ribbon shrinks, and it
is the right side of the printer). When working normally, the ribbon moves at about 1/4 the speed of the drum. Whenever the ribbon reached the end,
it would hit a switch that would reverse the direction of the ribbon feed.

When the ribbon started shrinking on the right, the entire roll would start bunching up on the right, leaving the left side of the drum
rotating at high speed, directly against the paper.

This condition generates quite a bit of paper dust.

It also tends to cause the paper to jam. If the jam isn't detected soon enough, the accumulated paper dust, ink dust, real paper, AND the rapidly rotating drum would generate enough heat-by-friction contact to start a fire.

This condition is made worse by the printer cleaning solution, which was usually denatured alcohol, whose fumes tended to collect in the ribbon. (had that start a fire once - somebody turned the printer on before the drum had dried; something sparked and there was a brief flash of flame)

The paper jam usually set off the "check" signal and the host would stop sending data to the printer, and report some message to the operator. Sometimes, the offline switch would also be triggered, which (at least in the printer) would stop the drum from spinning. The offline switch was actually triggered by a different condition. I think it was when the paper was no longer in contact with an "out of paper" sensor. If the offline switch wasn't triggered, the drum would continue spinning, and continue adding more heat.

The old lpd on UNIX v 6/7 used the check signal to report a "printer on fire" if the offline signal was NOT present. I believe it was the combination of offline and check signal that was used to generate the "out of paper" message.

"

His original message can be found with the message ID: "<linux.kernel.200208092200.RAA34736@tomcat.admin.navo.hpc.mil>" via groups.google.com

--
arcade

Not in the code but in the project name (2.80 / 5) (#65)
by trollbuster on Tue Jun 01, 2004 at 04:00:09 PM EST

For our final project in college our group decided to to a home security system complete with sensors and a keypad control panel that reported intrusions to a central computer. Because this particular school has a good reputation in the business community of the city our group had to set up an "official" company name for the project as recruiters would usually look at projects at the end of the year. We decided on Secure Homes Integrated Technology. I don't see what the problem was as we always typed out the name in full in all documentation and never used an acronym. After using the name for two months our instructor finally noticed and we got a note from him to change it because it "wasn't very professional" with no reason given. Had a hell of a time trying to come up with another good name and I think we finally just rearranged the words somehow.

Fortitude Under Central Kontrol (none / 0) (#66)
by Milo Minderbender on Tue Jun 01, 2004 at 04:18:14 PM EST

Oh well... I suppose the K could be "Keypad" somehow...

--------------------
This comment is for the good of the syndicate.
[ Parent ]
this one got accepted (none / 0) (#67)
by Norwegian Blue on Tue Jun 01, 2004 at 04:31:17 PM EST

I won't spell out the full name here, But the acronym for a certain finished project was A.R.S. The suggestion was proposed with a straight face and accepted after some deliberation . The acronym ended up on a lot of machines.

Well, more than my two hands anyway. I think.

[ Parent ]

alt.religion.scientology? :-) /nt (none / 1) (#70)
by localroger on Tue Jun 01, 2004 at 05:00:03 PM EST



What will people of the future think of us? Will they say, as Roger Williams said of some of the Massachusetts Indians, that we were wolves with the min
[ Parent ]
Action Request System? (none / 0) (#76)
by tchuladdiass on Tue Jun 01, 2004 at 05:39:15 PM EST

Also known as Remedy? (ticketing system)

[ Parent ]
I'll never tell (none / 0) (#78)
by Norwegian Blue on Tue Jun 01, 2004 at 06:10:45 PM EST

but I can concede this: if our perverted little minds hadn't been busy pondering possibilities for attaching an 'E' at the end, we could have noticed  that ARS is actually a quite flattering name. In latin.

But, let's not attract too much undue attention. Please move on, nothing to see here..

[ Parent ]

I use it daily... (none / 0) (#112)
by Chakotay on Wed Jun 02, 2004 at 08:27:00 AM EST

Our ticketing system is called ARS... It's a retarded version of Remedy, that will soon hopefully finally be replaced by something called SD1 - but still unfortunately based on Remedy :(

--
Linux like wigwam. No windows, no gates, Apache inside.

[ Parent ]
no cigar (none / 0) (#120)
by Norwegian Blue on Wed Jun 02, 2004 at 12:54:52 PM EST

I don't intend to take credit for 101 other programs that use the same acronym.

[ Parent ]
this one got so close (none / 1) (#81)
by Fuzzwah on Tue Jun 01, 2004 at 06:55:31 PM EST

It was put forward and accepted by management right up until someone wrote down the acronym: client liasion (for) information technology services.

The most enjoyable thing about it all was that the section was renouned by being staffed by only females. Numerous jokes were had any time we couldn't find any of them in the office.

--
The best a human can do is to pick a delusion that helps him get through the day. - God's Debris
[ Parent ]

Property Management System... (none / 1) (#89)
by czth on Tue Jun 01, 2004 at 10:34:15 PM EST

seemed somewhat funny when I first heard it. I suppose now I'm used to hearing it, though (plus I got married...).

czth

[ Parent ]

"I am Joe's Pancreas" (none / 2) (#72)
by claes on Tue Jun 01, 2004 at 05:05:32 PM EST

Was, I'm pretty sure, displayed once in a while on the control panel for a multi-million dollar Ion Implanter.

Any other Eaton ex-employes remember that one?

-- claes

Oooh I've got one (2.50 / 4) (#73)
by ksandstr on Tue Jun 01, 2004 at 05:15:33 PM EST

Though this is really an oo reference more than humorous by itself, in cases where a separate datatype wasn't warranted but you still needed to pass several things through an interface where only one would fit, I've been known to pass around void *foo[2] arrays (or, in evul evul javur, Object arrays) that are initialized somewhat like this:

void **params = g_new(void *, 2);
params[0] = first_parameter; /* ONE IS THE JEWEL OF THE NILE */
params[1] = second_thingy; /* THE OTHER IS THE MOON AND STARS */

Cute, and particularly effective if you're passing something small but important as the first parameter and a pointer to a larger context type thing as the second. Seeing as there isn't much point in trying to make C (or Javur, for that matter) look pretty, most people in our team just make do with snide block comments. Of course there are things like the nearly infamous ERR_SHRUBBERY #define that couldn't be removed for historical reasons, but being accidental it shouldn't count.

Funniest example I've seen so far is in the Haskell HaXml library's Combinators module, where "left of right" type combinations are achieved with the `o` form, informally known as Irish composition. The fun really carries over into ordinary code, so you'll end up with things like children `o` deep (tag "cthulhu").

Fin.

for class, but... (2.78 / 14) (#75)
by pb on Tue Jun 01, 2004 at 05:28:55 PM EST

From a threaded tftp server written for class, I created a 'pocket' datatype that consisted of a tftp packet and a socket:

struct pocket {
        struct packet * p;
        struct sockaddr * s;
};

(note: this was so I could pass it as one argument on the stack, using thr_create)

Hence, this comment (shamelessly stolen, apologies to Dr. Seuss and the original author(s)):

/*********************************************************
If a packet hits a pocket on a socket on a port,
And the bus is interrupted as a very last resort,
And the address of the memory makes your floppy disk abort,
Then the socket packet pocket has an error to report!
*********************************************************/

---
"See what the drooling, ravening, flesh-eating hordes^W^W^W^WKuro5hin.org readers have to say."
-- pwhysall

old joke (none / 2) (#94)
by llimllib on Tue Jun 01, 2004 at 11:51:44 PM EST

link

Peace.
[ Parent ]
I think (none / 2) (#192)
by ZorbaTHut on Fri Jun 04, 2004 at 03:18:14 PM EST

that was his point.

[ Parent ]
long time(); /* know C */ (2.88 / 17) (#77)
by gidds on Tue Jun 01, 2004 at 05:49:03 PM EST

I'm surprised no-one's mentioned this yet. Back in 1988, Mike Shon wrote a whole C program based on puns -- it's here.

Andy/
This isn't mine, but... (2.86 / 15) (#84)
by vadim on Tue Jun 01, 2004 at 07:37:12 PM EST

Put this in a header:

#define struct union /* Saves memory */
#define while if /* Saves CPU time */

--
<@chani> I *cannot* remember names. but I did memorize 214 digits of pi once.
hmmmm... (2.81 / 11) (#86)
by xcham on Tue Jun 01, 2004 at 08:04:59 PM EST

I can't take credit for this, this was my friend Andrey's humourous addendum to his first year Comp Sci final project: class Feces extends Exception { // etc.. } somewhere else.. public void Monkey(boolean bowelMovement) throws Feces { if (bowelMovement == true) { throw new Feces(); } }

odd error messages (none / 3) (#87)
by ajaxx on Tue Jun 01, 2004 at 08:09:51 PM EST

i can't claim credit for this one.  i've got a wireless bridge with flashable firmware.  the firmware ships as ARJ archives (why god why).  running strings(1) on the decompressed firmware yields this little beauty:

Hey Moe, it dont woik. NYUK NYUK NYUK NYUK bop Owww!

no idea how one would trigger that, particularly on a device with only web and tftp interfaces.

apple's C compiler (pre-OSX) had several humorous error messages which weren't too tough to trigger.

I have a friend who put some amusing ones in. (none / 3) (#178)
by static on Thu Jun 03, 2004 at 10:26:25 PM EST

It was printer server software for a small front-office. He got bored when doing the error handling and put in "Orange Marmalade? No, Paper Jam!" and "Pieces of Seven! Pieces of Seven! Parrot-y Error!" (it was a serial printer). The support staff were quite amused the first time they encountered one of these, but slightly annoyed they weren't told beforehand about them...

He's probably going to be annoyed I've told this story. :-)

Wade.


[ Parent ]

Great example in classic BSD code (3.00 / 8) (#88)
by ataraxia on Tue Jun 01, 2004 at 10:32:48 PM EST

Can't belive nobody has posted this one yet... This code has been around since the Berkeley days, I think. FreeBSD, /src/sbin/shutdown/shutdown.c has this set of prototypes:

void badtime(void);
void die_you_gravy_sucking_pig_dog(void);
void finish(int);
void getoffset(char *);
void loop(void);
void nolog(void);
void timeout(int);
void timewarn(int);
void usage(const char *);

Spot the joke. It's a real function, too!

--
Don't do something if it's stupid.
Hehe (2.80 / 5) (#95)
by wji on Wed Jun 02, 2004 at 12:37:17 AM EST

I didn't believe you, and weirdly enough Google turns up no such reference. But hey, I shouldn't be so suspicious...

In conclusion, the Powerpuff Girls are a reactionary, pseudo-feminist enterprise.
[ Parent ]
Re: Hehe (none / 1) (#118)
by Maniac on Wed Jun 02, 2004 at 12:10:23 PM EST

Eh? Try searching for die_you_gravy_sucking_pig_dog

[ Parent ]
My bad (none / 1) (#136)
by wji on Wed Jun 02, 2004 at 08:22:10 PM EST

I thought Google ignored underscores just like it ignores dashes, commas, et cetera.

In conclusion, the Powerpuff Girls are a reactionary, pseudo-feminist enterprise.
[ Parent ]
DEC VMS (3.00 / 8) (#91)
by krait on Tue Jun 01, 2004 at 10:38:32 PM EST

The VMS operating system, originally developed by Digital Equipment Corporation to run on VAX computers, and since ported to Alpha and IPF based systems, has some of the best acronyms embedded in it. Some classics like ICBM (IOGEN Configuration Building Module), and NSA (Non-discretionary Security Auditing), CIA (Compound Intrusion Audit), and KGB (Key Grant Block), all associated with the security subsystem spring to mind.

However, the absolute best was working FUBAR into hardware. The acronym stood for "Failed UniBus Address Register"

Quoting from the original "VAX Technical Handbook":

The VAX- 11/780 UNIBUS Subsystem

Failed UniBus Address Register (FUBAR)

The FUBAR contains the upper 16 bits of the UNIBUS address translated from an SBI address during a previous software-initiated data transfer. The occurance of either of two errors indicated in the status register will lock the FUBAR: UNIBUS Select Time Out (UBSTO), and UNIBUS Slave Sync Time Out(UBSSYNTO). When the error bit is cleared, the register will be unlocked.

The FUBAR is a read-only register. Attempting to write to the register will result in an error confirmation. No signals or conditions will clear the register.

If your VAX was FUBARed, it was truly FUBARed in the classic sense of the word.



Fun with Dates (2.92 / 13) (#92)
by Shibboleth on Tue Jun 01, 2004 at 11:25:30 PM EST

I once had to write a program which performed certain operations on data arrays that had a year value between 1970 and 1978. Therefore:

Cool = True
Uncool = False

Disco = Uncool


Do Until Disco = Cool

if Year gt 1970 And Year lt 1978 then

GetDownAndDance
Disco = Cool

Else

MockDiscoDancers

End if

Loop


I've got one (3.00 / 9) (#93)
by Tatarigami on Tue Jun 01, 2004 at 11:49:52 PM EST

Back in my previous job, if you tapped CTRL + more than one key, the customer database would throw up a 'cat on keyboard' error.

someday.. (none / 2) (#152)
by Norwegian Blue on Thu Jun 03, 2004 at 06:52:13 AM EST

I'll find a way to sneak this into our code.

[ Parent ]
Stoopid (2.66 / 6) (#96)
by Brandybuck on Wed Jun 02, 2004 at 12:38:38 AM EST

An authentication function I wrote last year for an embedded system:

void stupidBackdoorThatMarketingWants()

Er... (none / 0) (#197)
by arafel on Fri Jun 04, 2004 at 06:43:56 PM EST

Can you tell us which company that was for, so I make sure I never buy any of their stuff?
Paul
[ Parent ]
If you have to ask... (none / 0) (#198)
by Brandybuck on Fri Jun 04, 2004 at 11:03:15 PM EST

It's for a $250,000 system, bare bones. If this is still in your price range, and you're worried about buying one by accident, contact me offline...

[ Parent ]
Got plenty (3.00 / 6) (#97)
by OzJuggler on Wed Jun 02, 2004 at 01:30:02 AM EST

Gosh, where to start? :-)

This was in a VB app of ours which the user is not supposed to be able to exit from, but that's a real pain when you're debugging, hence...

Sub GetTheHellOutOfHere()
    ttermModel.Destroy
    Unload fMainForm
    End
End Sub

...later...

    'SUPER SECRET back door! Ctrl+Alt+F12
    If (KeyCode = vbKeyF12) And sCtrl And sAlt Then
        GetTheHellOutOfHere
    End If

And elsewhere a humorous default error message if none of the other cases are handled...

Sub TranslateErrors()
    If ttermModel.LastError = ttermModel.teOK Then
        LastErrorStr = ""
    Else
        '!! This was added 21/5/2001 in compliance with
[department manager]'s directive for
        '   the adoption of Haiku error messages.
        LastErrorStr = "Chaos reigns within." & Chr(10) _
                     & "Reflect, repent, and reboot." & Chr(10) _
                     & "Order shall return."
        Select Case AppState
            Case tsEmpNum
                Select Case ttermModel.LastError
                    Case teUnableToValidate
                        LastErrorStr = "Unable to validate employee number."
                    Case teInvalidParameters
                        LastErrorStr = "Invalid employee number entered."
                    Case teAlreadyThere
                        LastErrorStr = "You have sessions open on other terminals.  " _
                        & "Close the other sessions or wait for them to time out."
                End Select
    [..and so forth....]

The menu screen structure was modelled as a FSM, but since pressing Escape never needs to go to any state other than the previous state,
why waste space and time maintaining a whole history of screen navigations when you only need one variable to store the previous one?
So in the code for handling state transitions...

        If Not cancelled Then
            ShortAttentionSpan = AppState
            AppState = ns
        End If

Our app even had context-sensitive help!

Private Sub ShowHelpFor(helpContext As String)
    frmHelp.GetTherapy helpContext
End Sub

Of course a favourite target of code humour is creating and killing processes... or threads in this Java example...

            Timer asassination = null;
            if (spec.maxSeconds>0) {
              //Enforce maximum allowable execution time.
              asassination = new Timer(true);
              TimerTask sniper = new TimerTask(){
                public void run(){
                  proc.destroy();
                  this.cancel();
                  //!! generate an event and send to scribe.
                  PamEvent pe = new PamEvent();
                  pe.eventType = PamEvent.ET_NATIVE_EXCEEDED_TIMELIMIT;
                  pe.sourceTest = spec.testIDNum;
                  recorder.recordEvent(pe);
                }
              };
              asassination.schedule(sniper, spec.maxSeconds*1000); //One shot. One kill.
            }

And I can guarantee that all of these examples are in production right now.
Ah the luxury of being the sole analyst/programmer.

"And I will not rest until every year families gather to spend December 25th together
at Osama's homo abortion pot and commie jizzporium." - Jon Stewart's gift to Bill O'Reilly, 7 Dec 2005.

This is a funny ancedote (2.70 / 10) (#98)
by Resonant on Wed Jun 02, 2004 at 02:15:03 AM EST

...or at least I think it is. My friend is sitting coding one day, and I am watching him (I forget what we were working on). All of the sudden he opens up a new file, and writes this (C++): int main() { while(1) { do(yourmom); } } and I responded "Dude, your going to be really tired". So without missing a beat, he goes back and puts this: int main() { while(1) { do(yourmom); sleep(100); } } The hard thing to convey with that story is the speed at which it happened. The whole event lasted probably 20 seconds. Ironic, is it not?

"I answer, 'This is _quantitative_ religious studies.'" - glor
No formatting (none / 1) (#99)
by Resonant on Wed Jun 02, 2004 at 02:16:28 AM EST

Wow, do I feel stupid. Oh well, your programmers...figure it out :)

"I answer, 'This is _quantitative_ religious studies.'" - glor
[ Parent ]
A friend sent me this (none / 3) (#100)
by Wildgoose on Wed Jun 02, 2004 at 02:56:01 AM EST

He was working as a COBOL programmer at Royal & Sun Alliance, a large British Insurance company. He came across a list of variables all beginning "CAMP", in the middle of which was one named "CAMP-OOH-DUCKIE".

I thought of another one (2.50 / 4) (#101)
by Milo Minderbender on Wed Jun 02, 2004 at 03:22:14 AM EST

The teenage sense of humor that still resides within me likes this one... I wrote an e-commerce system once that generated "e-coupons" and sent you a code via email that you could type in to the site and get a discount if it applied to an item in your shopping cart. One of the subsequent requirements was to make a type of e-coupon that could be mass-mailed to all the people subscribed to receive e-coupons. I resented this requirement at little bit because it sounded a little like unwanted email (even though the unsubscribing really did work). I almost named them:
spampons


--------------------
This comment is for the good of the syndicate.
WONDERFUL!!! (none / 2) (#149)
by stalker on Thu Jun 03, 2004 at 06:01:09 AM EST

You had me giggle incontrollably with that. Now I *must* find an use for that word. Oh my, oh my... spampons :) tee-hee, heh heh :) heh.

[ Parent ]
One of my inept favourites. (3.00 / 8) (#113)
by scross on Wed Jun 02, 2004 at 08:40:57 AM EST

One of my all time favourites. The programmer appears to want to ensure that his string was zero terminated.
strcat(buffer, "\0");

Cheers, Sarah
lol (I actually did) [n/t] (none / 2) (#143)
by milksop on Thu Jun 03, 2004 at 01:26:36 AM EST


--
i make games.
[ Parent ]
I'll bite. (none / 1) (#184)
by Handyman on Fri Jun 04, 2004 at 03:37:32 AM EST

What's wrong with this one? Doesn't it just overwrite the existing zero-terminator with a new one?

I tried the following code, and it seemed to work fine.

#include "stdio.h"
int main() {
    char buffer[10] = "Testing";
    printf("'%s'\n",&buffer);
    strcat(buffer,"\0");
    printf("'%s'\n",&buffer);
    return 0;
}

Output:
'Testing'
'Testing'

Can you explain the problem to me?

--
Never be afraid to be the first one on the dance floor.
[ Parent ]

The problem (none / 0) (#191)
by ZorbaTHut on Fri Jun 04, 2004 at 03:03:45 PM EST

It's valid code, and "works". It just does nothing. Remember that C strings are delimited by the \0, so if I feel very clever and write the string "hello\0world" every function will consider that equivalent to "hello".

In this case, "\0" is equivalent to "", so that ends up being strcat( buffer, "" ); - which is obviously kind of pointless. :)

[ Parent ]

Except (none / 0) (#212)
by epepke on Mon Jun 07, 2004 at 12:20:10 AM EST

If the first nul it finds happens to be in protected memory, in which case it will generate an error.


The truth may be out there, but lies are inside your head.--Terry Pratchett


[ Parent ]
Eh? (none / 0) (#218)
by ZorbaTHut on Mon Jun 07, 2004 at 05:03:11 PM EST

It's a string on a stack, and it's not too large. Why would the first null delimeter be in protected memory?

[ Parent ]
If it's a malloc'd string... (n/t) (none / 0) (#221)
by nollidj on Tue Jun 08, 2004 at 12:15:42 AM EST



muahaha. MuaHaHA! MUAHAHAHAHAHAAAHAHAHAA!!!!
[ Parent ]

No. (none / 0) (#222)
by ZorbaTHut on Tue Jun 08, 2004 at 12:52:53 AM EST

strcat( somestring, "\0" ); is incapable of causing a segfault unless somestring is an invalid string or points to read-only memory. It will rewrite the \0 on the end - it will not extend the space taken up by the string at all.

char *foo = malloc( 8 );
strcpy( foo, "abcdefg" ); // seven letters, plus null terminator equals eight bytes
strcat( foo, "\0" ); // does nothing useful, but is safe.
free( foo );

[ Parent ]

Protected memory? Others have mentioned it (none / 0) (#225)
by nollidj on Tue Jun 08, 2004 at 10:35:54 PM EST

It conceivably cause some sort of error, was my suggestion. If the string is malloc()'d, strcat could just happily iterate through the heap for an arbitrary length. I am assuming that the programmer calling strcat(buffer,"\0") might not have buffer be null-terminated, else it is certain that nothing shall happen.

It is apparent that you're right (and nothing will happen), but I still do not liking this idea of the reading arbitrarily through memory. One could conceivably go outside the heap (although the possibility of doing so is pretty much nil), but you'd still just replace a null with a null. There are no environments where areas of memory cannot be read into? Would trying to write a null outside of the heap not cause an error?

muahaha. MuaHaHA! MUAHAHAHAHAHAAAHAHAHAA!!!!
[ Parent ]

Well (none / 0) (#228)
by ZorbaTHut on Wed Jun 09, 2004 at 05:11:14 PM EST

You're right, if you give strcat invalid arguments - i.e. things that aren't null-terminated strings - anything could happen. Most modern OSes won't allow you to read outside your address space (try running *(char*)NULL = 0; for a nice dramatic example) and very few programs will allocate precisely 4gb RAM. :)

However, once you're saying "invalid arguments", everything goes out the window anyway. :) I sort of don't bother thinking about that - it's like someone saying "My server has 99.99% uptime!" and you respond "Yeah, well, what about ELEPHANT STAMPEDES???!!!" Some things you just don't have any control over.

So: If foo is a null-terminated string that isn't in read-only memory (which does exist, yes), strcat( foo, "\0" ); cannot possibly crash, barring hardware failure or a buggy implementation of strcat. If it crashes, either you've got hardware problems, it's read-only memory, it's not a null-terminated string, or you need a new runtime library.

Or, if you're really unlucky, all four.

[ Parent ]

Strings on the stack? (none / 0) (#231)
by epepke on Fri Jun 11, 2004 at 05:07:46 AM EST

I don't often meet those, and in those cases it's usually threaded interpreted languages.

In implementations of C, strings don't generally go on stacks, or at least, I've never met an implementation that does that. The address to the sting might be on the stack. A declared automatic array variable, of course, will be on the stack, but the stack is not infinite, and above it is no-man's land.


The truth may be out there, but lies are inside your head.--Terry Pratchett


[ Parent ]
You forget how strcat works. (none / 0) (#194)
by gooberguy on Fri Jun 04, 2004 at 06:09:05 PM EST

The function strcat looks for the null character at the end of the string to append what it needs to. If the string for some reason isn't null terminated, then strcat will keep on going until it finds a null character somewhere in memory. Then it will delete that null character and replace it with the string to be appended, followed by a null character. In the parent's case, the end result will be that (if the string is not null terminated) some poor byte after a null character in memory will be changed to null.

[ Parent ]
No, it won't (none / 0) (#209)
by epepke on Sat Jun 05, 2004 at 11:28:55 PM EST

strcat will see "\0" just the same as "" as a string of zero length, so the only thing it will do is replace the first nul with a nul, which is pretty dumb.


The truth may be out there, but lies are inside your head.--Terry Pratchett


[ Parent ]
Actually it doesn't... (none / 0) (#185)
by hvangalen on Fri Jun 04, 2004 at 03:40:22 AM EST

Hi!

The line,

strcat( buffer, "\0" );

...does *not* append a NULL behind the buffer, but appends the digit 0 (zero).

So the code is doing something else than you think it does, which can be considered Code Humor as well :)

Cheers.

[ Parent ]
Wups. (none / 0) (#187)
by hvangalen on Fri Jun 04, 2004 at 03:52:50 AM EST

And if I didn't have such fat fingers I'd correctly would've concluded that the above wasn't true. :D

[ Parent ]
You all miss the point (none / 0) (#208)
by samjam on Sat Jun 05, 2004 at 04:50:21 PM EST

The point isn't that: strcat(buffer, "\0"); doesn't "do" anything useful, its that strcat requires that buffer already contains a null terminated string; in other words it CANNOT solve the original problem of adding a null to a non null-terminates string. Sam

[ Parent ]
Making a daemon... (2.50 / 4) (#114)
by beggs on Wed Jun 02, 2004 at 09:24:59 AM EST

This is from one of my first projects but I believe it is still out there:

void blasphemy(bool daemon){
    int pid = fork();

    // start child process
    switch(pid){
      case -1:
        fprintf(stderr, "COULD  ;NOT FORK -- EXITING!\n");
        exit(-1);
        break;
      case 0:
        // child -- all&n bsp;is good.
        break;
      case 1:
        // parent -- kill .
        exit(0);
        break;
      default:
        // fork() on sola ris returns the child pid to the parrent  ;on success so any positive 
        // return value i nicated that we are the parrent. 
        exit(0);
        }
    if(daemon){
        // only the daemo n process should ever get here...
        fprintf(stderr, "daemon&nbs p;process id: %i\n", (int)getpid());
        }
}

bool curse(){
    // blasphem once and you can&nb sp;be saved
    blasphemy(FALSE);
    // set group to null;
    setpgrp();
    // blasphem twice and you are&n bsp;cursed
    blasphemy(TRUE);

    // no one hears the cursed  ;screem
    fclose(stdout);
    fclose(stdin);
    fclose(stderr);

    return(TRUE);
}

--- -- ---- - ----- --------- :: brian jeffery beggerly :: :: beggs@SPAM.confusion.cc :: :: http://confusion.cc :: - -- ------- -------- -------
I see (none / 3) (#121)
by FeersumAsura on Wed Jun 02, 2004 at 01:20:36 PM EST

You were also going for the largest number of spelling errors possible in a section of source code. Congratulations.

I'm so pre-emptive I'd nuke America to save time.
[ Parent ]
who cares? (none / 2) (#131)
by beggs on Wed Jun 02, 2004 at 06:15:38 PM EST

if it makes it through the compiler it's spelled right.
--- -- ---- - ----- --------- :: brian jeffery beggerly :: :: beggs@SPAM.confusion.cc :: :: http://confusion.cc :: - -- ------- -------- -------
[ Parent ]
How about GNU libc... (3.00 / 7) (#116)
by jreilly on Wed Jun 02, 2004 at 11:36:37 AM EST

All C programmers know about strstr, strcpy, etc, right? Well, the gnu coders clearly got bored one day and threw in:
char* strfry(char*)
which obviously randomly swaps around characters in a string =)

Oooh, shiny...
Also memfrob (nt) (none / 1) (#196)
by arafel on Fri Jun 04, 2004 at 06:40:32 PM EST


Paul
[ Parent ]
Old time COBOL (2.80 / 5) (#117)
by xptm on Wed Jun 02, 2004 at 11:42:10 AM EST

Back in my early years i was doing some COBOL, and used var names like 'wine', 'barrel', 'bottle', so i can write move wine from barrel to bottle. perform DrinkWine until BottleIsEmpty. and things like that.

One of the old-timers (none / 0) (#216)
by Cro Magnon on Mon Jun 07, 2004 at 09:51:14 AM EST

in my office had a code segment: Perform Beat-Your-Wife until She-Screams. Obviously, he wrote that while he was having marital problems.
Information wants to be beer.
[ Parent ]
hm (none / 3) (#119)
by EMHMark3 on Wed Jun 02, 2004 at 12:43:32 PM EST

Had this for a sig a while back, can't remember where I got it from though:

if (false)
    panic();

T H E   M A C H I N E   S T O P S

Sun HME Linux Driver (2.80 / 10) (#122)
by rohrbach on Wed Jun 02, 2004 at 01:24:10 PM EST

The Sun Happymeal driver for Linux comments are quite nice ;-)

525         /* Welcome to Sun Microsystems, can I take your order please? */
526         if (!hp->happy_flags & HFLAG_FENABLE)
527                 return happy_meal_bb_write(hp, tregs, reg, value);
528
529         /* Would you like fries with that? */
530         hme_write32(hp, tregs + TCVR_FRAME,
531                     (FRAME_WRITE | (hp->paddr << 23) |
532                      ((reg & 0xff) << 18) | (value & 0xffff)));
533         while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
534                 udelay(20);
535
536         /* Anything else? */
537         if (!tries)
538                 printk(KERN_ERR "happy meal: Aieee, transceiver MIF write bolixed\n");
539
540         /* Fifty-two cents is your change, have a nice day. */
541 }

A complete and online version can be found there:
http://lxr.linux.no/source/drivers/net/sunhme.c

Regards,
/k

--
Give a tool to a fool, and it might become a weapon.

That whole file, in fact... (3.00 / 4) (#195)
by arafel on Fri Jun 04, 2004 at 06:39:19 PM EST

is pretty much filled with good comments. I think so far I like: == /* Lettuce, tomato, buggy hardware (no extra charge)? */ if (!tries) printk(KERN_ERR "happy meal: Transceiver BigMac ATTACK!"); == the best, but they're all pretty good. Strange how a lot of the panics and insults are in the sparc branch...
Paul
[ Parent ]
GPL == Amateur (1.06 / 15) (#124)
by FeersumAsura on Wed Jun 02, 2004 at 04:34:00 PM EST

The majority of examples that have been given by people are quite interesting, what is disturbing is those that are grossly unprofessional and show a level of humour that a five year old would be ashamed of. It was clear that the VB programmers had a much lower standard of code and humour, but the C users didn't fare too well either.

What was most interesting was that it highlighted how unprofessional some programmers are and that the "coders are god" ethos still pervades. This is the reason you're all unemployed, you can't act professionally in a professional environment. Just do what you're asked to do, take the money and run. If you want to make lame jokes, or bad puns work on a joke project and GPL it. No one will notice it as it becomes lost in the plethora of crap on sourceforge and there's no danger of being fired. If this business continues then the notion of GPL == amateur will become truer than it already is.

I'm so pre-emptive I'd nuke America to save time.

Being professional (none / 3) (#130)
by jadibd on Wed Jun 02, 2004 at 06:15:03 PM EST

[...] are grossly unprofessional and show a level of humour that a five year old would be ashamed of.

Well, I congratulate you for being such a professional professional! But, you know, being a humang being involves more than detachment and acting like a partly creativity-enhanced CPU.

Being creative involves all of a persons abilities, not only deploying ever more creative algorithms and applying the known ones in new ways. It also extends to being childish at times, playing around and playfully experimenting with new ideas. And poking fun at the powers that be. So what.

Calling this "unprofessional" just shows how stuck up the caller is, just go ahead, show us, how superior your angel like programming skills are, humble all the harmless jokers with your wit!



[ Parent ]
Be human on your own time (1.33 / 6) (#134)
by FeersumAsura on Wed Jun 02, 2004 at 07:39:02 PM EST

being a humang being involves more than detachment and acting like a partly creativity-enhanced CPU

You are free to be a human being when you're not at work. While at work you should operate in a professional manner.

Being creative involves all of a persons abilities, not only deploying ever more creative algorithms and applying the known ones in new ways. It also extends to being childish at times, playing around and playfully experimenting with new ideas. And poking fun at the powers that be. So what.

It still doesn't excuse unprofessional comments and method names etc. in release quality code. One day a maintenance programmer will be looking through your code. Up to date comments, accurate UML diagram and usuable documentation will be appreciated far more than toilet humor or jokes about people they'll never meet.

humble all the harmless jokers with your wit!

My code contains no jokes. Only meticulous indenting, fastidious use of Javadoc and useful comments in code sections all backed up by full sets of UML diagrams.


I'm so pre-emptive I'd nuke America to save time.
[ Parent ]

Yawn! (none / 3) (#145)
by Milo Minderbender on Thu Jun 03, 2004 at 03:35:36 AM EST

God, you must be boring to work with! If you can't comprehend how someone could have meticulous indenting, fastidious use of Javadoc and useful comments in code sections all backed up by full sets of UML diagrams and have a laugh at the same time, then you really have no sense of humor. You're probably the butt of the other programmers' jokes and don't know it.

On the other side of the coin, however, employees that try so hard to be funny such that they screw up the code with misspelled variable names (I worked with a guy once that thought his variables called things like "arrray" were the funniest thing ever) or generally make unreadable code are being very unprofessional and should be corrected or jettisoned. But it is most certainly possible to be professional and funny, and the employees will be happier and more productive because of it.

If you are interested enough by UML diagrams to not need any laughter around, you really are a boring drone.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
YHBT (none / 0) (#159)
by FeersumAsura on Thu Jun 03, 2004 at 08:55:53 AM EST

God, you must be boring to work with!

Why would I waste time talking to people I work with about non-work related matters? I have friends outside of work for that.

then you really have no sense of humor.

I have a great sense of humour, it allows me to troll people like you.

I'm so pre-emptive I'd nuke America to save time.
[ Parent ]

It's not a troll... (none / 2) (#173)
by warrax on Thu Jun 03, 2004 at 05:38:35 PM EST

if the troller (so to speak) has to reply to every post to keep it going. Well, it may technically be a troll, but it's a rather sad one. Good day.

-- "Guns don't kill people. I kill people."
[ Parent ]
Yeah (none / 0) (#175)
by FeersumAsura on Thu Jun 03, 2004 at 06:29:04 PM EST

boredom and lack of time didn't help.

anyway k5 is dying.

I'm so pre-emptive I'd nuke America to save time.
[ Parent ]

Um. (none / 0) (#205)
by KrispyKringle on Sat Jun 05, 2004 at 02:37:47 PM EST

Boredom implies an excess of time, not a lack of it.

See, as in my case, I have both an excess of time and a dearth of entertainment, hence my being bored enough to reply to someone like you.

[ Parent ]

too bored (none / 0) (#207)
by FeersumAsura on Sat Jun 05, 2004 at 03:46:05 PM EST

with k5 to out the effort in

I'm so pre-emptive I'd nuke America to save time.
[ Parent ]
Yeah, yeah, IBHT but... (none / 0) (#171)
by rodoke3 on Thu Jun 03, 2004 at 02:26:29 PM EST

people who think like that are the inspiration for "Office Space".

I take umbrage with such statments and am induced to pull out archaic and over pompous words to refute such insipid vitriol. -- kerinsky


[ Parent ]
part time humans (none / 0) (#176)
by jadibd on Thu Jun 03, 2004 at 07:09:22 PM EST

You are free to be a human being when you're not at work.

Thank god (or whatever entity you happen to believe in) I'm free to be a human being even while I'm at work.

Ok, so I'm in the happy position to define the standards for this company since I own it. But, so what, we even got a pretty positive result in a code review conducted by a competitor on behalf of one of our major clients. And, yes, there is a fair amount of jokes in the code.

Up to date comments, accurate UML diagram and usuable documentation[...]
..are not mutually exclusive with having fun while you work.

I suspect you'd never think twice about any job offering we may have for a Java professional but be assured, we wouldn't be tempted to offer the job to you either, just for the fear of you ruining the fun we have fulfilling our clients requests.



[ Parent ]

How ironic (3.00 / 6) (#132)
by Ta bu shi da yu on Wed Jun 02, 2004 at 06:40:04 PM EST

Professional environments would be places like Microsoft.

You do realise that the Microsoft codebase used to have the BURGERMEISTER variable (or something similar to this - read Charles Petzold's Windows 3.1x programming book, in particular the memory management section), because the programmers enjoyed eating at their local burger joint. So much for coding in a professional environment.

While we're on this subject, you are aware of the number of easter eggs that have been popping up in Office software for years? But then again, I suppose no true professional would code a car racing game or flight simulator in Excel. Hey.

---
AdTIה"the think tank that didn't".
ה
[ Parent ]

MS (none / 2) (#133)
by FeersumAsura on Wed Jun 02, 2004 at 07:35:16 PM EST

I never said Microsoft were a professional company. Also just because it is a professional environment is no guarantee that all employess will be professional. It's been shown quite clearly in this story that there are always bad apples at even the most professional of companies.

I'm so pre-emptive I'd nuke America to save time.
[ Parent ]
Yeah? (none / 1) (#144)
by Ta bu shi da yu on Thu Jun 03, 2004 at 03:24:32 AM EST

So what do you define as a professional company? I'd count it as a professional company, considering half of the worlds computers run it.

---
AdTIה"the think tank that didn't".
ה
[ Parent ]
MS (none / 0) (#158)
by FeersumAsura on Thu Jun 03, 2004 at 08:54:33 AM EST

MS are a professional company, I just never stated that fact in my original post. However, as I mentioned, a professional company may have some unprofessional workers who infect the code with gibberish.

I'm so pre-emptive I'd nuke America to save time.
[ Parent ]
Whatever. (none / 1) (#163)
by Ta bu shi da yu on Thu Jun 03, 2004 at 10:13:32 AM EST

So let me get this straight. You never said Microsoft is a professional company, but now you say they are a professional company. You state that people who use the GPL license are unprofessional, and can't code in a "professional" environment - however (bare with me here) you also state that the GPL will become more amateur than it already is if joke code gets into projects - implying that all GPLed software is amateurish already. Thus with one sweeping statement you codemn all software created under the GPL to the same category: "amateur".

Next, you state that professional coders should "Just do what you're asked to do, take the money and run." in a "professional environment". I must congratulate you on this point, because you certainly put your case forward most persuasively! Next time I look for quality in code, I'll try to find a company where the coders do this - NOT.

If people scroll all the way to your previous comment, it's pretty obviously you don't know what you're talking about. I mean, your best argument is against poorly written Linux error codes! GPL code can be just as professional as commercial code. In some cases it's even better. You also have the added benefit of code that's potentially gone through a massive code audit... yadda yadda yadda cathedral and the bazaar yadda yadda yadda. Note here that one of the reasons this model works so well is because of it's peer review. Really, crap quality code (under ideal and popular projects) is weeded out. In a "professional environment" (incidently, could you define what this means?!?) it appears you can still have unprofessional coders, and the code doesn't get picked up. So much for the quality code is produced in a professional environment argument...

You, unfortunately, seem to be coming from a perspective where software created under the GPL license is free, as in beer. There is absolutely nothing stopping a company selling GPLed software, or selling support/maintenance contracts to firms who need that software. And for goodness sake, it's a copyright license, not a guarantee that you'll create good/bad software!

---
AdTIה"the think tank that didn't".
ה
[ Parent ]

Read carefully (none / 0) (#165)
by FeersumAsura on Thu Jun 03, 2004 at 10:51:59 AM EST

So let me get this straight. You never said Microsoft is a professional company, but now you say they are a professional company.

Yes. Is that really so difficult to understand. If in post A I do not state that daffodils are yellow, this does not mean that I have stated that daffodils are not yellow. I have merely not commented on their colour. In no place did I say MS are not a profgessional company, I just failed to say that MS are a professional company.

ou state that people who use the GPL license are unprofessional, and can't code in a "professional" environment

Incorrect. I stated that people who use the GPL licence are unprofessional. I never stated they could not work in a professional environment.

however (bare with me here) you also state that the GPL will become more amateur than it already is if joke code gets into projects - implying that all GPLed software is amateurish already. Thus with one sweeping statement you codemn all software created under the GPL to the same category: "amateur".

Yes. I over generalized to create a reaction, which was effective.

/I mean, your best argument is against poorly written Linux error codes! /

Wow. I didn't even realise I'd made any real arguments. I'd just put some completely unjustified assertions up and let people reply.

I'm so pre-emptive I'd nuke America to save time.
[ Parent ]

So IHBT. (none / 0) (#188)
by Ta bu shi da yu on Fri Jun 04, 2004 at 07:10:46 AM EST

Oh well, I did enjoy the conversation nonetheless.

---
AdTIה"the think tank that didn't".
ה
[ Parent ]
Like the Linux Kernel for example? (nt) (none / 1) (#151)
by Peaker on Thu Jun 03, 2004 at 06:42:35 AM EST



[ Parent ]
You've (none / 1) (#157)
by FeersumAsura on Thu Jun 03, 2004 at 08:53:37 AM EST

hit the nail on the head.

It's error messages are a prime example of unprofessionalism in gpl software

I'm so pre-emptive I'd nuke America to save time.
[ Parent ]

Care to back that up with fact? (nt) (none / 1) (#161)
by Ta bu shi da yu on Thu Jun 03, 2004 at 09:52:01 AM EST



---
AdTIה"the think tank that didn't".
ה
[ Parent ]
"Professional" != "It works" (none / 3) (#177)
by epepke on Thu Jun 03, 2004 at 08:24:21 PM EST

Originally, the term "professional" was only used to describe business associated with the Church, which includes the priesthood, medicine, and law. The chief characteristics of these professions have been taking oneself too seriously, acquiring titles, wearing costumes, expecting deference and respect with or without giving anything of value in return, talking in a funny language to confuse the hoi polloi, and in all respects having a status and self-opinion above everyone else.

The people who actually made things work were called tradesmen or craftsmen or engineers.

Little has changed.


The truth may be out there, but lies are inside your head.--Terry Pratchett


[ Parent ]
sir, (none / 0) (#236)
by Battle Troll on Wed Jun 16, 2004 at 12:05:28 PM EST

You misused 'hoi polloi.' I guess that's engineer 'intelligence' for you.
--
Skarphedinn was carrying the axe with which he had killed Thrainn Sigfusson and which he called 'Battle Troll.'
Njal's Saga, ca 1280 AD
[ Parent ]
Can be professional and humorous at the same time (none / 0) (#167)
by aplope on Thu Jun 03, 2004 at 12:10:31 PM EST

While I don't agree with code like this going into production, I have to say that you can be humorous and professional at the same time. It does not always have to be toilet humor.

For example, our DBA had to update some records and needed to mark these records so we could easily tell which had been changed (and did not want to mess with the "last updated" field). So he found a column which from all appearances was not being used and put "Lil Dude" in this column. It was never meant to go to production, but unfortunately we had invoice statements sent to customers with "Lil Dude" on them! Senior management was not happy about this, but when they realized it was an honest mistake and never meant to be on the statements, they calmed down. Now it's something we laugh about and even have a server named "LilDude".

But as for method and variable names, I have to agree with using proper names just for the sake of the maintenance programmer to come after me. And if you will notice, most of the posts were people who were about to LEAVE their job. They weren't much in the way of being nice to the company or worrying about such stuff.

[ Parent ]

I don't think you meant it, which makes it funny (none / 0) (#217)
by decaf_dude on Mon Jun 07, 2004 at 01:51:36 PM EST

...and makes you look stupid.

Word amateur stems from the Latin amator, which means lover, devoted friend, devotee, enthusiastic pursuer of an objective; French amateur has similar connotaions and is probably where the English picked it from.

So, yes, I fully agree with you: GPL == amateur.

--
http://slashdot.org/comments.pl?sid=89158&cid=7713039


[ Parent ]
Get a life. (none / 0) (#234)
by guyjin on Tue Jun 15, 2004 at 05:15:51 PM EST

Or better yet, a soul. (or do you leave that at the door of your workplace, too?)
-- 散弾銃でおうがいして ください
[ Parent ]
excellent, sir. (none / 0) (#235)
by rmg on Tue Jun 15, 2004 at 05:51:45 PM EST

my hat goes off to you!

your daily shot of schadenfreude

dave dean
[ Parent ]

Perl code of biblical proportions (2.75 / 4) (#126)
by LrdChaos on Wed Jun 02, 2004 at 05:12:43 PM EST

This one's in Perl, but it's not being cryptic that makes it funny. The code isn't mine, it's from the source code to a web messageboard that I helped out on for a brief period:

sub chomp_url ($$) {
 my $the_red_sea = shift;
 return $the_red_sea if $the_red_sea =~ /^<img src=/;
 return $the_red_sea unless length($the_red_sea) > 70;
 return $the_red_sea unless $the_red_sea =~ m!://!;
 # Fix up 'dem pesky ampersands
 $the_red_sea =~ s!&!&!g;
 $the_red_sea =~ s!(?:(\?)|[&;])s=[\w\d]{16,32}(?:&|;|$)!$1!g;
 my ($moses, $did_indeed) = split /\:\/\//, $the_red_sea;
 my @miracle = split "/",$did_indeed;
 my $worker = substr($miracle[1], 0, 7,);
 my $maybe = substr($miracle[$#miracle],length($miracle[$#miracle])-7);
 return $moses.'://'.$miracle[0].'/'.$worker.'....'.$maybe;
}


D'oh! (none / 1) (#127)
by LrdChaos on Wed Jun 02, 2004 at 05:14:46 PM EST

Previewing lost my HTML entities in that post ... the line after the "# Fix up 'dem pesky ampersands" comment should read:
$the_red_sea =~ s!&amp;!&!g;

[ Parent ]
man 3perl errno (on debian) (none / 1) (#128)
by vadim on Wed Jun 02, 2004 at 05:17:25 PM EST

use Errno;

unless (open(FH, "/fangorn/spouse")) {
if ($!{ENOENT}) {
warn "Get a wife!\n";
} else {
warn "This path is barred: $!";
}
}

--
<@chani> I *cannot* remember names. but I did memorize 214 digits of pi once.
Author unknown (3.00 / 7) (#129)
by walwyn on Wed Jun 02, 2004 at 05:24:18 PM EST

Declaration of a Software Professional

class SoftwareProfessional
{
private:
   double  salary;
   long    lunches;
   float   jobs;
   char    unstable;
   void *  work;

private:
   complex UpdateSkills();
   long    DownloadPictures();
   long    PlayNetworkGames(SoftwareProfessional& OtherProfessional);

public:
   short         PaintTheManagers();
   virtual void  WorkDuringDay() = 0;
   long          SendMails();
   long          ReceiveMails();
   long          Send(Pictures& pictures);
   long          Send(Jokes& jokes);
};


----
Professor Moriarty - Bugs, Sculpture, Tombs, and Stained Glass

Users (none / 2) (#138)
by sethadam1 on Wed Jun 02, 2004 at 08:54:11 PM EST

I have written every character of my company's intranet, and the server side code is FILLED with sarcastic quips, funny functions names, and stupid comments, but by far, my favorite is this:

Anytime a new form/application on the intranet needs to maintain it's own user source, I aalways populate the db with my test users: Agustus Gloop, Veruca Salt, Mike TeeVee, Violet Beauregard, and Charlie Bucket.  

Profanity filter (2.85 / 7) (#141)
by motty on Wed Jun 02, 2004 at 10:50:31 PM EST

I was once asked to write a profanity filtering module in Perl for a certain well-known UK-based website, and managed to get away with calling it the 'Multiply Extensible Rude Description Eliminator', or 'Merde' for short.

I was not a happy bunny at the time; somewhere in cvs is a commit commented something like 'Removed profanities from comments', and another, commented 'Removed profanities from error messages'.

It's still in use.
s/^.*$//sig;#)

One of my old work-places... (none / 0) (#200)
by ramses0 on Sat Jun 05, 2004 at 12:13:52 AM EST

I got tasked with writing the profanity filter as well.  It is/was kind of neat because depending on category where postings were made, some words were verboten, some warnings, etc (had to account for adult sections, if applicable).

Anyway, it wasn't just enough to search for / flag the bad words, we also had to look for them at the beginning or end of words (ie: Fuck, Fucker, Motherfucker, etc.)  Long story short, the working title was SHIT_SCANNER, because ... well, that's what it did.  :^)

I think it ended up being offensive to somebody and we probably renamed it to "Bad Word Filter" or something more generic.

--Robert
[ rate all comments , for great ju
[
Parent ]

USS Unifarce (none / 2) (#142)
by davros4269 on Thu Jun 03, 2004 at 12:13:33 AM EST

My boss was actually a programmer who looked at our code, I never got to do anything funny...

I did manage to put in some funny comments and even some stupid ASCII pictures, like a picture of a fly with the comment something like, "I feel sorry for the next person that has to work on this pile of shit" - this was a few days before I quit...

I was working in Uniface at the time - really ridiculous environment, anyway, it was a mostly worthless GUI wrapped around a generic database engine - in order to access a table in the code, that table had to be "drawn" on the GUI - so amongst the visible fields and such we had to draw tables and hide them - that is, draw an element which represented a certain table, usually as small as the GUI editor would allow and then set it invisible...

I did this once and it sorta looked like a Star Trek ship, so I arranged the inviable tables more into the shape of a ship and added the invisible label, "USS Uni-farce" over it...

We had a multi-player tic-tac-toe game written - I was just making an AI when the boss axed the "project"...:(


Will you squirm when you are pecked? Quack.

Ha! (2.50 / 6) (#146)
by Milo Minderbender on Thu Jun 03, 2004 at 03:58:39 AM EST

This page is the top google hit for "Polish McNugget". :-)

--------------------
This comment is for the good of the syndicate.
No point in assigning zero when it already is (none / 2) (#147)
by lookout on Thu Jun 03, 2004 at 04:44:16 AM EST

if x <> 0 then x = 0

(from a Basic program anno 1980)


I beg your pardon (none / 0) (#160)
by Ashalind on Thu Jun 03, 2004 at 09:49:21 AM EST

...isn't that piece of code above equal to

if (!x) x=0;

this looks valid to me, although simply

x=0;

would be better of course...

[ Parent ]

No (none / 0) (#172)
by silk on Thu Jun 03, 2004 at 05:26:25 PM EST

The code is equivalent, instead, to:

if (x != 0) x=0;

.

[ Parent ]

Well (none / 0) (#174)
by jadibd on Thu Jun 03, 2004 at 05:38:53 PM EST

So it could be shortened to:

if (x) x=0;

[ Parent ]

BASIC too (none / 0) (#183)
by LocalH on Fri Jun 04, 2004 at 02:44:02 AM EST

That'll work in most BASICs too, with the exception of the semicolon. Since a nonzero value is considered true, IF (X) X=0 would work fine. For a bit more obfuscation (albeit not much), you could also use IF X X=0.

[ Parent ]
No point in *checking* when it always must be 0. (none / 0) (#186)
by hvangalen on Fri Jun 04, 2004 at 03:44:49 AM EST

Excuse me, but that code is doing something entirely different than you think it does.

You say there's no point in making X zero when it already is, but it is checking if X is NOT equal to zero, and making it zero if so.

In fact, you should've said, no point in checking a value if the end-result must always be 0 (zero). It could've just been an assignment x=0 which saves on expensive CPU ticks.

Cheers.

[ Parent ]
I think you're confused (none / 0) (#204)
by KrispyKringle on Sat Jun 05, 2004 at 02:29:02 PM EST

What he is saying--hopefully as a joke--is that there is no point assigning x <- 0 if x = 0 already. The code seems to be saying, if x is not equal to 0, make it so, i.e. if(x !=0){ x=0; } . There's obviously no reason to do this, as you (and the parent) both point out, since the end result is x = 0 either way. You simply restated what he said; he jokingly pointed out that the code's author apparently thought it was silly to assign 0 to x if it already was, while you more bluntly pointed out that the code's author should not have bothered with the conditional.

[ Parent ]
I've seen worse... (none / 0) (#232)
by xpi0t0s on Sat Jun 12, 2004 at 06:23:35 PM EST

I've seen worse: if (!ptr) strcpy(ptr,"");

[ Parent ]
not source code but manpage humour (2.75 / 4) (#150)
by kingcnut on Thu Jun 03, 2004 at 06:15:06 AM EST

Irix 6.5 dmedia.eoe Release Notes

fightclub in code... (none / 3) (#162)
by Ashalind on Thu Jun 03, 2004 at 09:58:51 AM EST

I've seen things like:

#if defined (BOSS_A_WANTS_SOMETHING) && !defined (BOSS_B_WANTS_SOMETHING)
<piece of code>
#if !defined (BOSS_A_WANTS_SOMETHING) && defined (BOSS_B_WANTS_SOMETHING)
<another piece of code>
#else
#error FIGHTCLUB
#endif

somewhere in sources of a big and complicated piece of software, that was still in development and subject to change almost every day, depending on what the Important People deemed to be preferred that morning... :)

char Broiled (none / 2) (#170)
by craigd on Thu Jun 03, 2004 at 12:55:27 PM EST

an old classic, allegedly snuck into multiple programs. May be a myth.


A man who says little is a man who speaks two syllables.
a_variable_name (none / 1) (#179)
by static on Thu Jun 03, 2004 at 10:32:14 PM EST

I've been known to use $xyz in PHP because I couldn't be bothered thinking up yet another variable name.

But in the unit tests, we could go to town. :-) I did up some code to test a number of time-matching and checking functions. So there as $a_time, $a_nother_time, $an_earlier_time, $a_nother_earlier_time, $a_later_time,... and so on and so forth.

Wade.


The funny thing is... (none / 2) (#180)
by readams on Fri Jun 04, 2004 at 01:01:12 AM EST

That supposedly "inept" int wrapper has genuine uses in Java. It's called a boxed representation of the integer, and allows you to do things like have an integer that can be null, or store the integer in a list or use it as a hash key. It happens to duplicate a class that's already available in the Java API, but failing to discover a class in the Java API is hardly total ineptitude.

although (none / 0) (#181)
by readams on Fri Jun 04, 2004 at 01:03:01 AM EST

I didn't notice that it's storing the int as a string. That could perhaps have been coded slightly more efficiently.

[ Parent ]
Failing to discover java.lang.Integer??? (none / 1) (#182)
by Milo Minderbender on Fri Jun 04, 2004 at 01:56:36 AM EST

Did you somehow miss the very first thread in this article? You're beating a horse that already resembles a hamburger.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
You missed the point (none / 0) (#193)
by p3d0 on Fri Jun 04, 2004 at 04:10:04 PM EST

That class stores the integer as a string pointed to by an object. The one in the Java API stores it as an integer embedded in an object.
--
Patrick Doyle
My comments do not reflect the opinions of my employer.
[ Parent ]
Database instance names (3.00 / 4) (#190)
by Ricochet Rita on Fri Jun 04, 2004 at 10:49:04 AM EST

::Slaps forehead:: I completely forgot about these...

The Oracle database historically uses 4-letter System ID names (SID's), with "orcl" being the default. Here are some of the ones we've used over the years, for various development & production instances (keep in mind that these are internal to the DB & *none* of the users have access to them, let alone the acronym key...):

ACID -- Aegis ComSys Integrated Database
AHOI -- Another Heinious Oracle Instance (production box for a Dept of Navy application)
ACME -- Acronyms for ComSys Made Easily
BABY -- Bring Another Beer, Yohimbe
DADA -- D. Asks, Development Answers (D. being the proj manager's name)
DUDS -- Development Understands, D. Shrugs
DODO -- Developmental Obfuscation Done Obsequiously
CRUD -- ComSys Remains Under Development (it was a looong project...)
CULT -- ComSys Used for Limited Time (years later, still in use!)
CONS -- ComSys On New Server
C*NT -- ComSys Under NT (a short-lived dev instance on WinNT)
DONT -- Development On NT (D's responce to the previous SID!)
DEFY -- Database(Doubtfully) Existing For Years (our meta-responce to the above)

A number of these are still in use today!

FABRICATUS DIEM, PVNC!

"true" (none / 1) (#201)
by WWWWolf on Sat Jun 05, 2004 at 09:10:09 AM EST

In PHP, like in Perl, all strings not equal to "0" are true in boolean context.

So, in one particular case, I used this string as a "true" value. Can't remember how it went, copied and pasted it from the web, but the end was the most famous part of it: "...for I am become Death, the shatterer of worlds."

The code was for getting the user confirmation for nuking something from the database. That kind of situations probably require some drama.


-- Weyfour WWWWolf, a lupine technomancer from the cold north...


0 or null. (none / 1) (#210)
by Zerotime on Sun Jun 06, 2004 at 12:17:12 AM EST

#!/usr/bin/perl -w

use strict;

my $string;

if($string) {
        print "True\n";
}

else {
        print "False\n";
}

---
"I live by the river
With my mother, in a house
She washes, I cook
And we never go out."

[ Parent ]

chop $uey; (2.80 / 5) (#202)
by NoseyNick on Sat Jun 05, 2004 at 12:09:15 PM EST

naming your temporary variables "uey" in perl, purely so you can chop $uey; :-)

I don't think we're in Kansas anymore Toto (2.75 / 4) (#203)
by sheepy on Sat Jun 05, 2004 at 12:42:43 PM EST

As a electronics technician some years ago I dropped a screwdriver into an emulator, after the smoke cleared I saw this on the terminal:

System Error:I don't think we're in Kansas anymore Toto

"Freedom is the right to be wrong, not the right to do wrong." John G. Riefenbaker

The best I've seen is an Opcode name (none / 1) (#211)
by dukerobillard on Sun Jun 06, 2004 at 11:03:42 AM EST

In the IBM PowerPC instruction set, there's actually an opcode called "Enforce In-Order Execution of I/O". In "Old MacDonald" fashion, the abbreviation is EIEIO.

http://hpcf.nersc.gov/vendor_docs/ibm/asm/eieio.htm

Hey, yeah I do that sort of stuff! (none / 0) (#213)
by A synx on Mon Jun 07, 2004 at 04:07:19 AM EST

Nothing wrong with slipping a little humor in code after all, we remember things we laugh at!


I often in threaded programming have the use for only one lock for the entire program.  Pretty much just a cheap way to share variables: lock the big mutex and then check/change all your shared variables, then unlock it for everything else.  For this mutex lock I was at a loss as to what to name it, when I suddenly recalled the game "popcorn" where people read out loud in a classroom and when they're done they toss the popcorn to the next reader.  Thus...

pthread_mutex_t popcorn = PTHREAD_MUTEX_INITIALIZER;

Hm... what's some other things I do... :)


sub Plumber {
        #SIGPIPE detected, but it'sa alright.
        print "Your princess is in another castle.n";
        exit(0);
}
$SIG{'PIPE'} = &Plumber;

Here's one I put to filter naughty subject lines in spam:


sub soap {
        # Wash yo' mouth out wif soap!
        $_ = shift;
[ lots of substitutions here ]
        return $_;
}

I'd find some more, but I got another thing to work on.  Now I know to combine code and puns intentionally.  I will do so subtly from now on!  Thanks muchly.



I actually thought of one (none / 1) (#223)
by epepke on Tue Jun 08, 2004 at 06:14:18 AM EST

One of my first commercial programming assignments, way back when giant lizards roamed the Earth, was to disassemble the Xerox 820-II Bios and modify it so that it could do synchronous as well as asynchronous communications. Getting this done would be a story in and of itself.

Anyway, I couldn't exactly understand one of the routines. So I named it McGuffin. It's from a not-particularly-funny joke that's probably 70 years old by now. A guy goes into a train compartment and puts something mysterious in the luggage rack above. Someone asks him what it is. The following dialogue ensues:

Q: What's that?
A: It's a McGuffin.
Q: What's a McGuffin?
A: It's a device for detecting lions on the Scottish highlands.
Q: But there are no lions on the Scottish highlands.
A: Well, then that's no McGuffin.

Alfred Hitchcock made his movies around McGuffins (the secret letter, the hidden plot) that were focal points of the plot but ultimately were meaningless.

My colleagues thought it was Egg McMuffin.


The truth may be out there, but lies are inside your head.--Terry Pratchett


Cool, thanks! (none / 0) (#224)
by Milo Minderbender on Tue Jun 08, 2004 at 06:34:33 AM EST

Google found more info about it here. Interesting. It's a great name for a procedure that does nothing.

--------------------
This comment is for the good of the syndicate.
[ Parent ]
Gibson (none / 0) (#226)
by epepke on Wed Jun 09, 2004 at 04:25:43 AM EST

I liked the rather reductionist view of Gibson on that page. It's pretty much spot on. The only thing it missed is to make the language obscure and esoteric when you've run out of things to say, in lieu of a proper ending. Then all the lit-crits can walk away with the feeling that something profound has been said.


The truth may be out there, but lies are inside your head.--Terry Pratchett


[ Parent ]
Better link (none / 1) (#230)
by Ta bu shi da yu on Thu Jun 10, 2004 at 03:44:55 AM EST

http://en.wikipedia.org/wiki/McGuffin

---
AdTIה"the think tank that didn't".
ה
[ Parent ]
I salute you (none / 1) (#233)
by ShiftyStoner on Mon Jun 14, 2004 at 04:06:10 PM EST

 for taking perhaps the most boring thing on the planet and trying to make it fun. It's still boring it's not gana make anyone laf. Unless theyd laf at a stick.

 Hey, now try making defraging fun.
( @ )'( @ ) The broad masses of a population are more amenable to the appeal of rhetoric than to any other force. - Adolf Hitler

I've never put funny code in... (none / 1) (#237)
by tonyenkiducx on Fri Jun 25, 2004 at 11:47:56 AM EST

..but I once slipped a copy of an old Atari game called CrossFire into the billing system of, what used to be called, Cable & Wireless. It was linked with a 1 pixel spacer gif from the main billing page, and even saved your score under your user acc! It dissapeared when they changed there name in the UK though :(

Tony.
I see a planet where love is foremost, where war is none existant. A planet of peace, and a planet of understanding. I see a planet called
You'll possibly only get this if your from the UK. (none / 2) (#238)
by u02sgb on Thu Jul 08, 2004 at 08:29:18 AM EST

We use Hewlett Packard Unix boxes for prototypes and to demo our systems for sales.

Our sysadmin named our new box "Sauce".

HP Sauce.. geddit :).

found in a header (none / 0) (#239)
by ericl on Tue Jul 13, 2004 at 08:02:31 PM EST

a header comment in some code at a big internet auction company (that you all probably know) has this in it -

@author a rank amature called edited who has never written a line of code before, needs to be treated like a 5 year old child, and is managed by people that should be managing a sweat shop that are even less competent than him.

Prolog (none / 0) (#240)
by robinmacharg on Fri Jul 23, 2004 at 11:52:01 AM EST

I could never really get my head round Prolog, but I did manage to express a degree of self depricating irony in it. The program:

funny(robin):- false.
funny(_):- true.

Generates output such as:

> funny('a horse walks into a bar...').

Yes.

> funny(robin).

No.


alt.language.bad (none / 0) (#241)
by wraith0x29a on Wed Jul 28, 2004 at 09:49:09 AM EST

Eventually some bright spark on our support team is going to notice that the two language options currently available for the PHP front-end on our SME business servers are 'UK-English' and 'BOFH-English'.

A (mildly censored) comparison..

lang/en-uk.php :

$lang['network_settings']['warn'] = "Caution: Entering incorrect information may cause your system to stop responding!" ;
$lang['network_settings']['good'] = "Network settings updated." ;
$lang['network_settings']['bad'] = "There was a problem with the network details you provided. Please try again." ;

lang/en-bofh.php :

$lang['network_settings']['warn'] = "For f*&^ sake don't f*&^ this up or you're really f*&^*d!" ;
$lang['network_settings']['good'] = "If you can see this then you are probably not too f*&^*d." ;
$lang['network_settings']['bad'] = "Uh-oh, you're f*&^*d." ;

..and some 300+ others.

So far only one system has been shipped with en-bofh still set as the default language.
It has been left that way at the customer's request.
"There are actually 11 kinds of people in the world: Those who don't understand binary, those who think they understand binary and those who know what little-endian means."

Code Humor Challenge | 241 comments (223 topical, 18 editorial, 0 hidden)
Display: Sort:

kuro5hin.org

[XML]
All trademarks and copyrights on this page are owned by their respective companies. The Rest © 2000 - Present Kuro5hin.org Inc.
See our legalese page for copyright policies. Please also read our Privacy Policy.
Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
Need some help? Email help@kuro5hin.org.
My heart's the long stairs.

Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!