Tuesday, May 26, 2009

My First Oslo MGrammar

Ever since working with FORTH, I’ve been a big fan of languages and understanding how they work.  FORTH did a great job of extending FORTH using FORTH, very cool.  Last fall I was introduced to Oslo, and was very impressed.  At the time, it looked like a pre-bleeding edge CTP, so I didn’t spend too much time with it.  Today (May 26, 2009) Microsoft released the May CTP of Oslo.  Although I’m sure the standards aren’t 100% baked, if you are interested, now is the time to start playing with it.  I have good intentions of publishing a better description of how this grammar was built, but with the limited time I have, I wanted to at least get my first grammar on my site.  There will be three components you need to know about when using Intellipad, the first is the development of the grammar, the second is where you enter your sample grammar and the third is the output.  The output is in the form of MGraph which you can use in your application.

 

Intellipad (better detail on the content below)

image

Here’s my very first MGrammar

module Pets
{
    @{CaseSensitive[false]}
    language MyPets
    {
        syntax Main = i:InitialStatement
          additional:(ThePet)+
          friends:(Friends)+        
          foes:(Foes)+
          => MyPets {
                     valuesof(additional),
                     Friends [valuesof(friends)],
                     Foes [valuesof(foes)]
                     } ;
       syntax ThePet = t:Pet w:Activity+ h:HowMuchTheyEat+
            => {t, Activities [valuesof(w)], Meals [valuesof(h)]} ;
       syntax Friends = f:PetsFriends => {valuesof(f)};
       syntax Foes = f:PetsFoes => {valuesof(f)};
        token Upper = 'A'..'Z';
        token Lower = 'a'..'z';
        token Digit = '0'..'9';
        token Name = Upper Lower*;
        token Time = '0'..'9' Digit?;
        token Age = '0'..'9' Digit?;
        token Cups = '0'..'9' Digit?;
        token Type = Upper Lower*;
        syntax Action = 'run' | 'jump' | 'play' | 'bark' | 'fetch'
                              | 'hunt' | 'whine';
        syntax Sex = 'male' | 'female';
        syntax Color = 'white' | 'black' | 'brown';
        syntax MealTime = 'breakfast' | 'lunch' | 'dinner';
        syntax AnimalTypes = 'Rat Terrier' | 'Terrier' | 'dog' | 'cat'
                             
| 'fish' | 'bird' | 'pig' | 'Poodle';       
        syntax Pronoun = "he" | "He" | "she" | "She" | "Her" 
                              | "His" | "her";
        @{Classification["Keyword"]} token AnimalColor = "color is";
        @{Classification["Keyword"]} token Will = "will" | "will also";
        @{Classification["Keyword"]} token Eats = "eat" | "eats";
        @{Classification["Keyword"]} token CupsOfFood = "cups of food for"
                             
| "cup of food for";
        @{Classification["Keyword"]} token For = "for";
        @{Classification["Keyword"]} token IsFriends = "is friends with";
        @{Classification["Keyword"]} token DoesntLike = "does not like";
        @{Classification["Keyword"]} token IsA= "is a";
        @{Classification["Keyword"]} token Minutes = "minutes" 
                              | "minute";
        @{Classification["Keyword"]} token Seconds = "seconds"
                              | "second";
        @{Classification["Keyword"]} token And = "and";
        @{Classification["Keyword"]} token YearOld = "year old";
        syntax InitialStatement = "About my pets";

        syntax Pet = n:Name IsA t:AnimalTypes IsA a:Age YearOld s:Sex 
                
Pronoun AnimalColor c:Color 
                
=> Profile {Name=>n, AnimalType=>t, Sex=>s, Color=>c};               
        syntax Activity = Pronoun? Will? a:Action For? m:Time? Minutes?
                 s:Time? Seconds?
                 => Activity {Type=>a, Minutes => m, Seconds => s };
        syntax HowMuchTheyEat = Pronoun? Eats q:Cups CupsOfFood m:MealTime
                 => HowMuchTheyEat {Cups=>q, MealTime=>m};
        syntax PetsFriends = n:Name IsFriends f:Name
                 => Friends {Name=>n, Friend=>f};
        syntax PetsFoes = n:Name DoesntLike f:Name => Foes {Name=>n, Foe=>f};
        interleave whitespace = ("and" | "," | " " | "\r"
                  | "\n" | "\t" | "." | "that")+;
    }       
}

Sample Text

What you see in bold is the tokens that make up my grammar, the plain text are the values I want to extract as data.

 

About my pets

About my pets

Razor is a Terrier that is a 9 year old male, and
her color is
white.  She will jump for 15 seconds
and bark for
2 minutesShe eats 1 cup of food for
breakfast and eats
2 cups of food for dinner.

Razor is friends with Rocket

Rocket does not like Rascal

MGraph

MyPets{
  [
    {
      Profile{
        Name => "Razor",
        AnimalType => AnimalTypes[
          "Terrier"
        ],
        Age => "9",
        Sex => Sex[
          "male"
        ],
        Color => Color[
          "white"
        ]
      },
      Activities[
        Activity{
          Type => Action[
            "jump"
          ],
          Minutes => null,
          Seconds => "15"
        },
        Activity{
          Type => Action[
            "bark"
          ],
          Minutes => "2",
          Seconds => null
        }
      ],
      Meals[
        HowMuchTheyEat{
          Cups => "1",
          MealTime => MealTime[
            "breakfast"
          ]
        },
        HowMuchTheyEat{
          Cups => "2",
          MealTime => MealTime[
            "dinner"
          ]
        }
      ]
    }
  ],
  Friends[
    [
      {
        Name => "Razor",
        Friend => "Rocket"
      }
    ]
  ],
  Foes[
    [
      {
        Name => "Rocket",
        Foe => "Rascal"
      }
    ]
  ]
}

 

More to come, I’m really excited about this technology!

 

Updated 6/12/2009 – Added Friends and Foes grammar and changed MGraph Structure

-ec

Sunday, May 24, 2009

Losing my Identity

HP TouchSmart tx2z (2.1GHz, 400GB HD, 3GB RAM)When I got home last night, I tried to boot my new HP TouchSmart Tx2 Tablet running Windows 7 and was greeted with the message.

The User Profile Service failed the logon.
         User Profile cannot be loaded.

After reading this a few times to try to figure out if this was proper grammar (I should really be the last one criticizing this).  My heart sank, I couldn’t get into my new machine.  I had thoughts of having to rebuild it. <g> need to add this machine ASAP to my Windows Home Server then I won’t have to worry about that.

I put out a call on twitter to see if anyone had seen this before and may have a solution @vb2ae aka Ken Tucker sent me a link to a web site.

Bottom line to restore my profile, I booted the computer into Safe Mode, then found a recent restore point.  I let the System Restore do its thing and I was back in business!

-ec

Saturday, May 23, 2009

Don’t be obsessed with trying to fix bugs in the real world

In catching up with one of my favorite podcasts, I listened to Stackoverflow #49.  One of the points that Joel made really struck home.  At about 32 minutes into the podcast Joel made a point about Taxi Drivers trying to run him over in NYC.  I encourage you to listen to this chunk of the podcast, but let me attempt to summarize.  With the significant number of cab drivers and with an average turn over of 3 weeks, it’s futile to get upset and slap the hood of the cab that just about ran you over.  This goes along with one of my favorite sayings “Never try to teach a pig to sing, it just annoys the pig”.

So what does this have to do with being obsessed with fixing bugs in the real world?  What brought this home to me is when he started discussing what we do as software engineers, we work in a very complicated discipline, our job is literally to manage thousands or even hundreds of thousands of details, make those somehow compile and turn into something that actually compiles and does what our customers need.  In reality this is really a close to an impossible task, but its our job to search out and destroy “stuff” that get’s in our way to get as close to as perfect as possible.  Where we see a problem, we want to fix it.  Period.  It’s very difficult for us to know about a bug, know what the solution is, but just not do anything about it.

As a consultant, it’s my job to understand the customers needs and deliver a solution.  To deliver a solution, we need certain things to be successful (or save us a number of hours, which in turn takes money out of our pocket and gives it back to the client).  We also see other internal efforts or processes that are failing, and the solution is actually fairly trivial to implement. 

As difficult and as tenacious as we are about eliminating problems in our code, sometimes we need to let go and just accept that “it is what it is” when dealing with things we have little or no control over.

I’m trying really hard, but when I see a bug whether it’s in my source code or in a process, internal or clients, it’s very hard not to get involved and attempt to fix it.  I have a bad habit of offering advice where it’s not been solicited.  This comes back to the saying “Never try to teach a pig to sign, it just annoys the pig”.  I first heard this in the early ‘90s and ever since than I’ve been trying to internalize it.  I had one client that was actually a pretty good gig.  After a few years of being there, I finally felt I was starting to have a real impact on their business and their department.  However to take it to the next level required some changes I just couldn’t make without executive level support.  After about six months of lip-service and sleepless nights trying to figure out how affect change, I finally gave up.  That client is doing just fine today (at least that’s what I hear).  What can I/we take away from that?

When working with People Systems, whether that be a cab trying to run you over in NYC, a project manager staffing their “pet project” over yours or even that person that drinks the last of the coffee without making a new pot shouldn’t have an impact on your attitude and how you do you work.

So what are some ways we can combat this?  As I get older and more experienced within this industry the answer is starting to become my default answer when someone asks me a question.  It depends.  It depends on you, your personality, your team, your culture, and the specific situation.   So what are some possible solutions?  Flight, Fight, Ignoring or Empathy.  

Please excuse me for a minute, my wings are done and I need to refill my beer.

image

Ok – thanks for waiting for me, great wings, now back to your regularly schedule blog.

Where were we?  That’s right, Fight, Flight, Ignoring or Empathy.  As someone who is passionate about developing software, our first reaction will be Fight, that is to say, we see a bug and, heck we know how to fix bugs right?  Why should this be any different?  Well it is.  In some cases this is the right solution.  If your company doesn’t implement any sort of source control because it just seems like a waste of time, your first reaction should be indeed, let’s at least do some real basic blocking and tackling stuff like getting this in place (Fight).  If after three months of people not getting it and still thinking source control is just a fad it might be time to vote with your feet and pursue other opportunity (Flight).  On the other hand, if someone drinks the last cup of coffee and doesn’t make a fresh pot are you going to let that ruin your attitude for whole day (Ignoring)?  Generally if you choose the Ignoring path, you really need to be careful, if you are going to let something go, make sure you let it go.  Don’t just put up with it and take out your frustration in other ways such as being too critical in code reviews or probably more common venting scheme of have back-channel conversations with others.  This is just unhealthy and lots of small things will build over time.

This brings me to what I see as the final option which is probably the best to exercise, empathy.  What do we mean by that?  Wikipedia defines empathy as:

Capability to share your feelings and understand another's emotion and feelings. It is often characterized as the ability to "put oneself into another's shoes," or in some way experience what the other person is feeling

Everyone has a different background, priorities and experiences.  The cab driver that is trying to run you over is just trying to make enough money to send back to his family.  The selfish developer is so focused on cutting code he doesn’t realize he is always drinking the last cup of coffee.  The team that doesn’t think they need source control…wait, no sorry, no empathy there.  Anyway dealing with these sorts of issues might be considered as a change requests, not really bugs.  Does this work for me?  I wish I could say that yes, I’ve got it all figured out, but I can’t.  Managing hundreds of thousands of details and fixing bugs in our software is not even a fraction as complicated as being obsessed with trying to fix bugs in the real world.

Whew, nice to get that off my chest.  Now I can save a little money by not going to my therapists this month.  After the incident at last months session, they probably need a little time off :*).

-ec

Tuesday, May 19, 2009

WACOM Bamboo Tablet/64bit OS/Silverlight & One-Note Conflict

I haven’t quite figured out the relationship yet, but if you are working on a 64 bit OS and are using a WACOM Bamboo tablet, then try to open a page that uses Silverlight or try to use a pen within One-Note, your mouse will freeze up.  If you logoff and log back in the problem goes away (you don’t have to reboot your machine)

Very odd.

Luckily the solution is fairly trivial.

Look for the file:

WISPTIS.EXE in the directory C:\Windows\SysWOW64

And just rename it (you could probable just delete it but I hate throwing anything away)

image

Once you do that, you will be able to use your kewl little tablet with your 64 bit OS without issue.

I have noticed that sometimes when I reboot, some lovely maintenance feature decides to help me and restore the missing file.  I just haven’t gotten around to writing some startup script to automate this yet.

UPDATED: 5/20/2009 8AM EST – It seems as though when I launch One-Note and a page contains a Visio diagram, a windows comes up saying “Reinstalling One-Note” at that point the very bad WISPTIS.EXE file re-appears.  This is obviously a big problem.  I’ll post more once I get a little more information.

UPDATED: 5/29/2009 8AM EST – Trying a new solution, compiled a simple Console App with the name WISPTIS.exe and put it in the C:\Windows\SysWOW64 directory, my hopes being I can fool whatever thinks this file needs to be there, that it is already there and not copy the one that screws up my system.  So far, I can pretty much do everything without the original file.  I’ll post if I find out differently.  Drop me an email if you want a copy of this file, or better yet, just create a small console app that does nothing.

UPDATED: 5/29/2009 8:01AM EST – Just tried opening a Silverlight page, it did finally open, but the browser froze up for about 30 seconds.  Since as of today (5/29/2009), I’m about 80% convinced that Windows 7 RC is good enough for my main dev box, I think my next step is just repave my machine with that.  Stay tuned, I’m not convinced that will resolve the issue, but I’ll let you know.

-ec

Sunday, May 17, 2009

Thoughts after attending The Day Of Ruby

On May 16, 2009, I attended the Tampa Day of Ruby. I’m always interested in learning Florida-tampasomething new and with so many people talking about elegance of the language I was extremely excited to spend a full eight hours focused on getting a crash course in Ruby. I was not disappointed. After attending the overview, here’s my summary:

Invest some time to practice, learn Ruby and Rails (and/or other elegant technologies) to become a better programmer. Use more traditional, main stream technologies to ship high quality production code using what you learned from your studies of the elegant boutique languages.

Let me explain; but first a little background. My “Ruby-esque” language experience was a language called FORTH. It has many of the same characteristics of Ruby, with main feature that it shared being the ability to extend the language using the language. We had a shop of about 10 people. The distribution of talent was probably fairly typical: 3 – Shouldn’t be programmers, 5 – Average Developers and 2 rock-stars. Ruby like FORTH is what I would consider an “Amplifier”, where most C or traditional languages would probably be more of an “Equalizer”. With FORTH, and I suspect Ruby, it would allow the talented people to do an extremely good job building systems. In the hands of people that shouldn’t be programming, well, let’s just say, they can make a real mess that could never be salvaged. With average developers, they don’t really use any of the real power of the language and don’t see any of it’s benefits. That is to say that poor developers develop systems that are 100x worse than the average and great developers can develop systems that are 100x better than the average developer. If we contrast that with “equalizer” languages like the C-family, the poor developers may be do 5-10x worse job and the great developers can do 5-10x better.

Leveraging the power of languages like Ruby and FORTH, require some level of natural talent plus the desire to invest time and practice.

So that brings me to my point, invest time to learn Ruby (or something similar); and I’m very serious about that; however in your day-job for creating production code use more traditional technologies. Most production LOB (Line of Business) type applications can benefit less by using an elegant technology like Ruby as they can by putting in a predictable and repeatable process to deploy that technology. To leverage a technology like Ruby, you need top-tier developers to take advantage of it’s benefits. If you don’t have top-tier developers, you’ll probably end up developing using Java or C/C++/C# techniques in Ruby. This results in adding just one more layer of complexity into the already incredibly difficult process of developing software.

I know a lot of companies use boutique languages for internal or support systems. I personally have mixed feelings on this, I think it’s probably a good way to practice if it’s done in the right environment however there are two risks I see in doing this. First being that most of these are research efforts, and generally the output of research isn’t as good as if you engineer your tool. This results in support systems which are critical for your developers to do there jobs that may be somewhat fragile. If there is one thing I hate as a developer more than anything else is to work a long day, get my problem solved, really want to be done for the day and end up fighting with the support infrastructure for another two hours to get my solution deployed. In addition to that, if you develop your support mechanism in FooBat ZX V2.3, what happens when you leave the company (or want to take a vacation) and that support tools needs maintenance. You may have some one that knows FooBat ZX V2.3, but if this was done as your first application using the technology, I suspect it may not be all that clean. As I mentioned earlier, I think in the right shop, using a boutique language for internal and supporting systems could make sense, but deciding to do so should not be made on a whim or a cool write up you read in a blog post.

So in summary, I learned a lot yesterday at the Day of Ruby, it brought back great memories of some of the software engineering discussions we had while implementing systems in FORTH. However as I still think FORTH is probably the most elegant language, other than screwing around on my own, I just don’t ever see recommending using this for any production work I do for my clients. I think the same will be true for Ruby.

Finally I have to commend Cory Foy and his initiative to put this together. It was obvious he is a very talented presenter and spent considerable time putting together the materials and thinking through the topics.

-ec

Monday, May 4, 2009

Windows Mobile Device Center and Windows Server 2008

I’ve just migrated a Windows Mobile development environment from Windows Server 2003 to Windows Server 2008.  If you want to connect your emulator or device to your computer to do development, you will need to install Windows Mobile Device Center.  Every time I tried to install Windows Mobile Device Center in my new environment, I received the following Error:

image

 

After a bit of research and trial and error, I determined the missing component was “Windows Media Player”.  Once I downloaded and installed this through the Desktop Features, I was able to easily download and installed Windows Mobile Device Center.

Also if your emulator can’t connect to the internet with your emulator be sure to click on “Connect Without Setting Up your Device” on WMDC after you connect.

 

image

Hope this saves someone a little time!

-ec