Re: 100% Java OS
Posted: Sat Mar 08, 2014 5:22 pm
Generally - yes, I agree. However, some methods like setters or getters are so obvious that it is just a waste of screen space to comment them. But it doesn't mean I refuse to comment. I will, but not as fast as may be you can expect.GhostlyDeath wrote:It is very important to comment your code as you write it, at least a description of what each method does, what the purpose of a class is, why a field exists.
I know this.GhostlyDeath wrote:Then once your code does compile or is mature enough you can just run javadoc on it.
As it was said - not all files are commented. But I can understand your 'stylistic clash'GhostlyDeath wrote:After glancing over the source files you eventually see that there are virtually no comments, then once some commented things start to appear out of nowhere, there is a stylistic clash.
It's all about project organization by the IDE. The Eclipse has defined a notion of project. It is not a directory (even if the directory with such name really exists). The project consists not only of the directory, but of many files and directories. To have some manageable piece on the disk all project's files are placed in the project's directory. And within the project directory there is some predefined structure to help manage everything else. For Eclipse it is a standard solution to have the src directory within the project's directory. The src directory separates source code from everything else in the project (like compiled code and project settings). And within the src directory the packages are placed. If the packages would be placed somewhere outside the project and src directories then it becomes separated from the whole project and less manageable.GhostlyDeath wrote:Java has the notion of packages, similar to namespaces in C++. Rather than having a directory tree of:
You instead have:Code: Select all
foo/bar/assembler foo/bar/compiler foo/bar/bootloader
Modularization is fine but having 12 directories (which will soon turn into 20+ directories) may become less maintainable. Although you seem to be using Eclipse with tons of different projects separate than combined.Code: Select all
FooBarAssembler/src/foo/bar/assembler FooBarCompiler/src/foo/bar/compiler FooBarBootLoader/src/foo/bar/bootloader
Yes, it can. I hope there will be such files in the future, but currently the class sources commenting is a more actual task.GhostlyDeath wrote:And each package can have a file called package-info.java which describes the actual package.
Yes, it is the issue of a plain Java compiler usage without the help from IDE. But an IDE really can help. You can try one of them.GhostlyDeath wrote:Unified directories also helps on having a single class path rather than it being specified multiple times.
Yes, you are right. But when looking at the code the developer can see all information required without any extra movement. This is the reason for long method names. It requires to hover mouse pointer over the method name and wait until the JavaDocs will be displayed in a small hint overlay - it's a bit more irritating than having long names occupy some part of the screen. And, of course, there is no ideal solution, so it is absolutely possible to cut those long names. But I hope you agree that there are just a few such long names.GhostlyDeath wrote:But with extremely long names, it takes up more space on the screen, in memory, and on the disk.
It's already inline. The goal was 100% Java and having external files with assembly code will cut many Java developers from using the system. And experienced assembler users can easily understand the Java Assembler code because it is very close to the Assembler language.GhostlyDeath wrote:Personally, I would just replace the "ldc #?; ldc #?; invokestatic (Ljava/lang/String;Ljava/lang/String;)V foo/bar/Assembly.asm" with inline assembly
You have described the heavy commandliner coding approach. But Java programmers much more often are IDE users. And the IDE helps them with the lists of method names and argument descriptions. Then for IDE-developers it seems much more convenient to use a habitual style of coding when after pressing the point they have all the help required. And beside of the help there is Java type checking for the assembly instructions. It is impossible to compile a program with 8-bit register replaced with 32-bit, for example - Java compiler will notify you about compile time error.GhostlyDeath wrote:Said static method would be:
Code: Select all
package foo.bar; /** * This is a special class which contains a static method for encoding assembly * instructions for use in the recompiler pass. */ public final class Assembly { /** * Encodes an assembly instruction from the specified string. * * @param is The target instruction set to use for the statement. * @param whatever Whatever assembly statement you want to encode. * @see InstructionSet */ @AOTSpecialMethod public static void asm(String is, String whatever) { throw new Error("This is an AOT special method, it cannot be invoked."); } }