Sometimes I rant on Facebook

Like today:

I don’t think subjects and verbs should agree all of the time. I mean, what if they’ve grown apart? What maybe verb doesn’t always want to go along with what subject says because it’s always about subject, subject is all, like, totally “It’s all about me”, which is interesting because “me” is an object. It can’t even talk about itself because “itself” is reflective (unlike the ever selfish subject).
Since verb does all of the action, maybe verb should come first and subject can just bloody well agree with it. Maybe you need to think about your desperate need to have everything ok in front of the neighbours. Yeah. Didn’t think about that, did you?

I may be dealing with HTML/CSS, JavaScript (React to Node), and (no)SQL languages, but I first majored in German, and I have never lost my interest in spoken languages. It’s also why I kind of roll my eyes a bit when people (including me) call them programming languages. Spoken languages are much more forgiving. Hell, I know a lot of JS programmers who write or say “… between him and I”. I IS NOMINATIVE! Use “me”, and object, because the preposition takes objects. Quit thinking that “me” is impolite. If this were code, you’d get an error. Shut down. Borked. I’ve seen code documentation written by someone who fears the semi-colon. Oh, the irony. Spoken language is forgiving. Or should be. Let’s not talk about Americans telling people to speak English while butchering the grammar or spelling.

I think programming is less a language than it is a grammar. Imagine writing consoule.log in one region and console.log in another. I know if someone is midwestern, a Texan, or from the Pacific northwest by how they refer to carbonated sugar beverages.

I like to think that somewhere someone would write “council.log” and in a pull request on GitHub, another would write only *console like people do when they see a their/they’re/there error.

I get it. People like to label things. What do we call Java, Ruby, C++, JavaScript, Go, etc? Languages was easy and makes sense, but was clearly chosen by someone who didn’t major in languages. They’re grammars. I guess that would have felt old and stilted. Maybe we should just give them another name: Stanleys.

Make it so.

 

What did I just say?

When I was at The Iron Yard in Austin, I struggled with using the language of coding language. It felt hokey. I was embarrassed to say things like “passed in” or “instance”. I felt like a poseuse. I also was nervous about being called out for it. Hear me out.

Language is often used as a way to exclude others. It is the secret handshake. Doubt me? Misuse a word that belongs to a certain group. I dare you to say “between him and I” (yes, Grammarly, I know. I’m making a point; don’t make me sic you). to a group of English teachers. Mispronounce “meme” to a teen. Tell a scientist that you have the “stomach flu”. How else can people better identify who is in and who is out? As a dual US-Australian citizen, I deal with this all the time when I choose to keep my Aus/UK spelling when I do my own writing. It’s my way of keeping my Australian identity while in Texas.

To protect my ego, I resisted. I can’t misuse the terms if I just don’t use them or if I use my own slangy terms. The problem is that the language is part of that culture. My instructors pointed out that if I want to be a developer, I have to use the right words. It stung. It felt like a criticism. Ok. It was. We need to not be so sensitive about criticism and using “critique” to soften it. I was not doing the right thing by me if I wanted to become a developer. If my instructors had let that slide, they’d have failed me. I got that. I was a teacher once and loathe letting things slide because it might hurt feelings. If seasoned developers laugh at me for using the word in the wrong situation, then they are the jerks. I had to let that go.

Still, new vocabulary doesn’t happen overnight. I had to hear the words, read the words, use and misuse the words until I didn’t realise I was no longer thinking about them. After I left the boot camp, newly minted and freshly scrubbed, I read coding blogs, logged hours in video tutorials, and talked to others about code. Somewhere along the way, these terms became a part of my own language. I noticed it when I was explaining functions to a middle school student. For some reason, after saying “passed in”, I paused. I don’t think the child noticed, but I had to take a breath.What did I just say? When did that happen? When did it become natural and not something I actively thought about? One day I hope to be the mentor to someone switching careers to become a software engineer. I want to be the safe person to practice speaking the language of code. Excluding is easy and all over the place. Let me not be that person.

Language: exclusion and inclusion

I wanted to title this “Jargon: how not to be a douche”, but I am too mature for that. Not much, as I then made a point to start off the post with it. I have my limits. You have yours.

As I read The Art of Readable Code (ARC), I constantly find connections to other parts of my life: my university life as a German major, my previous career as a teacher, and tweets from friends afar. This one particular tweet really resonated with me:

I read that tweet shortly after this passage from ARC: “… project-specific abbreviations are usually a bad idea. They appear cryptic and intimidating to those new to the project.” I am also on a slack channel where those with jobs like to post about all of the “ugly code” they see at work, which often gives those of us still looking for a job the feeling of being left out. “Oh, look at this. Bah ha ha …” without discussing what makes it ugly. For those of us still looking for our first job as jr devs, this smacks of “We are in the know. You are not.” I’m also severely tested as one who majored in language and edited, to not correct their ugly sentences. Must. Not. Take. Bait!

But wouldn’t I be doing the same thing? Ha ha ha, I can use a semi-colon outside of coding correctly. Aren’t I superior? I would be the douche. I’m ok with feeling that way. We can’t control that or change ourselves immediately, but I believe we should own up. It is also a natural reaction to competition. One wants to jab back.

I’m not on a dev team. I’m not employed; however, as I learn to code, I create apps and snippets for myself. While the practice is good for keeping up the skills, it’s not so good for variable names. I am writing for myself. I need to start writing for others, even if I am not. I am developing habits. I chew with my mouth closed when I am alone, so I am not worried about doing it when I am not.

If I hope to be one who collaborates and not competes with coworkers, then I need to practice avoiding exclusionary tactics. Cryptic naming is like jargon; it creates an us-vs-them feel. So. Here I go. Better naming conventions. Check! On it like mouse on enter.

The $2 word and $2 code

Work with me here. This is not about being cheap.

Before I enrolled in The Iron Yard’s front-end engineering boot camp, I was a freelance editor and proofreader. One pet peeve was the belief that the $20 word was better than the $2 word. Sure. By all means, increase your vocabulary, but when someone uses “endeavor” instead of “try”, my wanker-meter goes off. Loudly. Even better are those who write “endeavor to try”. Schaaahp. Leave “endeavor” for when your audience is fohncee and wearing wings made from peacock tail feathers. If you have a regular audience, “try” is good. There’s a time for Boccaccio and a time for concise instructions.

In order to write better code — to go from advanced beginner to intermediate — I’ve started reading The Art of Readable Code (copyright 2012 Dustin Boswell and Trevor Foucher, 978-0-596-80229-5, O’Reilly Books). It’s an easy read (buy it!). They don’t bog us down with those $20 words to show off all that they know. Their goal is to teach, not entertain or transport us to Edwardian England. I could read this in a day, but I won’t. I’d get nothing from it. I’ll take a small bite, savor the flavors, compliment the chef, and say “Good gad, Godfrey! This is delicious!” Or maybe I’ll just write about what I learned. I don’t know. I like saying “Good gad, Godfrey!”

The $2 code is easier to read. Good. Now what? Do it. Bugger! Everything is rough at the start of learning. The master potter once made hideous lumpy ashtrays. I acknowledge that, but that doesn’t mean that I’m okay staying there and populating my house and code with some fugly ashtrays.

My first aha: Better names for loop iterators.

I had been using i, j, and k to name my indices. On the surface, those names look good enough. They work. We know what we mean. Index i. If there are nested loops, then move to j and k. It makes perfect sense. It does until we stumble and need to debug. Nesting does my head in. Nested if-else and loops are the wire hangers of code for me. Or the toddlers jacked up on Skittles and Kool-Aid. How would I know what is wrong in my code if I have

if(course[i].class[k] == student[j]){//do amazing things}

It might look like it makes sense to me. I might spend time figuring out the code inside the block and not realize that it’s my indices that are wrong.

What if I had named my indices course_i, class_i, and student_i? Or, to make it shorter: crs_i, cls_i, stu_i? How would this help? You tell me:

if(course[course_i].class[student_i] == student[class_i]){//do amazing things}

or

if(course[crs_i].class[cls_i] == student[stu_i]){//do amazing things}

The first line tells me that my problem is in my if-condition. My indices do not match up. The second line has indices that match up, so right away, I would think that my problem is in my code block.

I will never again. Even for just i in a small practice code on Codepen. If I reuse it, I don’t want to have to change my name for the index.  The benefit of clarity outweighs any increase in code size. It’s like the Oxford Comma. If I use it all of the time, I don’t have to switch when I need it to be clear:

I will give Dustin Boswell, Trevor Foucher, and Cletus O’Reilly $1000.

Clearly, I’m going to divide 1000 by three and send them on their merry way, each with $333.33 (I’ll keep the penny).

I will give Dustin Boswell, Trevor Foucher and Cletus O’Reilly $1000.

Do I give Dustin $500 and make Trevor and Cletus split the other half ($250 each)? Or do they each get a third? They don’t know. I have not made that clear.

If I do it all of the time, I don’t have to pause and think about future issues. Bud nipped. The Art of Readable Code has been a valuable read so far. Not a lot of steamy sex, but I hear that’ll change in the next printing.