Add info on other languages linters, formatters, testing suites etc
Closed this issue Β· 15 comments
The same way we do when explaining the data structures. Languages to support:
- R
- C++
- Fortran
A cry for help! Could you advise on linters, formatters and testing suits for:
- @SaranjeetKaur - R
- @alexdewar and @jamesturner246 - C++
- @cc-a - Fortran
I'll compile whatever you tell me and put it in the right place in the lessons.
For formatters, pretty much everybody uses clang-format
and most IDEs support it.
clang-tidy
is probably the most popular linter (the name always confuses me -- it sounds like it should be a formatter), but I've heard CppCheck is also a good one.
For testing, I've always used GoogleTest, but I think Boost Test and Catch 2 are also v popular.
With compiled languages like C++ and Fortran, it might be worth mentioning that your compiler can give lots of helpful linter-type warnings. For gcc and clang, it's a good idea to pass the -Wall -Wextra -Wpedantic
flags to get extra ones.
What he said π
Let's also add info about package managers, or similar, to include in the page where we talk about conda, poetry, etc.
I actually think I can answer most of the fortran stuff:
Fortran
- Package manager: Fortran Package Manager (FPM)
- Testing: Test-Drive. See the Fibonacci series example coded in Fortran.
- Linting: Via compilers, like gfortran or Intelβs ifort and ifx
- Formatting: findent and fprettify
- VSCode integration: VSCode Modern Fortran extension, which integrates with the above linters and formatters and the Fortran Language Server fortls.
For C++ you have vcpkg
and Conan. You can also use the system package manager, but it's not a particularly portable approach.
So, to summarize for C++:
C++
- Package manager: Conan and vcpkg
- Testing: GoogleTest, Boost Test and Catch 2. See our C++ testing course using Google Test.
- Linting: clang-tidy and CppCheck, although compilers can give lots of helpful linter-type warnings. For
gcc
andclang
, it's a good idea to pass the-Wall
,-Wextra
and-Wpedantic
flags to get extra ones. - Formatting: clang-format
- VSCode integration: C/C++ VSCode extension, including a full tutorial on how to set VSCode to work with C++., but for Windows it might be easier to just use Visual Studio.
LGTM. I've generally not bothered trying to make VS Code work for C++ on Windows though, because it's a bit of a pain and you can just use Visual Studio.
It seems like it's possible though: https://code.visualstudio.com/docs/cpp/config-msvc#_prerequisites
And for R, pending on @SaranjeetKaur 's seal of approval:
R
- Package manager: packrat and checkpoint
- Testing: testthat
- Linting: lintr, with RStudio integration.
- Formatting: styler, with RStudio integration.
- RStudio: The linter and formatter both can be integrated with RStudio via RStudio Addins.
LGTM. I've generally not bothered trying to make VS Code work for C++ on Windows though, because it's a bit of a pain and you can just use Visual Studio.
It seems like it's possible though: https://code.visualstudio.com/docs/cpp/config-msvc#_prerequisites
Added as a comment.
For fortran i'd probably mention pfUnit as a more fully featured test framework and there is fortran-linter which I've never tried. Whilst the compiler provided warnings are very useful I don't know of any IDE that actually supports running them to provide inline linting.
OK about pfUnit and fortran-linter.
About the last comment, in theory VSCode does it: https://fortran-lang.github.io/vscode-fortran-support/#linting
The fortran-linter does not integrate with VSCode, which is obviously not a problem, but for many people might be a limitation.
It's funny: fortran
linters and formatters are written in python
, while python
linters and formatters are written in rust
. Now, it should be that rust
linters and formatters were written in fortran
, to close the circle π
About the last comment, in theory VSCode does it: https://fortran-lang.github.io/vscode-fortran-support/#linting
Ah, good to know.
And for R, pending on @SaranjeetKaur 's seal of approval:
R
- Package manager: packrat and checkpoint
- Testing: testthat
- Linting: lintr, with RStudio integration.
- Formatting: styler, with RStudio integration.
- RStudio: The linter and formatter both can be integrated with RStudio via RStudio Addins.
These are all good!