Do other programming languages really not have switch pattern matching?

You mean to tell me other programming languages don't have pattern matching that can match to all of these types? How do people cope with the fact that their languages don't make it this easy?

Attached: 1655185425695.png (611x264, 10.76K)

Other urls found in this thread:

youtube.com/watch?v=BXqblYbUAeI
peps.python.org/pep-3103/
twitter.com/SFWRedditVideos

youtube.com/watch?v=BXqblYbUAeI

Attached: hmtst.png (374x312, 11.1K)

stop baiting javapoo

function x(a)
print("this is a ", typeof(a), a);
end;

python does this

in c++ this is just
std::visit([](const auto& v) { std::cout

Does it really?

> 0 references
Even author of this shit is not using it

>match to all of these types
Rust can do this just fine, assuming a is actually an enum type, and not some Box (basically the equivalent of "object"). But if you're doing that level of fuckery, you probably need to be shown the door anyways.

any expression can be matched with any expression

peps.python.org/pep-3103/

in haskell this is just
show

There's nothing wrong with open unions besides the fact that Rust doesn't handle them very comfortably.
Heavily OOP languages favor open polymorphism at the expense of closed polymorphism, Rust does the opposite.

>open unions
Sure... if that's what you want to call telling the type checker to go fuck itself.

>Do other programming languages really not have expression oriented syntax?
This switch stuff is just plain shit if you actually use it.
You can only put expressions after them so you have to use a regular switch if you want to do something vaguely useful, but then you can't return anything or put it anywhere useful.
Fundamentally, putting statements in the language just completely ruins any hope of having nice looking syntax.
>x switch
C# is so bloated that they have to use almost every way that you could write a set of reserved keywords to add stuff that some random FP lang had 20 years ago.
They built fucking SQL statements into the language, it's beyond belief.
I don't mind the language itself but you could compress its features into something 10% the size and probably have less stuff missing.

>public static
Holy fuck Java is ugly and retarded.

It can be useful to tell the typechecker to fuck off, yeah. Any correct type system prohibits some valid programs. (This is also the principle behind unsafe blocks.)
But it's not inherently dangerous. Trait objects are open and type-safe. You can't downcast trait objects besides Any, but the only reason for that is efficiency, it'd require adding a TypeId to every vtable.

Bro that's C#

How do you cope with not being able to write a free function?

90% of the time, the OOP polymorphism solution boils down to writing pieces of the same function in multiple places instead of keeping it all together.

>that's not Java, it's Microsoft™ Java

>Box
Do...do people really do this?

Java btfo

>I don't mind the language itself but you could compress its features into something 10% the size and probably have less stuff missing.
Most of the cshart features don't integrate well either. Try combining pointer/refs with generics or iterators, Try having fixed in readonly structs, try using the ever so fucking pointless mess that is ToString(),