Oracle Appeals Google’s Java Win. What’s next for Dalvik?

Larry Ellison points finger at Larry Page. Shakes it. Offers cookie. Redundantly.

This week, Oracle appealed Google’s win at the patent trial over the Java application programming interface (API) being used in the Android operating system.

In a new document published this week (PDF), Oracle’s lawyers start by introducing a character called Ann Droid. And then tell a story about Ann ripping off Harry Potter: The Order of the Phoenix. Quite strange, but hilarious to think of a serious legal department putting this into such an important document:

 

Ann Droid wants to publish a bestseller. So she sits down with an advance copy of Harry Potter and the Order of the Phoenix—the fifth book—and proceeds to transcribe.

She verbatim copies all the chapter titles—from Chapter 1 (“Dudley Demented”) to Chapter 38 (“The Second War Begins”). She copies verbatim the topic sentences of each paragraph, starting from the first (highly descriptive) one and continuing, in order, to the last, simple one (“Harry nodded.”). She then paraphrases the rest of each paragraph. She rushes the competing version to press before the original under the title: Ann Droid’s Harry Potter 5.0. The knockoff flies off the shelves. J.K. Rowling sues for copyright infringement.

Ann’s defenses: “But I wrote most of the words from scratch. Besides, this was fair use, because I copied only the portions necessary to tap into the Harry Potter fan base.”

Obviously, the defenses would fail.

Defendant Google Inc. has copied a blockbuster literary work just as surely, and as improperly, as Ann Droid—and has offered the same defenses.

Continue Reading “Oracle Appeals Google’s Java Win. What’s next for Dalvik?”

Learn to Code: Chapter 2 – Black Tie Function

She only wants you for your brain…

This is the third part of my Learn to Code series. The previous part is here: Chapter 1 – Meet Bob.

 

See Bob. See Bob Run. Run Bob, Run!

We last spoke about making Bob run 5 miles. We were going to do that by performing an action – a “function” in programmer parlance – called “run”, and give the number 5 (meaning the miles he is to run) to the function. We do that like this:

bob.run(5);

 

The problem is, we haven’t said what “run” actually means or does. Later we’ll use code that already exists but this time it’s all up to us. We’re going to have to write this “run” function ourselves. Again, this is a very easy thing to do once you understand the pattern you use.

function (miles) {
}

 

Here we say we want to create a “function” and that the function will take some information in brackets that we can refer to by the name “miles”. You see, when information (such as the number 5) is “passed” into the function, it is important that we can get to it because we can use it to change how the function operates. You can write a function once, but pass different things to it each time and it will behave differently every time. That is the real beauty of programming.

You will notice there aren’t any semi-colons in the bit of code above, this is because we are using a pattern that the computer will understand – those curly brackets (called “braces”) tell the computer when you’re starting and stopping to describe your function. However, when we write code inside those braces, we still must use semi-colons to differentiate one .

The devil is very much in the details when programming. Different programming languages have different requirements for WHERE those curly braces go. Sometimes they should be on the same line as the start of your function, and sometimes they go on the next line down. Like this:

function (miles)
{
}

 

But the language we are learning needs them to be on the same line as the word “function”.

Here’s an example of combining curly braces and semi-colons. Gosh it’s getting complicated… but stick with it, this is as complex as it gets. let’s write some code inside the function that uses that number 5 that was passed in, which we can refer to as “miles”:

function (miles) {
    return miles + miles;
}

 

This is now a fully-functioning function. If you’ll pardon the pun. Although… not a particularly useful one. Yet.  Continue Reading “Learn to Code: Chapter 2 – Black Tie Function”

Learn to Code: Chapter 1 – Meet Bob

You understand that, right?

This is the second part of a series of articles called Learn to Code. Click here to go to Chapter 0, “Wax on, Wax off”.

 

Learn to Code

Well done. You’re now a World class programmer! And you’ve been given a brief  by your customer who wants you to write some software for them. The following sentence is the first line of their brief to you:

“Bob is a man. He is 30 years old. He can run 5 miles.”

What a peculiar start!! But bear with me. Remember, in order to start programming, we have to fully understand the real-world thing we are transforming into some computer code. Let’s take that sentence apart and write some bullet points about what we know about Bob:

  • Bob is a “something”.  A real thing. A proper object.
  • That thing is categorised as a “man” (whatever that is).
  • Bob has something called an “age”. The value of his “age” thing is “30”.
  • Bob can perform an action known as “running”.
  • Bob can do that action for “5 miles”.

 

Sorry for all the quotation marks and playing-dumb, but all will become clear as we move through this lesson.

Like pretty much anything in the universe, Bob can be defined by a set of “properties” (like his age, height, inside leg measurement) and the actions that he can perform (like “run”). In proper programming, we call these “properties”, “properties” (hahaha, surprise! I slipped a programming term into your vocabulary!). Slightly more complex, we call the actions he is capable of performing, “methods” or “functions”, depending on which programming “language” you’re using. We’ll use the term “functions” to start with because the first programming language you’ll use demands this terminology.

The programming language we’ll start with also prefers things to start with a lowercase letter. For now, just accept that, we’ll cover why later. Let’s start by creating Bob in code.  Continue Reading “Learn to Code: Chapter 1 – Meet Bob”

Learn to Code: Chapter 0 – Wax on, Wax off

Warning! Programming might not make you rich. On a completely different topic, here’s Paul Allen’s private yacht, “Octopus”. (He’s a programmer).

So you want to learn to code? Well this is the right place. I assume no prior knowledge, except knowing how to turn on a computer, open a text editor such as Notepad, and have some idea of the operation of a keyboard. It may not be immediately obvious WHY I’m covering some of the topics in this article, but rest assured that, like Daniel-san painting fences or waxing Myagi’s car, it is all about preparing your state of mind.

Actually, while we’re on the subject of films, before you begin, make sure you watch The Social Network and The Pirates of Silicon Valley. They’re essential viewing for wannabe programmers!

 

Basic Mathematics

WAIT! Stop! Don’t be afraid, we’re only going to touch the absolute basics. Primary school stuff. Nothing else. That’s all you need!

Really? I hear you ask. Yes!! You don’t need to be a maths whiz to be a great programmer. Leave all that business to the computer!!

If you’ve ever written this:

1 + 1

…you’ve written a “program”. A program is simply a set of “instructions” for the computer to perform. Even if it’s just 1 + 1! Sure, most programs are a lot more complicated than adding 1 to 1, but at its most basic, that’s it. Easy!

Computer programming (also known as “coding”) is usually done to replace human effort with automation. The first step in any coding project is usually to break the real world problem down to its smallest parts. That way you can better understand what it really is that you’re turning into code.  Continue Reading “Learn to Code: Chapter 0 – Wax on, Wax off”

Automatic Task List in Visual Studio

Uhh… a little help?

The Task List in Visual Studio is apparently very well hidden. But if you’ve ever put a “TODO” comment in some code in Visual Studio, you’ve already started to use it! This is a feature of Visual Studio that has been around since at least VS 2005 and yet I talk to so many developers who have no knowledge if its existence!

 

Enabling the Task List in Visual Studio

Go to View, and click on “Task List”, it is usually about half way down the list. Continue Reading “Automatic Task List in Visual Studio”

Whatever You’re Good At, Graph It

Facebook’s Open Graph – connecting creepy stalkers and sexy, unobtainable femmes faster than ever before…

What are you good at? What do you, or your business, do best? Is there something you do better than anybody else? Once you have identified your specialism, turn it into a graph.

TL;DR: I predict that graphs will become the standard way of storing and sharing information. And that providing graphs containing useful information such as banking data or flight prices will end up being a thriving, trillion-dollar economy.

 

What is a Graph?

A ‘graph’ is a collection of things connected together using a common piece of information. For example, you are connected to the people on your street with a common postal code. You are connected to several tens of thousands of people across the country by sharing the same bank. And you are connected to a much larger graph of people who are Internet users.

But the ‘things’ that are connected together don’t all have to be the same type of thing. The most famous and successful graph on the planet is Facebook’s Social Graph. The social graph is a connected network of people, photos, events, likes, comments and many more things. A photo in itself is a good, monetisable, chunk of information to store (just ask Flickr!). But a photo which is connected to the people in the photo, the place it was taken, and the event that was happening, brings a wealth of context to such a simple thing as a snapshot. But graphs are about more than just things and the connections between things, the type of connection adds an order of magnitude again more information.

Continue Reading “Whatever You’re Good At, Graph It”

Common JavaScript Gotchas – Part 1

This is a gotcha. But don’t worry, Noel Edmunds isn’t anywhere nearby.

Pop quiz, hotshot, the image shows a common JavaScript ‘gotcha’ – or inadvertent mistake through incomplete knowledge of something. What exactly is happening here?

You create a simple function called “getPerson”, and it returns you a JSON object with a single property on it, “name”. However! When you come to use the “name” property, it is undefined.

How come?

 

The Amazing Solution!

I prepared this gotcha after a lunchtime discussion with some colleagues turned to the “Python” programming language (yes, we’re geeks, get over it).

One chap made a derogatory comment of Python, something like, “what kind of a programming language uses white-space as flow control?!”

The irony is, ubiquitous JavaScript is happy to use whitespace as flow control too…

JavaScript Uses Whitespace as Flow Control? What on earth are you on about, Richard? You lunatic.

It’s true! The problem with the code above is where the curly brace ‘{‘ is placed after the return statement.

 

JavaScript Gotcha!

Wrong:

<!DOCTYPE html>
<html>
	<head>
		<title>JavaScript Gotchas 1</title>
	</head>
        <body>
		<script type="text/javascript">

              		var getPerson = function () {
				return 
				{
				    name: "Bob"
				};
			}

                        alert(getPerson().name);
                </script>
	</body>

</html>

 

Right:

<!DOCTYPE html>
<html>
	<head>
		<title>JavaScript Gotchas 1</title>
	</head>
        <body>
		<script type="text/javascript">

              		var getPerson = function () {
				return {
				    name: "Bob"
				};
			}

                        alert(getPerson().name);
                </script>
	</body>

</html>

 

As JavaScript doesn’t require you to define the return type of a function (like C# does, for example), you can just simply call “return” at any point and it will end the execution of the function. This is the important part: Semi-colons in JavaScript are sometimes optional! And calling return is one of those cases!

From the JavaScript parser’s point of view, you’ve simply called “return” and then put a line break (return key on your keyboard). The parser assumes you want to return then and there and ends execution. It DOESN’T go looking around on the following lines to see if you’ve specified something to actually return!

So in-fact, the above call to “getPerson()” returns you “undefined”, and “undefined” doesn’t have anything on it called ‘name’.

Bottom line: JavaScript uses whitespace as flow control!

 

Mitigation

You can stop this from happening by always ensuring your curly braces go on the same line as the return statement (as above in the “Right” code example). In fact, in JavaScript you should always try to write your code with the curly brace on the same line as the statement that prefixes it. It’s the “One True Brace Style” after all. (Although I prefer Eric Allman indentation for everything that isn’t JavaScript).

 

    if (expression) {
        // do something
    }

 

    for(var i = 0; i < myArray.length; i++){
        // Enumerate myArray
    }

 

Etc. Etc. Etc.

In the next “Common JavaScript Gotchas” article, I will be delving into the murky depths of Type Coercion! (I bet you’re salivating at the thought.)

 

 

Google Launches Chrome Packaged Apps

Google has announced the release of Chrome version 22 to developers. The exciting thing about this version is Chrome Packaged apps: a mechanism which allows web applications to behave much more like native applications, blurring the lines between the two. Packaged apps are installed for offline use by default and also open up new low-level system APIs, unlocking access to TCP/IP, Bluetooth and USB.

New “typed data” sources also give developers new tools to interact with photos, music and other content.

Here’s more from Erik Kay, Engineering Manager, Chrome Division:

 

Continue Reading “Google Launches Chrome Packaged Apps”