I work on a small team (2 primaries with one or two other occasional contributors) on a project/product that spans a number of separate platforms. We do embedded firmware in straight C on Arm0 chips. We write python and a little bit of shell scripts for small Linux computers that are similar in size to Raspberry Pi's. We write iOS apps in Swift. We write Android apps in Kotlin. We shoot for a certain amount of parity between the Android and iOS apps.

Rare is the day where I work in one code base alone. I find myself torn between two extremes:

1) In each language/platform/environment, adhere to all of the coding conventions, best practices, and idioms of that particular community.

2) Roll your own conventions/idioms that tend to be a converged "melting pot" of them.

An even minor example of something like this is parentheses on conditional expressions. C and Kotlin require them. Swift does not. But of late, I find myself putting them in the Swift code, because it's just easier to be consistent.

At the same time, I'm not adding semi colons in all of Python/Kotlin/Swift just because C requires them.

These decisions on where to hybridize, where not to, feel arbitrary to me. A matter of personal style basically. I'm curious if others have been able to build a more principled approach to doing this. Or do others go down this path, and then reject the whole effort and go completely idiomatic in each area (this doesn't seem realistic to me, because there are "patterns" in each system that are more idiomatic in one than the other).


1 Answer 1


I think it would be good to know the level of talent that you are dealing with. If there is one guy who does most of the work in one area, you may want to have him establish the conventions for that area. However, if you know you are going to hire others in that area, you may want to personally impose a popular coding style to give yourself a small leg-up.

Also, how flexible is the staff from a personality standpoint? How important is it that their habits not be disrupted? These are important considerations. As Steve McConnell talks about in Code Complete, a different enough coding style can impact a coder's ability to understand the code.

Have these conventions been a problem for any of the developers? I work in a company where I must write code in several different projects with very different languages. In particular, we have C/C++, C#, Java, Qt/Qml, JavaScript + Web(CSS, XHTML, etc). I'm the Architect, I'm responsible for setting appropriate style conventions for these projects/teams.

My recommendation is that for each language that you use, pick a style that is based on a popular published style guide for that language. An incredible amount of thought goes into these style guides, I cannot recommend them enough. Reading them can be a joy by itself, you learn so much.

For languages that are similar enough to allow for similar styles, I recommend you adopt a similar style that is mostly shared between these languages. For example, we use Microsoft's Dot Net style guide for both C/C++ (we of course customized it, but it feels right) and C#. However, some languages enforce incompatible capitalization rules.

For example, we would not be able to require Haskell method names to be capitalized the same way we do in C/C++ or C#. The language won't allow it. In such a case, pick from a published style guide for your Haskell code, and enforce it through coaching and reviews. This will save you from having to do some serious legwork.

If you are working with a framework, the framework may constrain or supply conventions of its own that make the framework easier to work with. Not only that, but the conventions may actually be necessary to work with the framework. In these cases, of course, bow down to the framework and make an exception. Be deliberate, and modify your style guide so that there is a precedent.

I hope this was helpful. Let me know if there is anything I left out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.