« first day (2200 days earlier)      last day (2751 days later) » 

6:00 PM
For members, you just always specify the type, period.
 
@fredoverflow "these days" - so it's just a fad
 
@Mysticial auto my_auto = makeauto(); my_auto.drive();
 
Ven
@fredoverflow no really it's mostly an issue because it makes the compiler horrendously slow
 
Then on assignment from incompatible type you just get an error.
End of story.
When I write a function... I don't care about call sites.
I just write a function with a given interface.
 
Ven
If only we had good tools, amirite
 
6:00 PM
@Griwes This exactly
 
And then it's the same story: you get an error if you call it with the wrong thing.
 
@Ven Wait, isn't the Scala compiler already horrendously slow to begin with?
2
 
Why is Griwes always right about everything again
 
And for what's in a repository... well, I assume noone's checking in broken code? :P
 
user1804599
@fredoverflow straw man
 
Ven
6:01 PM
@fredoverflow and you have no idea how much that makes it slower.
 
Because if they are, then all assumptions can be thrown out the window anyway.
(Where by broken I mean not compiling.)
 
@Griwes I check in broken code all the time (though at least normally on some feature branch).
 
auto x = window.getXCoordinate();
auto scaled = x / 10;
is x a fucking int or a double?
 
Ven
@fredoverflow i.e. If you're defining an implicit value, never forget to put its type. implicit val a = 3 is many times slower than impliit val a : Int = 3 (for more complex cases)
 
@Mysticial Yes.
 
6:02 PM
@JerryCoffin You're not supposed to read code on feature branches. :P
@Mysticial Do you care?
 
Ven
Because without that type ascription the compiler needs to do local type inference
 
@Mysticial It's an x coordinate scaled down by 10, next
 
If you care, then write x / 10.f.
 
Ven
@Mysticial i don't care :p
 
If not, then write int scaled = x / 10;
Both cases fixed. Next!
lol SO is rate limiting me
"Please wait 7 seconds." well fuck you too.
 
Ven
6:03 PM
THE WORLD IS RIGGES AGAINST GRIWES
 
Ironically I had to wait 5 seconds to send that one.
I'M TYPING TOO FAST
 
@Griwes I'd guess this is the basic point of litb's idea of SANA to start with: where you think it's helpful to give an explicit type (even if the code would be the same if you used auto) go ahead and give an explicit type.
 
But that's AAA!
 
@Griwes Just think how much worse that would be if you used auto for that typing! Case closed!
 
Write auto everywhere where it's deeply unhelpful to spell the actual type.
 
6:06 PM
@JohannesSchaub-litb The problem there is returning a std::tuple instead of a named struct. Not using auto does not make your life much better.
 
@Griwes That's not how I recall its being propounded. At least from memory, his claim was that you should use auto essentially everywhere except when you depended on an implicit conversion from what was returned to a particular type you wanted (especially things like proxy/facade types that you weren't expected to ever use directly).
 
Is Coliru dead?
 
caps only 20 minutes late to the party
 
@caps i agree that tuples and pairs in return types are smells
 
@Morwenn actually nvm, no, it does not
 
6:07 PM
:(
 
@JerryCoffin You need to take everything with a grain of salt. :P
 
but I see no problem with them if they are used in a namespace { ... } one-shot function
 
@JohannesSchaub-litb ewww
Defining a function local structure is trivial.
 
Ven
@JohannesSchaub-litb the problem is that you could have an abstraction ;-)
 
There's exactly one place where tuples are truly useful and that's in generic code.
 
6:08 PM
@Griwes So, in essence, SANA is the low-sodium substitute for AAA.
 
Haha, two of my PRs have made it into a CppCon talk https://www.youtube.com/watch?v=Os5YLB5D2BU&feature=youtu.be&t=1491
^_^
 
@Griwes Yes. Because rounding changes the behavior of the code. If I'm asked to debug something that had that in it. I would know right away the error is there if I could see that x was an int.
 
That was quick. lol
@Mysticial If you want a double, then write x / 10.0.
End of story.
Be explicit about wanting a double.
 
Xeo
@Griwes don't you get a float from that? :P
 
6:09 PM
error in that expression. if you had explicitly written double the error would not have happened
 
@Mysticial I'm gonna go with int because that tends to be in "pixels" which you cant have partials of
 
that f is very explicit
 
Shush.
@JerryCoffin I think that if litb is presenting the spirit of it correctly, then it's too low-sodium.
@JohannesSchaub-litb IMO not writing / 10.0 if you want floating point division is a bug.
 
@JohannesSchaub-litb omg yer famous!
 
haha now it must pay off to invest into my new auto doctrine!
 
6:11 PM
@Borgleader The "window" wasn't exactly the best example. I was mainly trying to highlight the issue where sometimes you actually need to know the type if you want the code to be correct. Yes you can figure it out if you dig deep enough into the code, but that's time you don't need to waste if the type was clear from the code itself.
 
@Mysticial Oh sure, I was just saying, in this case it should be int.
 
perhaps i should visit the dragon's den
 
@Mysticial If you need the type to be a specific one... then you specify it.
 
Also, in VS and/or Reshaper/VAX you should be able to get the type by just hovering.
 
As simple as that.
But more often than not, you don't need that.
(Because most types are slightly less bad than integers.)
 
user1804599
6:14 PM
I want to be cloned.
 
@Mysticial It is the right type!
 
@Borgleader My main issue of overuse of auto is with user-defined objects. Often times, I want to know the type of the object so I can look up the definition and see what other methods it has. In the absence of an IDE, I need to lookup function name. But that fails miserably when the function is operator[] or some stl container of another user-defined object.
 
user1804599
Because I am incredibly awesome.
 
auto main() -> int {
    std::cout << "Hello, Mysticial!";
}
 
And even with an IDE, it fails when the types are dependent inside a template.
 
6:15 PM
100% agreed to mystical
 
@Mysticial Well, that fails with or without the IDE. :)
 
qtcreator almost always fails to deduce auto types
 
@rightfold class rightfold implements Cloneable
there you go
 
@fredoverflow pls no
 
not so smart like kdevelop
 
6:16 PM
one rightfold is already one too many
 
@JohannesSchaub-litb get a better tool
2
 
and definitely the github browser is even dumber
 
@Mysticial Meh.
 
there's two things here to consider. 1) Using auto for saving keystrokes. 2) using auto for not committing to a single type
 
Almost Always Auto says that even when you want to explicitly specify the return type, you still use auto: auto var = FooBar();, or auto str = std::string("my string"). It gives you more consistent syntax across the language.
 
6:19 PM
IMO c++ needs 1) without also giving you 2)
but i don't see how this could be accomplished
 
@caps auto str = "my string"s;
 
@fredoverflow That's even better.
 
Unless you overlook the s and think it's a const char* :)
 
@StackedCrooked I DEMAND YOU FIX COLIRU I CAN'T LIVE LIKE THIS
:D
 
what about my pet peeve bug report llvm.org/bugs/show_bug.cgi?id=5916
 
6:21 PM
@Griwes Right. I just noticed it didn't work anymore.
I'll try to fix it soon.
 
Much obliged. :D
 
Probably not a biggie. But I'm lazy..
 
I talked with sehe about this a while back. I'm very pro-auto.
Sep 4 at 21:58, by caps
@sehe auto name = type(), using name = type, auto name() -> type, auto name = [](){} -> type I don't know, it looks consistent to me. :shrug:
Sep 4 at 22:01, by caps
ReallyLongType::WithSeveralNamespaces::GoesHere foo();
Type bar();

auto foo() -> ReallyLongType::WithSeveralNamespaces::GoesHere;
auto bar() -> Type;
 
@StackedCrooked coliru with type inference tooltips would be cool
 
My personal rule with auto is:
1. Don't use it, if the real type is "sufficiently" easy to type.
2. Use it no more than 1 layer of indirection.
3. Use when you technically need to. (dependent types, private type return value)

Which basically limits my use-cases to:
1. auto iter = container.begin();
2. for (const auto& item : container)
 
6:22 PM
@JohannesSchaub-litb ewwwww
 
@Mysticial exactly my approach aswell
 
@JohannesSchaub-litb so basically tooltips that show "auto" :)?
6
 
(1) is silly.
I don't understand what (2) means.
 
@StackedCrooked lulz
 
@Griwes auto* but not auto**
 
6:23 PM
i guess he means auto x = foo(); auto y = x.lulz();
 
That's even more silly than (1).
Guys, on a completely serious note, I knew @Mysticial doesn't know either C or C++, but you, @JohannesSchaub-litb? :D
 
i would like to see an editor which replaces all occurences of auto visually with the correct type
 
ewww
I mean
ewwww
 
I'm not pro-auto to save on typing.
 
perhaps marking it yellow or something to indicate that it's a visual sugar ontop of auto
 
6:25 PM
have fun with std::bind
 
@Griwes My cicada detector is even simpler: "are they plonked by me"
 
or anything that uses expression templates
 
so that it's not in the tooltip, but directly in the text the programmer looks at
 
Stuff like this:
auto foo = object.getFrob();
auto bar = foo[key];
auto baz= bar.getBaz();
Getting the type of the last one can be a pain-in-the-ass.
 
I wish I could use auto more often, but I must keep code c++03 compliant
 
6:26 PM
@JohannesSchaub-litb Heck, have fun with vector.
Remember you'll also see the allocator.
 
so that basicly means - no auto
 
Have fun with vectors of variants.
 
@Griwes only for auto types
 
@Mysticial Perfectly reasonable code, if you make the names mean anything.
 
and it should use the sugar type. i.e not look through typedefs use the type that theuser specified
 
6:26 PM
@Griwes typedefs/using
 
@JohannesSchaub-litb Yes, that's what I'm saying.
 
i mean the type specifier the user used
i.e leave default arguments off
 
So what?
I'm writing auto foo = fmap(some_vector, something);.
 
i think this would be very nice
 
I never specified the type.
 
6:27 PM
@Borgleader Never typedef; always using:
 
and it would somehow indicate BarType foo = ...;
 
Sep 4 at 21:58, by caps
@sehe auto name = type(), using name = type, auto name() -> type, auto name = [](){} -> type I don't know, it looks consistent to me. :shrug:
 
Maybe deep inside fmap, but there's std::invokes involved there.
(I would NOT want to see that.)
 
don'T know how to squeez it into the space of auto tho
perhaps when writing, the cursor just jumps to make space for the real type
 
Also eh, all my interfaces are clear enough.
Next!
 
6:28 PM
@Griwes ahem
 
(The fact that I'm not actually writing any C++ at work probably helps.)
@GundolfGundelfinger what
 
@Griwes I disagree that names can always sufficiently describe the type without making it unwieldy.
 
FYI, I don't always use auto.
 
And that falls into the same category as misleading names or comments. An explicit type is clear because the compiler enforces it.
 
6:30 PM
@Mysticial Thousand of programmers from other languages disagree with you
And all 12 Haskell developers
@Mysticial Orthogonal
 
@GundolfGundelfinger What? Everybody knows what is the return type of mbind.
 
@Griwes "my interfaces are clear enough"
 
one of the basic drawbacks of dynamically typed language is lack of documentation by type specifiers in the program text
 
@Mysticial Agreed, somewhat: we need sensible concepts to be usable there to sometimes care about a specific interface, but not about the specific type.
 
@JohannesSchaub-litb In VS for C# code they have a thing where they tell you the use count of a method, maybe that could work for this. Where you use auto, you would that the resolved type.
 
6:33 PM
@JohannesSchaub-litb Nah, that's actually the good part: you focus on the APIs and not on the data structures (and if your API is badly named or doesn't document its data types then, well, you know what to fix).
I like that I can specify the bare minimum of type information I need for a thing to typecheck.
Ideally I never want to specify more.
@GundolfGundelfinger Yes, because it's clearly a monadic bind and that interface requires no further documentation.
 
Yes it's "self explanatory"
 
Yes it is.
 
Flip it on its head: what do you gain from using auto versus spelling the type name?
 
@GManNickG Mostly consistency.
 
@caps What does that even mean?
 
6:37 PM
Also correct typing without implicit narrowing or similar conversions.
 
@GManNickG I can stop caring about the specific type.
 
@GManNickG Longer time before you get carpal tunnel syndrome? :)
 
Sep 4 at 21:58, by caps
@sehe auto name = type(), using name = type, auto name() -> type, auto name = [](){} -> type I don't know, it looks consistent to me. :shrug:
 
Which makes it easier for me to notice patterns. :P
 
@caps Consistency here doesn't mean anything. To literally see the letters "a" "u" "t" and "o"? Yeah I guess that's consistent but...so what?
 
6:38 PM
@GundolfGundelfinger The most common case of me wanting to kill the person who used auto is something like this:
auto message = factory.newMessage();
message.symbol = "AAPL";
message.price = 11500;
message.quantity = 100;
message.type = 'B';
Boss tells me to set the self-match prevention flag. I find the code above. I have no clue what the type is. So I don't know where to find it to find the field to set.
 
what's not clear about this?
the 'B' is questionable
but that's unrelated to auto
it should really be message_type::buy or whatever
also price should be a different type
 
@Mysticial I type message. and my editor shows me what is there.
 
you're welcome
 
@GundolfGundelfinger What is message_type here?
 
@Griwes IDEs don't work here.
 
6:40 PM
@GManNickG an enum obviously
 
@Mysticial That doesn't make any sense.
 
@Griwes What editor? I'm reading the code in github.
 
Are you saying that if they hadn't used auto, you wouldn't need to go and look at the definition of the return type of newMessage?
 
Okay, here's a thing:
The problem with the readability of that isn't that he used auto.
 
@caps Yes. And you also would have lost nothing.
 
6:40 PM
@caps Basically, I have an unknown type. I need to set an extra field. But don't know what type I'm supposed to grep for in the codebase to find its definition.
 
The problem is that the fields haven't been typed strongly enough.
 
And I need the definition of the type so I know what field to set.
 
That would've been a problem regardless of whether he used auto or not.
 
@Griwes Exactly.
 
@Mysticial Again: message. and you know everything.
"IDEs don't work here" is a nonsensical statement.
 
6:41 PM
@Mysticial Yes you do. The return type of newMessage.
 
@Mysticial also very bad idea, don't buy apple stock
 
Using auto instead of a type for consistency is like having everyone put paper bags on their heads for consistency. You still ultimately care who you're talking to, so I'm not sure what problem you solved.
 
@Griwes Again: IDEs don't work in our environment.
2
 
lol relying on C++ IDEs
 
@Mysticial lol
 
6:42 PM
@GManNickG Then you don't have to edit anything, because you're just reading it.
@Mysticial Again: that's a nonsensical statement.
 
@caps The file has 50 headers. I grep the code base for "newMessage()" and I get 5000 hits across 10 million LOC.
 
@Mysticial You have a tool problem. What type is factory?
 
That'd mean your codebase has bigger problems than setting a flag.
You should halt development immediately and sort it out before proceeding.
 
@caps And that's how I would trace it. But I've already wasted time I wouldn't need to have.
 
Newsflash: techniques assuming your code is not shit don't work when your code is shit.
2
 
6:43 PM
@Griwes Welcome to real life production code.
 
@Mysticial Barely. grep for FactoryType::NewMessage
 
welcome to shit production code
 
^
 
that's vastly different
 
6:44 PM
@caps Doesn't work. because it's defined inline in the class.
 
Hell, our production code is shit and all I'm talking about works there!
 
Let the first person who's never had to work in shit production code throw the first stone.
 
(Because our build system isn't shit and has sensible cmake setup that generates sensible IDE projects.)
 
working with shit production code is no excuse for not fixing it
 
^
 
6:45 PM
@Griwes Using cmake? Sounds like shit to me
 
@GManNickG cmake itself is pretty shitty, yeah.
 
@Mysticial And you can't easily find the header where it is defined? In addition to the tool problem, you seem to also have a code organization problem.
 
Doesn't stop competent people from writing non-shit solutions with it.
 
In your environment, I can see the case for not using auto on that line of code.
 
Let's say all my code is perfect, and even in Mysticial's example I can trivially find the header by searching for the function "newMessage()" and then read the return type, this is still extra work, and you've gained nothing for it.
 
6:47 PM
But auto is not the problem.
 
@caps Well, the file might have 10 - 50 includes. I don't know what the name of the file is. But I can try searching for through all the includes. But they're not easy to find and there's also about 100 -I's on the build command.
 
@GManNickG Here's a thing, unlike some people I'm capable of both striving for better tools and using the tools I have in a way that results in something nice at the same time.
 
@caps Actually it is. Because without auto, the user would've put the real type there. And I would've saved a bunch of time.
 
@Mysticial If you have a FactoryClass defined somewhere outside of FactoryClass.h (or some other consistent naming scheme of your choosing) I think you have a code organization problem. :shrug:
 
@Mysticial No, the code being shit is the problem.
 
6:48 PM
try kdevelop. since it uses clang it knows what the real type is
 
You should fix that problem.
 
It would seem the general argument against auto so far is that bad programmers can't deal with it.
 
It might seem that auto is "the" problem, but it's just a problem that's the result of a cascade of problems, and the underlying condition is something else - in this case, shit code.
 
That's a slimy argument, "deal with it" can mean whatever you want
 
Did you watch House MD, @Mysticial?
 
6:49 PM
@Griwes I agree the code is shit. But I can't fix 10 million LOC when I have deadlines to meet.
 
Your mom is slimy too
 
Don't treat symptoms; treat the illness.
 
@JohannesSchaub-litb Or juCi++ (though it's still quite new and a bit rough around the edges).
 
@Griwes What about my scenario? The code is 100% perfect, the only decision is whether to use auto x = myUniqueFunctionName() or thetype x = myUniqueFunctionName(). I can easily see the return type by grepping for the function name.
 
@JohannesSchaub-litb Doesn't qtcreator also power itself with clang?
 
6:50 PM
@GundolfGundelfinger Good counterpoint
 
@GManNickG Do you care about the specific type? Or just about the interface?
 
@Griwes I care about readability. I want future readers to understand this code with the least amount of effort.
 
Is the type important? Or just its interface?
(Yes, it's the same question, because it's the exact same dilemma.)
 
@Griwes Some code has colon cancer: the treatment is more dangerous than the disease. Seriously: if you're writing new code, there should rarely be a reason to avoid auto. If you're dealing with large body of existing code: retrofitting auto and getting decent results will often require fairly major rework.
 
@JerryCoffin But that rework will benefit you greatly in the long run, not just when using auto.
 
6:52 PM
@Griwes Let's consider both. Type important in one because it's a protobuf, interface in the other because it's an object representing a connection to something
 
@GManNickG Again: is the type important, or just the interface? (There's never a point where the interface is not important.)
If the type is important, write down the type.
 
In either scenario I have some concrete type TheMessage or TheConnection, why not spell it out other than being lazy?
 
If it isn't, don't.
@GManNickG Is it important?
I'm not asking whether you know it or not.
 
Does the C++ community have a crowd-sourced code review resource? Would be pretty cool. #cpp
 
I'm asking whether knowing a specific type, as opposed to its interface, gives you any important bits of knowledge.
 
6:54 PM
Wanted to answer CodeReview.SE :P
 
@Griwes Undoubtedly. Unfortunately, most business decisions are based on results this quarter, not in the long-term.
 
@Griwes It's a type, it lets me know what operations are available. All types are important in that sense
 
TBH, production code is read more often then it's written. So if it takes 10 seconds to write out the type to save N future readers 10 minutes each of grepping, it's a net win.
2
 
@JerryCoffin Well, if we just sit silently while that's happening, it'll never change. :P
@Mysticial If your readers need 10 minutes to read code with auto, then your names are utter shit (aaaaand we made a full circle).
@GManNickG No, the interface lets you know what operations are available.
This is probably the part that's so often misunderstood: what's the importance of a specific type, and what's the importance of the interface.
 
6:56 PM
@Griwes This is just pointless semantics on what a "type" is. Fine, an "interface". Whatever auto deduces.
 
@GManNickG auto deduces types.
 
@Griwes you don't say?
 
More often than not, when working with vectors, I don't care it's a vector.
I only care about the fact I'm dealing with a SequenceContainer.
Hence, it's not important to me that it's a vector. I don't care about the type, I care about the interface.
 
Sure, but C++ doesn't have the ability for you to ask for that, so you either spell out your concrete type or you use auto
 
I write auto and use SequenceContainer functions.
 
6:58 PM
Why?
 
Using the interface usually makes it obvious that it's a thing that's a SequenceContainer.
 
@Griwes Oh, I realize this. Consider Google's code base. They've been maintaining (and defending) their code standards for years now. It's largely based on their mountain of existing code. By now they could have rewritten it (twice, if necessary) and be money ahead. But, talk with management about work that introduces bugs, doesn't add new features, and won't be finished for 2 years. 'bout all I can say is: "good luck with that."
 
What is your argument for auto here other than saving keystrokes?
 
@GManNickG Because I don't really care about the type?
@GManNickG Genericity!
 
is it possible with concepts that you can say auto<SequenceContainer> c = ... ?
 
6:58 PM
I don't care it's a vector. At all.
 
wouldn't that be cool
 
@Griwes Is this a template or concrete code?
 
I care I can push_back into it.
@GManNickG Concrete code. So what?
 
the compielr itnernal type would be the vector. but it would be type checked as SequeneContainer
 
This makes it trivial to factor that part out.
@JohannesSchaub-litb I believe concepts lite do give you something like that
 
6:59 PM
This is just type classes
 
No.
 
I hope concepts aren't just hacked together and they actually put some theory behind it
 
Concepts are not type classes.
 
6:59 PM
They are isomorphic in many features, but not the same.
 
user1804599
Type classes. <3
 

« first day (2200 days earlier)      last day (2751 days later) »