Book Review – Anathem by Neal Stephenson

Anathem by Neal Stephenson

Anathem by Neal Stephenson

Here comes the blurb:

Anathem, the latest invention by the New York Times bestselling author of Cryptonomicon and The Baroque Cycle, is a magnificent creation: a work of great scope, intelligence, and imagination that ushers readers into a recognizable — yet strangely inverted — world.

Fraa Erasmas is a young avout living in the Concent of Saunt Edhar, a sanctuary for mathematicians, scientists, and philosophers, protected from the corrupting influences of the outside “saecular” world by ancient stone, honored traditions, and complex rituals. Over the centuries, cities and governments have risen and fallen beyond the concent’s walls. Three times during history’s darkest epochs violence born of superstition and ignorance has invaded and devastated the cloistered mathic community. Yet the avout have always managed to adapt in the wake of catastrophe, becoming out of necessity even more austere and less dependent on technology and material things. And Erasmas has no fear of the outside — the Extramuros — for the last of the terrible times was long, long ago.

Now, in celebration of the week-long, once-in-a-decade rite of Apert, the fraas and suurs prepare to venture beyond the concent’s gates — at the same time opening them wide to welcome the curious “extras” in. During his first Apert as a fraa, Erasmas eagerly anticipates reconnecting with the landmarks and family he hasn’t seen since he was “collected.” But before the week is out, both the existence he abandoned and the one he embraced will stand poised on the brink of cataclysmic change.

Powerful unforeseen forces jeopardize the peaceful stability of mathic life and the established ennui of the Extramuros — a threat that only an unsteady alliance of saecular and avout can oppose — as, one by one, Erasmas and his colleagues, teachers, and friends are summoned forth from the safety of the concent in hopes of warding off global disaster. Suddenly burdened with a staggering responsibility, Erasmas finds himself a major player in a drama that will determine the future of his world — as he sets out on an extraordinary odyssey that will carry him to the most dangerous, inhospitable corners of the planet . . . and beyond.

This is an epic, awesome book.

It lays a lot of groundwork that pays off in the later parts, so the beginning is a bit slow and contains some info dumps.  But if you persevere and absorb some of the information, it all pays off at the end.

I highly recommend it.

Book Review – Blood Song: A Raven’s Shadow by Anthony Ryan

Blood Song: A Raven's Shadow by Anthony Ryan

Blood Song: A Raven’s Shadow by Anthony Ryan

Rather than summarizing the book in my own words, why don’t I let the book jacket blurb do it:

From “a new master storyteller” comes the beginning of an epic fantasy saga of blood, honor, and destiny…

“The Sixth Order wields the sword of justice and smites the enemies of the Faith and the Realm.”

Vaelin Al Sorna was only a child of ten when his father left him at the iron gate of the Sixth Order. The Brothers of the Sixth Order are devoted to battle, and Vaelin will be trained and hardened to the austere, celibate, and dangerous life of a Warrior of the Faith. He has no family now save the Order.

Vaelin’s father was Battle Lord to King Janus, ruler of the unified realm. Vaelin’s rage at being deprived of his birthright and dropped at the doorstep of the Sixth Order like a foundling knows no bounds. He cherishes the memory of his mother, and what he will come to learn of her at the Order will confound him. His father, too, has motives that Vaelin will come to understand. But one truth overpowers all the rest: Vaelin Al Sorna is destined for a future he has yet to comprehend. A future that will alter not only the realm, but the world.

Although the blurb is accurate, somehow it doesn’t convey what makes this book good, although it’s hard to do that without giving spoilers.

I really liked this book – it’s gone straight onto my list of favorites.

I was initially worried that it would be the first part of a series of books that slowly took us through the life of the main character and wouldn’t end properly, but there’s a good resolution that makes it a complete story and yet leaves the door open for the sequels.

As far as criticisms go, the author isn’t great at describing action – in fights it’s at times hard to tell who hit who.  The last quarter of the book is also arranged quite differently to the rest of the book, which makes it feel a bit uneven.

On the up side there’s some character development, a lot of world building and lots of cool twists.  I’m looking forward to the rest of the series (although I have no idea where the author will take it from here).

How to interact with a form from a background thread in WPF and VB.NET

Code

Code (Photo credit: three_sixteen)

Let’s say you’re writing a program that does a lot of work. You don’t want to have an unresponsive user interface, and you want to have the ability to abort the work part way through. You have several options – using async versions of blocking methods, making async versions of your own blocking methods, or you could do all the work on a separate thread.

Let’s say you decided to do the work on a separate thread. This makes it easy to abort the work, because you can just abort the thread.  Now you want to be able to have the worker thread report its state and progress to the main thread that owns the UI.  An easy way of doing this is by having an object that represents the worker, and having that object raise events that your form can subscribe to.

Unfortunately if you run this code, you’ll get an InvalidOperationException saying “The calling thread cannot access this object because a different thread owns it.”  The problem you have is that when your worker object raises an event, even though the event handler is in the form object it’s actually still executing in the worker thread.  Confusing, I know – things like this are why most programs don’t take full advantage of modern multi-core processors.  There’s plenty of scope for language, framework and tool makers to improve the ease of use of asynchronous programming.

In WinForms you’d call invoke on the control, passing it a delegate function that makes the actual updates to the UI.  In WPF controls don’t have an invoke method, instead you use the Dispatcher property on the control and call invoke on that.

You still have to pass invoke a delegate function to do the update, which is a pain – your one line event handler is now two methods and a delegate.  Wouldn’t it be handy if you could use a lambda to get it all on one line again?  How about this:

Private Sub Worker_State(pS_State As String) Handles Worker.State
    Dispatcher.Invoke(New Action(Sub() lblCurrentState.Content = pS_State))
End Sub

Pow.  And as of Visual Basic 2010 you can also do multi-line lambdas, so you can do more complicated event handlers like so:

Private Sub Worker_Progress(pI_Progress As Integer, pI_Total As Integer) Handles Worker.Progress
    Dispatcher.Invoke(New Action(Sub()
                                     pgbState.Maximum = pI_Total
                                     pgbState.Value = pI_Progress
                                 End Sub))
End Sub

Use it in good health.

EDIT:

Apparently there’s an easier way to do this – use BackgroundWorker which supports progress events and cancellation without needing to jump through any Dispatcher hoops.

Bret Victor is awesome

I’d never heard of Bret Victor until this video went around (viral?) last year:

Bret Victor – Inventing on Principle from CUSEC on Vimeo.

I can’t describe how inspired I was.  In the past people have talked about how inspiring speakers are, but apart from a few catchy quotes I was never blown away in the way people describe.  Until this video.

I responded strongly to the practical examples he showed, but I also took to heart the point of his talk – what am I doing with my skills?  Am I changing the world or killing time cashing a paycheck?

“The best minds of my generation are thinking about how to make people click ads. That sucks.” — Jeff Hammerbacher

Then few months later I came across an article about how programming is learned and taught and how programming languages could be designed much much better.  In a lot of ways it reminded me of the Bret Victor talk, and it wasn’t until I got to the end and saw who wrote it that I realized that the similarity was because it was also written by him.

Bret Victor is awesome.

This next bit is less uplifting.

Responding to the original video, I decided that I did want to change the world and something that I felt strongly about and might be able to affect was freedom on the Internet.  This was about the time that SOPAPIPACISPA and ACTA were raising their heads, so I thought the issue could be settled once and for all if Internet censorship etc. was just fundamentally flat out impossible.  I had the solution all designed in my head, but hesitated on investing a lot of time on implementing it because there’s no point in having a solution if nobody’s going to use it.  I really didn’t feel that anything created by one guy in his spare time could end up being the backbone of the Internet.  It turned out I was right – the solution already exists and nobody uses it.  I suppose on the up side their solution is pretty close to mine, so if I’d actually implemented it, it probably would have worked.  I guess I’ll have to come up with something else revolutionary to do.

The article on programming languages made me realize why I felt so disappointed in Go and Dart – if anyone had the resources to do something revolutionary it was Google, and instead they created programming languages that were only incremental improvements on existing ones.  It takes a lot of effort to learn a new programming language, so if you’re going to invest that much effort in something it might as well be a leap forward.

Enhanced by Zemanta

How to create an object and set its properties in one line in VB.NET

Code

Code (Photo credit: three_sixteen)

This just took me forever to find, so to help out anyone else who needs to be able to do this:

In VB.NET if you want to create an object and set its properties on one line (and there isn’t a constructor that does what you want), the feature you’re looking for is called Object Initializers and the syntax is:

Dim cust = New Customer() With {.Id = 2, .Name = "Bob"}

There’s also a similar thing called a Collection Initializer which lets you create an populate a collection on one line.  This is already possible with arrays using array literal syntax, but Collection Initializers let you do it with any collection type:

Dim names As New List(Of String) From {"Bob", "Susan"}
Enhanced by Zemanta

My scorecard for President Obama’s first four years

Shepard Fairey's second Obama hope poster from 2011, at the time of the Occupy movement

Shepard Fairey’s second Obama hope poster from 2011, at the time of the Occupy movement

In January 2009 I wrote a blog post about My hopes for President Obama’s first four years.

The unspoken assumption was that he would be re-elected for a second term, and so he would have a “first four years” and not just “four years”.  Such was the feeling of hope in the long-ago, golden days of January 2009.  Not that a Democrat would earn re-election, but that a president would be worthy of re-election.

And really, that should have been a warning sign.  Hope?  Optimism?  About politics?  Get real.

So here’s the list of things I hoped the president would achieve four years ago, along with how I think he did on each point:

Read the rest of this entry »

Will Google Chrome’s ubiquitous spellcheck/suggest improve the state of Internet grammar?

English: Content: Well-known C19th pangram The...

English: Content: Well-known C19th pangram The quick brown fox jumps over the lazy dog Category:Screenshots of Linux software (Photo credit: Wikipedia)

Google Chrome is a popular browser.  There is some debate about how popular, because these things are hard to measure.  Being advertised on Google properties helps (watch out for the FTC) but so does being secure and fast.

One of the features of Chrome that doesn’t get talked about much is that it has a spell checker built into every field you can type in.

Who cares, right?

But think about it – you no longer need to rely on whatever spell checking tool a site owner happened to install, if any.  Now you know that you have a spell checker regardless what site you’re on, regardless of whether the site owner thought you needed a spell checker.  When would you not need it?

If spell checking is everywhere then you can even forget about having it and you’ll only be reminded when you misspell something.  It’s a pleasant little surprise – “good catch, spell checker – you’ve got my back!”  Once you get used to having it, using a browser without this feature is painful.

So what happens when you combine a popular browser with ubiquitous spell checking?  A lot more spell checked emails, spell checked blog posts, spell checked status updates…

In theory, this should improve the spelling of the whole Internet.  Millions of people spelling a bit better means millions of new pieces of content that millions of other people are reading.  As they read they’re being reminded of how things should be spelled.  It has to be better, right?

Maybe.  It depends on whether people care about the little red underline.

In November 2011, the Chrome team announced that they were going to change Chrome to use Google Suggest as its spell checker.  Previously it was using Hunspell, an open-source spell checking library that many other applications use.  The problem with Hunspell (and all similar dictionaries) is that it only has a limited list of the most popular words, so regardless who you are, there’s likely to be some word you’ll use that is spelled correctly but that Hunspell says is misspelled simply because it isn’t in its dictionary.

Now who has a great big list of (pretty much) every word ever written?  Google does…  And what service already uses this data to predict words that usually go together?  Google Suggest does…  Sounds like a match made in silicon heaven.

To use the data as a spell checker all Google Suggest has to do is check the frequency of use of the word as typed versus the frequency of the word that Google Suggest says is most often used in its place in the same context.  For example if you typed “cnat dance”, Google Suggest doesn’t actually know that “cnat” isn’t a valid word – it doesn’t have a list of valid words like Hunspell does – but it does know that it is very rarely (if ever) used in reputable documents (like UN transcripts).  Then in order to determine the correct spelling it checks to see what similar word is commonly used in the same context and suggests “can’t”.

Additionally to misspellings, Google Suggest offers other possible corrections, like grammar errors.  Since these aren’t as certain and maybe not as important as spelling errors, they’re underlined in grey instead of red.  For example if you typed “cant dance”, even though cant is a valid word (that Hunspell would let go flying past) Google Suggest would point out that “can’t dance” is used a LOT more frequently.  Therefore it’s probably not correct and you get a grey underline.

The weakness of this approach is that it uses the content of the Internet to determine what’s right.  So if eventually enough people spell “can’t” as “cnat” or “cant”, Google Suggest will start thinking that’s what’s right.

So do your part – spell something correctly on the Internet!

EDIT: Apparently I jumped the gun and all of these features hadn’t rolled out yet.

Enhanced by Zemanta

Creative coincidences

Have you ever noticed that sometimes similar but unrelated things happen at the same time?

Armageddon (1998 film)

Armageddon (1998 film) (Photo credit: Wikipedia)

For example Armageddon and Deep Impact are both movies about an asteroid heading for Earth, and they both came out in the same year.  The Illusionist and The Prestige are both movies about magicians and they came out in the same year.  Antz and A Bug’s Life – animated movies about insects – same year.  Mission to Mars and Red Planet – movies about Mars – same year.  Dante’s Peak and Volcano – volcanoes – same year.

Maybe those aren’t good examples because it’s possible that one studio found out what the other studio was working on and decided to compete head-to-head with a similar movie.  I don’t know why they would choose to do that, but it’s possible.

Perhaps a better example would be that there are at least three indie games (FTL, Star Command and Starship Corporation) being built at the same time that have very similar setting and mechanics.  They’re all games where you design your spaceship and manage your crew while you fly around encountering various aliens and environmental threats.  All three have also done Kickstarter-style funding drives.  Did they inspire one another?  Did they all have some other common inspiration?1  Maybe it’s zeitgeist.

They’re so similar, it just seemed strange to me.

If we asked the creators, I bet they’d all say that they just happened to come up with the same thing at the same time.  Life’s weird sometimes.

Outside of the entertainment arena, the radio (and a lot of other things) were invented simultaneously and separately by different scientists (apparently this is called multiple discovery), so maybe these are just ideas whose time have come.

I often find that no sooner have I written down a great new idea than I find out about a movie or book or game that has done the same thing (only better).  It’s discouraging, but I don’t seem to be the only one with this problem.

Enhanced by Zemanta
  1. Star Trek? []

My second Chrome extension (sort of) – eReaderIQ Integrator

I read a lot of books.

About three years ago I bought a Kindle, so now I read a lot of eBooks.

Although books have a pretty low entertainment cost per hour, it can still get expensive to read a lot.

eReaderIQ Logo

eReaderIQ

There’s a helpful website called eReaderIQ that can track eBooks you want to read and notify you when the price drops.  This works especially well for me because I have a long wishlist of books I want to read, and when I need a new book I just take a look at the high priority items on my wishlist.  So by importing my wishlist into eReaderIQ I get automatically notified when a book I already know I want to read gets cheaper.

eReaderIQ can also notify you when a paper book you’re interested in becomes available as an eBook.  This isn’t as important as it was back before all new books came out as eBooks, but there is still a back catalog of books that haven’t been digitised yet.

eReaderIQ is great but it can still be a bit labor intensive to add a new eBook to be watched for price drops.  You have to copy the book’s ASIN or URL, open up a tab to eReaderIQ’s Kindle Price Drop Tracker and paste it in.

Kindle Paperwhite

Kindle Paperwhite (Photo credit: Zero2Cool_DE)

eReaderIQ also has price history graphs for eBooks that it’s watching, but again it takes some work to get to.  I really wanted a price history graph for eBooks – I never understood why Chrome extensions like The Tracktor and The Camelizer have price graphs for everything but eBooks.

eReaderIQ has a tools page with bookmarklets to make watching an eBook for price drops and checking their price history easier.  This is great, but I thought it could be better – clicking the bookmarklet still involved changing pages, and I really just wanted to be able to do things from the Amazon product detail page.

Since I had a bit of experience writing Chrome extensions, I thought it would be pretty easy to create an extension that embedded the price history for an eBook into its product detail page (zero clicks!) and had a page action that let you watch the eBook on the current page for price drops (one click!).  I could even make the extension determine whether the product detail page was for an eBook or a paper book and either price watch or watch for availability as an eBook automatically (still one click!).

Initially I thought I might be able to create the extension without any help from eReaderIQ since getting a price history graph should just be a matter of retrieving the right URL, and adding a price watch should similarly only require posting to the right URL.

I did an initial attempt but quickly hit a roadblock in that some of the URL parameters weren’t obvious to me.  Rather than spend a lot of time trying to work it out, I thought it would be worth contacting eReaderIQ and seeing if they were interested in helping me out.  I thought there was a chance they would be interested, because although it would mean extra traffic to their servers, it could also mean more people using their site.

I really had no idea what sort of response I would get – some companies are very insular, insist that all development is done in-house and are opposed to anyone else interacting with their site in any way.  Others are very open and allow anyone to do anything, some going as far as providing public APIs.

It turns out that eReaderIQ wanted to make a Chrome extension but didn’t have any experience with them.  We ended up collaborating and  so, the eReaderIQ Integrator Google Chrome extension was born.

I had intended to do all of the work myself so as not to take up any of their developers’ time but they were very forthcoming and added server-side code to support the extension.  In fact, by the end the extension ended up just passing information to server-side code that did all of the rest of the work.

It also turned out that inserting a price history graph into the page like The Tracktor extension does might fall afoul of Amazon’s TOS, so we decided to show it in a popup instead.  It’s one click instead of zero clicks, but that’s still very good.

I’m now working on converting the extension to a Firefox extension.  It will be my first Firefox extension, and so far… it’s a pain.  As the new kid on the block Chrome was playing catch-up with Firefox for a long time, but I have to say that going from developing Chrome extensions to Firefox extension, Firefox are now behind.

Enhanced by Zemanta

Short Story – Last day

Writing

Writing (Photo credit: jjpacres)

I wrote a short story!  Unfortunately it’s not very cheerful.  And it has a few things in it that make me nervous.  But I hadn’t written anything in a long time, so now I have.  It’s not what I’m supposed to be working on, but the advantage of short stories is that they’re short.

The whole thing just came from the first line, really, and it was flowing so well that I had to write it down or it would be lost forever.

The more I read it the more I hate it, so I thought it would be better to publish and be damned than file it forever or delete it.

I’m pretty sure I messed up some of the research.

Oh well.

Enhanced by Zemanta