Verbose Logging

software development with some really amazing hair

T + G I F R

On Defining New Types

· · Posted in Programming
Tagged with

I was working on my twitterstream package the other day and got thinking.

When do you make a new type? When don't you make a new type?

Type System Basics

If you use a programming without a strong static type system, you probably don't have much to worry about. In ruby and python for example, it doesn't really care about what you pass a method or function, as long as it has whatever methods you expect it to have. This is called duck typing

The Go programming language is statically typed. When I define a function, I have to specify that the function takes an int as the argument. I also specify the return type.

func AddOne(int x) int {
    return x + 1
}

Compare this to ruby:

def add_one(x)
    x + 1
end

The ruby version only cares if x implements a + method. You could do something like this: