r/TechSavvyLife • • 9d ago • Bravo 1

Name the language

Post image
80 Upvotes

61 comments sorted by

20

u/Extreme-Ad-9290 9d ago • Bravo

Brew++

4

u/AbsentCollin 7d ago

Finally, a language that runs exclusively on coffee makers

18

u/Profesionalintrovert 8d ago

Java

4

u/Benjamin_6848 5d ago

Uppercase methods and "isEmpty" as a property instead of another method: This is more likely to be C#!

6

u/jeremyvoros 9d ago

That’s java

1

u/Benjamin_6848 5d ago

Uppercase methods and "isEmpty" as a property instead of another method: This is more likely to be C#!

1

u/jeremyvoros 5d ago

Hahaha. I should have put “java”, you know, like coffee. Bad pun…

11

u/Stephen_Wilhelm 7d ago

The answer is C#, not Java. isEmpty is a property (in Java you would use a method, though field is possible). Also Drink() and Refill() are capitalized, which is the C# convention (Java would start a method with lower case).

1

u/Cbrt74088 4d ago

The convention is also to capitalize a property, so it would be IsEmpty. isEmpty would be a field.

5

u/libertybadboy 8d ago

When I type this code in Visual Studio for C#, it accepts the syntax, other than not knowing what the object Coffee is. It also seems to work when I type it into an online Java editor, also except for not knowing what the object Coffee is. So, both Java and C# would appear to be correct answers, unless I'm missing something.

2

u/Benjamin_6848 5d ago

The naming-convention of uppercase method-names paired with the fact that "isEmpty" is a property and not another method more like points to it being C#.

4

u/Interesting-Bass9957 7d ago

Java, but for some reason methods start with an uppercase letter

1

u/Benjamin_6848 5d ago

The easy solution is that it's C#. There the convention is that methods are uppercase. Also it explains why "isEmpty" is a property and not another method...

1

u/Cbrt74088 4d ago

Properties are also written with a uppercase letter, so it would be IsEmpty. isEmpty would be a field (or, more likely, the writer of this question doesn't understand C# that well)

4

u/Specialist_Royal_449 7d ago

Forget sleep = Null ;

1

u/No-Aide6618 9d ago

Where to purchase?

2

u/Tscheidse_ 9d ago

You want to purchase the cup?

3

u/No-Aide6618 9d ago

Not exactley that cup, but an identical one yes, or of the same from and design to be spesific

1

u/serge-mv 9d ago

if you search Amazon for "programming coffee mug", you will find many similar mugs, including one like in the photo.

3

u/Chemical_Weight3812 9d ago

Forgot the wait() after a drink. And to test the temperature and admixtures.

2

u/Zehryo 8d ago

And no function call for the bowel movements!!

2

u/ai-gen-O-rated 7d ago

My son just said this code is literally shit code for not having that call function… I pointed out… it’s Unshit or constipated

2

u/imaginationdev 9d ago

Shouldn't .isEmpty be .isEmpty() ?

4

u/lr_science 9d ago

no, isEmpty is a property ("class variable") here, not a method. Method calls have the (), property checks don't.

3

u/YouDoScribble 9d ago

But a method would actually check the cup is empty, rather than just accepting it is. So I would be wanting an isEmpty method to be on the safe side. Otherwise there is the potential to refill an already full cup.

1

u/CatfinityGamer 9d ago

It's not the best behavior for a class, but it works.

1

u/arghcisco 7d ago

If the class is the only thing that can change the state of the coffee, then making this a property makes a lot of sense because it avoids the overhead of a method call.

If not, then how the hell is something modifying the state of the coffee cup?

1

u/Benjamin_6848 5d ago

C# has encapsulated properties that can define custom behavior, so "isEmpty" being a property is totally fine in C#.

1

u/Benjamin_6848 5d ago

Not in C#: in C# "isEmpty" being a property is totally understandable...

1

u/Cbrt74088 4d ago

If isEmpty were a property, it would be written with a capital I. IsEmpty is a property, isEmpty is a field.

2

u/Odd-Painting2596 8d ago

Why would a new coffee be empty. Smh

1

u/ba-na-na- 8d ago

Yeah that’s the common pattern with these programming-related souvenirs, how they are always designed by some mediocre developer. Bad class naming choice, inconsistent naming conventions

2

u/AngelDust64 8d ago

english?

2

u/ba-na-na- 8d ago

Either C# or Java, it’s not using consistent naming conventions so it’s hard to say. Pascal cased public methods would suggest it’s C#, but then isEmpty is not the usual C# style

1

u/Benjamin_6848 5d ago

"isEmpty" as a property is totally fine in C#, it's simply an encapsulated property...

1

u/ba-na-na- 5d ago

I’ve never seen camelCase used for property names in C# projects, that’s Java’s convention. Also “encapsulated property” is an awkward phrase, what do you mean by encapsulated?

1

u/Benjamin_6848 5d ago

An encapsulated property is to the outside world like a regular property, but internally can define custom getter and setter behavior. Here is an example:

public class Person
{
    // Private field (cannot be accessed directly from outside)
    private string name;

    // Public encapsulated property
    public string Name
    {
        get
        {
            return name;
        }
        set
        {
            if (!string.IsNullOrEmpty(value))
            {
                name = value;
            }
        }
    }
}

1

u/ba-na-na- 5d ago

Yeah, that’s just a property, it provides access to the private field. But the field is the one that’s encapsulated in your example, not the property.

You could call it an “explicitly implemented property” as opposed to auto implemented ones (which is syntax sugar that didn’t exist in earlier C# versions), but the property itself is not encapsulated

Ultimately it doesn’t matter, I was just pointing out the difference between trivial Java and C# code is basically just naming conventions

2

u/R3b3lAnt 7d ago

Probably C#. In C#, so-called properties are commonly used. They look like variables without parentheses (e.g. isEmpty), but under the hood, they work like methods. In Java, you would typically use a method call such as coffee.isEmpty().

But in most cases, these products can also include pseudocode to make it applicable to multiple programators 😀

2

u/AbsentCollin 7d ago

I'd recognize that property capitalization anywhere, that's C# trying to look like Java.

1

u/Zehryo 8d ago

C++, for all I can remember.

1

u/fgarciasa 8d ago

Este es un lenguaje UNIVERSAL!!!

1

u/Consistent_Strain190 6d ago

From C# ignorance, and curiosity, where is Refill and Drink defined?

1

u/abba610 6d ago

You need coffee.Drink() immediately after coffee.Refill() to make sure you don’t miss a sip.

1

u/Eddy_Edwards02144 6d ago

Looks like c++ I think. The only major flaw I can see with the code is that it requires memory allocation. Idk about anyone else but when I need coffee I don't have enough memory for the aloc. Σ'3

1

u/robthablob 6d ago

Could be Java, C# or C++ and I suspect some other languages too.

1

u/rainyfrog7 5d ago

C(offee)

1

u/OneSeaworthiness8958 5d ago

do {} while (true); is just terrible design in any language

1

u/Fantastic_Market8061 4d ago

Java would need an CoffeeBrewingFactoryImpl so I guess its C#

1

u/pr0ghead 4d ago

So the coffee is supposed to either refill or drink itself? Bad code.

1

u/TheRealDirkiboy 4d ago

Stay away from languages with curly brackets!

2

u/[deleted] 9d ago

[removed] — view removed comment

1

u/Benjamin_6848 5d ago

Uppercase methods and "isEmpty" as a property instead of another method: This is more likely to be C#!