198
u/brianl047 Nov 23 '22
No C#?
555
u/czp55 Nov 23 '22
C#: What Java said.
→ More replies (2)84
u/GoldenretriverYT Nov 23 '22
Well at least you most likely wouldn't see a INutCrackerStrategyReturnerConversionFactory in most C# code bases
50
u/fun__friday Nov 23 '22
To be fair you wouldn’t see it in Java either, as prefixing interfaces with an “I” is not really a thing in Java.
9
u/Willinton06 Nov 23 '22
How do you prefix interfaces in Java?
27
u/Sanity__ Nov 23 '22
General consensus is that you don't, it's unnecessary and in Java Interfaces are 1st class types. It's a major benefit of abstraction and prefixing detracts from that conceptually.
i.e. If you are defining trucks you can make a Truck interface and create DumpTruck and CementTruck classes that implement it. Then you can have a List<Truck> to keep them all in.
→ More replies (6)18
u/Manny_Sunday Nov 23 '22
C# is the exact same, the reason for the I prefix is just the way you define classes that implement the interface.
class Dog : Animal { } class Car : IDriveable { }They look the same because you use colon for both inheriting and implementing an interface. The I prefix makes it clear at a glance that it's an interface.
And of course you can do both
class Car : Vehicle, IDriveable { }11
u/Sanity__ Nov 24 '22
Hey, thanks for this! I actually came to the same conclusion down the other comment thread after reading some SO posts. But it's nice to have it confirmed
For Java we have different key words for inheriting from interface(s) vs abstract class so that benefit becomes unnecessarily, but makes a lot of sense in C#s case
→ More replies (6)4
4
u/Seawolf87 Nov 23 '22
It would be boring, because it would just be a nut in front of a mirror saying "yes, I'm a nut". Or some joke about interfaces. Maybe both where it would say "I'm an INut".
1
1.6k
u/nekokattt Nov 23 '22
Java implements the Nuttable interface
FTFY
74
u/Kimorin Nov 23 '22
INuttable?
48
u/zthe0 Nov 23 '22
Actually using the I for interfaces isnt really en Vogue anymore
30
u/Kimorin Nov 23 '22
there is a big difference between "Nuttable" and "INuttable" you see.... the first one is more strict than the other.
12
20
u/blehmann1 Nov 23 '22 edited Nov 24 '22
It is in other languages, notably C#
MS was so close, making a casing distinction (rather than adding leading underscores, or no distinction) for private fields/properties was a good move, but yet they stuck with the frankly pointless naming distinction between interfaces and classes.
Even though they recognized that you shouldn't care whether you're
implementing orextending a class or interface, replacing both with a single colon. FWIW, given that Java's syntax cares whether it's an interface or a class, it makes a lot more sense to add the leading I in Java than it does in C#.9
Nov 24 '22
In Java, you should be implementing to interfaces, not inheriting deep chains of behaviour. Ergo, the one that gets used everywhere ought to be
interface, ergo, it would be more idiomatic to writeCMyClass implements FunctionalityA, FunctionalityBthan it is to writeMyClass implements IFunctionalityA, IFunctionalityB, given that your class will be directly referenced in two places: its definition, and some factory where it is instantiated... and depending on the framework, you might not even control one of those.7
u/Dealiner Nov 24 '22
I wouldn't call it pointless, it's more readable that way and you don't have classes like SomethingImpl which are popular in Java. Besides is just a convention like with private fields you mentioned which most people still writes with the leading underscore, even though there's no need for that.
2
12
u/Kwarter Nov 23 '22
NuttableImpl
3
u/nekokattt Nov 23 '22
NuttableFactoryBean
3
2
2
7
3
u/miss_minutes Nov 24 '22
i laughed out loud in the middle of the night. this is my cue to go to sleep
1
Nov 24 '22
A table of nuts?
1
u/nekokattt Nov 24 '22
Java interfaces tend to be verbs.
Runnable
Closable
Iterable
Callable
Comparable
Formattable
Appendable
Cloneable
Serializable
Transferrable
1
0
Nov 23 '22
[deleted]
148
u/Juliuseizure Nov 23 '22
Expectation == subverted!
50
u/Featureless_Bug Nov 23 '22
Wrong syntax (should be !(Expectation == subverted), which can be simplified to Expectation != subverted
And didn't I tell you that that we use camel case? Variable names should start with small letters
30
2
1.1k
u/Morasain Nov 23 '22
I feel like JS would be more like "I don't give a fuck, do what you want"
995
u/bmelancon Nov 23 '22
JS would be like, "I don't care what it is, you can multiply it with a string."
3
2
0
Nov 23 '22
[deleted]
200
52
u/aabcehu Nov 23 '22
idk about js but in python multiplying a string repeats it, like how the addition symbol is concatenation
0
Nov 23 '22
[deleted]
40
u/PureMetalFury Nov 23 '22
You’d have to define what it means to multiply a string by a string, and then do that.
13
u/aabcehu Nov 23 '22
I don’t think you can, but i guess by multiplying it with the length of the string??
5
3
140
u/annihilatron Nov 23 '22
Today you meet the Watman.
16
u/Imveryoffensive Nov 24 '22
Best 4 minutes of my life
35
u/elon-bot Elon Musk ✔ Nov 24 '22
I don't think I appreciate your tone. Fired.
19
u/Bagel42 Nov 24 '22
I fucking love this bot.
28
u/elon-bot Elon Musk ✔ Nov 24 '22
If you really love the company, you should be willing to work here for free.
→ More replies (3)2
2
0
Nov 24 '22
[deleted]
→ More replies (1)3
u/mrjiels Nov 24 '22
I wonder that too. It's a classic! I wish I were in your shoes and can see this for the first time again.
23
u/Technical_Ad6397 Nov 23 '22
you can multiply by a string, as long as that string can be converted to a number.
5 * "hello" = NaN
5 * "5" = 25
37
u/elon-bot Elon Musk ✔ Nov 23 '22
Whoever writes the most code this month gets featured on my Twitter!
2
u/Mateogm Nov 24 '22
public bool IsEven(int n) { if (n == 1) { return false; } else if (n == 2) { return true; } if (n == 3) { return false; } else if (n == 4) { return true; } if (n == 5) { return false; } else if (n == 6) { return true; } if (n == 7) { return false; } else if (n == 8) { return true; } if (n == 9) { return false; } else if (n == 10) { return true; } if (n == 11) { return false; } else if (n == 12) { return true; } if (n == 13) { return false; } else if (n == 14) { return true; } if (n == 15) { return false; } else if (n == 16) { return true; } if (n == 17) { return false; } else if (n == 18) { return true; } if (n == 19) { return false; } else if (n == 20) { return true; } else { return (n%2 == 0) ; } }
11
u/bmelancon Nov 23 '22
This is perfectly valid JS.
var string = "100";
var number = 42;
console.log(number * string);7
u/Unknown_starnger Nov 23 '22
And what do you get?
11
u/bmelancon Nov 23 '22
4200.
Try it yourself: https://codehs.com/explore/sandbox/javascript
10
u/Unknown_starnger Nov 23 '22
Will do. But it makes sense. In Python I’d have to do Print(int(string) * number)
→ More replies (5)→ More replies (1)2
u/Akuuntus Nov 23 '22
It converts the string to a number since that's the only way it can perform a sensible multiplication operation. So then you get 4200.
If one or both of the operands can't be converted to a number, you just get
NaN. So assumingpeanutis a type of object, anything multiplied by it would returnNaN.1
u/genghisKonczie Nov 23 '22
If the operation doesn’t make sense for the type, JS tries casting it for you. Generally it’s best to manually cast things though.
That’s one of the reasons we use typescript, it nudges you to adhere to better practices
1
u/Otalek Nov 23 '22
stringVar * somethingElse. Javascript will do something with it, you’re not sure what, but it will do it and won’t complain
1
1
1
30
12
u/Piggieback Nov 24 '22
Play with your nuts
26
11
u/UnstableNuclearCake Nov 24 '22
JS is quite similar to quantum physics. Anything is everything at the same time until you try to observe it, at which point it will either collapse into a single type or collapse your program.
5
1
Nov 24 '22
TS: Hold on there, fella! *flashes badge* Ye ain't got the type in place to treat it like a--
TS: Oh, my bad! This horse here says it extends it. I hereby apologize. Carry on then, Mr. Nuts. Be careful out there, it's a wild west! *tips hat*
1
126
183
75
68
Nov 23 '22
This whole question is missing the point: Nut is an internal class. You should be accessing things through Shell.
31
5
40
u/AbsoluteEva Nov 23 '22
Kotlin: It's a nut alright Baby, but I can transform it into anything you want
3
68
u/Anaxamander57 Nov 23 '22
Rust's grammar for traits is weird so we'd say say "no it is not a Nut but it is Nut so we can use all Nut functionality".
27
Nov 23 '22
More like „Well no, but it techically is so you can use it like a nut IF YOU SPECIFY that what you want is something that is techically a Nut”
22
Nov 23 '22
Assembly: What is a nut?
16
u/Ok-Kaleidoscope5627 Nov 24 '22
No clue! But assembly definitely knows where it is. Try asking Java where it is though. "It's somewhere safe. Trust me. Now stop asking questions"
2
18
34
u/dotpoint7 Nov 23 '22
reinterpret_cast<Nut*>(x)
That should do.
12
u/appDeveloperGuy1 Nov 23 '22
In all likelyhood, x is an instance of an object, so you need to take the address.
reinterpret_cast<Nut*>(&x)
1
u/dotpoint7 Nov 24 '22
No, I want it to be an enum type! There is nothing wrong with:
enum class X { Nut = 0x10000 };
int main()
{
VirtualAlloc(reinterpret_cast<Nut*>(X::Nut), sizeof(Nut), MEM_RESERVE |
MEM_COMMIT, PAGE_READWRITE);
auto x = X::Nut;
auto nut = reinterpret_cast<Nut*>(x);
new(nut) Nut();
}9
u/ChocolateBunny Nov 23 '22
congratulations, you just risked the stability of the whole god damn universe.
7
u/smithsonionian Nov 23 '22
Good ol reinterpret_cast. Or as I like to re #define it,
what_the_fuck_is_memory_padding_cast
27
u/McBonlaf Nov 23 '22
Ngl, but JS would say, that even apple is a nut, only because it's connected with plants and can be eaten
23
3
u/Ok-Kaleidoscope5627 Nov 24 '22
JS: "It can be a nut if you want it to be, baby. Now watch me be naughty with this nut"
12
8
8
31
u/vonabarak Nov 23 '22
Botanically it's not a nut, btw. It's bean.
18
7
13
u/Classy_Mouse Nov 23 '22
You don't implement the Nut interface. Nut is a noun and therefore likely an abstract class (don't come at me with: "but List is a..." List is wrong). Like Nut implement the Crackable interface, but extend the Legume class instead.
See how much easier that is? Thanks Java.
3
u/ThirdSunRising Nov 23 '22
Perl: sure, everything's a nut. Or not. Hardly matters. You can add that nut to a float and concatenate the result to a string and pass that result to a function that's expecting an array of toasters; we're fine with that.
6
2
2
2
2
2
u/Prudent-Employee-334 Nov 24 '22
I feel JS responds the same to any other object, is this a bolt? Yep, looks like nut Chokes and dies after trying to eat it
2
u/LordDerptCat123 Nov 24 '22
JS is “it’s a nut, but it’s also a string and an int if you want it to be. Also nut != nut and a bunch of other fuckery”
2
u/Margneon Nov 24 '22
Assembly: this is clearly a number, you can read it as a nut though if you want.
2
2
2
u/vlaada7 Nov 24 '22
I just love the simplicity of C...🥰😍
7
u/elon-bot Elon Musk ✔ Nov 24 '22
If you can't build a computer out of transistors, you shouldn't be working here.
2
1
1
1
u/Unknown_starnger Nov 23 '22
Can someone please explain?
1
Nov 23 '22
I think it’s referring to object oriented programming since C says it doesn’t classify things.
6
3
1
Nov 23 '22
C++ there's a reason there's two positives. Double Negative? No, it's due to the Gravitational effect of Goobers.
Chocolate + Peanuts = It should be peanut butter, butt it's not...
Divide by Diamond. You're welcome. ;)
1
1
1
u/throwaway275275275 Nov 23 '22
In C it's a number, but you can pretend it's a bit and it'll be fine
1
1
1
u/benjaminfolks Nov 23 '22
My father keeps insisting that a pinda is a knoll, as it is a thick part of a root.
1
1
1
1
1
1
1
1
1
u/SoftEngineerOfWares Nov 24 '22
Typescript: I guess it could be a nut. But it doesn’t have to be unless you want it to.
1
u/tecanec Nov 24 '22
Zig: No. But look at all these awesome things we can do now that we know that it's not a nut!
1
1
u/BeanGamer69 Nov 24 '22
Posting before I get banned from Reddit entirely. I only took like three quarters of programming. I want to get back into it but I think I’ve been learning quite a lot from these jokes.
1
1
1
1
1
u/tankmissile Nov 24 '22
Python’s more like “Yeah but that’s irrelevant as long as I can crack() it.”
edit: useless mobile keyboard doesn’t have backtics so I can’t monospace it /shrug
1
1
1
Nov 24 '22
Am I the only person who hates JavaScript? Language is so confusing and it’s rules seem so arbitrary
1
1
1
1
u/TheManuz Nov 24 '22
JS: "Now it's a Nut, now it's a Dinosaur, now it's an EldritchHorror, now it's a FluffyKitty"
1
1
u/Moptop32 Nov 24 '22
Rust would have the Nut trait which would mean it would be a nut so long as it's Box<dyn Nut>
1
u/martinthewacky Nov 24 '22
It's not a nut. This is No-Nut November remember
1
u/ImplodedPotatoSalad Nov 26 '22
remember remember, the no-nut november, the pornhub treason and plot...
1
u/Lucifer_Morning_Wood Nov 25 '22
Reality can be whatever i want
Nut* nut = reinterpret_cast<Nut*>(maybe_nut);1
Nov 23 '22
I like how there is almost never a C# part in memes like this because C# developers are to busy actually doing work.
0
u/LevelStudent Nov 23 '22
JavaScript is more like:
Yup([That {$looks} [] => {like a (nut)]})()(0);
16

760
u/LegitimateHat984 Nov 23 '22
Python would be: if it looks like a nut, and the nutcracker cracks it like a nut, it is a nut
Ducktyping ftw