Code quality
Is there any enforcement of a style guide for this project?
- Parts of code are all over the place.
- There are tons of random extern and static members and functions that belong to no class.
- You redefine
BOOLfor apparently no reason (?), as well asTRUEandFALSE(?). - C code is littered among supposedly C++ files, and from what I've seen the C standard library is used more often than the C++ counterpart.
- Tons of C strings all over the place as opposed to std::string
- Where C strings aren't used, wxStrings are, which will make it very, very difficult should you ever decide to move away from Wx.
- Basically no use of C++11
- Main directory is cluttered with MSVC solution files and build scripts (also, do you really still need to support VS 2010?).
- You have no
CONTRIBUTING.md(!!). - Incorrect alignment all over the place
We have a few guidelines... But the code has been programmed over many years, by various people with different styles, and although we form a team, we don't have such strict rules or enforcement. If the code looks good, it's good enough for us.
We use "C/C++", not specifically C++. PCSX2 was originally C, and we converted some parts of the code to C++, but only when it was an advantage, and not a waste of time. We don't use C++11 because most of the codebase was written long before C++11 was finalized, and we aren't going to waste time rewriting existing code just because C++11 has some fancy feature.
No comment on the BOOL part.
What do you mean with incorrect alignment? Oh you mean code formatting. The github viewer is using 8-character tabs, while we assume 4, so chances are it's not that badly aligned as you think.
The thing is, is that "good enough for us" makes it very difficult for new contributors to get into this project, and is probably a major reason why PCSX2 is suffering from a lack of contributors. When people can't make heads or tails of the arrangement and flow of the program, you begin to see loss of interest.
There's nothing we can do at this point, because as we keep saying over and over, we don't have the time for big projects anymore. Also, that hasn't stopped people in the past. It didn't stop a group of people from forking pcsx2 to work on new experimental features, which later got merged into the main pcsx2, and those people became part of the team.
We have multiple ways people can contact us: The issue tracker, forums, IRC channels, even email. We are not a big project, people-wise. We don't have a strict review policy, or a method to follow in turn to contribute because we don't believe one is necessary. People are free to jump in and make a PR with their changes. If they are scared someone may already be working on it, they can ask. If they want to tell others they will be working on it, they can make a PR in advance, with an explanation about what they are working on. So anyone is welcome to help. Fork the repo, make a branch, start coding, send a PR.
Something as simple as mixing tabs and spaces for indenting can be fixed with a simple bash command in bulk. So not all issues in that list are complicated to work out IMO
Code clean ups don't take very long. In fact, if you came up with some rules for this project you'll find contributors jumping in just to apply those rules and make the code easier to read. I'd change it now but I'm not sure what you guys even want. You say you guys use 4 character tabs -- like most projects. That's not something github has a problem with. In fact, if you display it with 16 character tabs, it should still look exactly the same. The problem would be from inter-combining spaces and tabs for indentation or not using spaces to align. You see, I'm not even sure if you guys do use 4 character or 2 character or 8 character or spaces or tabs -- they are all used in this project.
As for C++11, it comes with your compiler. It's there and it's beneficial. It makes your code many many times more readable, especially in the case where it was an unreadable mess beforehand. I can pick just about any file in the repo and it would look more readable with C++11. Some things that are done in 100 lines of C could be done in a few lines of C++11. You reimplement a lot of things that are now standard. Not just once, but once per file. Many times they are implemented in ways that are buggy, not consistent and require deep thought to understand the meaning behind them. For instance when reading a line that has '... = ((ff0 >> (3*0+12)) & 7) - 1;' and wondering what the logic is behind it.
Some questions that need answering (and enforcement as a style guide, not just whimpy guidelines):
- Tabs or spaces? Tab width?
- Curly brackets on the same line or on a new line?
- Spaces between (e.g.) if and the condition or not?
- Commenting style and frequency (doxygen?)
- Magic numbers? (Constants that are not thoroughly explained)
- Classless fields and functions (with reasonable exceptions)?
NULLvsstd::nullptr?- C vs C++ style type casts?
- Bare vs smart pointers (with reasonable exceptions)?
- One class per file (with reasonable exceptions, e.g. Lots of tiny classes)?
- C vs std strings?
- Variable prefixes?
- Variable/function/class case styling?
- etc.
A standard, at least, must be created, at least as something to strive to. It's very difficult to maintain a project when you can't read the code.
Yeah um, whitespace needs to be standardised. Not even all regularly contributors agree on this. We tried to agree on curly brackets on new lines, it's not enforced everywhere though. Keywords that aren't separated by whitespace look strange. Comments are good. Automated documentation generation creates a lot of busywork imo but I'm not speaking for the team on this one. Unexplained magic numbers are bad, duh. Everything does not need to be a class. Some things should be that currently aren't though. std::nullptr is C++11, definitely not. All types of casts have their place. I guess you're thinking the new C++11 smart pointers? Just no. One class per file is awful Java nonsense. C strings have their place. Okay, naming is something we actually should have standards for.
What's wrong with C++11? Are some of your contributors stuck with MSVC 2008?
Many C++11 features are pretty disgusting.
Well, just because many of the features are 'disgusting' as you put it, does not mean that there aren't many others which are very useful and even necessary at this point in time. The fact that a feature comes with the C++11 standard should not be enough for you to immediately discount its value.
Many != all
I certainly think we don't want to mandate using C++11 features without discussion.
There are certain C++11 features I'd favor, like using range-based loops where enumerating STL containers, or using "auto" (compile-time type inference) on long (templated) variable types.
But I don't believe REQUIRING any of those features is good, specially when a lot of people dislike the new skin in vs2012/2013, and would like to keep using vs2010. (I know other people prefer vs2010 because they want to keep coding in XP, but I have no pity for them)
msvc2010 has plenty of C++11 support (not all, but enough). You could go with what is supported in that release. Of course no one is going to use C++11 features for the sake of it. I don't think any project does that and it doesn't really make sense to assume that's what supporting C++11 means. Only if they actually help readability or remove a situation where pcsx2 reinvents the wheel.
I don't really understand the reason for needing to discuss its usage at all. It comes with the compiler that everyone is using, it's built-in (no extra headers), it makes the code more readable, it's easier to code (less lines, more features). If there's some feature from C++11 that you are already using but your own frankenstein implementation, why not use the C++11 version? If there's some feature from C++11 that works around using hundreds of lines of unreadable code, adds no bloat to the project, no extra lines, makes it hugely readable, why not use the C++11 version?
I also wouldn't have any pity for developers refusing to update their compilers (to a drastically improved version) because, in the case of Visual Studio, it also comes with an IDE redesign.
Using features supplied by the C++11 standard is not 'forcing' anything on anyone. It's merely taking advantage of useful features that are available to you.
Developers have plenty of options when they're using an outdated and obsolete Visual Studio. They can update their IDE. They can install mingw. They can dual-boot or use a Linux VM.
In a world of quickly-evolving technology, developers have to evolve quickly as well.
Yes but using rude words: we don't have to fuck everyone over just because someone wants the code to be more "pretty".
Except you wouldn't be fucking anyone over, because everybody is capable of adapting to such a change.
Regardless, this isn't even about the code being more "pretty". You are suffering from a lack of contributors because people can't understand your code. Not only is it a mess, but there is no effort to try and fix it. Using C++11 features where they are called for is just one tool to try and tame the codebase of PCSX2.
C++11 features won't make the code more approachable, it'll make it incomprehensible to everyone but the few people who have actually studied the new standard.
The current code is incomprehensible to people who know C/++ inside and out. C++11 is fairly easy to understand, simply out of the fact that the syntax is cleaner, less code and simpler. It certainly would make it much more approachable.