C++ CheckStyle

C++ CheckStyle

Every programmer is developing in group of programmers. The smallest group is yourself and yourself a couple of weeks later. If you can't communicate easily to yourself how can you expect to communicate to others?

Any decent professional programmer understand that when developing in groups a good best practice is to use a common code layout style of the source code - mostly to make communication easier. It is much more easy to understand something when the form - the layout - is the same every time, instead of being different, confusing, misleading and right-out annoying due to different layout styles of source code files received from different programmers.

So many modern programming languages have a (static code analysis) tool for checking that a source code file is in compliance with a specific code layout style.

Note that I differentiate between a static code analysis tool for checking code layout style (form) and a tool for checking coding style (content) - the latter tool is in fact much more important because it can ensure that programmers adhere to a certain programming standard - typically to ensure that code is not degrading with respect to quality, performance, security and other important factors. But the topic of this post if the code layout style checking tools.

But what about C++?

I've been programming for many years in C++ and frankly speaking I've seen every conceivable type of style of code layout that you can imagine. What I've learn is that communication between programmers is more noise free if the source code files shared between programmers are kept in a fixed standard code layout style. New developers get much more quickly into the jargon and can focus on the real job - to fix a bug or implement a new feature, and the more experienced programmers can more easily spot novice mistakes etc.

But C++ do not have a standard tool for checking code layout style. There are many different compilers and many different editors - developed by different vendors, but none of them provides tools for checking C++ code layout style.

The hunt for a C++ Code Layout checking/beautifier/pretty-printer tool

But that doesn't mean that there aren't tool around. I've found the following list of tools, which I will update whenever I found new ones. They are listed with no priority or preference in mind.

Table updated June 5th, 2011

NameLatest versionProgrammed inType
Uncrustify  Open source
Astyle (Artistic Style)2.02 (2011-05-16)C++Open source
Universal Indent GUI   
Polystyle  Commercial
SQCBW   
GC! GreatCode   
Pork   
Vera++1.1.1C++ with Boost library. Rules are written in TclOpen source (Boost Software License)
Bcpp (C++ Beautifier) C++ 
Make pretty Perl and Bash and uses BcppOpen Source (GPL)
KWStyle  Commercial
JIndent (as of writing this tool is not yet released) (most likely Java)Commercial
cppcheck1.48 (2011-04-09)C++ with QtOpen source

But none of them really satisfy my needs for style and indent style and freedom to extension with more layout rules.

What the C++ community needs is an open-source CheckStyle like tool

The most difficult part is to implement a parser that sufficiently parses C++ source code well enough for checking code layout style. I would prefer a parser that covers C++ 100% (including preprocessor, templates, C++0X stuff, etc) as this will also be helpful as basis for more advanced static code analysis tools. The major hurdle is that there is not really a good up-to-date C++ grammar freely available.

Preferably the tool should both be able to check a source code file for compliance and - if desired - automatically change the source code file to be compliant. The tool should be available on the command line and is most likely a good candidate for a plug-in in many editors and build environments (running before or after a compiler).

Programmers can't handle the freedom

It seems to me that we programmers cannot handle the freedom of the free layout style of our favorite programming language. So programming language creators better learn from past mistakes; that the layout style of the language is also important - and they better stick to a fixed layout style. It will help everybody.

Relevant Links


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值