Doing new things is hard, choose your hard

In my last post I touched on the topic of quitting, and how easy it is to take the easy path instead of the hard one and quit. Most of us quit all the time, big and small things alike. When things get a little tough, it’s really easy to drop back to a place where you feel comfortable. And while we often quit, we rarely understand the consequences of that act before it’s too late.

When was the last time that you were assigned with something you’ve never done before and it seemed easy and straightforward? If I had to guess, the answer is never. New things are hard to us for a reason, we didn’t create any patterns around the process yet. Even if it’s something that you’ve enjoyed doing in the past, it takes you time to get accustomed to it in a different environment.

Maybe this is a filter of some kind, because people who persist in their efforts are the ones you hear or read about. We all have our struggles in life, the only thing that differs is will you give up or continue fighting, will you take the easy road, or the hard road. Just bear in mind that the easy road can and probably will be harder for you in the long run.

People have different learning patterns, and different backgrounds. While new associations in our mind are easy to create, it sometimes takes time to link everything together, or to figure it out. That process is hard. If you ever tried to learn a foreign language you’ve encountered it, along another issue, you need to use the language to learn it.

The best way that I’ve experienced is using what you’ve learned from day one, it will be hard for a while, but much easier in the long run. Yes, you will go full Tarzan mode with constructs that translate to “I want go food” or something similarly funny.
The trick is not to be afraid or ashamed while you are learning something new, otherwise it wouldn’t be hard for you to do it. If you are surrounded with the right kind of people, they will encourage you and help you, even dedicate significant amounts of time into helping you, because that is something they also care about.

Same thing goes with learning new computer languages, or programming paradigms. Yes it’s hard to learn Object-Oriented programming, it is also hard to learn Functional programming. While I’m on the subject, it’s pretty hard to learn testing, and that is just the high level stuff. Everyone one of us has been an apprentice at one point or another.

Sometimes I am still an apprentice in some new technology that I’m interested in. You will always have new stuff to learn, it will (probably) be hard, maybe you even won’t succeed, but are you willing to immediately give up the benefits you could reap for your whole lifetime just because you need to suffer for a day, or a week? I’m not, when something gets too easy for me, I just have to find something new that will push me even harder in the direction I’m moving to. It’s pretty easy to figure out that most of the things that you appreciate in your life are hard. Raising children is hard, running a business is hard, competing in sports is hard, sometimes even breathing seems hard. Do you really want to spend your whole life as a couch potato, watching TV and not achieving what you might if you just put in some effort?

I’ll end this with a nice quote from a three-time Tour de France winner Greg LeMond: “It never gets easier, you just go faster.”

It’s really easy to quit

I remember when I was in my late teens, although I rode on the bicycle around a lot, I never did anything longer than a few kilometres in one go. I had an old steel mountain bicycle, heavy as hell, but it was enough for me.

Once I decided to visit a friend who lived about 25km away, and decided to bike there. It was one of the worst experiences in my life. I barely managed to do it, having cramped muscles for days after that, also I went back home by train, bicycle with me.

Nowadays, after 15+ years I can successfully ride for 100 and even more kilometres, probably using less energy than ever before. I admit that I have better bike(s) now, but that is not the point. 15 years ago I just gave up on the spot, as soon as it got hard. Quitting was easy, except for the next couple of days when I could barely walk, but the act of quitting seemed pretty liberating. You just run away and don’t look back.

A few months ago I went on a ride alone, and after 2 pretty hard rides in the two days preceding the current ride, my legs were pretty empty in the start. And I had 4 climbs on the route. I almost gave up after the first climb, but then something hit me. The pain you are feeling now, just means that when you go out tomorrow, or the next day, you will be even stronger than you are today.

By putting constant effort, especially when you don’t feel like it, you will gradually improve. I like to measure my cycling performance a lot, because if you can measure something, you can improve it. I’m far from being a pro, and I’m pretty far from competitive racing, excluding one with myself. The bike pulled me out of a really bad place I had put myself into. I’ve lost 40 kilo over 3 years on the bike, and now I’m feeling better than ever.

I’m using a cycling analogy here, because it’s the easiest thing that comes to mind here. But the real story I want to tell you is about yourself. You are the one that quits when it gets hard, I know it, I was the same, quitting when things get tough. Requiring constant and immediate feedback is something people cherish a lot, but the things that give you immediate feedback are mostly bad for you.

What I’m trying to point out here is that you are the only person responsible for your own destiny. If you are willing to go through life as a quitter, giving up as soon as it gets a bit harder than usual, you will become weaker and weaker. By not challenging yourself with new things every day you slowly degrade.

There is a pretty common saying that businesses which are not growing are falling apart. You could be stagnating, but given that everyone else around you is growing, you might as well be in the red, it is mostly the same. And this relates to people really well. Just think about your parents, or grandparents. Some of them know how to use a computer, some are pretty proficient with it, and some can’t even use a microwave.

Back to you, if you are a programmer, there was a time in your life when the only thing you knew how to code was ‘Hello World!’ in some language that you don’t use anymore. Why did you continue through the hardships of learning other languages, patterns, algorithms, just to call it quits today?

I hopefully have a couple of decades left to do something productive, can’t even imagine the language I’ll maybe be writing code in before I choose to retire. I might not even be writing code then, but I’m not afraid of it at all. Life is a constant change, and by accepting it, and going with it, you will find yourself being a better person than you were before.

One person told me a pretty resonating thing, and it stuck in my head. If I didn't challenge myself to do hard things, I would still be stuck doing a shitty job that I did 3 years ago. And it’s true for me too, on different levels. I now have a really great job, more energy and a lot more chance to hopefully get to see and play with my grandchildren in 20+ years. And I don’t really care about what will happen tomorrow, because I know I will deal with it.

P.S.

Exercising is really good for you, and you must start immediately if you want to play with your grand children, even great-grandchildren if you are really lucky. I know people who can’t even go out and play with their own children because they just called it quits on their own health. It’s really sad, but I don’t think they will even live to see their grandchildren. Tech jobs are pretty sedentary ones, and I know how easy it is to stuff yourself with fast food, while working 12+ hour days, getting bigger and bigger. If you are in this situation and don’t know where to start, there is a great book by Joe Kutner called The Healthy Programmer. If you need more help don’t be afraid to contact me. I’ll be glad to help you get on your way to feeling and doing better.

Don’t (only) focus on the code

Every developer aspires to create great things, but often the most important issue is not just the quality of your code, but many other and obscure things that are setting you back from achieving your and your company’s goals.

You should write good, well tested code, which doesn’t have to be perfect, but merely good enough. I know that some of the purists will get mad but that is often the case. As the saying goes, Perfect is the enemy of good enough. I won’t go into the quality of the code anymore, because I believe you, as most of the programmers do, write good enough code. What you should focus on is something completely different.

There are three things that you can do while working for a company or consulting for a client:

  • Create value
  • Reduce expenses
  • Both of the above

Ultimately I want you to always think of the ROI (Return On Investment), for either your employer, your client, or yourself in the end. If you steer away from that focal point, and start procrastinating on delivering the product, because the code, design, or copy is not perfect, you will never ship it. Also, if you are not embarrassed by your first release, you have shipped too late.

Now, think long and hard, what situations call for further improving the quality of your code to stick them in the three categories mentioned above? Testing and refactoring bad code will improve future maintainability, which reduces expenses in the long run. Optimising for performance and making the application faster can bring you more clients and earn more money. Optimising workflows will cut the time needed for the end-user to finish a unit of work faster, which reduces expenses per unit of work, allowing them to do more in the same amount of time, or to work less.

Automation is a nice thing to have, but unnecessary in the beginning. If the product that you are creating succeeds, and you start spending a lot of time on processes that should be automated, please automate them, and delegate the execution to someone else. But don’t do it before it really starts to hurt, because you are wasting your (and the company’s) precious time.

Understanding how and why the software does what it does should be the main thing for you to learn about. I agree that you can be some level III programmer in an enterprise behemoth, really detached from the process, being fed with your daily or weekly tasks through some project planning tool and not really knowing how the sausage is made. Maybe you are one of the Dark Matter Programmers, and aren’t really ambitious to move up, and that is also OK. I know people that are in the same situation as you are, happy with the work they are doing. Although I consider this approach highly insecure and uncertain for the long run, it is practical for the present, for them.

If you are focusing on the process, and eliminating the obstacles to reach one of the three points mentioned above (create value, cut expenses, both of them), then your software will be better in the long run. In that process you stop being just a programmer that is easily replaceable, and start being a true business consultant, with a unique set of skills.

As an example, there is a process that each end user has to do to make one widget. It includes going through 10 different screens, and entering a dozen parameters on each screen to produce the widget. Creating any type of widget generally takes 10 minutes Although the company makes different types of widgets, let’s say that one widget accounts for 80% of the sales, and all others for only 20%. Optimising the code in this situation does nothing, because the code has to produce a variety of widgets, and unless it’s really messed up, you should leave it alone.

Optimising the process on the other hand is something completely different. Especially if we have a situation like I mentioned above. I really love the Pareto principle, and try to use it all the time, applying it to any situation will allow you to focus on the stuff that really maters and ignore/drop the stuff that doesn’t.

How do we apply it to the above example? Let’s call the widget that accounts for 80% of the sales The Golden Goose. All widgets have around 100 properties you can set while creating them, but 95 of them are the same for each Golden Goose. So why bother entering and checking each one for a process that happens 80% of the time. Optimising the process from 10 screens and 100 parameters that takes at least 10 minutes and allows for a lot of human error, to one screen and 5 parameters, which reduces the widget preparation time to only one minute will drastically increase the user productivity, allow them to push out more widgets in the same time.

By focusing on the business and not only on the task at hand, you will stand out among your peers. There is no difference whether you are an employee, a freelancer or a consultant, your customers will generally have more respect for someone who looks at the bigger picture, and speaks their language. You can do yourself a big favour and read a couple of business books. It is a very big chance that you work for one, so why not invest a couple of hours in understanding how businesses work. It is a very small chance that those hours are spent in vain. If you don’t know there to start, The Personal MBA by Josh Kaufman is really great, and I can’t recommend it more.

The LinkedIn experiment

If you are an engineer you probably don’t see much use from LinkedIn as a service. It is full of recruiters, who can be very annoying from time to time. You can choose to link people you have worked with, went to school with, or know from one source or another. Aside from this fact, I didn’t see that much use in LinkedIn. So I decided to run a small experiment. No, I won’t give them access to my email or something stupid like that, but I’ll do my best to use the site as it was intended to.

I’m not really hoping to gain anything from it, aside from maybe a new connection or two. I know I’ll get spammed like there is no tomorrow, and that was one of the reasons I killed my profile a couple of years ago. But this time I mean business.

I’ll do my best to post updates, link interesting articles, fill my profile with everything I can, and even leave a review or two. I’ve already started doing some of those things, and I’ll follow the plan at least till fall.

As I’ve previously mentioned, I don’t want anything. I’m not looking forward to getting spammed by recruiters, and I probably won’t be looking for new projects soon. I just want to see what can be done with it. I’m always open to finding new acquaintances and similar minded people. I was also considering joining (or starting) a mastermind group, and maybe LinkedIn can provide some help with that.

If I don’t get anything out of this small experiment, and I sincerely doubt that I won’t, I believe it will be a small amount of time well spent. I’ll surely write a post about my results in a couple of months.

Understanding the Ember run loop

All of the Ember.js internal code, and most of the stuff you write while creating an Ember.js app runs with the help of the run loop. It is used to batch, order and reorder jobs in a way that is optimised for efficiency. I didn’t notice it’s existence before I ran into problems with the JavaScript setTimeout function callbacks and when manually running async calls to the API.

How Ember run loop works

If you’ve read any of the productivity books out there, they all state that batching similar jobs is the key to success. Ember run loop works in a similar way. By running same or similar jobs at the same time, the browser doesn’t have to skip around from task to task, which eases the burden on it, and if you change the same property a couple of times in the same loop cycle, it will only have to process the last change.

Jobs or tasks are scheduled into different queues, and the queues are processed by priority until they are empty.

Queues

Ember run loop consists of six queues

Ember.run.queues
// => ["sync", "actions", "routerTransitions", "render", "afterRender", "destroy"]

Each one of these queues is responsible for some jobs batch that runs inside of it.

  • sync contains the binding synchronisation
  • actions is the general work queue, and the one that generally handles promises.
  • routerTranisitions contains transition jobs in the router
  • render contains the jobs that are associated with rendering the page and updating the DOM
  • afterRender runs after the DOM is complete, after all the render jobs have been executed. This is the perfect place if you want to update the DOM after it has been rendered.
  • destroy is responsible for destroying everything other objects or jobs have scheduled to destroy.

Testing

Ember run loop is really important when running tests in Ember. Ember raises errors in testing mode when we try to schedule work without the run loop.

When should you use the run loop

Strictly speaking, all non Ember api code should be wrapped inside an Ember run loop. That includes:

  • AJAX callbacks
  • DOM updates and event callbacks
  • Websocket callbacks
  • setTimeout and setInterval callbacks
  • postMessage and messageChannel event handlers

Be sure to wrap the callback body in the ember run loop and not the whole invocation. For example:

var controller = this;
socket.on('channel', function (data) {
  Ember.run(controller, function() {
    console.log(data);
    this.set(‘message’, data.message);
  });
});

This fires an Ember run loop after the callback is executed, and the callback code will be executed at exactly the right moment.