Posts
  • Eric Gunnerson's Compendium

    Whither "Ask a Language Designer"?

    • 15 Comments

    Simon wrote:

    “Any chance of the "ask the designers" column starting up again on your MSN community site?”

    The answer to that question is “Yes”, I'm hoping to get something more regular than once a year up there in the near future, but I haven't said anything because we have a bit of a history of overpromising in that area.

    If you have a question that you want answered, please add it in a comment

  • Eric Gunnerson's Compendium

    A Glove Story

    • 2 Comments

    I've been working the past few nights wearing a pair of IronClad gloves. Nice, comfortable, and no problems tossing around 2x4s or sheets of plywood. I can even open a can of my favorite beverage without taking them off (okay, I'll confess, my favorite beverage is STP).

    Recommended

  • Eric Gunnerson's Compendium

    Why destructors and not just Finalize()?

    • 11 Comments

    In one of the comments, Niall said:

    “I am curious as to why the C# syntax for a finalizer is the destructor syntax. It doesn't bother me one way or another, but I am still curious.”

    So I thought I'd devote a bit of time to that question.

    Say I'm writing some code that wraps some sort of resource. Here's the code I might write if C# didn't support the destructor syntax (and the class already has implemented the Dispose design pattern:

    class MyClass: MyBaseClass
    {
        IntPtr myResource;
        ... lots of stuff here...

        protected override void Finalize()
        {
            Dispose(false);
        }

         protected override void Dispose(bool disposing)
        {
            // free myResource here...
        }
    }

    That seems pretty straightforward. What's wrong with the code?

    The answer is the reason that we have a separate syntax. Please post your answer in the comments.

  • Eric Gunnerson's Compendium

    ...unreceptive to change...

    • 11 Comments

    In my “Minus 100 points” article, Shawn took me to task for the reasons why we didn't put 'with' in the language.

    Unreceptive to change is, when I think about it a bit, probably a true statement. We are fairly unreceptive to change - it took a lot of customer feedback to get us to change our stance on accessibility for properties. I don't think that is necessarily a bad thing - I think the best languages were designed either by a single person or by small groups, and I'm not a big fan of languages designed by committee (Ada comes to mind...). The C# Language Design Team is a benevolent dictatorship - we all have our say, but Anders is the overall custodian of the language design. I think that's important if a language is going to stay true to its philosophy.

    On a specific issue, we might appear unreceptive for a number of reasons.

    The first reason is that your request is probably not the first time we have heard such a request. We do take note of them (see property example above), but in most cases we've already spent a considerable amount of design time on the issue (by that I mean hours). In the case of 'with', we looked at what other languages had done, how well the construct worked, and then made the call on whether we thought it would be good to add it. We have a considerable amount of language design experience and familiarity on the team, which means we generally know the prior art fairly well. I'm sorry if this comes of as arrogant at times - we're working at doing a better job of communicating in this area.

    'With' was a very conscious decision, especially because it's present in both Pascal and Delphi, Anders' previous babies (okay, Pascal was really Wirth's baby, but Anders was involved with one of the more popular variants).

    As I said, we might choose to add it in the future, but given the divided nature of the customer feedback that we get, it's likely that we'll stay where we are.

    Eric

  • Eric Gunnerson's Compendium

    Funny post about google searches

    • 4 Comments
    Rory Blyth posts these thoughts about google searches...
  • Eric Gunnerson's Compendium

    Minus 100 points

    • 26 Comments

    When I switched over the C# compiler team, I had hoped that I would be able to give some insight into how the design team works, what decisions we make, etc. Language design is a very esoteric field, and there's not a lot written about it (though “Design and evolution of C++“ is a pretty good read). I had hoped that I would be able to do this with concrete examples, as that makes it much easier.

    I've been watching for candidate topics to write about, but haven't yet come up with any good ones. One of the problems is that features have a tendency to morph in design (and in whether they'll make it into Whidbey) as time goes by, and it would be bad for me to say, “we're talking about doing<x>“ and then have us decide it wasn't a good idea. Or, for us to decide that <x> doesn't fit into our schedule, or it would break existing code, or any of the other reasons that might cause us to pull a feature. We're generally not comfortable really talking about those things until the feature is in somebody's hands.

    In lieu of such an example, I've decided to write something a bit more abstract about how we look at things.

    ******

    I've been spending a lot of time answering customer questions about why we do (or don't) have certain language features in C#. (as an aside, yes, we will be getting more of this online on the C# dev center).

    In some of those questions, the questions asks why we either “took out” or “left out” a specific feature. That wording implies that we started with an existing language (C++ and Java are the popular choices here), and then started removing features until we got to a point where we liked. And, though it may be hard for some to believe, that's not how the language got designed.

    One of the big reasons we didn't do this is that it's really hard to remove complexity when you take a subtractive approach, as removing a feature in one area may not allow you to revisit low-level design decisions, nor will it allow you to remove complexity elsewhere, in places where it support the now-removed feature.

    So, we decided on the additive approach instead, and worked hard to keep the complexity down. One way to do that is through the concept of “minus 100 points”. Every feature starts out in the hole by 100 points, which means that it has to have a significant net positive effect on the overall package for it to make it into the language. Some features are okay features for a language to have, they just aren't quite good enough to make it into the language.

    A feature like expression filters in VB is in this bucket. Yes, being able to put a condition on a catch is somewhat more convenient than having to write the test yourself, but it doesn't really enable you to do anything new.

    Being able to have property accessors with different accessibilities was another example of this. We had some experience with users being able to specify different levels of virtual-ness (virtuality?) on different accessors in an early version of the language, and it was a really confusing feature, so we elected to remove it. We felt similarly about differing accessibilities, and so we left it out of the 2002/2003 versions of the language, but we got *so much* feedback from customers that we re-evaluated the utility of the feature, and decided to add it to the language in the Whidbey version.

    One can argue that we should perhaps have come to that conclusion earlier, but I don't think that being cautious is a bad thing when doing language design. Once you add a feature, it's in the language forever.

    I should also probably note that this isn't the only reason features don't make it into the language. Some features provide enough utility in the abstract, but when we go to come up with a workable design for the feature, we find that we can't come up with a way to make it simple and understandable for the user. That means that in some cases we like a feature in the abstract, but it's not in the language.

    There is also another class - features that we don't want to get near the language. But that would be another post.

  • Eric Gunnerson's Compendium

    New Toys

    • 4 Comments

    For the holidays, I picked up:

    • A Taiyo edge R/C hovercraft. A real-live hovercraft with all the maneuverability and controllability of a real hovercraft (ie not a lot). Lots of fun, but it's really hard to drive. Though the drive fans reverse, if you really need to turn around and thrust in the opposite direction. Downside - the batteries only last about 10 minutes.
    • A “super bowl“ Electric football. Electric, not electronic. I never owned one myself, but some of my friends had them. The current version has updated teams, but still the same old buzzing playfield and the same old somewhat randomized movement (a bit like junior-high football). It will be travelling to work to amuse my co-workers (“wow, that's almost as boring as Pong...“).
    • A Rush in Rio DVD, which I have not yet had time to watch.

    I also bought (for myself) a Zilog Z8 Encore Development Kit. This is either destined for a future holiday light project, a linear motor (I'd like to build a “marble-track“ like display, but I want it to run automatically and I don't want to build a chain-style lift. Or, perhaps something else.

     

     

     

  • Eric Gunnerson's Compendium

    Holiday Letter

    • 12 Comments

    Every year, I attempt to write a humorous holiday letter. Here's the 2003 edition, for your perusal - and with any luck, enjoyment.

     

    Holiday Letter Reloaded – Gunnerson 2003

    Now with 30% fewer laughs!

     

    I hope you are well during this holiday season. I had resolved after last year that I would attempt to write something humorous every month (note that I’m not saying that I would write something humorous, merely that I would attempt to), but like most resolutions, I didn’t keep to it, so I’m pretty much starting from scratch, and I’m late.

    Our New Arrival

    On July 15th we welcomed a new 6 pound addition to our family. Now, you can say what you want about pets. Go ahead, I’ll wait. Done? Okay. As I was saying before you interrupted, pets provide a lot of benefits, but you can’t deny that they can make things a bit messy (yes, go ahead and deny it, if you must…). Our two cats (official motto: “eat, sleep, poop, and shed”) certainly bear that out.

    While I’m not looking to replace them, it would be nice to have a pet that provides companionship and entertainment, but is a little lower maintenance. Or – let’s dream a little – perhaps one that actually makes life easier for you.

    Enter Alfred. Alfred is our roomba. Unless you spend your time as inefficiently as I do, you probably don’t know that a roomba is a robotic vacuum cleaner. Set it down, turn it on, and it vacuums a room for you.

    Now, some may think that a robotic vacuum cleaner is not a true pet. They are wrong.

    Top 8 Reasons why Alfred qualifies as a pet:

    1.      It has a name.

    2.      If you leave things out, it messes them up.

    3.      It’s unpredictable. Have you ever sat and watched a cat play with a feather for 15 minutes. That’s nothing – you’ll find yourself following your roomba around, wondering what it’s going to do next. For half an hour.

    4.      It knows when it’s messed up. One day, after it broke a picture that I had stupidly left out (see reason #2), it went into our room and hid under the bed.

    5.      You remember the whole pet rock thing, right?

    6.      You can get college credit for studying them

    7.      You force other people to watch it do tricks. Now, some say that “clean” isn’t much of a trick, but when the other residents of the house can only perform “run away and hide” and “yowl until you feed me”, I say that “clean” starts looking pretty good.

    8.      When it does something cute, you take pictures of it.

     

     

    Equine Insanity  (Equinsanity?)

    Loyal readers may remember that last year Samantha took up horseback riding. Kim and I had a long discussion where we came up with some ground rules around Samantha’s interest, including the very important “we will not buy a horse” (craftily phrased as, “You could ride all the poor horses that other people don’t have time to ride?”).  This worked will for several months, until Kim started taking lessons. Now, the house is carpeted with tack catalogs, and dinner conversation revolves around ‘cantering’. This has me more than a bit concerned. Two bits, or perhaps even three bits concerned.

    To be fair, Samantha has started learning some of the things that should one day make her a crackerjack stablehand (ie “somebody who earns her lessons”). She’s starting with the simple things, like getting horses tacked up, brushing them, washing them, but my guess is that in 6 months, she’ll be replacing their shoes and driving them to the vet for checkups. As long as I don’t have to buy a horse trailer.

    Crisis Planning

    As many of you know, next April I will be 40 years old. Though only ¼ of the way towards my planned lifetime of 160 years, it is a major milestone, and the traditional age at which the male of the species has a “mid-life crisis”.

    I don’t want to be unprepared for this, so I’ve decided to take the bull by the horns, avoid the dilemma, and give the horse a drink.  My crisis will “push the envelope” enough to make people doubt my good judgment (perhaps that doesn’t really push the envelope…) while still carrying a reasonable chance that, with a good lawyer, jail time will be minimal.

    It wasn’t easy coming up with something, as doing so clashes with my innate laziness.

    Fate smiled on me, however, in the form of a bonus I got from my job. Not a monetary bonus, nor a fruit basket, nor even a commemorative “thanks for showing up for the last 5 years” clock, but an extra 20 pounds, courtesy of stress and a hectic schedule. (To be fair, my “eat ‘til bedtime” diet probably didn’t help).

    If I worked things right, I could kill two birds with one activity. Bicycling would meet the fitness goal, but I had to figure out how to make it meet the “poor judgment” requirement. It turns out you can do this if you merely gradually escalate the “Insanity quotient” to the proper level. Read the following items, and my guess is that you’ll hit that point by the third one…

    1. Riding for an hour at lunchtime.
    2. Riding to Bothel and back on a sunny summer day.
    3. Adding extra steep hills to your 30 mile ride for “fun”.
    4. Riding the 56 miles it takes to go Lake Washington on a windy day.

    This approach was quite successful, with about 600 miles of riding during the summer, culminating in a 66 mile ride in early September. It’s not clear, however, if it counts towards your crisis if your wife and daughter ride 44 of those miles. I’m still waiting for the sanctioning body to rule on that issue.

    Doctor in the House?

    Samantha and I are very proud of Kim’s performance in school this year. She’s getting good grades in all her classes, and though she still has problems with her language at times, her deportment has improved noticeably. This year of classes will be followed by research, a dissertation, and exultation, if everything goes right.

    That’s all for now. If you want to keep track of what I’m up to, you can read my weblog at http://weblogs.asp.net/ericgu. It’s a combination of job related items and some of my other hobbies, such as really bad jokes.

    Eric, Kim, Samantha, Tastrophe, Earl, and Alfred


    The Challenge

    It was a typical hotel room, with a typical bathroom, except for a small placard:

    Together we can save millions of gallons of water from chlorine and detergents

    You decide

    Leave towels you wish to re-use hung up or on the rack

    Towels you leave on the floor will be washed.

    Conservation takes care of everyone

    Help us make a world of difference

     

     

     

     

     

     

     

     

    I had to help. Millions of gallons were at stake.

    After I showered the first morning, I dried off, and then went to hang my towel. Intrigued by the obvious lack of a towel rod, I carefully searched the bathroom to determine where to hang my towel. Did I miss it, distracted by the attractively arrayed display of toiletries? No. Time to re-consider...

    Obviously, the placard wasn't interested in working with people who gave up easily, but rather with those who could operate in a towel rod-hostile enivironment. The secret had to be one of camouflage. There was a towel rod, but not an obvious one.

    Once I realized that, the solution was easy. I put my towel over the shower curtain rod, and confident in success, I exited the area.

    I returned several hours later, only to find that my towel had disappeared. What had gone wrong? I retraced my steps, and realized my error. In my haste, I had ignored the regulations, and had neglected to arrange the towel to maximize the evaporation coefficient. I went to sleep, confident that the next day would bring success.

    When the time came to try again, I carefully draped my towel over the rod, arranging it in the proper manner. Before leaving I performed a standard towel check, and everything was fine.

    I returned that afternoon only to find the towel gone again. Knowing that my procedures were correct, the only alternative was that I had  misunderstood the directions. As I re-read them, there it was, staring me in the face. That morning I had draped my towel over the curtain when I was supposed to have hung it instead. That had to be it.

    That night, my mind was in turmoil. Would I be given a third chance? If not, would I be responsible for the wastage of millions? Could I live with myself if that happened?

    Sleep came with difficulty.

    I was jittery that third morning. I left the towel placement for the end, so I wouldn't mess it up accidentally. I don't know how it happened, but I left the room, leaving my towel lying on the floor. My lack of attention to detail sealed the fate of many gallons.

    I now must live with my failure.

     

  • Eric Gunnerson's Compendium

    LOTR Review

    • 7 Comments

    This afternoon, the C# team went to see LotR: Return of the King. I should preface this by saying that I'm not a big Tolkien fan (or a fan of fantasy in general). Note: There are some spoilers in this post.

    It's not a bad film, but contrary to Scoble, I don't think it was very good. Here are my issues:

    • There was enough fluff to cut this down to 2:30 from 3:00 hours, easy. The first hour had very little action and could have been trimmed down without affecting the movie
    • The movie has 4 endings, all with pull-back shots and stirring music. First, the bad guys are vanquished. Then Aragorn (sp?) becomes king. Then, the hobbits return to the shire. Then, Frodo leaves. Then Sam has a final scene. 5 endings.
    • The military tactics are pretty poor. You have a bunch of trebuchets on your fortress, but you let the enemy attack you for 15 minutes before you start using them. You have a force attacking your front gate, and all you do is crouch inside, waiting for them to break through. Where are the platforms to drop burning oil on your attackers? Where are the murder holes in the gatehouse? Where are the arrow loops? Could you at least put some of your archers on the top of the wall?
      Or if your cavalry is decimating your opponent and you're confronted by warriors mounted on huge beasts, do you use your superior mobility to continue to rout the footsoldiers, which will be easy because they've broken? No, you stop chasing the footsoldiers, and instead try to attack the huge but slow beasts. Stupid.
      It always bothers me when people do stupid things in movies.
    • Too many confused fighting closeups.

    If you're a bit LoTR fan, this may not bother you.

     

  • Eric Gunnerson's Compendium

    SpaceShip One breaks the sound barrier

    • 2 Comments

    Burt Rutan is a national treasure. Scratch that. Burt Rutan is a global treasure.

    Rutan, the designer of the Voyager aircraft that circumnavigated the world on a single tank of gas.

    His most recent project at Scaled Composites is an attempt to with the X Prize, and has once again come up with a very innovative design. In their most recent test flight, SpaceShip One became the first private non-government vehicle to break the sound barrier, on a short (15 second motor burn) that took it to Mach 1.2 (930 MPH) and 68,000 feet.

    The press release is here.

  • Eric Gunnerson's Compendium

    My lights are done...

    • 12 Comments

    delta a few miscellaneous strings that will go up in the next day or so, my holiday display is complete. I think I'm up to about 4000-5000 lights so far.

    There are three main displays:

    Santa and the Sleigh

    An animated Santa, run by an 8-channel homebuilt animation controlling sporting a Motorola HC11 microcontroller. Santa has 6 blue landing lights that flash, then Santa, sled, and reindeer appear, and then Santa goes up on the roof.

    Santa in the day

    Sleigh and reindeer from behind

    Rooftop Santas

    Santa at night

     

    Going up the roof

    Up on the chimney

    Tree O'lights

    The tree of lights is just that, a tree made entirely of lights. The controller is the same system as before, but this time it's running a 16-channel system.

    Tree in the daytime

    Hooking up the lights

    To see the tree in action, look at the whole-house view pictures at the bottom.

    Multi-colored house lights

    This grew out of my observation that having single-colored house lights was boring. So, the house is outline with a “light cable“ made of 4 different strings of lights - one each of red, green, blue, and white - hooked up to a special 4-channel controller (once again, based on the 68hc11) that supports dimming. The house is green one minute, blue the next, with a few chaser light effects thrown in. Here's what the controller looks like:

    I took some AVIs of Santa and the tree, but they didn't come out too good and are too big to fit on my website, so you'll have to satisfy yourself with a view of the whole yard.

    The balls of light in the foreground are 100-light balls that are hung on a 30' spruce in the front yard. The tree of lights is the huge blaze of light on the left side. Oh, and the large white light above the tree is the moon, which I ordered special for the night.

    Here are directions if you're in the neighborhood.

  • Eric Gunnerson's Compendium

    Garden d'lights 2003 - Bellevue Botanical Gardens

    • 6 Comments

    Every year, the Bellevue Botanical Gardens bring out the lights. They do a wonderful job of creating plants out of lights.

    Recommended.

  • Eric Gunnerson's Compendium

    Review: Space - A Journey to our future

    • 3 Comments

    Today, I took my 9 yo daughter and a friend of hers to the Pacific Science Center, to see the “Space” exhibit. The girls liked it, but I'll only give it a C grade.

    Highlights:

    • A functioning IR camera with a display screen, but with no useful instructions with what to show. I had to take the girls in front, show them how their fingers were cooler than their hands, and then have them unzip their coats to see how much hotter their bodies were.
    • Some interesting exhibits (a moon rock, a mars meterite)

    Lowlights:

    • Very disappointing age-appropriate displays. You want to show kids the different kinds of planetary probes, so you display them with the names of the missions. As if kids have any idea (for example) the difference between Viking, Magellen, etc. Even worse, for earth-orbiting satellites, you list the names of the satellites.
    • A 'trip to mars' section that is, in my mind, a total waste of space. First, you walk down a tunnet to a martian-like surface (okay), where a person directs you to touch an actualy martian meteorite. Okay, that's a bit cool, but there wasn't any depth beyond that. You then go into a 10 meter wide simulation of a martian colony. In cubbies on the side, it has a) a sleeping bunk, b) a fake galley, and c) a two-station computer where you fly an ROV over to investigate “interesting sites“ and shoot probes at that. A very bad video game with no obvious reason and no science tie-in.
    • Too much money spent on shiny and clean exhibit design. Too little money spent on people who understand education and making a subject interesting.
    • A “space bike“ simulator, with three recumbant bike-things like spokes in a wheel. You like down, buckle in, and then the machine spins around which you watch an LED display above your head that displays only “0000“, so you don't get sick. You can pedal if you like, but it doesn't do anything, so I have no idea why they bothered with the pedals. Two minutes, and then you're done.
    • A mock-up of a Saturn V stage, with some well-done launch pad effects and some sonic effects as well. And the point was?
    • Here are the pathetic teacher's resources for the exhibit.

    Overall, a huge waste of effort.

    As part of the Space them, their are showing “The dream is alive” and “Destiny in space” in the IMAX theater. We went to Destiny in Space, which is undoubtably the worst of the IMAX space films. IMAX films do best when they stay close to an actual action, but this film spends tons of time on poorly-explained planetary eye candy.

    We also saw two demos - one on supercold (liquid nitrogen), and one on combustion. Both were far better than the space exhibit.

  • Eric Gunnerson's Compendium

    Here there be tigers - operator overloading and conversions

    • 5 Comments

    I came across a discussion in the last few days that I thought I would share with you. It concerns the following code:

    class Utility
    {
        public void Process(object o);
        public void Process(string s);
    }

    and then a call to Process that passed in a string.

    C# does permit this sort of overloading, and it has some complex rules (see 7.4.2.2 in the spec for the details) to decide which is the better conversion, and therefore which function will be called. The rules are complex - I wrote our compiler conformance suites for this, and I still have to diagram it to get it right.

    It's string here, which probably didn't surprise anybody. For classes, the rules will prefer the more-derived/more-specific type.

    But what about the following:

    public void Process(int i);
    public void Process(uint j);
    ...
    ushort x = 55;
    inst.Process(x);

    Which method is called?

    The answer is “Process(int i)“, and this happens because, the language always prefers conversions to the signed types over conversions to unsigned types (a preference one way or the other is required to make things coherent in the presence of both signed and unsigned types).

    Behavior like this can be more than a little confusing to users of a class. As language designers, we have to make sure that there's a well-defined behavior in cases such as these, but that doesn't mean that you have to create such cases.

    My advice:

    Think deeply before overloading on two types that have conversions defined between them. If you do need to overload on numeric types - say you're writing something like String.Format - then you need to overload on all the types.

  • Eric Gunnerson's Compendium

    Lost our lease - Everything must go!

    • 1 Comments

    As part of a consolidation move, my blog is migrating to http://weblogs.asp.net/ericgu (RSS). The new blog is up and running, so I'm going to start posting there instead of here. The existing content will get migrated over at the end of the month.

    I've only played with it a bit, but I think that I will like .Text better than Blogx. The huge advantage already is that I can set it up so that I get email on comments, so now you'll know that if you don't get a response, I'm ignoring you, where before, you couldn't be sure.

     

  • Eric Gunnerson's Compendium

    A Devil's Chaplain and courteous disagreement

    • 6 Comments

    I just finished reading “A Devil's Chaplain” by Richard Dawkins. Dawkins is one of my absolute favorite science writers, both because of his perspective (it's easy to like authors you agree with) and his phenomenal writing style. Dawkins holds the Simonyi Professorship of Public Understanding of Science at Oxford (yes, that Simonyi), which I believe lets him do whatever he wants.

    If you have never read “the Selfish Gene”, do so. Before I read it, I had a fairly good understanding of evolution, but Dawkin's approach (from the perspective of the gene) made it much more clear to me. Organisms are just machines that genes build to get themselves reproduced (okay, that's probably an oversimplification...) Dawkins also coined the word “Meme” in this book.

    But enough digression...

    A Devil's Chaplain is a collection of various writings that Dawkins has done over the years, and since the items weren't meant to go together, it is uneven in places, though still quite interesting. But I want to talk about one section in particular, the section that contains his reviews of books by Stephen J. Gould, who died in May of 2002.

    Gould and Dawkins could be described as “the monsters of evolutionary biology“, both for their scientific contributions and to their books. But they have a very real disagreement on how some of the evolutionary mechanisms work (*not* a disagreement on the basic mechanisms, as some have claimed). So having them review each other's books gives a very interesting perspective.

    What is wonderful about Dawkins' reviews of Gould's books is that the way that he manages to disagree with what Gould says while still giving Gould the respect that he reserves, both for his work and for his writing. It's so rare to see such civilized disagreement in our society, which makes it so striking.

    So, in sum, a decent book, but read “The Selfish Gene“ or the “The Blind Watchmaker“ first.

     

  • Eric Gunnerson's Compendium

    Welcome... Again...

    • 5 Comments

    My blog is now in its new home on asp.net. I have mixed feelings about the move.

    While it's different, it's already clear that .Text is a better solution than BlogX was, and has people actively supporting it. But I'm unhappy about two things:

    1. I lose my google redirection for a few months
    2. I'm going to have to pony up for technorati to track this new blog.

    The archive will remain at http://blogs.gotdotnet.com/ericgu for a while.

  • Eric Gunnerson's Compendium

    Strong AI, and back to the moon...

    • 7 Comments

    Rory wrote a post about strong AI and whether we should spend money there rather than going back to the moon. I started writing a comment for his blog, but then decided to write my own entry.

    I don't know if you were around during the 80's, but there was a big push towards AI during that decade. The buzz was that the Japanese were going to "eat our shorts" (though I'm fairly sure that phrase was yet to be invented) in this area.

    There was a lot of money spent there (perhaps not $15B, but my guess is that it might have been $1B), but very little result.

    I think it's because AI is just a very difficult problem.

    To comment on the space side, scientific exploration aside, I think the best goal to push for is solar power satellites. There are some PR issues (with microwaves), but the technology is well understood, and once they were there, using them as a source of power would have very little environmental side effects (though waste heat would still seem to be an issue). I don't see how the developing countries can become developed without huge increases in total energy consumption, and the only other reasonable option is nuclear. Nuclear has very low environmental impact and is cheap enough if done well (and we know how to do it well, though we haven't yet), but is a very hard political sell, both from the "no nukes" perspective and the prospect of further nuclear proliferation. On the other hand, if a country like China (which already has nukes) wants to build reactors, I think we should do our best to help them build good ones (like this or this), and we should consider whether we can make a reactor proliferation proof. But, back to the space topic...

    Indirectly, I do think that building SPSs makes an argument for going back to the moon. The big problem with SPSs is the huge expense in building them. The issues are:

    1. Photovoltaics are expensive
    2. Launch costs are astronomical (pun intended).

    There are starting to be some approaches to #1 that may yield lower cost cells, but they aren't quite there yet. You could use something else for #1 (like a solar furnace), but that seems more finicky to me.

    The second problem is harder to solve. You can like get a 10x reduction over current expendables if you go simple and you launch all the time. You might get a lot more with a space elevator (assuming that you can truly build one). But the simplest way is to not lift from the earth, but to mine lunar materials, and build the SPS components either on the lunar surface or in space.

    Problems? Well, you would have high-tech with people in an extremely remote and expensive place to get to. That would require some very smart planning.

  • Eric Gunnerson's Compendium

    Troubleshooting holiday lights

    • 7 Comments

    I spent a fair bit of time putting up my lights this weekend, and had to do some troubleshooting sets that weren't working.

    This can be tough to do without a bit of help. While many bulbs have shunts that prevent the string from going out, they don't always work, nor do they help when lamp wires break.

    When that happens, I fall back on a non-contact voltage detector. Mine is a Fluke VoltAlert 1AC, which I bought at Home Depot for about $20. This is wonderful for general electrical work, since you can detect hot wires without having to have access to the conductor. Great if you're replacing an outlet and you want to make sure that the power is really off.

    For holiday lights, here's the way you find the bad lights.

    Find which section of lights is off (duh). This may be only half of a 100-light string. Start at one end of the string, testing each light, working your way along the until you find a difference in state. Test the light by holding the tester near the bulb part; if you get too close to the cable part, you'll get a positive from the traveler wire that's in the cable. I generally like to start at the end where there is power. The bad bulb will show power to it, but because it's bad, it won't be passing on power to the next bulb in line.

    One little note. Most plugs on US devices are polarized - the two plugs are different in size - for safety purposes. This ensures (for example) that a lamp socket has the hot lead for the tip, so that if you change a bulb without turning the light off, the screw part will not be hot. Most holiday lights, however, don't have this issue, so they're generally not polarized. This means that you can turn the plug around 180 degrees, and switch the hot and dead sets of bulbs in your broken set, which can sometimes make things more convenient.

    One final note: It's a lot easier to do this before you put the bulbs up on the roof, or 25' into the air.

     

  • Eric Gunnerson's Compendium

    Unmanaged objects and memory usage

    • 6 Comments

    I few years ago I wrote a small utility class named Win32Window, so that I could write an automated tool to close down some of the dialogs that would appear whenever outlook lost a server connection (which was often, since it happened whenever I opened or closed my laptop). It wraps some of the high-level Win32 window handling functions. As part of that, I wrote a couple of routines to do screen and window capture, though I've never really used them.

    Yesterday I got an email from someone who was using the routine for real, and it was eating his system's lunch (not actually the term he used, but words to those effects). It's always unfortunate when a poorly-coded sample makes it out into the wild. One would hope not to have any of those, but I learned in writing my book that a) It's not possible to be perfect on technical details, b) that if you cover enough details, you will make some mistakes, and c) some of them will be howlers, and make people think you are a total moron.

    I was hoping this case wouldn't be that bad.

    I opened up my project, modified my test app so that it would capture screenshows on a timer, started up perfmon to look at the .NET memory counters, and set it running, with one screenshot ever 100 mS. Though the counters on perfmon barely budged, in about 15 seconds things were getting slow, and soon after that, things got *really* slow - so slow, that I had to reboot.

    In looking at my code, I found that I hadn't released some of the unmanaged graphics items, but fixing that issue didn't change the behavior at all. I switched to watching the normal (ie not .net) memory counters, and found that they went up a big chunk every time I did a screenshot.

    I played around with the excelled CLR Profiler, but the current problem with the CLR profiler is that it doesn't have a very good delta view, and it's optimized for looking only at managed objects, not managed wrappers, which tend to be small in the managed world but big in the unmanaged world (think of a bitmap. On the managed size, there is a single IntPtr reference to the unmanaged object, which might easily exceed a megabyte in size). So, I didn't get anywhere with it.

    I next added a "CLR" button in my app, to call:

    GC.Collect();
    GC.WaitForPendingFinalizers();

    If my hunch was correct, this would find that managed object and finalize it, and the memory use would go down. That proved to be correct, which led me on a hunt further.

    The final issue was actually two issues. First, I wasn't freeing a Graphics object that I should have. Second, I had code that was something like:

    desktopWindow.Image = Win32Window.DesktopAsBitmap;

    which works fine, but has the side effect of never disposing the current bitmap.

    But I thought managed code meant I didn't have to think about such things...

    Unfortunately, this is a case where our current solution doesn't work very well. In an ideal world, the GC would have cleaned up after those huge bitmaps, but unfortunately, it has no way of knowing how expensive the underlying unmanaged objects really are, so I could allocate tons of new Images with creating enough memory pressure to force a GC to occur. That's somewhat unfortunate.

    The fix for the second issue is to call dispose on the old image. That gets me back to a steady-steate situation. The code will make its way up to the GDN archive in the next few days; if you're using this code, drop me a line and I'll send you an updated version.

  • Eric Gunnerson's Compendium

    How do you look for code?

    • 59 Comments

    Another question, this time from one of the other PMs on the team:

    The C# team is trying to understand how you look for code when stuck or trying to learn some new technology. Currently the solution we provide is in the documentation – you can find among other things -

    • Walkthroughs on the product
    • Documentation for each method
    • How to articles that target specific tasks
    • Code snippets
    • Working pieces of code that we ship in the product that do a specific task.

    How do you try to find code for a task that you don’t know how to write? Is the Help content in VS organized well and is it adequate? What would you change to help people ramp up on new code, tasks, or the capabilities of the tool faster? What annoys you about the samples we provide today?

     

  • Eric Gunnerson's Compendium

    The Mad Scientist's Club

    • 3 Comments

    The year is 1974. Disco was at it's height (or depth, depending on how you look at it).

    And I was reading a book by Bertrand Brinley called The Mad Scientist's Club. I has a story of a bunch of boys who have various adventures and make their townspeople look foolish.

    I loved it. Unfortunately, I lost the book.

    Last year, I thought of it again, and found a website run by one of the children of Brinley. I bought a copy of The Mad Scientist's Club and "The new adventures of the mad scientist's club", and introduced them to my 9-year-old daughter, who loved them.

    Definitely recommended if you have kids. I just ordered the prequel ("The Big Kerplop") to give to my daughter as a holiday present.

     

     

     

  • Eric Gunnerson's Compendium

    Floating Point Arithmetic

    • 5 Comments

    Waaaaaay back in college, I spent some time on queueing theory (you know, Poissan distributions and all that). The most surprising part for me was that a random distribution of arrivals pretty much ensures that you will have clusters that are very busy, and times when you are totally idle. Once you work on the math a bit, you understand why, but our commonplace notion is that "random" should be "smooth".

    Incidentally, this also explains why it's so hard to determine whether environmental factors are causing health issues. You can't just look at a cluster of cancer cases (for example) and surmise that there is something causing it, since a random distribution will give you clusters. So you have to do some fairly sophisticated mathematics to determine whether the cluster is due to random chance or whether there is something else going on.

    If the average person understood this - and they could with some very simple experiments - it would help science understanding immeasurably. Humans are programmed to extract patterns from data, and it's not surprising that we see patterns that are really just random chance.

    So, once again, I've digressed a bit, but I assure you that this really does have something to do with floating point arithmetic. The point of the journey is not to arrive...

    I was talking about clustering, which brings us to the topic of newsgroup questions. It's not uncommon to not get a specific question for 6 months, and then get the same question 3 times in a week. The question for this week is "I'm doing something mathematical, and the answers are wrong."

    The problem usually has to do with the fact that the person asking the question doesn't understand that floating point is an imprecise representation. I got this drummed into me long ago in my numerical analysis class, where I learned (and promptly forgot) all about poorly conditioned matrices and the like.

    Back, once again, to the topic.

    The canonical discussion of FP arithmetic (for this audience, at least) is a 1991 paper by David Goldberg titled "What Every Computer Scientist Should Know About Floating-Point Arithmetic"

    Even if you know a fair bit about FP math, there's a lot of good stuff there.

  • Eric Gunnerson's Compendium

    Barbecued TurkeyAlt

    • 7 Comments

    Reading Chris Anderson's post about Deep Fried Turkey got me thinking...

    I've been barbecuing turkey for about 5 or 6 years now, and in the spirit of sharing, here's my recipe:

    Supplies

    • Bird, 1, large. We generally have a lot of people over (~15), so this means somewhere around a 22 pound bird. I prefer a fresh turkey over a frozen one, but it's up to you.
    • Grill, Weber, charcoal, 22" size. Some people use gas barbecues, but I'm very much a traditionalist. It helps if it has the fold up edges so you can get under the grill easily.
    • Briquets. I'm a Kingsford man. Some swear by chunk charcoal, but I prefer briquets.
    • Roasting tray, 8" x 10"
    • Thermometer. You can use a normal dial-indicator kind, but I prefer a remote digital one. If you use a dial one, cover the dial with aluminum foil.
    • Wood chips. Turkey has a fairly mild flavor, so you want a subtle wood. I usually use a fruitwood, like apple or cherry. This year, I used alder (because I forgot my apple wood and had some alder logs), which my wife liked better but I didn't like quite so much. You want to avoid strong woods, such as mesquite, or hickory (my least favorite wood).
    • Two "turkey lifter" thingies. Look a little like goalposts.

    Recipe:

    1. Prepare the bird. At the minimum, you'll want to remove the "yuckola blobs" from the inside. Some people like to brine their turkey before hand. I think it helps a little in moistness, but the barbecue will give you a fairly wet heat anyway, so it's not that much of an issue. Rub on butter and add salt/pepper as desired.
    2. Start around 30 briquets.
    3. Put the briquets on the edges of the grill, with the roasting pan between them.
    4. Put the bird on the grill.
    5. Put the thermometer into the thickest part of the breast.
    6. Lift up the edge parts of the grill, and put some chips on the briquets.
    7. Close the lid

     Now, every 30-60 minutes, open the lid, add briquets to keep the amount constant, and add wood chips if desired. Less is more on the wood chips - I usually don't add any after the first hour.

    Continue until it reaches the desired temperature. I've typically gone to 165 degrees, but I notice that Alton Brown says 161 degrees.

    Remove from the grill, and use the drippings to make gravy. Carve the turkey, and enjoy.

     

  • Eric Gunnerson's Compendium

    Have you ever asked yourself "Why am I here?"

    • 9 Comments

    I'm not talking about the metaphysical question of whether there is a purpose of existence. I'm speaking of a more concrete concern. Why am I here, sitting at my desk, working on a computer, at 1:48 PST, on a late November day?

    When I could be here...

     

Page 41 of 46 (1,133 items) «3940414243»