David Cuthbert's LiveJournal Friends [entries|friends|calendar|userinfo|calendar]

Go (not the board game) [12 November 2009|10:07pm]

mcmartin
[ mood | analytical ]

As you may have heard, a few days ago Google released a new programming language that they'd been developing for awhile. And by "they", I mean Rob Pike and Ken Thompson, both of whom were instrumental in the creation of Unix, its predecessors, and its successor. They also invented UTF-8. So, you know, there's some reason to pay attention.

As it happens, Pike gave a talk about what I suspect was the early parts of this project in a CS 343 class I took at Stanford as a grad student not that long ago.

If that's true, the answer for "why a new programming language?" is pretty clear; Google wanted something vaguely Python-like for writing their services in, but Python's famously horrible handling of concurrency and multithreading meant that it wasn't really appropriate for this.

Their new language, "Go", uses an old but reasonably well-proven mechanism for multithreaded communication. Despite being well-proven, it's almost never actually used, so in order to make this a proper language primitive they basically needed to write a new runtime from the ground up anyway. And once you do that, you might as well redesign the type system and so on and so forth, and pretty soon you have an entirely new language.

I figured that as something of a language geek I'd look at it and see what I could do with it. As it happened, I did have a project that could use it; while I was extracting karma information from Ultima IV save files (see my previous post for why I was doing that) I was using an ad-hoc Python one-liner for it:

struct.unpack("<8H", file("party.sav", "rb").read()[326:342])

Go advertised itself as being a systems programming language primarily, and binary unpacking is the sort of thing that one would normally use C for. Writing a somewhat more detailed savefile unpacker in Go might let me see more of the language in action.

It turns out that I didn't need a whole lot for this: the source code, u4scan.go, didn't really do much with the type system that a C struct couldn't handle just fine.

That said, I did get to see enough to like the type system a lot. I've never been much of a fan of OO or inheritance - my designs rely heavily on composition and what the Design Patterns guys would call the "strategy" pattern. Which is to say, my design sensibilities are much more in tune with ML or Haskell; I'm happier thinking of verbs that can act on various different nouns instead of thinking of nouns that carry verbs with them. It's all the same in the end (you get a 2D matrix of verbs and nouns), but it does influence what's easy to express.

Go takes Objective-C style "protocols" - types that are simply collections of the methods defined on an object - and pushes them as far as they will go. The result ends up bumping up against Haskell's typeclasses, which is about the strongest praise I can give. The type guarantees are much closer to Haskell's than ObjC's, though there's more declaration that needs to happen first. Go has some type inference, but it's not as good as the best inferrers. Nevertheless, it looks like an excellent combination of duck typing with static typing - ObjC's was far too easy to break.

Unlike Haskell, it's possible to break it in Go; the binary.Read function I used in the savegame scanner was able to unpack a binary file into nearly-arbitrary structures. (The requirement is simply that they be fixed-size and thus properly representative of a chunk of binary data.) Its reflection capabilities handle the rest. That made the meat of this project refreshingly easy. (I'd actually written some code using the unsafe portions of the language to convert floating-point numbers to and from their bitwise representations; it turns out that while it's not documented as being able to do this, the binary encoding package can handle floats fine.)

Go's ObjC-like use of protocols as the fundamental unit of typing extends to being able to add methods to arbitrary types (even primitives!) outside of their nominal definition, which means that I can organize things in the data-directed manner that I prefer.

As a professional C++ programmer, Go's declaration syntax gave me trouble until I realized that it was actually Pascal syntax with most of the punctuation removed.

So, yeah, as a language it's fairly nice. As a programming environment, however, there's almost no need for non-language-geeks to mess with it. It's simply not there yet. It's less there than Inform 7 was in its first public beta:

  • No foreign function interface. This would be less of an issue, but...
  • No I/O more complex than sockets and files. Interactive user interfaces aren't really in the cards.
  • No Windows compiler, since Google doesn't need one. All binaries are Linux and Mach-O (Mac OS X).
  • Even on Linux and Mac, the "real" compiler is a variant of the Plan 9 From Bell Labs compilers and so they don't use any runtime your home system will have; as a result, even Hello World is a 580KB binary and they only go up from there.

I suspect that if the gccgo subproject (which ties, unsurprisingly, into gcc's backend) gets some development, it will solve the last two problems neatly - if it works on gcc, it should work with MinGW as well.

But yeah, as it stands, fun to read about and maybe mess with, but unless you're actually part of the core development team, I can't see it being used for anything serious by anyone else for awhile yet.

post comment

I am the coolest [12 November 2009|08:37pm]

mizufae
[ music | Me and the Man in the Moon - Craig Robertson ]

Sarah: holy shit
the star trek shoes are only 50 bucks
oh wait
different ones
http://io9.com/5402793/airwalk-beams-up-new-star-trek-sneaks
http://www.fanboy.com/2009/05/to-boldly-step-where-no-fanboy-has-gone-before.html
omg the silver ones are so
silvery
Ian: ahahah
Sarah: aaaugh
the yellow shoes are SO YELLOW
if only they were TOS gold
honestly though
i want shoes that have all three starfleet colors
in STRIPES like adidas style
mmmm
Ian: would be solid
Sarah: with the command insignia embroidered on the side
Ian: I've always kind of dug the adids look
Sarah: in wilver, on black
Ian: adidas, even
Sarah: silver, too
Ian: was going to say, what the fuck is wilver
Sarah: THAT would be hands down the awesomest
wilver is like the color of a DIRE WOLF
@_@
wilver is like silver only BADASS
wilver things can be both wet and on fire at the same time
Ian: please indicate the portion of the wolf that is "wilver": http://faculty.evansville.edu/ck6/bstud/wolf.jpg
Sarah: XD
its BUTT
*points*
also you are a nerd
Ian: oh please, I saw an opportunity to make a joke by slamming "dire wolf" into google and went for it
Sarah: neeeeeeeeeeeeeerd
now i'm gonna go draw designs for star trek shoes
Ian: you have fun with that, you paragon of high school social success

EDIT: HOLY SHIT YOU GUYS THEY KIND OF ALREADY EXIST

1 comment|post comment

Hacking the Virtues: Becoming the Avatar in Five Easy Steps [12 November 2009|08:05pm]

mcmartin
[ mood | virtuous ]

I've been on an Ultima IV kick recently, since I'd never really gotten around to beating it as a kid.

If you're unfamiliar with the game, Ultima IV is unusual in that there's no particular Final Boss whose rear end you need to kick; the goal of the game is to become a paragon of Virtue and then collect and wield various mystical items to cement your status as the Avatar of the Virtues.

As you may have guessed, this also means that you get to run rampant if you decide that Virtue is for little people, and, indeed, the accidental moral of the story is that the correct way to become a paragon of Virtue is to lead a highly profitable life of crime and then use the proceeds to finance various good works.

I hadn't realized that as a kid, and so my playthroughs tended to end with me getting lost, trapped, or otherwise incapable of meaningfully continuing because my foes were far more powerful than I was and I couldn't gear up enough to take them down. I had not learned from the example of the Saga of Steve the Avatar. This is the tale of Steve, who becomes the Avatar and then has various further adventures (the saga continues through Worlds of Ultima: Martian Dreams, Ultima VII Part 1: The Black Gate, and Ultima VII Part 2: Serpent Isle) despite being a complete and utter sociopath. And yet, paragon of Virtue. Being the Avatar is awesome.

After having this epiphany, I resolved to try to set right what had once gone wrong, by going wrong where before I had gone right. And it worked pretty well, except that I noticed that my Virtues weren't quite behaving the way I'd expected them to, given what I'd seen in the Saga of Steve. So I whipped up a little program to study my save file and give me precise Virtue information as I acted. Once I had proof stuff was wrong, I went sourcediving. This is what I found.

Cut for length and spoilers )
1 comment|post comment

whoa! [12 November 2009|06:45pm]

polarbee
[ mood | full ]

From the few inches of snow that fell in town, we were really not expecting the foot that fell up by our house.

Posted via mobilebloger

post comment

US Airways Flight 1549 re-enactment [12 November 2009|11:38am]

bluepapercup
A truly exhaustive and impressively thought through re-enactment of the events leading up to and during the bird strike and subsequent ditching of Flight 1549. This is a firm specializing in accident re-enactment and they had access to passenger testimony as well as all FAA materials including the cockpit voice recorder.

http://www.exosphere3d.com/pubwww/pages/project_gallery/cactus_1549_hudson_river.html

I really recommend the radar videos, but the whole thing is fascinating.
1 comment|post comment

What I made today instead of artish things [12 November 2009|03:13am]

mizufae
[ music | C89.5 - ]


VOTE VOTE VOTE


Also an abomination )

2 comments|post comment

From Twitter 11-11-2009 [12 November 2009|02:03am]

mizufae

Tweets copied by twittinesis.com

post comment

Comic for November 12, 2009 [12 November 2009|12:00am]
dilbertdaily


post comment

In which I am an attention whore. [11 November 2009|11:10pm]

mizufae
says what it is on the tin )
THANK YOU FOR YOUR TIME
3 comments|post comment

Year 2, Day 284 [12 November 2009|01:00am]

aki
Year 2, Day 284

Year 2, Day 284, originally uploaded by mer-made.

Autumn has arrived.

post comment

Year 2, Day 283 [11 November 2009|10:47pm]

aki
Year 2, Day 283

Year 2, Day 283, originally uploaded by mer-made.

A quick crappy shot (the shots I was trying to take didn't come out at all) in Davis at, obviously, night.

post comment

Year 2, Day 282 [11 November 2009|06:46pm]

aki
Year 2, Day 282

Year 2, Day 282, originally uploaded by mer-made.

In case you were unsure. Central Square.

post comment

In Flanders Fields [11 November 2009|11:11am]

polarbee
[ mood | thoughtful ]

In Flanders fields the poppies blow
Between the crosses, row on row,
That mark our place; and in the sky
The larks, still bravely singing, fly
Scarce heard amid the guns below.

We are dead. Short days ago
We lived, felt dawn, saw sunset glow,
Loved, and were loved, and now we lie
In Flanders fields.

Take up our quarrel with the foe:
To you from failing hands we throw
The torch; be yours to hold it high.
If ye break faith with us who die
We shall not sleep, though poppies grow
In Flanders fields.
- Lt.-Col. John McCrae (1872-1918)

1 comment|post comment

From Twitter 11-10-2009 [11 November 2009|02:02am]

mizufae

Tweets copied by twittinesis.com

post comment

Inanna [11 November 2009|01:38am]

mizufae
[ music | C89.5 - ]


Click for fullsize PLZ

This is what I made while listening to the nonstop club dance radio station. What do you think? I really like it!

5 comments|post comment

Comic for November 11, 2009 [11 November 2009|12:00am]
dilbertdaily


3 comments|post comment

Year 2, Day 281 [10 November 2009|09:52pm]

aki
Year 2, Day 281

Year 2, Day 281, originally uploaded by mer-made.

The collected works of my co-worker's daughter.

post comment

Year 2, Day 280 [10 November 2009|09:45am]

aki
Year 2, Day 280

Year 2, Day 280, originally uploaded by mer-made.

Apple crisp, fresh from the oven and steaming up my lens. (I know, kinda gross looking.)

post comment

[10 November 2009|08:54am]

patpandahat
[ mood | awake ]

( You are about to view content that may not be appropriate for minors. )

post comment

[10 November 2009|02:36pm]

deadmachinery

[samogonnoeozero]
[ mood | apathetic ]



 

2 comments|post comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]