Saturday, May 25, 2013

Other: Code, Grammar, Gender Politics, and Gender-Neutral Singular Pronouns

Not only do I obsess about software engineering and gadgets, but I'm a grammar geek as well. Furthermore, I'm very big into gender equality.  Which is why I had a minor struggle at work recently when I had to figure out what to write for a gender-netural singular pronoun in a code comment.

It was something like:
    // Give the user the option to disengage so that he or she or it can rejoin later
    foo.allowDisengage();

Because I'm writing professional code that could possibly be read by thousands of people, it was different from, say, a blog post, where one can write whatever he wants.  ;)  Writing code also means there is a limit to how many characters I can put on a line, and in this case I had 100 characters, which includes tabbing.  So what does one do when faced with this dilemma?

A lot of people would just write "they", as in "so that they can rejoin later", but that's grammatically incorrect and also physically painful to me.  Just using "he" is arguably sexist, and so the same could be argued for "she".  Switching between the two to give equal time to both genders (as I have done in college essays) isn't an option in such short documentation.  Using "he or she" is awkward and feels like a waste of letters when facing 100-character limits.

I'm a big fan of Spivak pronouns, which are words that were made up for the sole purpose of giving English some gender-neutral singular pronouns.  Instead of "she", "her" and "hers", you might right "ey", "em", and "eirs".  But I'd get a considerable number of questions in my code review if I used "ey".

Grammar Girl--a blog that everyone needs to bookmark--suggests you rewrite your sentences to avoid the problem, which is what I did.  Something like "Give the user the option to disengage so that rejoining later is possible".  The Grammar Girl also says that "they" is the future of generic singular pronouns, but I hope not.  I am a huge fan of not changing the definition of the English words so that, thousands of years from now, English speakers will be able to read current texts with no trouble.  Adding new words (like Spivak pronouns) is fine.  And there's no way to tell if a pronoun is referring to a single entity or multiple when you use "they".

A friend also suggested using "s/he", which probably would've served my purposes just as well.

Update: Everyone should just use singular "they".

Saturday, May 18, 2013

Code: FileStructExaminer

I wrote a program, FileStructExaminer.

It's a hex file viewer, for programmers and other people who look at data files a lot. It's free, open source, and GPL-licensed. And it's the main reason I've taken a year and a half break from this blog. Changing jobs also had an impact. To explain it further I will post the FAQ.

In theory, I should begin updating this blog now, but between a more demanding job and my other hobbies, I'm not sure what I can promise in terms of updates.

Downloads:




FileStructExaminer FAQ:

1. What is this? Who? When? Where?
FileStructExaminer is like a hex editor, except that you can't edit. You can view files.  So it's like a hex viewer.  However, the main point is to see structures within the file. It was written by Omari Christian and finished in early 2013.  Right now it is hosted at dropbox. Go to Omari's Tech Blog (omaritech.blogspot.com) for the current location of the program and its code.

2. Why? How?
This was created for several reasons, mostly for fun and also to exercise my Java programming skills. I wasn't programming in Java much at work when I began the project.  It was also created because the hex editor I was using at the time didn't allow conditional statements (if, else, etc.).  I couldn't find a single free hex editor that supported conditional statements, so I wrote this one.

It was written in Java, using the Netbeans IDE.  Java was used for practice reasons and because it's easy to make a nice GUI.  Java is also pretty portable.

3. How do I use it?
Please see the User Guide.  For help with the struct file language, see Grammar.

4. Why is it so terrible?
Several reasons.  All my reasons for starting this project pretty much were killed off.  I started writing this in 2012, when I wasn't using Java much at work and had a bit of free time to work on it.  I also thought I might use it, since I was working with binary files that had a certain structure to them.  A few months later, I found myself with a new job, writing only Java code, and with very little free time at all.  I was fairly certain I wasn't going to ever use this software.  I pretty much abandoned the project.

However, I had put a lot of work into it, and it was almost at a state where it was usable, so I eventually just decided to scrap a lot of features that I was going to put into it and put only the most basic functionality into FileStructExaminer.  That way, at least it would be released and my effort wouldn't be in vain.  Maybe it would be popular and I'd finish it.

It's sorta rushed for that reason.  There are a lot of features I wanted to put into it, most notably arrays, but also more operators, struct dereferencing, a struct definitions section and more.  Alas, there was no time and I was running low on motivation.

Also, it's the biggest project I've ever worked on outside of work or school and I did it all myself.  I feel proud of what I accomplished, but I acknowledge that it could've been much better.

5. How does it work?
Upon startup it checks the settings.ini (if it exists) file for a structure file.  If it doesn't exist, it is done starting up until the user provides a structure file.  When the user provides a structure file, the file is first lexed into a text file that's easier to read (spacing added, comments removed).  The file is then parsed into a list of items (vars, conditionals, structs, ints, chars and other datatypes).  Any errors in the structure file are shown to the user in the main window.  If the structure file is error-free, the user gives the program a binary file.  The binary file is then parsed.  Every structure file item in the list is assigned a value based on the data in the binary file.  If a condition in a if-conditional is true, the items in that if-block are parsed.  If not, they are ignored.

Assuming there are no errors parsing the binary file, the structure and data of the binary file are displayed in the main window.

6. Future plans?
I had planned to release this as a first version and add features as people requested them; now I have no plans to do so.  I don't have the time or inclination to work on this project anymore.  That's why I'm releasing the code.  If people see potential in this, perhaps they can continue the project.

7. I found a bug.
Then download the code and fix it?