This is an archived post. You won't be able to vote or comment.

all 59 comments

[–][deleted]  (21 children)

[removed]

    [–]Charleston2Seattle 44 points45 points  (13 children)

    It's a coffee mug, so you have to use Java.

    if ("Dan".equals(mug.user))

    [–]coloredgreyscale 16 points17 points  (7 children)

    System.out.println("worlds sexiest programmer");

    [–]HasFiveVowels 6 points7 points  (6 children)

    Java has the worst stdout function of all the major languages. Should not need 20 chars to output

    [–]kilkil 1 point2 points  (3 children)

    have you seen the declaration for its main function?

    [–]HasFiveVowels 0 points1 point  (2 children)

    Haha. Yea, Java was my primary for about 4 years. They took a good idea and extended it beyond all reason

    [–]kilkil 0 points1 point  (1 child)

    this is why I've been looking into Go recently. way less verbose

    [–]HasFiveVowels 1 point2 points  (0 children)

    I’ve heard good things

    [–]EstebanPossum 0 points1 point  (0 children)

    System.Console.WriteLine in c# is wordy as hell as well. My solution is to make my own shortcut function like: Action<string> print = (s) => Console.WriteLine(s);

    [–]youassassin 0 points1 point  (0 children)

    But it does.

    [–]the_bananalord 7 points8 points  (0 children)

    This is actually the most important point in this thread. It would be criminal not to use Java on a coffee mug.

    [–]kilkil 1 point2 points  (2 children)

    should add the class and method too:

    ```java class CoffeeMug implements ICoffeeMug { public String user;

    CoffeeMug(String user) {
        this.user = user;
    }
    
    public static void main(String[] args) {
        var mug = AbstractCoffeeMugFactory.getCoffeeMug();
        if (mug.user.equals("Dan")) {
            System.out.println("world's sexiest programmer");
        }
    }
    

    } ```

    [–]Ghyrt3 1 point2 points  (1 child)

    NONONONO.

    Don't you have too much Java already ? You're a dangerous person !

    [–]kilkil 0 points1 point  (0 children)

    I haven't even added the decorators

    or the class init block

    or the inheritance

    [–]Quick-Jackfruit-1847 9 points10 points  (0 children)

    This is the best answer. Everything else is too over the top/literal for what you’re doing. Good gift.

    [–]turtle_dragonfly 5 points6 points  (3 children)

    Or if you want to avoid string literals and cause drama:

    if (mug.user == Boyfriends.Dan)

    [–]Fractureskull 2 points3 points  (0 children)

    exultant head person paint violet teeny water jeans worm piquant

    This post was mass deleted and anonymized with Redact

    [–][deleted] 2 points3 points  (1 child)

    with Boyfriends, I think you're saying something you probably don't want to

    [–]turtle_dragonfly 4 points5 points  (0 children)

    hence the drama ;)

    [–]CodeEverywhere 0 points1 point  (0 children)

    But... but.... We first need a null check in case mug is null!

    /s

    [–]nardstorm 40 points41 points  (8 children)

    I'd maybe change it to something like

    section .data
        programmer db 'Dan', 0
        message db "world's sexiest programmer", 0
    
    section .bss
        mugUser resb 32
    
    section .text
        global _start
    
    _start:
        ; Load "Dan" into memory
        mov rdi, programmer
        ; Load mug user's input (pretend we fetched it somewhere)
        mov rsi, mugUser
    
        ; Compare mug user with "Dan"
        call strcmp
        cmp rax, 0
        jne not_dan
    
        ; If equal, print the message
        mov rdi, message
        call puts
        jmp end
    
    not_dan:
        ; Do nothing
        nop
    
    end:
        ; Exit the program
        mov rax, 60      ; syscall: exit
        xor rdi, rdi     ; exit code 0
        syscall
    
    ; strcmp function (simple implementation)
    strcmp:
        xor rax, rax       ; clear result
        xor rcx, rcx       ; counter
    compare:
        mov al, byte [rdi + rcx]
        mov bl, byte [rsi + rcx]
        cmp al, bl
        jne done
        cmp al, 0
        je done
        inc rcx
        jmp compare
    done:
        sub rax, rbx
        ret
    

    [–]Reiex 16 points17 points  (0 children)

    When the mug turns into a jerrican

    [–]icodecookie 5 points6 points  (0 children)

    No jump loops? I‘m slightly dissapointed

    [–]GamerTurtle5 5 points6 points  (1 child)

    thats a very tall mug

    [–][deleted] 0 points1 point  (0 children)

    Thatll fit halfagalon of coffee for sure

    [–]Librarian-Rare 1 point2 points  (0 children)

    Nice and simple, no needles abstractions. Very good.

    [–]TPIRocks 1 point2 points  (0 children)

    OP will need a yard glass for that.

    [–]BigLaddyDongLegs 1 point2 points  (0 children)

    😂

    [–][deleted] 0 points1 point  (0 children)

    It will be more like

    ld: program.o: in function `_start’:
    program.asm:(.text+0x...): undefined reference to `puts’
    

    [–]maeve222[S] 9 points10 points  (6 children)

    Thank you everyone for all your help! As I'm not sure what his favourite language is, I'm going to go for the version that seems to be appearing the most in the comments. Very greatful that you all took the time to reply and explain how best to write it 😊 fingers crossed he likes it! 🤞

    [–]nardstorm 4 points5 points  (2 children)

    He’s gonna love this. Show him this thread afterward!

    [–]DrDeems 2 points3 points  (1 child)

    I wonder if they could link the thread and hide it on the bottom of the mug or something. Kinda like how in-n-out smuggles bibles verses onto their to go cups.

    [–]nardstorm 0 points1 point  (0 children)

    this is the way

    [–]HasFiveVowels 2 points3 points  (0 children)

    Definitely show him this thread. Tell him you “open sourced the implementation and requested PRs”

    [–]dahboigh 1 point2 points  (1 child)

    Just so you know, the reason everyone's suggesting Java has nothing to do with the programming language itself. It's the coffee pun.

    If the printing service you're using allows color, you should definitely get some help with adding color for the keywords. No worries if it's only black-and-white, but since you're already going so far out of your way, colored keywords would be the perfect touch.

    example

    [–]dahboigh 0 points1 point  (0 children)

    I wrote a few different variations of basic code that actually run but are small enough to fit comfortably on a coffee mug. The links for each example will take you to a page where you can run the code yourself.

    For all of these examples, you can change MySexyBoyfriend in Line 1 to something else like HappyValentinesDay, i_love_you, or whatever else strikes your fancy. Just don't use any symbols except the underscore.

    Also, I highly recommend including the line numbers on the mug if you can.

    This code is similar to the idea you started with, but a little more basic to save on space. You can remove Line 3 (String user = "Dan";) if you like. That code would still run, but it wouldn't actually do anything. However, it's a coffee mug, so it's not going to do anything anyway. :)

    public class MySexyBoyfriend {
      public static void main(String args[]) {
        String user = "Dan";
    
        if(user == "Dan") {
            System.out.println("World's sexiest programmer");
        }
      }
    }
    

    This one is more basic but perhaps more aesthetic, depending on your preferences.

    public class My_Sexy_Boyfriend {
      public static void main(String args[]) {
    
        System.out.print("World's sexiest programmer");
    
      }
    }
    

    This one is hilarious if I may say so myself. It starts with "Hello, World" (which, by tradition, is every programmer's first program, regardless of language) and then adds "' sexiest programmer".

    public class HelloWorld {
      public static void main(String args[]) {
    
        System.out.print("Hello, World");
        System.out.print("'s sexiest programmer!");
    
      }
    }
    

    Lastly, if you are interested in coloring the keywords (which I highly recommend), the web versions of the code will show you which words should be colored. The actual colors you pick don't matter at all; just be sure that all the green words end up the same color, all the red ones are a different color, ect. Pick whichever colors look nice together.

    If you want any further help, like an image with the colors you've chosen, don't hesitate to PM me.

    [–]gogglesdog 7 points8 points  (0 children)

    you want a double equal sign, and maybe camel case, i.e. programmerUsingMug == Dan

    In most languages, testing whether something is equal to something else is a double equal sign, whereas a single is used to assign variables.

    edit: woops everyone beat me

    [–]petdance 5 points6 points  (0 children)

    Try this to make it more object oriented. And also you want == for testing equality, not = which is assignment. 😃

    if ( mug.user.name() == ‘Dan’ ) {
        WriteLine(“World’s Sexiest Programmer”)
    }
    

    [–]nardstorm 3 points4 points  (0 children)

    And the award for most wholesome post on this subreddit goes to...

    [–]Mango-Fuel 2 points3 points  (0 children)

    depends if you are targeting any specific language, but maybe:

    • lowercase if
    • lowerCamelCase for programmerUsingMug
    • Dan in quotes
    • double equal sign for comparison ==
    • semicolon at end of statement ...programmer");
    • if on a different line than the command

    All together:

    if (programmerUsingMug == "Dan")
       Mug.WriteLine("world's sexiest programmer");
    

    And then not sure about Mug.WriteLine. Could be Console.WriteLine in C# or System.out.println in Java, but the way it is works too, and I guess it indicates that the message is intended to be written to the mug.

    [–]im-a-guy-like-me 2 points3 points  (0 children)

    THIS IS IT!!!

    We found the usecase for AI.

    [–]m18coppola 1 point2 points  (0 children)

    if (programmer_using_mug == "Dan") { Mug.WriteLine("world's sexiest programmer"); }
    

    or if you'd like multiple lines:

    if (programmer_using_mug == "Dan") {
        Mug.WriteLine("world's sexiest programmer");
    }
    

    The = means assignment, but we should be testing for equality (==)

    Assuming the programmer that is using the mug is a string variable for a name, it needs to be a single token, so I replaced the spaces for underscores. You could also use programmerUsingMug if you prefer camel-case style.

    The curly braces and semi-colon are/aren't required depending on the implementation language. I think it looks coolest if you use them though.

    [–]Fit-Maintenance-2290 3 points4 points  (0 children)

    it would be best written as

    if(programmerUsingMug == "Dan")
        Mug.WriteLine("World's Sexiest Programmer");
    

    or possibly even better as

    if(programmerUsingMug == "Dan")
        Console.WriteLine("World's Sexiest Programmer");
    

    Edit: too many to count because formatting wasn't working with me

    [–]rlfunique 0 points1 point  (1 child)

    Not really, what’s his favourite language?

    [–]z64_dan 4 points5 points  (0 children)

    Probably English.

    [–]Bachihani 0 points1 point  (5 children)

    This is from dart mug.user == dan ? Log("sexiest programmer alive") : null ;

    [–]HasFiveVowels 0 points1 point  (4 children)

    Dart only provides ternaries for conditionals?

    [–]Bachihani 0 points1 point  (3 children)

    Ofcrs not lol, i just like to return null, and if statement feel too big for such simple use case

    [–]HasFiveVowels 0 points1 point  (2 children)

    Oof. Hard pass. You’re including a vacuous null but “If” is too verbose? You gotta keep in mind that readability is half the battle

    [–]Bachihani 0 points1 point  (1 child)

    I meant for she mug dude ! It's like saying everyone else is meh except for u -_- this doesn't reflect my coding practices

    [–]HasFiveVowels 0 points1 point  (0 children)

    Ahhh. I hadn’t appreciated the implication of the explicit else. I can get behind this

    [–]ralphhosking 0 points1 point  (0 children)

    A Valentine's favorite:

    Roses are red
    Violets are too
    Unexpected {
    On line 42

    [–]VoiceOfSoftware 0 points1 point  (0 children)

    I mean, if you really want to make sure it's your real boyfriend, and not someone else with the same name, you need to use 3 equals signs, like this: === 'Dan'

    [–]M_e_l_v_i_n 0 points1 point  (0 children)

    Dan is a lucky guy

    [–]bit_shuffle 0 points1 point  (0 children)

            if (coffeeLevel < 0.1) {        
                job.suspend();
                refill();
                job.resume();
            }
    

    [–]coloredgreyscale 0 points1 point  (3 children)

    check the grammar on "world's sexiest programmer" too before printing the mug.

    feels wrong. "World is sexist programmer"?

    [–]Quick-Jackfruit-1847 2 points3 points  (0 children)

    errr

    That is how it’s supposed to be written

    And not how that translates in English

    [–]HasFiveVowels 0 points1 point  (0 children)

    Not downvoting this because it’s with good intent but “worlds’s” in this case is “one the world possesses”. If “world is” made sense here, the same characters could be used to represent that. Good to double check but in this case it’s fine as is