Yeah it's an everyday struggle trying to find enough space in my files for all the code. Filesystem real estate really is unaffordable for most millennials.
You can comfortably fit 150+ characters plus navigation side bar in a line on the average 16:10 screen nowadays. And if a line of code is longer than that, you should really put a line break in there.
In my mind it depends on the use-case. If the code I'm editing or the language I'm using favors the second style, I'll use it. However, since I use an inordinate amount of C/C++, it makes more sense for things like struct types, and therefore makes sense to carry over to functions, etc.
If you think of struct { ... } as a type in and of itself (which it is), it makes more sense to write them in multiple lines with the { on the same line as struct. Writing it otherwise, in my mind, makes it look strange, since both struct and the {} are part of the same type. Just my 2¢.
I've no clue if you're serious or not, but if your code regularly is at lines of 150+ characters wide, you should really reconsider how you write code.
It looks jank as all fuck at first but when you start thinking about it it gets better (comments before keywords are how I read it in my head)
{
// stuff
} /* is */ struct S;
{
// stuff
} /* is */ function f() -> void;
{
// stuff
} /* run */ if (x);
{
// stuff
} /* do */ for/while(...);
{
// stuff
} /* is */ namespace x;
For namespaces, this has an additional effect: The file is more likely to be read bottom-up, which means the top of the dependency graph is read first.
You think it does, but if you were actually working in a language that did this, you wouldn't like it.
You would just be reading arbitrary code wondering what its purpose is until you get to the bottom. Then go "ohhh, that's what this function is for". In reality, you would just end up scrolling to the bottom of the function before you began reading the content of the function, because you need that context to even want to read the rest of the function.
Yeah, and in the inverse, the most important stuff comes at the bottom because it depends on everything else in the file, it makes it easier to follow that natural progression of "how do we get here"
So my main argument against this, apart from ergonomics, is that the most important part of an entity like a function should come first. The implementation is not nearly as important as the name, return type and parameters of the function.
143
u/PM_4_DATING_ADVICE Apr 23 '19
Yeah it's an everyday struggle trying to find enough space in my files for all the code. Filesystem real estate really is unaffordable for most millennials.
34
u/unfixpoint Apr 23 '19
Anyone else more bothered about the font not being mono-space than the indentation style?
64
u/[deleted] Apr 23 '19
Gonna make a new language and do this
Checkmate, liberals.
6
u/Abdul_Alhazred_ Apr 23 '19
Oh god why, Oh wait...
6
u/Shadow_Being Apr 23 '19
I think if youre worried about space efficiency of your code then its because your write spaghetti code.
Gotta keep your code style really tight to be able to follow that mess.
6
u/canyousaymaria Apr 23 '19
Thanks I hate it
37
u/evan795 Apr 23 '19
I'm quite partial to
4
u/Herb_Derb Apr 23 '19
How is it space efficient? It uses so many more spaces than the usual style!
4
u/corobo Apr 23 '19
Let’s just solve this once and for all