Attack the Block

How many readers of this blog know that Objective-C blocks are initially created on the stack, unlike every other type of Objective-C object? I believe this is for performance reasons.

It used to be a bigger deal, before ARC. Why? Because those stack-based blocks would be deallocated once their scope ended. If you tried to reference a stack-based block outside its enclosing scope, your app would crash and burn.

To get around this, you had to send a copy message to the block, which would perform a special sort of copy to copy it to the heap instead, like every other Objective-C object. Then it could be passed around, because it wasn’t tied to the stack’s scope anymore. Of course, then you’d also be on the hook for sending it a release message, or you’d have a memory leak.

That’s why, if you have a block property, you’re supposed to use the copy attribute, not the retain (now strong) attribute:

typedef void (^MyBlock)();

@interface MyClass : NSObject

@property (nonatomic, copy) MyBlock myBlock;

@end

All that’s water under the bridge with ARC, however.

ARC adds those copy calls for you, in the same way that it adds retain and release calls for regular Objective-C objects. You’ll never have to worry about using a stack-based block outside of its scope accidentally, because ARC will never let you do that.

The result? Now, when I mention the dangers of stack-based blocks to my younger coworkers, they have no idea what I’m talking about.

Interview Ballyhoo

I did quite a bit of interviewing recently before I got my new job.

I’ve come to believe your success depends much more on the attitude of the interviewer than how much you prepare. Anyone can find a gotcha question you can’t answer. Anyone can twist your lack of instant recall of a topic into an irrecoverable failure. You simply can’t know everything off the top of your head.

And on the flip side, anyone could talk you through your nervousness or your sudden blanking on things-you-knew-an-hour-ago, if they really wanted to. Anyone could connect with you and get you to open up about what you understand.

Could, but often won’t.

So while you should definitely do the preparations that they advise you to do — many companies give you fairly detailed lists of things to study — you shouldn’t kick yourself when you get rejection emails.

And you will get them, and they’ll almost never give you very helpful feedback. That just seems to be the way it is, however frustrating.

Like a Beacon in the Dark

This might be old news to my readers, but…I recently had to test beacon support for an iOS application.

I learned that you can do so without actually buying separate beacon hardware, by taking an iPhone and making it broadcast like a beacon.

I did this by installing a freeware application called GemTot SDK. It’s from a company called PassKit which sells GemTot Beacons.

You can also follow their blog post’s instructions for building their Xcode project yourself and running it on your phone.

But I figured, absent taking the time to inspect the code thoroughly myself, it was safer to use the version that had already been through App Store review.

Here are the steps:

  1. Search for “GemTot SDK” on the iOS App Store, download it, install, run. (There are separate iPad and iPhone versions.)
  2. In the iPhone version, tap the “Beacon” tab all the way to the right.
  3. Set the “Broadcast Signal” switch to On.

That’s it! You have a functioning beacon.

In the tests I did, I believe I needed to set either the Major Value or the Minor Value to something other than zero. So if things aren’t working, you could try that, though that doesn’t appear to be necessary in general.

If you need the UUID of the beacon, you can tap on the tiny beacon text near the bottom of the screen, and an alert will pop up to tell you it’s been copied to the clipboard.

If you want a quick and dirty way to tell that the beacon is broadcasting, take a look at https://github.com/mlwelles/BeaconScanner, which has a pre-built binary in addition to buildable source code (and a nicely informative README with a bunch of links).

(Build and) run that Mac app, and check the window to see if your beacon’s there.

If you want to test your iOS app, though, you’ll need a second phone (or other iOS device).

Hands-Off Managers

In my last post, I included links from Cate’s blog on how to be a good “hands-on” manager.

For example, a good “hands-on” manager:

  • Actively tracks direct reports’ progress.
  • Holds regular one-on-ones.
  • Advises on career path.
  • Intervenes to help with personal conflicts and organizational changes.

That’s really hard, and I don’t think I’ve ever seen the full package in my long employment experience. (Sometimes that that’s just because the team is too large.)

What I have seen frequently is the “hands-off” manager.

For example, a “hands-off” manager:

  • Talks to you only if there’s an issue or problem.
  • Provides little to no oversight.
  • Delivers bare minimum of a performance review.

The negative side of this kind of manager is that you get no support when things go wrong: you’re on your own to find solutions to your problems.

But that’s also the positive side. When you do something right, it’s not because of someone else’s input. It’s all you.

And “leave everybody alone unless something goes really wrong” is a lot easier than the first set of bullet points above, so you’re a lot more likely to find bearable “hands-off” managers than bearable “hands-on” managers: if there are fewer interactions overall, there’s less chance of bad interactions.

If you can’t have good managers, would you rather have a career full of so-so “hands-on” managers, or full of of so-so “hands-off” managers?

Advice for New Managers

Cate in the blog “Accidentally in Code” has a 5-part series on “Things to Figure Out as a New Manager”:

Part 1: Your Schedule

Part 2: Social Support

Part 3: Communication

Part 4: Feedback

Part 5: Trust

I could have used this earlier in my career.

I don’t see a lot of advice about managing in the tech industry in the weblogs I read. I’d like to see more. This is a good start.

A taste:

Because people are less likely to give their boss feedback, it becomes all the more important for you to give yourself that feedback to them. To own when you screwed up, and apologise. To acknowledge what you learned and what you would do differently. To recognize implicit feedback, and make it explicit between you.

Not That Kind of Troll

Looks like my first Entertainment post will be a review of a kids’ show.

Not just any kids’ show, however: as far as I know, it’s Guillermo del Toro’s only TV show, and it’s on Netflix: Trollhunters.

The good:

  • Amazing, movie-quality animation. It has a gorgeous, colorful 3D look, used to good effect on the non-human characters.
  • A fantasy world that seemed like a nice blend of del Toro’s usual penchant for the grotesque and the safer world of children’s cartoons.
  • Great comic timing. Lots of throwaway pratfalls and one-liners that made me think of Pratchett (high praise from me).
  • Some really fun writing and voice acting. Kelsey Grammer stole every scene he was in (and he was in a lot), as did Jimmie Wood as “Not-Enrique”.
  • Some nice character growth and a few notable turns. Not Shakespeare, but fun to watch.

The bad:

  • I disliked that “the girl” was just “the girl,” i.e. the romantic target of “the boy,” for maybe half or two-third of the episodes. We didn’t see much of anything from her side for far too long — though to their credit they eventually changed that.
  • One very very bad episode that was trying to skewer tropes about the tropical island Natives but really just ended up repeating them. Ugh.
  • Some sexist jokes involving a Barbie doll. Also ugh.

So yeah, there was some racism and sexism. I can understand if that’s a deal-breaker. I would hope they do better next season, if there is a next season.

They want to (the last episode ends on a cliffhanger), but here’s possibly the most interesting thing about the show: its lead voice actor was Anton Yelchin, who died in an accident in June of 2016. del Toro chose specifically to keep him in the show because he fulfilled his vision of the part so well.

But now they’ll need someone new.

Living in the Future

Now that I’ve announced the return of the old blog posts, let’s talk about the rest of the changes around here!

You may have noticed the new URL: apontious.com. With any luck, this will be the “last URL you ever need” to get to my writing. Old links with the subjectiveobserver.wordpress.com will still work as well — I plan on supporting them indefinitely — but please use the new URL whenever possible.

The blog’s name has also changed. I’m pleased to announce that this blog is the top hit on Google for “Weaponized Fluff,” which means my branding’s on point, right? Even if the name didn’t originally come from me. And if you come to the website, there’s a new black and white design that I’m pretty happy with.

Be warned: this will be more than just a technology blog. I may talk entertainment, I may talk politics (with comments off), I don’t know yet. If you just want the tech stuff, subscribe to https://apontious.com/category/programming-tech/feed/ or bookmark https://apontious.com/category/programming-tech/.

Living in the Past

Oh, we won’t give in,
We’ll keep living in the past.

— Jethro Tull

Lots of other stuff going on in the world, but for a moment, let’s go living in the past, shall we?

Let’s go back to a time when I wrote a website with a godawful color scheme and a prescient name. When Subversion was new, Unix was still old (but new to the Mac), and I used terrible puns for post titles — well, that hasn’t changed, has it?

When I closed down helpfultiger.com, I removed its posts from the Internet entirely. Now, with the relaunch of my blog on apontious.com, I’ve brought ’em all back, under the tag “From Old Helpful Tiger Blog”.

The technical how-to posts are mostly out of date, but there are lots of philosophical posts I still agree with. Have a look!

Edit: forgot to mention that the comments came over, too!

Boom Boom Enum

To quote a fairly awful movie: “We were so, so wrong.” — me

Remember I said you couldn’t use Swift value types for a linked list? The real reason is because you can’t have references to other value instances, just copies (thus making bi-directional linked lists a recursion nightmare), but the compiler error was “a value type can’t refer to itself”.

Turns out, one Swift value type can refer to itself: enumerations. By adding the indirect keyword, you can use Swift enums to, for example, represent a binary tree structure:

indirect enum Tree {
	 case node(Int, left: Tree?, right: Tree?)
}

And it works! But is it a good idea? Hell, no!

Why not? Because accessing the “properties” of your data structure is a pain in the ass:

switch node {
case let .node (data, left, right):
	// Do something with data, left, and right
}

As far as I know, you need an otherwise extraneous switch statement, a case statement, and an extra set of local variables just to access the values. (Whereas for a class all you need is dot syntax.) And you need to do that everywhere you want to access them, every method.

And the compiler will complain if you don’t use all of the enumeration values, so you have to remember to use _ for those:

switch node {
case let .node (_, left, _):
	// Do something with left
}

I tried writing a full tree traversal implementation in Swift with enum-based trees and it was an unholy mess that I would not repeat.

Learn from me. Don’t use cool language features at the expense of maintainability.

Interview Hullabaloo

I have one major piece of advice, if you’re interviewing for a developer job, or really if you’re interviewing for any job.

If you get the sense that the interviewer is dissatisfied with how you did, don’t hesitate to ask what they’re dissatisfied about.

For example: “It feels like I didn’t completely answer your question. Is there anything I could expand on for you?”

Or: “Did my solution to the exercise cover everything you wanted me to cover?”

If they just say yes, but they still seem dissatisfied, well, then there’s nothing you can do.

But I’ve often found that this will bring forward whatever reservations they have, and give you a second crack at them.