Re: Haskell is our first choice for building production soft...
by mehrdadn on Monday January 11, 2021 @08:18AM
(#25728488)
+1 for auto being overused. I always felt I was shouting into the void (hah) by saying the same thing... it's nice to see someone else agrees.
Re: Haskell is our first choice for building production soft...
by nicoburns on Monday January 11, 2021 @11:33AM
(#25731277)
I find that types can reduce readability as well as enhance it. They add noise and make it harder to concentrate on the variable names which are often much more important than the types which are often (but certainly not always) obvious from context.
Re: Haskell is our first choice for building production soft...
by secondcoming on Monday January 11, 2021 @03:26PM
(#25736091)
Interesting point.
I'd never have believed it myself, but find myself using acronyms instead of variable names when the type allows it.
void foo(MyType mt, const MyOtherType& mot);
It's the variable names that are the noise, types are everything. And no, it's not Hungarian notation either in case anyone suggests it!However, it maybe doesn't work that well with things like class member names. YMMV
Re: Haskell is our first choice for building production soft...
by nicoburns on Monday January 11, 2021 @05:22PM
(#25738325)
I guess it partly depends on how varied your types are. In some domains you can find yourself working with 10 variables that are all strings, or all floats/integers. At that point the type isn't that helpful for distinguishing which variable is which.
Re: Haskell is our first choice for building production soft...
by secondcoming on Tuesday January 12, 2021 @05:58AM
(#25745162)
I should have added that fairly liberal use of type aliases also helps.
using B64String = std::string;
B64String encode(const std::string& text);
std::string decode(const B64String b64);
Generally, I prefer being able to read a line of code and understanding exactly what it does. If I need an IDE and have to repeatedly try to find the definition of something then, in my opinion, that's wasting my time.
C++'s 'auto' is really useful but it's over-used IMO. I think that there's a belief that if you're not using 'auto' everywhere then you're not writing 'modern' C++. Just becuase your code compiles doesn't necessarily mean it's correct.