melreams.com

Nerrrrd

Impressively evil

I’ve seen bad things done in java. The kind of things you can’t unsee. But I’ve never seen anything quite like this java program that makes 2 + 2 = 5:

import java.lang.reflect.Field;

public class Main {
    public static void main(String[] args) throws Exception {
        Class cache = Integer.class.getDeclaredClasses()[0];
        Field c = cache.getDeclaredField("cache");
        c.setAccessible(true);
        Integer[] array = (Integer[]) c.get(cache);
        array[132] = array[133];

        System.out.printf("%d",2 + 2);
    }
}

Thanks, codegolf user MichaelT, I didn’t need to sleep again anyway.

It’s normal to feel stupid

This interview with Saron Yitbarek is really interesting and you should read it. Saron currently leads the Tech Jobs Academy program at Microsoft and she founded CodeNewbie.org.

My favourite part of her interview is:

What advice would you give to a younger version of yourself starting out in development?
You’re going to feel stupid most of the time, and that’s ok. Also, don’t go at it alone. Things are much easier when you do it with a community of people who are just as passionate about coding as you are.

The terrible irony of programming is that programmers love feeling smart and somehow we choose a profession that makes us feel stupid most of the time. Seriously, I’ve been at this for nine years and I feel stupid very very often. Just the other day I spent a couple hours fighting with a CSS issue that turned out to be a min-height on the containing element issue, it wasn’t even near the sidebar that I was trying to change. Feeling stupid is completely normal and probably an inevitable part of learning any complicated skill, not just learning to code.

It does get better, though. With experience you learn that even though you feel stupid for a while (maybe a long while) eventually you figure it out. To quote Cecily Carver’s Medium post Things I Wish Someone Had Told Me When I Was Learning How to Code:

I’ve found that a big difference between new coders and experienced coders is faith: faith that things are going wrong for a logical and discoverable reason, faith that problems are fixable, faith that there is a way to accomplish the goal. The path from “not working” to “working” might not be obvious, but with patience you can usually find it.

It’s kind of like levelling up in an rpg – you just have to grind through the boring low level part until you gain enough XP to get to the next part of the story. Just like being at a low level in a game feeling stupid doesn’t mean you’re bad at the game, it only means you haven’t been playing for very long. If you just keep trying for long enough you eventually learn that even though you feel stupid now that doesn’t mean you’ll never figure it out.

As a little bit of an aside, there’s a theory going around that if you were praised for being smart as a child rather than for trying hard (which I hear is pretty common for girls) then running into a task you aren’t instantly great at is a terrifying blow to your identity as “the smart kid.” It’s totally possible, even likely, that there are all kinds of issues with that study and the conclusions drawn from it, but that theory rings absolutely true for me. Every time I run into a problem I can’t solve right away, I get scared that this is the problem that proves I was never really all that bright. It sucks but it’s totally normal. I’m still struggling with that myself, the only answer I have is to keep trying anyway.

Feeling stupid absolutely does not mean you’re just not cut out for coding. It’s a totally normal stage that everyone goes through. Everyone feels stupid most of the time when they start coding and anyone who says they never feel stupid is a liar (pants on fire!) and not even a good one. Even when you’re experienced you will still feel stupid pretty often.

If you see people around you who don’t seem to be as bothered by feeling stupid, either they’re good at hiding it or they’re just more used to it than you are because they’ve been doing it longer than you have. Once you spend enough time feeling stupid you stop getting very worked up about it. That’s not to say it doesn’t still suck (see my CSS story above), but once you go through the cycle of getting stuck, feeling stupid, and figuring it out enough times it doesn’t seem like such a big deal anymore.

Feeling stupid doesn’t mean you are stupid, it just means you’re like every other person who has ever tried to learn to code.