Possibly naive/metaprogrammer take on style guides: we should share code as ASTs & every user should bring their own pretty printer (style preferences) to how they view it as text.
Yes, even to how names/ids are compounded from word chains.


I had a few minutes so I wrote up a basic outline of this in more detail. I'm certainly not the first person to think of this but it's a shame I've never seen it gain widespread support. blog.shivoa.net/2017/11/tabs-v

@shivoa Hmm good thought. Probably the reason is inertia; large parts of programming have not changed for decades in this regard. For example, why I can't put pictures into code comments (diagrams, explanations, etc.)? And so on.

@hannah @shivoa That's no problem. I use VS Code as my default editor, but I include Vim controls. ;-) The source code performs clang-format checks that verify all merged code uses tabs, so I've gotten pretty used to that style now.

That said, it also does a weird mix of pythonic naming conventions inside C++. Typenames are PascalCase, but variables and functions are in snake_case.

@willnationsdev @shivoa @hannah
Why weird? PascalCase for classes, snake_case for identifiers and ALLCAPS for constants is pretty standard in C++ code, at least as much as camelCase for identifiers. Most C libraries use snake_case so C++ follows along.

@akien @hannah @shivoa Really? I never knew that. Granted, I'm not the most experienced programmer. Only been programming for, like, 6 years, 4 of which were in college devoted exclusively to camelCase conventions (I didn't even mess with Python-like syntax until I started learning GDScript earlier this year).

I've grown accustomed to it, but I had thought it was something born simply out of your guys' preference for Python syntax and tooling, etc. Good to know it's more commonplace.

@shivoa @hannah @akien Wait, that's not entirely true. My first experience with programming was GameMaker Language, which uses snake_case. But I only dabbled with it briefly since I was still not sure I could make it as a programmer at the time.

I went into college to be a Christian missionary in Japan, and then 1-year in I realized I needed to find a major that'd allow me to feed myself, and I tried out programming. Lo-and-behold, I enjoyed it immensely (and was ok at it).

@akien @shivoa @willnationsdev I think that camelCase works best for C++ but snake_case was used in C due to the lack of classes so names would actually be the sole way of organising code.Functions like libname_create_http_handler() and stuff are a relic of C that has made its way into modern C++.

That being said I'm a C# programmer so it's all rather uncivilised as far as I'm concerned ;)

@shivoa @aras I have a friend who works somewhere where they use resharper (or similar) to convert all code to house style on commit & they have hooks to allow individuals to re-format into their preferred format when source is pulled from the server.

It's not quite the "store source as ASTs" nirvana you're proposing, but it is doable right now :)

@darbotron Yep, I really hope that workflow appears in a standard VCS platform/tools in the near future. Once it becomes widespread, I don't see many going back.

Sign in to participate in the conversation
Gamedev Mastodon

Game development! Discussions about game development and related fields, and/or by game developers and related professions.