r/TechSavvyLife • • 15d ago • Bravo 1

Name the language

Post image
98 Upvotes

65 comments sorted by

20

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

Brew++

4

u/AbsentCollin 13d ago

Finally, a language that runs exclusively on coffee makers

19

u/Profesionalintrovert 15d ago

Java

5

u/Benjamin_6848 11d ago

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

6

u/jeremyvoros 15d ago

That’s java

1

u/Benjamin_6848 11d ago

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

1

u/jeremyvoros 11d ago

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

11

u/Stephen_Wilhelm 13d 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 10d ago

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

5

u/libertybadboy 14d 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 11d 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 13d ago

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

1

u/Benjamin_6848 11d 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 10d 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 13d ago

Forget sleep = Null ;

1

u/No-Aide6618 15d ago

Where to purchase?

2

u/Tscheidse_ 15d ago

You want to purchase the cup?

3

u/No-Aide6618 15d ago

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

1

u/serge-mv 15d 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 15d ago

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

2

u/Zehryo 15d ago

And no function call for the bowel movements!!

2

u/ai-gen-O-rated 14d 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 15d ago

Shouldn't .isEmpty be .isEmpty() ?

4

u/lr_science 15d ago

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

3

u/YouDoScribble 15d 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 15d ago

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

1

u/arghcisco 14d 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 11d ago

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

1

u/Benjamin_6848 11d ago

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

1

u/Cbrt74088 10d 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 15d ago

Why would a new coffee be empty. Smh

1

u/ba-na-na- 14d 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 15d ago

english?

2

u/ba-na-na- 14d 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 11d ago

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

1

u/ba-na-na- 11d 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 11d 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- 11d 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 14d 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 13d ago

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

1

u/Zehryo 15d ago

C++, for all I can remember.

1

u/fgarciasa 14d ago

Este es un lenguaje UNIVERSAL!!!

1

u/Consistent_Strain190 12d ago

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

1

u/abba610 12d ago

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

1

u/Eddy_Edwards02144 12d 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 12d ago

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

1

u/rainyfrog7 11d ago

C(offee)

1

u/OneSeaworthiness8958 11d ago

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

1

u/[deleted] 11d ago

Java would need an CoffeeBrewingFactoryImpl so I guess its C#

1

u/pr0ghead 10d ago

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

1

u/TheRealDirkiboy 10d ago

Stay away from languages with curly brackets!

1

u/rocketmannot 4d ago

Hate this kind of stuff

1

u/Klutzy_Barnacle_9283 4d ago

Pseudo-brewScript

1

u/ludolfina 4d ago

Do you have any idea how little that narrows it down

3

u/[deleted] 15d ago

[removed] — view removed comment

1

u/Benjamin_6848 11d ago

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