Archive for the ‘Uncategorized’ Category


2011 in review

In Uncategorized on January 1, 2012 by Matt Giuca

The stats helper monkeys prepared a 2011 annual report for this blog.

Here’s an excerpt:

The concert hall at the Syndey Opera House holds 2,700 people. This blog was viewed about 27,000 times in 2011. If it were a concert at Sydney Opera House, it would take about 10 sold-out performances for that many people to see it.

Click here to see the complete report.


Can MPEG-LA change their minds in 2015?

In Uncategorized on January 16, 2011 by Matt Giuca

We know that the MPEG-LA famously promised not to charge distributors of H.264 content after December 31, 2015. But are they really (legally) held to that promise?

In law (and I am not a lawyer), you can make a statement to the effect of “so-and-so grants a worldwide, perpetual, irrevocable, royalty-free license to do such-and-such.” Typically words like “perpetual” and/or “irrevocable” are used. Such a statement has legal weight. You can’t just make such a promise and then turn around and start charging royalties. For example, the WebM codec is patented and those patents are owned by Google. The reason we (the open web) like WebM is because:

Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable … patent license to [infringe VP8 patents owned by Google].

(The full text is more complicated than that, but you can read it here and as far as I can tell, it has that effect. Note that this isn’t to say someone won’t discover other non-Google owned patents on WebM, but at least you can’t be sued for any known patents.)

Now MPEG-LA has promised (PDF) a much smaller set of patent exemptions (specifically, for Internet broadcasters distributing using H.264 video and not charging a fee) with the following statement:

In the case of Internet Broadcast AVC Video (AVC Video that is delivered via the Worldwide Internet to an End User for which the End User does not pay remuneration for the right to receive or view, i.e., neither Title-by-Title nor Subscription), there will be no royalty for the life of the License.

Now firstly, this is not the legal text of the license. This is a summary. I would quote the actual license that MPEG-LA is forcing upon all H.264 users (and thanks to Apple and friends, potentially forced upon the web in perpetuity), but … it is not available online. MPEG-LA’s “Agreement” page contains a link to the summary PDF I linked above, and a request to “e-mail your name, company and address to our Licensing Department and a hardcopy of the AVC Patent Portfolio License will be sent to you promptly”. I can’t find an up-to-date copy of the license anywhere online. I see no reason why they don’t have a PDF copy of this “open standard”‘s patent license online, except that perhaps they don’t want us reading it. Instead, we must deal with summaries and press releases. Anyway, the sentence of the summary quoted above refers to section 3.1.5 of the secret patent portfolio.

Anyway, going by the summary, you’ll notice that it contains no such language as “irrevocable” or “perpetual”. And it uses the phrase “for the life of the license“. The press release uses the same curious phrase. Now I’m speculating here. I haven’t read the license and I am not a lawyer, but as I read it, the life of the license is not the same thing as the life of the patent pool. As far as I am aware, this license was initially made through to 2010. The MPEG-LA renewed the license in 2010 and now extends to 2015. Therefore, have they actually promised anything new? Legally, as I read it, they are not bound to this “promise” at all, nor have they even promised a perpetual license. If H.264 is indeed the standard for web video by the end of 2015, we (or at least, those who serve video) could find ourselves with no choice but to pay up in 2015.

While Engadget may trust the words of MPEG-LA (“Yes, the license terms are worded poorly, but those are the answers straight from the patent horse’s mouth. Everyone can breathe again, ‘kay?”), I don’t trust a shady, vague promise written by a company whose sole means of existence is to extract patent royalties in a license I can’t even see — only a properly worded legal document ensuring a perpetual, irrevocable patent license.


Valgrind and if statements

In Uncategorized on October 4, 2010 by Matt Giuca

Valgrind has a handy warning: “Conditional jump or move depends on uninitialised value(s)”. I discovered the other day that using if statements can help trigger this warning.

Consider this C program:

int foo()
    int x;
    return x;

int bar()
    return !foo();

int main()
    printf("%d\n", bar());
    return 0;

Note that foo returns an undefined value, and bar inverts it (returning an undefined value as well). However, this will go undetected in Valgrind, because there is no conditional jump in the generated assembly code.

Now, change bar to the following, equivalent (but more verbose) code:

int bar()
    if (foo())
        return 0;
        return 1;

The sort of code I tell my students to replace with !foo(). Yet now, Valgrind will produce the warning message “Conditional jump or move depends on uninitialised value(s)”, because now the generated code has a conditional jump (the if statement). Interesting.


A doubly-linked list in Haskell

In Uncategorized on March 30, 2010 by Matt Giuca

I wrote it this morning. I wasn’t sure if it could be done.

Since Haskell is a pure language, you can’t mutate things. That makes it tricky to construct cyclic data structures, but you can using Haskell’s laziness. A quick example is the cycle function in the Haskell prelude, defined thusly:

cycle            :: [a] -> [a]
cycle []          = error "Prelude.cycle: empty list"
cycle xs          = xs' where xs'=xs++xs'

Note that you could write “cycle xs = xs ++ cycle xs”, but that isn’t strictly a cyclic list, it’s an infinite list. There is no semantic difference, only a very subtle operational one.

I used the same trick to create a full doubly-linked list (note that you can’t update this data structure, you can just create one from a singly-linked list and explore it as you wish).

data DoubleList a = Cons (DoubleList a) a (DoubleList a)
                  | Nil

instance Show a => Show (DoubleList a) where
show Nil = "Nil"
show (Cons left x right) = "Cons <left> " ++ show x ++ " " ++ show right

fromList :: [a] -> DoubleList a
fromList xs = fromList' Nil xs
        fromList' :: DoubleList a -> [a] -> DoubleList a
        fromList' _ [] = Nil
        fromList' prev (x:xs) = self
            where self = Cons prev x (fromList' self xs)

interactive :: Show a => DoubleList a -> IO ()
interactive Nil = putStrLn "Empty list"
interactive (Cons left x right) = do
    putStr $ show x ++ " (l, r)> "
    prompt <- getLine
    case prompt of
        "l" -> goto left
        "r" -> goto right
        _ -> interactive (Cons left x right)
        goto Nil = do
            putStrLn "End of list"
            interactive (Cons left x right)
        goto target = interactive target

The show function doesn’t show the left side, because that would create an infinite string. But you can use the “interactive” function to explore the list interactively.


Default argument types in C

In Uncategorized on August 31, 2009 by Matt Giuca

A thing I did not know: When you call a function in C without a prototype or with unknown arguments (for example, printf), all arguments are “promoted” to a bigger size.

Anything smaller than an int (bool, char or short) gets promoted to an int. A float gets promoted to a double. This means on a standard 32-bit machine, all variadic arguments are either 32 or 64 bits.

This explains something I’ve always wondered, which is why in printf, %f formats doubles, not floats, and %lf is the same as %f — there is no way to actually pass a float to printf, only a double. It’s different with scanf, where %f writes to a float*, and %lf writes to a double*.

Source: C language standard (ISO/IEC 9899:1999), section Function calls, item 6:

If the expression that denotes the called function has a type that does not include a prototype, the integer promotions are performed on each argument, and arguments that have type float are promoted to double. These are called the default argument promotions.


Linking C++ code with GCC

In Uncategorized on March 15, 2009 by Matt Giuca

If you’ve written C++ code with GCC, you’ll know that you need to use the program g++, both for compilation and linking. For multi-module programs, this means every .cpp file gets compiled with g++, and then the entire program must be linked separately using g++. If you try to link the program using gcc, it will almost work, but you’ll get a lot of “undefined reference” errors, like this:

test.cpp:(.text+0x11): undefined reference to `std::cout'

The need to use g++ to link the entire program causes trouble when you have a very complicated build process you don’t have full control of. For instance, I’m trying to link C++ code with Mercury, and I have to use the Mercury linker, which in turn calls gcc.

So just a quick tip: If you are forced to use gcc to link the program, just add the library “stdc++”, as you would any other library, and it will work. That is, add the option “-lstdc++” to your GCC linker command line. For example:

g++ -c hello.cpp
gcc -lstdc++ -o hello hello.o

Please let me know if there are any cases in which this doesn’t work.


What’s the deal with JavaFX?

In Uncategorized on July 20, 2008 by Matt Giuca

Apologies: This is going to be a blind, uninformed post. Maybe I’m just looking at a bad example, etc. But I’m particularly unimpressed.

Firstly: The marketing just stinks. I’ve tried to find out information about JavaFX a bunch of times. I’ve clicked through some interactive tutorials which explain what JavaFX the language is. But where are the demos? If this is anything like Flash, surely there should be cool demos everywhere to grab everyone’s attention?

I found a demo just now of a Tetris clone. Here’s what I had to do to get it running:

  1. I had to download a JNLP file and tell my browser to “Open with Java Web Start”. (So it’s not running as an applet; though I’m sure it could be).
  2. Then it asked me where on my machine I would like to store “cache files”.
  3. Then I had to wait for the applet itself to download 3 separate files. (Including the JavaFX runtime; the site explains that this file will eventually be included in JRE).
  4. Then I was presented with a security warning – the applet is not signed, and do I agree to run the app.

After all that the keys are Alt+V, Alt+M and Alt+H to move the blocks around. Surely you can capture arrow keys in JavaFX?

This is not what I have in mind when I think RIAs. This isn’t even running in a web browser. It’s basically a desktop app. What I am experiencing cannot possibly be a “flash killer”, because it just requires too much effort on the part of the user. Imagine having to download and run a JNLP file every time you wanted to watch a YouTube video! The popularity of YouTube is due to immediate accessibility provided by the Flash platform.

This just feels like Java. Perhaps JavaFX (the language) makes it faster to produce web apps (I don’t know; I haven’t used it). But to me, the battle of different RIA technologies is about the end-user experience, not the developer experience. What I see offers nothing over Java applets which have a bunch of accessibility problems that Flash doesn’t.