You're using IE. Scroll down.
home :: tech

Old linesmen stories

My first job was at an international carrier making the internet. Only a small bit of it but still, it was a great fun time. Line failures are common in this line of work. Someone opens up a cabinet a gives the wrong patch a firm tug or closes a door and something that wasn’t meant to bend ends up in a sharp turn. Sometimes a whole cable would fail, dug up by some nameless builder. Sometimes an undersea cable carrying millions of megabits per second of voice and internet between two continents would break. This is fortunately rare as there’s not much construction work under the sea. Most of time it’s a ship going by a coast dragging its anchor through the sea floor, sometimes a storm is so severe a cable gets tossed and turned until it breaks. When this happens there’s only one thing to do, call The Boat and wait two weeks or a month for it arrive, hoist up the ends and mend the cable.

But every once in a while something weird would happen. A cable would die and some hours later it would just come back online. When that happened the older more experienced cable maintenance guys would just shrug it off and say “it’s just the US army splicing in”. It was said half jokingly, half in awe. Splicing into an optical fiber is hard enough in dry land, cutting in and fusioning the light splitter is delicate work and doing it 100m under sea is nothing short of amazing. It involves cutting the cable in 2 and fusioning each individual fiber on both ends to the spliter piece that separates a bit of the light onto a second spy cable. You have to keep it dry throuhout the process and seal everything back up in the end. But the common wisdom was the americans could tap into undersea cables 15 years ago.

Or maybe it was only old linesmen tales and the americans never tapped anything.

/tech | edited on 2013/06/23 -- permalink, click to comment

The Other Conundrum

The space used up by Other in my iPhone has been creeping up for while. Other is iTunes speak for “i don’t know what this is”. It’s basically what’s left of the used up space after all media and apps are accounted for. A bit of Other is natural, there’s always system temporary files lying around, config files, upgrade images and other random stuff. But when it get to 4G things have gotten out of hand.

screenshot of itunes showing 4G used by Other

At this point a regular user gives up and does a full restore from a backup. Not being a regular user I went with getting to the bottom of this so I evasioned my iPhone.

A bit of poking around the filesystem and sure enough something looked strange.

2.6G    ./Podcasts

I’m pretty sure I don’t have 2.6G worth of podcasts and iOS thinks so too.

usage says 693MB in Podcasts

So there’s 2G lost in Podcasts.

ls -1 | wc -l
210

Looking at the file count Podcasts never deleted anything and that’s despite me deleting stuff manually.

So where’s the other 2G ? Well, I found a bit over 500M in staged iOS updates and couldn’t be bothered to look further. The moral of the story is Podcasts.app is an unmitigated disaster. It’s probably the worse app Apple ever released. The first versions just downloaded stuff over and over using up cellular data. Then the control appeared but despite being set to never use 3G it would happily stream over cellular. And this space leakage is just as if Apple is forcing people to buy more expensive phones.

/tech | edited on 2013/03/04 -- permalink, click to comment

What’s wrong with Go anyway ?

Who do you think you are knocking on Go and Ken this way ?

First, I don’t care for that tone, are we in church ? Second, all languages have good and bad stuff. Javascript has a lot of bad parts and it doesn’t stop being my favorite language.

On to the knocking

package main

import "fmt"

func main() {
    fmt.Println("Hello, world")
}

Nothing much here except that Println that throws me directly to Java. Also, there’s a strange lack of ;; which is disconcerting but might not be a problem in the end.

func fib() func() int {
    a, b := 0, 1
    return func() int {
        a, b = b, a+b
        return a
    }
}

func main() {
    f := fib()
    // Function calls are evaluated left-to-right.
    fmt.Println(f(), f(), f(), f(), f())
}

There’s a disturbing number of func right in the first line. Obviously Go is strongly typed and I’m immediately sitting in Introduction to C trying to figure out to prototype a function that returns a list of functions that return void * and take two functions as arguments each taking two pointers to int as arguments having the function an argument that’s an array for pointers to void. This isn’t a good feeling. On the plus side Go’s syntax seems more natural reading left to right as “a function fib that takes no arguments and returns a function that returns an int”. Then on the next line we have something I always hated with a passion, :=. I understand the point of making = and == very distinct but if you want that change == not =. := is just non natural except for a very strict group of computer scientists.

Then we have a return statement with a repetition from the fib() proto. Some people will say this is just good programing making sure you got the right thing, me I was saying just a couple of days ago every time you have to write exactly the same thing in two places you’re doing something very wrong. Of course you’re going to return func() int, you’ve said it 2 lines ago. And then there’s something I put right up there with i += i++ + ++i. What’s a,b = b,a+b supposed to mean ? Do you do a = b and then b = a+b ? Is it a list assignment of (b,a+b) to (a,b) ? I can’t tell. I’m sure somehow Go has got ()less lists and it’s a list assignment but it confuses the hell out of. Also, = ? There’s two assignment operators ? One for initialization and another for changing values ? Really ? At this point we got :=, = and ==.

One point for Go, this example shows closure. On the other hand everything is strongly typed except variables which are inferred. f := fib() means, f is a variable of type whatever fib() returns so if fib’s interface ever changes some interesting stuff will happen and the interpreter will never be the wiser. You get all the hassle of typing and none of the benefits.

The next example is a bit longer so I’ll go inline.

// Number is a pointer to a Number
type Number *Number

Really ? Number is a pointer to Number ? Are you on crack ?

// The arithmetic value of a Number is the
// count of the nodes comprising the list.
// (See the count function below.)

// -------------------------------------
// Peano primitives

func zero() *Number {
    return nil
}

func isZero(x *Number) bool {
    return x == nil
}

func add1(x *Number) *Number {
    e := new(Number)
    *e = x
    return e
}

Let’s try to digest this in the context of Number is a pointer to itself. You create a new Number called e. First, new(Number) makes me sick after all these years of trying to kill new in JS. Then you say *e = x which I have no idea what’s supposed to do. Looks like pointer manipulation and you’re throwing away the new(Number) and pointing e to x. Or you could be deferring x somehow and making the value of e be the same as x.

func sub1(x *Number) *Number {
    return *x
}

No clue what this is supposed to do. You’re taking an argument and returning.

func add(x, y *Number) *Number {
    if isZero(y) {
        return x
    }
    return add(add1(x), sub1(y))
}

Still lost, this looks like it’s splicing stuff off y but using sub1 that looks like an identity function. The * in *x and *Number must be different I guess.

func mul(x, y *Number) *Number {
    if isZero(x) || isZero(y) {
        return zero()
    }
    return add(mul(x, sub1(y)), x)
}

func fact(n *Number) *Number {
    if isZero(n) {
        return add1(zero())
    }
    return mul(fact(sub1(n)), n)
}

Still lost.

// -------------------------------------
// Helpers to generate/count Peano integers

func gen(n int) *Number {
    if n > 0 {
        return add1(gen(n - 1))
    }
    return zero()
}

Lets try and work out gen. You tail from nil then go add1(nil) which is *e = nil. I sense * = is some kind of append list operation. Now if *e was pop wouldn’t that be funny ?

func count(x *Number) int {
    if isZero(x) {
        return 0
    }
    return count(sub1(x)) + 1
}

Well, looks like it is. You’re splicing stuff off x and counting how many times you can do it before you run out of elements. This also tells me arguments are passed by value so this Number arrays are being copied left and right.

// -------------------------------------
// Print i! for i in [0,9]

func main() {
    for i := 0; i <= 9; i++ {
        f := count(fact(gen(i)))
        fmt.Println(i, "! =", f)
    }
}

After all the weirdness above main is pretty simple. As far as I can tell Number is a list of Number objects and * can either push or pop depending on being a lvalue or a rvalue. Hopefully the next one is better.

import (
    "fmt"
    "math"
)

So this should be a list of strings. Which means a,b = c,d isn’t list assignment. Hum.

func main() {
    fmt.Println(pi(5000))
}

// pi launches n goroutines to compute an
// approximation of pi.
func pi(n int) float64 {
    ch := make(chan float64)
    for k := 0; k <= n; k++ {
        go term(ch, float64(k))
    }
    f := 0.0
    for k := 0; k <= n; k++ {
        f += <-ch
    }
    return f
}

make. Is it like new ? But different ? (turns out new allocates and returns a pointer like in C++ but make allocates some specific types and doesn’t return a pointer - bad) chan seems to be a qualifier so ch is a chan of floats. Then you can run a loop going a function on ch. Maybe this is the parallelization feature I’ve heard about. This is probably the first neat thing on the language so far so lets see where this goes. I’m sure term is defined to take a float64 but you need to type cast the int to keep the interpreter happy and you do it in a awkward way too, is float64() a function ? A keyword ? Syntax for cast ? Is it even important ?

A couple of lines down we find <-ch which looks like an iterator or generator. The syntax is awkward versus <= but the principle seems sound, you fill ch with values by going term on it and then pull them out as needed. The syntax does allows lazy evaluation but go func(ch) is kinda strange.

func term(ch chan float64, k float64) {
    ch <- 4 * math.Pow(-1, k) / (2*k + 1)
}

So <- is 2 operands, left is pop and right is push apparently, makes some sense. Not sure I like it though. Hopefully this is a back pressure mechanism and you evaluate term to fill ch when it reaches a low watermark. The syntax seems hard to follow and what if a single generator function fill more than one channel ? Confusing.

// Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch chan<- int) {
    for i := 2; ; i++ {
        ch <- i // Send 'i' to channel 'ch'.
    }
}

Oh groan an actual generator with more specific prototype syntax. So what’s term ?

// Copy the values from channel 'in' to channel 'out',
// removing those divisible by 'prime'.
func Filter(in <-chan int, out chan<- int, prime int) {
    for {
        i := <-in // Receive value from 'in'.
        if i%prime != 0 {
            out <- i // Send 'i' to 'out'.
        }
    }
}

Ok, a pipe filter. There’s a lot of work here to make streams fit into “normal” for loop syntax. I find filter functions much more intuitive.

// The prime sieve: Daisy-chain Filter processes.
func main() {
    ch := make(chan int) // Create a new channel.
    go Generate(ch)      // Launch Generate goroutine.
    for i := 0; i < 10; i++ {
        prime := <-ch
        fmt.Println(prime)
        ch1 := make(chan int)
        go Filter(ch, ch1, prime)
        ch = ch1
    }
}

First time I read this main it felt like i was reading Conway’s Quantum Superpositional Perl. Turns out this is just a bad intro example that does something really fancy. ch is your 2.. channel and you can take a prime number from it right of the bat cause we know 2 is prime. Then you create a new channel that filters on this prime make ch this channel. So by now ch emits 2,3,5,7,9,.. . Then you extract the 3 and add a new filter to the channel filters using 3 so now you have 2,3,5,7,11,.. . And so on. Despite the awkward syntax this is actually very cool.

So what’s wrong with Go anyway ?

The syntax is very very awkward. It makes it hard to read both at the statement level and at the package level. It has a lot of brilliant stuff like streams and concurrency but the syntax is like if a C programmer read about Perl, wanted to make a language as awesome as Perl but looking like Python and not totally alien to Java programmers. As a result we get some stuff that’s proven a mistake in Javascript and madness like type T struct { a int } func (tv T) Mv(a int) int { return 0 } // value receiver func (tp *T) Mp(f float32) float32 { return 1 } // pointer receiver var t T

t.Mv(7)
T.Mv(t, 7)
f := T.Mv; f(t,7)

which is a declaration of an object with 2 methods crammed into C. The 3 function/method calls are equivalent.

Looking at the examples and some of the documentation it seems Go must undergo the same process JS is/should be undergoing, remove a bunch of optional syntax and confusing shorthands that allow easily misreadable idioms. When that happens Go will kick ass!

/tech | edited on 2013/01/06 -- permalink, click to comment

Expandable Storage

Where it comes to phone storage there’s basically 2 camps, all onboard and mostly off board via memory cards. Mostly the all onboard camp is composed by the iPhone while the mostly offboard camp is populated by the Androids. People like slamming the iPhone for not being expandable and forcing you to go all in at purchase time while Androids (and symbians before that) let you get more storage space when you needed it. Surely the all onboard approach is a planed obsolescence tool, it helps you decided when to get a new iPhone. But it’s also a ver y sound engineering decision.

Android users are familiar to this scenario: you pop a shiny new 16G card on your phone and it still tells you there’s no more space for apps. How can that be ? There’s 10G free right there. However, the OS can’t trust it. It’s formatted using a subpar filesystem and the user might pop it out at any time. It’s no place to store apps that might even be running and suddenly disappear. So apps are limited to a bit of the small onboard storage that’s reliable. On the other hand the iPhone users can use all of the limited onboard storage for apps cause it’s all first class. So what you win in flexibility you lose in flexibility. And then there’s windows phone were you get to use a crappy slow card for apps that you can’t actually remove without breaking the phone.

(written shortly after hacking around with apps2sd on ICS to get more app storage)

/tech | edited on 2012/08/10 -- permalink, click to comment

ASUS RT-N66U

My venerable Asus WL-500W finally kicked the digital bucket and forced me to upgrade. It was running dd-wrt so I went around and looked for something dd-wrt capable. I ended up finding the Asus RT-N66U which is dual 2.5/5GHz, openly dd-wrt friendly and carbon black.

Why would you want a 802.11N 5GHz band router you ask ? Well, first off 2.4GHz is saturated with noise if you live in a building. In my building channel 6 is useless (I mean, you can even associate) and everything else is overused. I need to go to channel 13/14 to make it actually work. The other reason is on 2.4GHz despite having N enabled you’ll probably also have B/G compatibility for older or cheaper devices so once that one G client connects your wireless speed will be pulled down. On the 5GHz you’ll only have N clients so you’ll be going full tilt. And what’s full tilt ? On 5GHz my macbookpro did around 115Mbps download versus about 80Mbps on 2.4GHz channel 13 and no G clients. The gigabit ethernet switch did OK, I measured about 800Mbps server to server. This are payload speeds, so actual wire speeds will be 8 to 10% higher.

Geting to this speeds means the CPU can’t be a slouch, the Asus RT-N66U has a 300MHz Broadcom MIPS chip and 265M RAM.

cat /proc/cpuinfo
system type          : Broadcom BCM5300 chip rev 1
processor          : 0
cpu model          : MIPS 74K V4.9
BogoMIPS          : 299.82
wait instruction     : no
microsecond timers     : yes
tlb_entries          : 64
extra interrupt vector     : no
hardware watchpoint     : yes
ASEs implemented     : mips16 dsp
shadow register sets     : 1
VCED exceptions          : not available
VCEI exceptions          : not available

It also has a roomy 32M flash which means plenty of space for fat firmwares. Also 64k of it can be used for nvram (which is used to save the configs) but more on that later. There’s 2 USB2.0 ports as usual and I haven’t craked warranty on mine yet but this pictures show a 3.3V serial header (J1), what looks like a JTAG header without the pins (J2) and a microSD slot people say is wired and works. For some reason ASUS left it locked inside the case and useless to mostly everybody. It was nice of them to put the serial header in there, I spent most of an evening soldering one into the 500W.

I booted the stock firmware long enough to confirm stuff worked. There’s a nice novelty on the N66U, the recovery mode (which is access by powering on with the reset button pressed until power starts blinking slowly) now has a small web server on http://192.168.1.1/ where you can upload a firmware and clear nvram. Not only you don’t have to mess around with tftp to load firmware but also clearing settings doesn’t involve loading a specific mini build anymore. That particular bit saved my bacon once already while loading dd-wrt.

You’ll need a recent build of dd-wrt, their wiki says 18946 or 19342, I’m on 19342 mega and it’s working fine apart from not supporting 64k nvram hack yet. Despite the router having it, the bootstrap loader (CFE) doesn’t seem to know about it so the firmware must do a hack the use all the space. I’m not exactly sure how the hack (which is in stock firmware) works and what would happen when you clear nvram from recovery mode, most likely only half would get erased. There’s a thread about this here if you want to read more about it.
Flashing dd-wrt is straight forward, just follow the instructions and use the recovery mode mini http server.

/tech | edited on 2012/07/22 -- permalink, click to comment

So Long, and thanks for all the Tech

The news of Steve’s death were expected but still came as a shock for everybody. Like if the guy was holding on for one last product launch.

Lots of people wrote extensive, thoughtful and well written eulogies. I will just remark what most impressed me about Steve Jobs, he was a master of simplicity. Simplicity is hard, everyone who tries to write software knows this. For me simplicity is really hard, I’m a crufter so seeing someone churn out products by removing, not adding, features is like magic.

Steve came back from NeXT to Apple, brought UNIX and built an aesthetic and simple UI around it. Then he did the same to the mp3 player and to the smart phone. My first analysis of the iPhone was focused on what it lacked, not what it had. It sounded pretty foolish as soon as iPhones started filtering into people’s hands and it became obvious it wasn’t missing anything. Everything that couldn’t be made perfect was removed. Deliberately. That kind of focus and courage is unique.

/tech | edited on 2011/10/06 -- permalink, click to comment

Programing for Nokia

  • 2007: Symbian is great, you should all be using our awesome C++ API and our awesome IDE!
  • 2008: Maemo is the future! We don’t like the Gtk+ C APIs but we don’t know what we’re gonna do. We hear Flash Lite is great!
  • 2009: Maemo6 is going to be awesome! And it’s all Qt C++!
  • 2010: Did we say Maemo6 ? We obviously meant Meego! Excellent news, common UI Qt API in Meego and Symbian!
  • 2011: Windows Phone is totally awesome so we’re going with that! Symbian is going to die. Qt what ? No, you’re totally going Microsoft now.

This latest jump shouldn’t bother anyone as anyone with a shred of sense has given up hope 2 years ago.

/tech | edited on 2011/02/13 -- permalink, click to comment

What Should Nokia Do ?

Tomorrow Nokia will probably announce their demise. So I’ll write here what Nokia should actually have done. Two years ago at least.

  • Put Symbian on life support. This is a no brainer but life support in Nokia context will probably mean a 1000 headcount considering all the legacy to support.

  • No more S40. All devices under 150EUR come with Symbian^2. We all say Symbian is crap but it’s still a lot better than anything else in featurephone space.

  • Don’t do 100 phones at a time. Nobody needs to choose from 30 models in a given range. Focus on a much smaller number and do them well. Nokia knows how to, technically, build good phones. But it fails at building compelling phones.

  • And finally, get the Maemo/MeeGo team on top. They seem to be the only team capable of delivering in interesting product in the last 2 years, even against the rest of the company. And then make them integrate Android for everything from midrange to highend. And meanwhile make them do a MeeGo tablet.

But this is not what Nokia will do.

/tech | edited on 2011/02/10 -- permalink, click to comment

FinalWebPro

Apple is probably working on a pro HTML authoring tool. Lets review the recent events:

  • Apple keeps Flash out of iOS;
  • Apple removes Flash from the Lion install, whoever wants it needs to get it from Adobe;
  • iWeb is missing from the iLife11 announcement while mail templates are demonstrated from something that felt like 1 hour.

So my take on this is the Web team is hard at work on a HTML5+JS pro authoring tool to obsolete Adobe Flash. In fact, all Apple needs to declare full out war on Adobe is to throw in a decent Photoshop replacement.

And lo and behold, between writing and publishing time Adobe concedes defeat and announces a flash-to-html tool. Flash is now irrelevant.

/tech | edited on 2010/10/30 -- permalink, click to comment

The iPad use case

A number of people asked me if I’m in line for an iPad. The short answer is, I’m not. I lack a clear use case for it and that kind of money can buy my kids some nice holidays. But the iPad is a beautiful machine. It looks like something out of the future and while I haven’t held one yet I’m pretty sure it feels like that too. Somewhat like the guy who designed the first flipphone cause he wanted a Star Trek tricorder, but totally better.

I don’t have a use case for the iPad but then again I’m not the typical user. We already have a netbook on the couch the wife uses for Facebook games (which, for the time being, is about the only reason Flash is important on something) so that’s covered. I myself have been, as of late, living on my N900 and while sometimes annoying for lack of horsepower (and little Maemo5 snafus) it has been rendering my workstation more and more as the thing I use to do development and gaming on. The N900 is a proper computer and fits in my pocket which are two very important requirements for me. The 98% of the population who isn’t like me will use the iPad exactly as I use the N900 and for them it will slowly and steadily become their personal machine. So, to the people saying the iPad isn’t a real computer and won’t catch on cause it’s neither a PMP nor a notebook I say poo poo. That’s a weak argument if I ever heard one.

Meanwhile, iPhoneOS 4.0 has came out which will bring, among other things, proto-multitasking to the iPad enabling IM, music player and VoIP. Next year an iPad2 will surely come out with a front facing camera, iChat and Skype videocall. If everything goes according to Apple’s plan, Flash will be a memory like Java applets are now and the iPad will be the personal device.
Speaking of Apple’s plan, the iPhoneOS4.0 SDK basically kills the upcoming Adobe Flash iPhone cross development GUI app. That gotta sting, not only Adobe but also all the Flash developers who were planing to code the next iFart in Flash and become millionaires. They’ve become upset and trash talked Apple and I wouldn’t be surprised if a lost profit class-action suit cropped up (please oh please do, that would be so entertaining). My take on the whole thing is, iPod/iPhone/iPad is a closed system, Apple never made representations otherwise and if you want to make money off it you listen to Apple and play by Apple rules. Don’t like them ? Pack up, leave and develop for Android which is an open system or buckle down and learn Objective-C/Cocoa. Either way, shut up.

/tech | edited on 2010/04/11 -- permalink, click to comment
blog comments powered by Disqus
Archive: