Jump to content

Programming language guidelines

From Bath Wiki
Revision as of 07:11, 26 August 2026 by Pm2022 (talk | contribs) (improve clarity, link to language guidance)

Students should use whatever language they feel most comfortable with, as this helps maintain security and code quality standards.

A consistent style throughout the projects is desireable. So for each language we have used in the past we have written up some code quality and style guidelines.

If you are going to write in a new language, please follow the general code quality guidelines below.

Recommendations

Language-specific guidance

You can find quality and style guides for specific programming languages in Category:Programming language guidelines.

Static Sites

For static sites it is best to use a static site generator like hugo and write the pages in Markdown.

This keeps the page simple and makes it much easier to edit for non-technical people, while also meaning we don’t use Wordpress (it’s insecure).

Some static site generators:

Other Projects

Always use a language that suits the purpose of your project. For websites, here are some recommendations for languages with good web development support:

Languages and combos that are not good for this purpose, due to the lack of type safety or security:

  • TypeScript (unless it's just for the frontend or utilising a package which performs runtime type validation)
  • Python
  • Perl
  • JavaScript (use TypeScript instead for our sanity) - except small scripts for pages.
  • Ruby (does not implement some parts of http request spec correctly)
  • PHP (due to being run as root in most circumstances, this has significant security vulnerabilities). If you don’t know what this means, look up web shells, almost all of them are PHP so it’s better just not to even have the possibility of being compatible with them.
  • Any esoteric languages (I feel like they all probably don’t even support this)
  • Java (it sucks, use Kotlin instead at least)
  • C/C++ (they are not great for webservers): use Zig or Rust instead please

Please also choose a language which another student may be able to read in 5 years time.

General Guidelines

As we don’t have requirements on what language you should be using, we have some general code quality guidelines.

However for the languages we have projects in we have written more specific code guidelines (see Category:Programming language guidelines).

  • All functions should be documented (even if it’s just one sentence explaining what it does) using the official documentation standard for a given language e.g. Docstrings for Python, JSDoc for JavaScript + TypeScript etc.

    For more complex functions, more descriptive documentation should be included

  • Prioritise readability over thousands of comments

  • Follow language styles and use a linter. For example, in Python follow PEP8 standards with snake_case variable names, in JavaScript and TypeScript follow ESLint/Biome with camelCase.

  • Please make use of modules + splitting code up into multiple files (sensibly)

  • NO TRAILING WHITESPACE! Install an extension to auto remove it please!

  • Use spaces over tabs (this ensures alignment is correct between machines)

  • Trailing commas when array or parameters on new lines for all languages which support it (if the language doesn’t support it please question your choice of language). E.g.

    def my_func(
      param1: int,
      param2: list[str],
    ) -> list[int]:
      return [
        1,
        2,
        3,
        4,
      ]
    
  • Trailing commas when the bracket on a new line

So basically in summary write documentation and follow the language's style!