Vegard Skjefstad

Menu Close

Tag: Programming (page 1 of 4)

Google Translate Firefox Extension

I made a Google Translate Firefox extension that lets you translate between any two language from the Firefox address bar. Awesome!

When I write for this site, I use many different tools1. To spice up the language a little, I use is a life saver when I want to look up definitions of words. And Google Translate is handy because English is my second language, and I often find myself in need of a little translation from Norwegian.

Both and are easily available through Firefox search engine integrations. I simply open a new tab, hit either t for thesaurus or d for dictionary, enter the word I’m looking for, and the respective site in queried. It’s all very convenient. For a while I’ve been looking for a similar solution for Google Translate, but I’ve found none. The Firefox extensions that exist for Google Translate are either massive feature creeps, or very limited.

I needed a simple extension that made it possible to translate between any of the languages supported by Google Translate. And what’s the programmer’s approach when we have a problem that isn’t already solved by someone else? We solve it ourselves, of course!

Read more

December One-liners: Programming Special!

Here are the new one-liners for December. This time it’s programming special, with a few sprinkles of less nerdy wisdom. Most of the quotes below are collected from the Twitter account Programming Wisdom. They’re not exactly haha-funny, but if you’re a programmer they should make you think. Enjoy!

  • “It’s all talk until the code runs.” – Ward Cunningham
  • “In theory, there is no difference between theory and practice. But, in practice, there is.” – Jan L.A van de Snepscheut
  • I’ve got an idea for a really scary Halloween costume. How do I dress up as “The World Right Now”?
  • “What one programmer can do in one month, two programmers can do in two months.” – Fred Brooks
  • “Good software, like good wine, takes time.” – Joel Spolsky
  • “Debugging is like being the detective in a crime movie where you are also the murderer.” – Filipe Fortes
  • Trying again to persuade my wife to participate in a twosome.
  • “We build our computer systems the way we build our cities: over time, without a plan, on top of ruins.” – Ellen Ullman
  • “Think about it; and think about it carefully. Nothing happens in our society without software. Nothing.” – Robert “Uncle Bob Martin
  • “I ran a half marathon” sounds so much better than “I quit halfway through a marathon”.
  • “A language that doesn’t affect the way you think about programming is not worth knowing.” – Alan J. Perlis
  • “Programs must be written for people to read, and only incidentally for machines to execute.” – Harold Abelson & Gerald Jay Sussman
  • “Debugging time increases as a square of the program’s size.” – Chris Wenham
  • “One of the best programming skills you can have is knowing when to walk away for awhile.” – Oscar Godson
  • The trick to really enjoying someone’s company is to not spend a lot of time with them.
  • “The strength of JavaScript is that you can do anything. The weakness is that you will.” – Reg Braithwaite
  • “The best programs are the ones written when the programmer is supposed to be working on something else.” – Melinda Varian
  • “A primary cause of complexity is that software vendors uncritically adopt almost any feature that users want.”- Niklaus Wirth
  • “Every great developer you know got there by solving problems they were unqualified to solve until they actually did it.” – Patrick McKenzie
  • Life doesn’t hand me lemons, it fires them at me rapidly from a lemon cannon.
  • “The next best thing to having good ideas is recognizing good ideas from your users. Sometimes the latter is better.” – Eric Raymond
  • “Looking at code you wrote more than two weeks ago is like looking at code you are seeing for the first time.”– Dan Hurvitz
  • Having nutrition information on a bag of Cheetos is like having dating tips on a box of Crocs.

C# for Java Developers, Part I

If all the planets align correctly, and World War III doesn’t break out, I might be dabbling in C# within the next 12 months. But I’m a hard core Java developer. How do I effectively learn C# while at the same time staying sane? Here’s my quick and dirty C# for Java Developers guide.

C# (pronounced see sharp) first appeared in the year 2000, 5 years after Java. It’s currently at version 7, which was released in March this year. The language is similar to Java in many ways, but it’s also very different. Both Java and C# are typed statically and strongly, object orientated, use curly braces to define scope, and semi colons to indicate line endings. While they have similar syntax, the C# syntax differs enough from Java that it might look a bit confusing to a long time Java developer at first sight.

The structure of this guide is as follows: Each hand picked topic consists of three sub sections. One code sample from each camp, and then some quick bullet points that cover what I consider the most important takeaway from the particular subject. All code you see is also available in the C# for Java Developers GitHub repository.

A word of warning: I’m writing this guide as I learn C# myself, so don’t except everything to be 100% accurate. Consider reading this as a way to kick start your own C# adventure.

Without further ado, let’s jump in the deep end of the pool.

Read more

Esoteric Programming Languages: Brainfuck

“B” is for Brainfuck.

In early February, Stack Overflow data scientist Julia Silge published an article titled “What Programming Languages Are Used Most on Weekends?“. The data used to deduce what’s hot and what’s not among our fellow nerds during the weekend, is what tags are used on Stack Overflow questions.

Haskell, a function programming language, saw most questions during the weekend. Now, a high number of questions on Stack Overflow doesn’t necessarily mean that a language is immensely popular. It might just mean that Haskell programmers are dumb. Oh, I kid, I kid. I’m sure Haskell programmers are quite intelligent – and I’m hoping they have a sense of humor.

Anyway. What the data from Stack Overflow do show, is that programmers are focusing on very different things during our workweek than we do during the weekend. While a workweek is filed with cringe worthy topics like SharePoint, TSQL, and (gasp!) VBA, the weekend tend to be for experimenting with new things.

Let’s have a brief look at an esoteric programming language that might be of interest for your next weekend of experimenting: Brainfuck.

Read more

java.util.Optional Addendum

So you thought I was done with the Java 8 posts now, didn’t you? I thought I was, too, but no. As pointed out by Terje in this comment, my java.util.Optional example wasn’t very good1. Let’s treat his comment as code review feedback, and see if we can crack out a better example.

Terje argues that it would be better to use an Optional to clarify that something can be null. Or perhaps nil – non-existent – is a better term for the Optional’s state; as we saw in the previous post, the point of the Optional is that it does not contain null values. Instead, the Optional object is empty and its isPresent() method will return false. Another good point that is raised in the comment is that, even though it might be tempting, it could be bad to use Optional everywhere. Use Optional when something can be null, don’t use Optional if something can’t be null.

With all that in mind, here’s another example where the use of Optional perhaps makes more sense. Imagine a service that returns a user’s full name given a user name. But what happens if there is no user with the given user name? I’ve seen many creative solutions: Throw an exception, return an “I’m afraid I can’t let you do that, Dave”-string or return null. All of these solutions have their own flaws, which we will not get into now. Instead, let’s solve this conundrum by returning an Optional.

public Optional<String> getFullName(String username) {
    if ("th".equals(username)) {
        return Optional.of("Tony Hawk");
    } else {
        return Optional.empty();

If the input to getFullName(…) is “th”, then an Optional containing the String “Tony Hawk” is returned. For any other input the method, it returns an empty Optional. Usage of the getFullName(…) method could look something like this:

System.out.println(getFullName("th").orElse("No user found"));

Here, we print full name if it’s contained in the Optional, or the string “No user found” if the returned Optional is empty.

Better? Better.

Copyright © 2000-2019 | Privacy Policy | Statement of Audience | Hosted on