Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Lensflare17095194dAgree. If the language allows this, it’s a clown language. If you think that this is a good idea, you are a clown.
-
Liebranca843194dA very good rule of thumb, very much fucked in the ass worldwide; excuse me while I violate every single orifice of reason by representing multiple possible data types using only one structure.
-
lorentz15247194dAll functions return only one type, the type defined as the return type of the function. "a string or false" may be a valid type in your language.
Rather, I would phrase this requirement as "all type unions should always be tagged, and it should never be possible to access the value without visually acknowledging the fact that it's in a union, preferably asserting the tag. -
k0pernikus5454194dThe problem is: A function can have error states. You always need a way to communicate the error. Union types are one way, so are exceptions, or the error type of go.
Not all of those are equal, yet you'd be surprised how many developers hate using exceptions. -
Tounai1281194dIf you remove everything that is ugly, you’ll end up with Java, and Java is ugly, so you will end up with nothing
-
Wisecrack9974189d@Tounai quirks and imperfections are sometimes what make something beautiful.
Without her vague lopsided grin, mona lisa woulda just been an average looking street whore with hobbyist modelling aspirations. -
lorentz15247189dJava has pattern matching with custom matchers and immutable context, so you better get off its back right now because not a single popular language has adopted functional patterns as elegantly and effectively as Java.
-
lorentz15247189dTheir caution in introducing language features has paid off, now C++ is struggling to come up with syntax for pattern matching that doesn't look grotesque and isn't already valid C++, because every wee fad was awarded the most concise imaginable syntax.
-
Lensflare17095189d@lorentz
> not a single popular language has adopted functional patterns as elegantly and effectively as Java.
C#, Swift, Rust and Kotlin comes into mind. -
lorentz15247189d@Lensflare you're right, that was a silly statement. I do still think though that java has gained a lot of really great features recently, and the reason they could do it is that they were abundantly cautious about extending the core language.
I am of the firm belief that a function should always return just one type.
I think it's the most convoluted thing that a function should be allowed to return any kind of type.
I've seen shit like return a string when something is valid and then a boolean if it's not valid.
To me, that kind of flexibility has some funky code smell.
I'm looking at you WordPress 🤨
rant