67

I recently received this lovely coffee mug as part of the 10M questions celebration.

The side of the mug looks like this:

enter image description here

if(owner.isCoding()
&& mug.isEmpty())
{mug.fill('coffee');}

I'm not a Java programmer, but I'm guessing this is Java syntax and that this is something of a pun given that "Java" is a nickname for coffee, at least in dated American slang.

However, given that we don't see the class declarations for owner and mug, I'm guessing it could also be C++; perhaps it's deliberately ambiguous.

I like the mug but I sort of feel like a poseur carrying it around since I don't use either of these languages. So I would appreciate some info, particularly if there's an inside joke I'm not getting. Is there any significance in brackets being on the same line instead of:

if( owner.isCoding()
    && mug.isEmpty() ){
  mug.fill('coffee');
}

(I understand there may be a line limit for the printable area on the mug.)

11
  • 85
    It is pseudo-code in a language with C-derived syntax. If you're worried about being a poseur, imagine how I feel, drinking tea out of this 'coffee' mug.
    – Cody Gray Mod
    Commented Mar 7, 2016 at 13:30
  • 7
    Cross-site dupe. meta.stackexchange.com/q/138755/1288 Commented Mar 7, 2016 at 13:34
  • 31
    I'm a little bit more worried about filling your mug with a string, rather than an instance of a coffee object. This might be a case of string obsession.
    – DJMcMayhem
    Commented Mar 7, 2016 at 15:46
  • 7
    It might not be Java on the outside, but it could very well be CoffeeScript on the inside ;)
    – Machavity Mod
    Commented Mar 7, 2016 at 15:54
  • 11
    clearly it's written in jQuery.
    – Kevin B
    Commented Mar 7, 2016 at 16:13
  • 1
    @Cody me too. But the worst part is, none of my co-workers appreciate it because they all don't care about SO. :-(
    – simbabque
    Commented Mar 8, 2016 at 8:28
  • 1
    It wasn't ever going to be Java since Java doesn't have strings with single quotes :( Commented Mar 8, 2016 at 9:37
  • 6
    It's valid JavaScript. But also, it's 'writing on a coffee mug'...or in other terms 'script written on java'...javascript! Commented Mar 8, 2016 at 23:07
  • 5
    Imho it's not java. If it's java it should enclose mug.fill('coffe') with try { } catch (CupOverflowException e) {} or declare throws CupOverflowException on the method that runs the code :). Though I would love to have this cup and drink coffee from it in front of my colleagues :D. Commented Mar 9, 2016 at 6:23
  • @C8H10N4O2 How in the world did you get this cup and I don't :-( Commented Mar 9, 2016 at 14:11
  • It would be super cool if we got a coffee mug with the algorithm printed in our most answered language. Call it the 'buzzbuzz' algorithm 8-) Commented Mar 9, 2016 at 14:42

5 Answers 5

102

Congratulations on receiving your swag!

It is definitely not Java, as Java uses double quotes for string literals (single quotes are used for character literals). The same holds for C++. It could be JavaScript, though.

Code snippets (in tutorials, or in StackOverflow questions) don't always show the declarations, because they can be derived from the context. And they're probably too boring to print on a mug.

While the mug itself is not coded in Java, it can definitely be filled with Java.

5
  • 5
    Could also be Groovy, though it wouldn't be idiomatic on the property accesses. Commented Mar 7, 2016 at 15:11
  • 1
    And here I was thinking 'java' was slang for coffee everywhere. Didn't even realize it was an actual place. Commented Mar 8, 2016 at 5:38
  • 16
    It can't be Javascript, because surely it would have more jQuery.
    – Stryner
    Commented Mar 8, 2016 at 20:04
  • 2
    @Stryner Depends if there's any vanilla flavour.
    – Kyll
    Commented Mar 9, 2016 at 14:14
  • 1
    It's SCRIPT written on a cup of JAVA. JAVASCRIPT!!! Commented Jan 10, 2017 at 19:49
142

It's not Java, it's our own language that we developed called Nij. And, I regret to inform you that we're recalling all mugs due to consumer safety concerns.

As you note, the mug has this line of code:

if(owner.isCoding()

The more experienced of you will notice, no check is done to ensure owner is the expected type. While no incidents have been reported, the following scenarios might result in undefined mug behavior:

  • Owner changing, or non-owner use of mug
  • Existential difficulties of owner

We urge everyone to drink with extreme caution while we work this out.

22
  • 2
  • 18
    Must resist urge to create [nij] on SO Commented Mar 7, 2016 at 14:52
  • 75
    They also have another serious issue: That if statement should be a while loop. As it's currently written, the mug will only be filled once, which is very, very bad :-) Commented Mar 7, 2016 at 14:57
  • 9
    Surely worse than that - what if the owner is no longer coding because they have Run out of Coffee! they're unable to concentrate on coding but their mug isn't giving them more coffee!
    – Ian
    Commented Mar 7, 2016 at 15:08
  • 2
    Surely even worse than that - what if the owner never actually started coding because there was no coffee in the mug to begin with ?! (@Ian) Commented Mar 7, 2016 at 15:14
  • 4
    @JonasCz Should be a do...while. Regardless, there is clearly need for optimization here.
    – user2535467
    Commented Mar 7, 2016 at 15:24
  • 2
    Coffee first @tak3shi , which will handle the bug the JonasCz brought up. And add in an if to ensure coding. Depending on how important the project is, possibly throw an exception if mug.isFull && owner.isSlacking.
    – user2535467
    Commented Mar 7, 2016 at 15:30
  • 33
    So what you're saying is if we continue to use this mug before it's patched, we might get a bug in our coffee? Eww, gross!
    – DJMcMayhem
    Commented Mar 7, 2016 at 15:42
  • 2
    Let´s swap owner with mug in the code. Mug is better in writing Nij code and the owner knows how to fill a mug with coffee.
    – tak3shi
    Commented Mar 7, 2016 at 16:05
  • 6
    May we expect a patch or a service pack in 6-8 weeks?
    – Abhitalks
    Commented Mar 8, 2016 at 5:07
  • 3
    We also have to see what happens when we put something other than coffee in these things. We're going to be experimenting with gravy and Jello shortly.
    – user50049
    Commented Mar 8, 2016 at 5:58
  • 11
    Is the word "nij" some kind of in-joke that I'm missing? Commented Mar 8, 2016 at 19:55
  • 5
    No overflow checks either. C'mon people did you forget where you work? Commented Mar 8, 2016 at 20:15
  • 4
    @KyleStrand "Jin Yang".Explode(0).Reverse(); and that's totally legal in Nij.
    – user50049
    Commented Mar 9, 2016 at 10:36
  • 2
    Calling a method on an object that could possibly be null? If someone fills that cup with scalding coffee while it does not yet have an owner, the stack trace is going to blow the bottom out of the cup. Commented Mar 10, 2016 at 10:13
19

magic strings are a questionable pattern, I suggest returning an enum as in owner.beverageOfChoice. Be that as it may, 'coffee' works for me.

1
  • Yep. There definitely needs to be a variant for tea drinkers. I want my mug to be filled with tea, Earl Grey, hot.
    – Simba
    Commented Mar 9, 2016 at 14:03
4

It may very well be Java, depending on how long it took for you to receive the mug.

/runs and hides

1
  • 3
    My mug has been sitting on my table ever since I got one, and it hasn't run once yet. You could be onto something.
    – user50049
    Commented Mar 10, 2016 at 11:39
4

It is not Java, but if you execute the script twice in a row, it will overflow with Java.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .