Down to the wire

I embarked on my maiden programming voyage with Valaa Technologies. This is part three. 1 | 2 | 3 | 4

Jason Rakes
valaa.log
7 min readSep 21, 2018

--

Over the weekend I tried to think about Valaa as little as possible, but my brain wasn’t having it. My morale boost on Friday quickly faded, replaced with gnawing worry about the following week. I lounged in bed or, when I dragged myself out to collect the week’s potato and fish stick ration, mused about humans as complex bundles of functions, executing.

Soon, I’d be heading into the second half of my five-week stint at Valaa. Despite bussing home dazed and headachey each day, I didn’t have much to show for it: a BMI calculator that crunched one equation, and the worst task list ever. I was dragging my body across hot asphalt, screaming, while everyone else strode past on working legs.

Still! I was gouging out progress. I could recognize and sloppily use some of the building blocks of code: variables, functions, arrays, loops. I’d already spent hours thrashing around in simmering pots of confused despair, finally emerging poached and dripping, but victorious.

On Sunday, I turned my phone off and went to bed early. When I closed my eyes, I saw Zero glowing back at me. Instead of falling into a restful sleep, I laid awake for hours.

Over the next few days I was exhausted, and a ball of nerves. I managed to get some decent writing done, but by mid-week it was time to forge ahead in Valaa. When I sat down with Ville, I was a mess, making day one mistakes, unable to produce basic syntax.

“What are you doing?” he said.

I couldn’t answer.

Despite my shakiness, we went over the basics of geolocation and higher level functions, both of which would be critical to the completion of HelloHiker. I didn’t feel as overwhelmed as before. Over the weeks, I’d begun to distinguish between the feeling of deep versus shallow confusion: “I will never understand this without significantly more help,” and, “I can probably understand this, if I struggle with it for long enough.”

I’ve always been willing to struggle if necessary, so I got to work.

As a reminder, my final project, HelloHiker, would emulate a public journal in real life. Hikers along the Appalachian Trail would be able to drop messages that would be tied to their (private) coordinates at any given time, and anyone using the app nearby would be able to read them.

I returned to my desk and stared into the distance for a few moments, lagging out, then turned my notebook to a blank page and sketched out the app.

First, I’d need to figure out how to calculate the birds-eye distance between two coordinate sets. Luckily, I learned, people have done this before. It’s called the Haversine Formula:

I understand some of these words.

This would be the backbone mathematics of my app. I found a few posts on StackOverflow about applying the formula in JavaScript, and a couple of hours later I had translated it into Valaa and created a button that accurately calculated the distance between Helsinki and Stockholm. It was another fist-pump moment — I was happy, and a bit shocked, that I’d been able to get it working so soon.

Baby steps.

Then I used the geolocation code Ville had shown me and successfully displayed my own geolocation on the page (61.4972, 23.77860).

Over time I’d built up a pool of reference material from Ville’s lessons and my previous projects. These were an invaluable resource as I moved forward, combining concepts I’d already learned and layering on new skills. Learning programming reminded me a bit of learning a new language: I had to leverage what little I knew to compose a message in a way the other party understood.

I definitely looked dumb to native speakers, but if the message got across, I didn’t ask too many questions.

Over the next week or so, I continued to build up HelloHiker. It evolved from a plain HTML page with a list of information and failed tests into something that actually resembled a little application.

I’d added an input field and, using what I’d learned from SuperTask, created a ForEach loop that displayed each submitted message on the page. At the same time, the coordinates of the user who wrote the message were recorded and stored behind the scenes in Valaa.

I’d spent a truly horrific number of hours grinding out a fancy version of the chat app from day one, but it was something.

There was a problem: the most important part of the app was still a mystery to me.

The Haversine Formula, that fancy bit of math from before, wasn’t actually doing anything. No one would use my app so they could click a button to find out the distance between Helsinki and Stockholm. The formula needed to adapt to the situation — needed to run the current user’s coordinates and compare them with all coordinates stored in Valaa as notes. Then, if the output was less than five (meaning the message was dropped within 5km), the message would appear to the user. The rest would stay hidden until the user moved closer to them.

One morning, gazing down at me appraisingly, Ville asked, “Have you thought about how you will filter out the messages which are too far away?”

“Um, a bit,” I said. “An if statement embedded somewhere in the ForEach loop?”

“No.”

“Ah, right.”

“You will use what is called a filter function.”

“Ah…right.”

“Let’s make an example.”

It looked simple enough — a way of excluding certain values from the ForEach loop if they didn’t meet a certain criteria. To finish HelloHiker, I’d have to adapt the simple example we’d just created to the collection of coordinates and messages my users would be generating, then run them through the Haversine formula. Ville said he wanted me to figure out the rest on my own and returned to his desk.

To me, this meant: “Figure out the solution, or die.”

I spent the next couple of hours staring at code, comparing my example and HelloHiker. I googled around, even tried a halfhearted Feynman, but nothing was moving. I didn’t want to get frozen up like I had with the BMI calculator, so for a couple of days I danced around the issue and worked on secondary features. It was constantly in the back of my head, though, and by the time Friday came around, I couldn’t ignore the problem anymore.

It was the final week.

I spent the weekend very worried. I’ve never been good at leaving work at work, so when there’s a problem I’m struggling with, it can get under my skin.

“But you’re just there to learn, right? So there’s really no pressure,” Liisa told me, in response to my agonizing.

I shrugged. “I guess so.”

But I already understood that the pressure was self-created, knew that the expectations from Ville and the rest were almost entirely in my imagination. None of it felt like much comfort.

And anyway, putting pressure on myself was the point.

On Sunday I couldn’t sleep, again. I alternated between tossing and turning, and reading. At half past two I was staring hopelessly up at the ceiling when my heart skipped a beat.

The logic for the filter function had clicked into place.

I began muttering to myself and gesturing at the ceiling, talking through the specific steps I needed to take and testing the idea for weak points. Suddenly terrified I’d forget everything by morning, I pulled myself out of bed, grabbing a sheet of paper and a turquoise pen.

I sat down at the kitchen table, its chipped black surface washed in the dull glow of the stove light, and started scribbling.

Then, I slept.

Working from home on Monday, I tried to apply my solution. I didn’t get it working, but I hoped it was only a syntax issue — the logic still felt sound. I sent Ville an email explaining my thinking, coffee going cold in front of me, and prayed I wasn’t tragically wrong.

On Tuesday morning I opened HelloHiker on my phone and began dropping notes, starting at my doorstep. Outside, the wind carried with it the briskness of coming autumn, and I shivered in the t-shirt I’d rushed out in. At my bus stop I dropped another note and, after nodding to the driver and folding into a seat near the back, dropped them steadily along the route to work. Each note sprang to attention on my screen, a virtual breadcrumb trail from my apartment to Valaa’s office.

By the time I arrived, traipsing upstairs to the third floor, I had a dozen notes on my screen. I opened Zero and checked that they had all been stored, then opened Google Maps in a new tab. I copied each set of coordinates and pasted them into the search bar, adding a marker at each point. Ten minutes later, I was looking at my commute, represented by a dozen green flags. The only critical feature missing was the filter.

Not long after, I saw Ville approaching and wheeled to face him.

“I know why your filter function is not working.”

As I’d hoped, he pointed out a minor issue with my syntax. After a few more minutes of debugging, I opened HelloHiker and clicked the button “Find notes near me.” The notes I’d left on my doorstep and at my bus stop, those farthest away, disappeared.

HelloHiker worked.

--

--