General
As this is for students, we want to allow students to use whatever language they feel most comfortable with, especially due to our security and code quality standards.
However having said that we want a consistent style throughout the projects (which is quite difficult with so many people working on that). So for each language we have used in the past we have written up some code quality guidelines.
If you are going to write in a new language, please follow the general code quality guidelines below.
Recommendations
And now as any pedantic programmer, I will give my recommendations for you to be using.
Static Sites
For static sites we ask that you don’t use a programming language and instead use a static site generator like hugo and write the pages in markdown.
This is just to help the simplicity of the page and make 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
We recommend using a language which suites the purposes of your project. As most projects will be websites, we recommend using a language with a good library for this. These include:
- Python (using flask)
- Rust (using rocket)
- Go (using gorilla/mux)
- TypeScript (there are too many frameworks to list)
- Perl (using Mojolicious) - not exactly recommended but mojolicious is just a great library.
What not to use:
- JavaScript (use TypeScript instead for our sanity) - this does not include 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++ (like why?) 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.
-
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 withcamelCase
. -
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!