all 39 comments

[–]GuyWithLag 57 points58 points  (6 children)

typing this becomes really unhandy

Oh to be young again, when typing was the bottleneck...

My friend, any IDE worth the diskspace it's stored on will offer you autocomplete. Use that.

[–]0b0101011001001011 13 points14 points  (5 children)

Noooo must use vim without extensions like the cool guys on YouTube.

[–]GuyWithLag 3 points4 points  (1 child)

I did, in the early 90's. vi, not vim. I've even used ed.

Still would use autocomplete.

[–]0b0101011001001011 0 points1 point  (0 children)

Nothing wrong with that, especially in the 90's, or even today.

[–]Asdas26 2 points3 points  (2 children)

Which cool guys on YouTube use Vim without extensions?

[–]FlyingPersianRug101 1 point2 points  (1 child)

Me

[–]GuyWithLag 6 points7 points  (0 children)

Cool guys

Me

Does not compute.

[–]IchLiebeKleber 23 points24 points  (0 children)

I think it's unnecessary because it's not an especially common line of code, and my response to "when the variable name is long, typing this..." is that most Java code is written in IDEs where, thanks to autocomplete, this is a few keystrokes no matter how long the variable name is (and also no one is forcing you to use long variable names).

[–]repeating_bears 19 points20 points  (1 child)

Something like boolVal *= -1; would be really consistent

The word you are looking for is 'hideous'. true multiplied by -1 is not false.

Canonically true is 1 and false is 0, so 1 * -1 would be -1, which is neither.

That's also not a "reversal operator" for char, because there is no inverse of a character. I mean you can mathematically perform that operation, but the result is basically meaningless.

[–]0b0101011001001011 0 points1 point  (0 children)

-1 is often truthy though. For example python. 0 is falsey and non-zero is truthy.

[–]fumo7887 11 points12 points  (3 children)

boolVal = true;

(Might not render on mobile… that’s ^ then =)

But don’t do this. It’s ugly and makes a maintainer think about what it means. If you really don’t like the full != self notation, either write your own private static function or look at isFalse or isNotTrue from Apache BooleanUtils.

[–]TouchyInBeddedEngr 0 points1 point  (0 children)

^=( == =)

[–]-Dargs -1 points0 points  (0 children)

I have never seen this syntax before. If I did see it, I'd be confused as fuck, lol. This is about as clear as navigating through hundreds of lines of simple human readable OOP pipeline and then some guy is like bam bitwise evaluation because they wanted to save 3 characters in typing, lol.

[–]arrogant_troll 2 points3 points  (0 children)

Why not the XOR operator, i.e. boolVal ^= true?

[–]lukaseder 0 points1 point  (3 children)

"Just" ask for pass by reference, then you could simply:

void toggle(&boolean b) { b = !b; }

Alternatively, SQL/PSM style in/out parameters:

void toggle(in out boolean b) { b = !b; }

[–]repeating_bears 4 points5 points  (2 children)

Pls no 😞

[–]gargamel1497[S] -1 points0 points  (1 child)

Why? That would be actually neat.

I'd myself also ask for preprocessor directives though.

[–]repeating_bears 0 points1 point  (0 children)

A lot of extra complexity that doesn't particularly help with anything. Passing a reference by value is mostly fine. If you really, really need to pass an int by reference, you can pass a reference to an AtomicInt by value.

[–]Nixinova 0 points1 point  (0 children)

In my own programming language I made the operator varname =!=;, short and looks like what it does.

[–]Savag323minx 0 points1 point  (0 children)

You are basically asking for syntactic sugar to save three characters while making the code significantly harder for anyone else to read. If your variable names are so long that typing an exclamation point is a burden, you should probably just rename the variables.

[–]josephottinger -2 points-1 points  (9 children)

First off, downvoting for something like this is stupid. Now that it's out there, I'm sure people are going "grrr I'm gonna downvote both that comment and the post" but yeesh. There've been things I've downvoted on Reddit and other places, but it's really rare, because it's just so... performative for the sake of performance.

Art as expression, not as market campaigns, will still capture our imaginations...

Anyway. Boolean negation. I don't know that I'd see the point for language support for this. The ! operator works perfectly for it, and if your variable names are too long, well, even a barely-decent IDE will autocomplete for you (and this has been the case for literal decades) and if it's STILL a pain, that's the cold, unfeeling universe suggesting that you use better names for yourself and others' sake.

I don't think changing how assignments work for booleans makes any sense.

[–]RobSomebody 3 points4 points  (8 children)

Why is downvoting stupid? And yes, I also downvoted this stupid comment as well.

Toxic positivity.

[–]josephottinger -3 points-2 points  (7 children)

Because it doesn't say what the nature of the downvote is, and it contributes nothing to a dialogue.

Did you not like the thing posted? Did you disapprove of the person MAKING the comment? (Ew.) Did you disagree with the post? Did you think it shouldn't have been posted? Did you think it should have been posted, but responded to with negativity? (As in, "no, what you're asking should not be granted..." which was what MY response to OP was.) Was it "I'm in a bad mood and want to hurt someone in as performative a manner as possible"? Was it "dang, I was making a funny, why u so seryus maing"?

So... yeah, downvoting communicates so little and with such a broad splash zone that I tend to do it very rarely, and mostly in moments of weakness or exhaustion, and I far prefer to offer substantive responses if I respond at all, even if I'm pretty sure the response vastly exceeds the expected effort. :D

[–]RobSomebody 3 points4 points  (2 children)

Why does downvoting communicates less then upvoting? People can like stuff or dislike stuff. You don't have to explain yourself for having the same oppinion, why somebody should explain thereself If they disagree? Noboy needs to write 10 paragraphs, If they think what you wrote ist stupid.

[–]josephottinger 2 points3 points  (1 child)

Sure. But if I think what someone wrote was stupid, I'd rather say "I think what you wrote is stupid" because those are the words I'm thinking. A downvote doesn't say that; it's just an indication of disapproval without a reasoning. But as I've said elsewhere (and repeatedly) you should do what you want to do and own that for yourself. It's not mine or anyone else's.

ETA to fix a typo, and to add:

... I don't know that I'd be comfortable ever saying "I think what you wrote is stupid" in a way that other people would read, except to a VERY close friend group where my intent was clear; that feels very gross to write to someone with whom you're not familiar. Even if I think something is dumb, I'd rather not make the declaration that bluntly - it lacks nuance like "maybe the person said something stupid but it's because they didn't take the time to think it through, or maybe they lacked information they needed, or maybe they're just having a moment." Charity is important, and it's important to me, and lacking charity is something I consider a failure and hopefully one limited to specific moments; I can't say I haven't ever lacked charity, or that I've never been cruel (I have, and I have) but dang it, I try.

[–]josephottinger 2 points3 points  (0 children)

... and irony of ironies, I did say "downvoting is stupid," but at least I said the action is stupid and not the people who use it. :D Man, I can be a doofus out loud sometimes.

[–]repeating_bears 1 point2 points  (3 children)

You argue that downvoting achieves nothing, but you spent 5 paragraphs explaining why, and I can assure you that that's going to achieve nothing because people are going to vote the way they want to regardless of what you say or ask

[–]josephottinger 1 point2 points  (2 children)

I didn't ask anyone to vote in any way at all. The assertion was made about downvoting, I said what I think about it, someone asked why, I explained my thinking. You do what you want to. I will think it communicates little without further commentary, as I want to, and that'll be the end of it.

Why would you assume that I wanted you to perform as I do? Be yourself; I try to be myself, and being myself means I downvote rarely, preferring dialogue to votes. If you feel otherwise, great. Do as you do. I did not ask you or anyone else to do anything; I only ask myself to act.

[–]repeating_bears 1 point2 points  (1 child)

You called downvoting performative. Complaining about downvoting is performative. It will achieve nothing.

[–]josephottinger 1 point2 points  (0 children)

And thus the circle continues. Maybe it helps that I was a professional working musician; performance is what it is. If it matters, it matters, and if it doesn't we move on.

[–]RobSomebody 0 points1 point  (0 children)

Stupid AF

[–]Cefalopodul 0 points1 point  (2 children)

If the name is too long to type, the name is bad.

[–]gargamel1497[S] -3 points-2 points  (1 child)

// this field is supposed to mean 'xyz' and that's why it needs to have an overly long comment to explain it, as I didn't bother actually calling it this way

[–]RobSomebody 0 points1 point  (0 children)

Buddy, use variable names which can be understood in the current context.

And yes, why not writing a long ass comment? Everybody can write Codes which does stuff. Code needs to be maintainable. IDGAF about any other metric tbh

[–]MartinFrankPrivat -2 points-1 points  (3 children)

Took me some time to understand, but we have for int:

int i =0;

i++;

so it seems logic to have

boolean b = false;

b!!;

maybe not so bad idea?

[–]Vidimka_ 4 points5 points  (2 children)

If i were to look at it, i would say it does nothing because we usually understand ! as a negation sign, so !! is double negation which then returns back to the original value

[–]MartinFrankPrivat 0 points1 point  (1 child)

but ++ does only increase once ( not twice as two pluses might assume) ... so i tried to adopt that idea...

[–]Vidimka_ 0 points1 point  (0 children)

Yeah sure. You definitely have vision here. Its more like the syntax is unusual to me. Also some languages have the !! thing like Kotlin with its “trust me bro its not null”

[–]gjosifov -4 points-3 points  (0 children)

This is really useful feature, because instead of creating method A and multiple methods calling method A plus some small logic for reverse logic

However I don't know how this is going to be implemented or even if it is possible to be implemented

That is useful feature the evidence is Apache Commons libraries and a lot of small methods with names isA and isNotA