hiberlite icon indicating copy to clipboard operation
hiberlite copied to clipboard

Code Style

Open paulftw opened this issue 10 years ago • 2 comments

When I started the project in 2004(ish) I didn't know much about coding styles. Decision I regret the most is using tabs (because it's 2014 and nobody else seems to be using tabs for formatting).

We should a) choose a C++ Style Guide for all future code; b) convert existing files to this style.

I think Boost style guide would be a natural fit, since whole library is mimicking Boost Serialization where possible.

Any ideas or suggestions on this?

paulftw avatar Nov 10 '14 04:11 paulftw

In my view, it would make sense if it's automatic and possibly a pre-commit hook. I've been thinking about using Astyle or better ClangFormat, as it is based on a real compiler, but then gave up the idea for my projects.

There are many things to a style guide, and the discussions about those are always hot. I'd rather recommend writing down "C++ usage best practices in hiberlite", as these are more dangerous than whitespaces, and can be best checked using code reviews. Google C++ Style Guide is an example of such an approach, and is a living document too. There are, of course, automatic checkers of C++ usage too: Clang Static Analyzer, cppcheck, cpplint.py, etc

d-led avatar Nov 12 '14 14:11 d-led

I know style guides are a subject of numerous flame wars. Choosing the best one is not my goal. Two reasons for wanting an automated formatting tool are:

  1. get rid of the tabs
  2. have consistency and guideline for future contributions

There's little to no value in trying to decide on what is the best style guide is, or inventing a bespoke style guide for hiberlite. It has to be good enough and simple to police, thus my interest in an off the shelf formatting tool. Something that'd be quick and easy to install. I'd go with either Astyle or ClangFormat.

An argument against Google guide is that they are building end products, whereas hiberlite is more like a "standard" library (not really standard but really wants to become one when it grows up). So I'd like user facing API to follow same style as STL and Boost.

paulftw avatar Nov 13 '14 05:11 paulftw