Your Brain, And the Effects of Syntax Highlighting

Dr. Edward de Bono wrote a little epistle once, on the value of Syntax Highlighting in your IDE.

"You are in a plane that is coming in to land at Heathrow airport in London. The plane passes over several car parks. You say to yourself: 'I am going to notice all the cars coloured red.' You look at the car park and all the cars coloured red jump out to you. Red is a fairly common colour. So you choose 'bright blue'. This colour is much more rare and your eye scans over the cars. Suddenly a bright blue car jumps out of the mass.

"There are two important points about this simple experiment. The first point is that you are giving instructions to your own brain. The second is that you are 'sensitizing' the brain to certain types of input."
Edward De Bono
Textbook of Wisdom

Syntax Highlighting is a mainstay of today's IDE's -- it helps your eyes choose to look at just one thing at a time.

If you want to look at comments, you tune out all but the green writing, for example.

To detect the keywords, you look at the blue writing and only the blue writing.

Query editors were much slower than IDE's at gaining syntax highlighting. So we developed a ritual of typing keywords in UPPER case, so that the eye can separate them more easily.

Some people might argue that syntax highlighting is just a kind of garish cosmetic to distract you from the dire ugliness of the language's syntax. Perhaps if the syntax were perfect, then no highlighting would be needed. Or: the uglier the language, the more desperately it needs cosmetic enhancement from the IDE.

One way to create such ugliness is to combine lots of language in one file. Classic ASP springs to mind.

And in classic ASP, you find some pretty brutal syntax highlighting -- no one's gonna miss those bright yellow <% signs.

Some of the ugliest syntax around is found in Text Templates used for generating code. I don't blame the tools -- it's just the polyglotic nature of code gen.

My favourite codegen tool is CodeSmith -- and, naturally, CodeSmith templates can get fairly ugly.

Here, syntax highlighting is of most importance, and you find the same ultra-bright template delimiters as in ye olde Visual Interdev:

syntax highlighting in codesmith

What i'd like is something cleverer -- some way that let's you separate out the two languages that are intertwined. So that your mind can more easily switch gears between pondering one language and another. I don't know how. ;-)

Recently i've heard of a new spin on syntax highlighting -- in VB 9 you can embed XML statements directly in your code, so called 'XML literals'. These statements are 'lowlighted' instead of 'highlighted:'

Lowlighting as a form of highlighting

Notice (above) how the xml is just slightly faded into the background. Subtle, but interesting.

I tinkered with the settings in CodeSmith to make the template delimiters a little more subtle:

subtler syntax highlighting in codesmith

It's better, but you're limited by the color picker they use, which confines your choice somewhat.

***

CodeSmith's bin folder has a file called ActiproSoftware.SyntaxEditor.dll so i'm guessing they use components from ActiPro Software

(ActiPro: "The core SyntaxEditor control provides a free implementation of C# and Visual Basic that has syntax highlighting, outlining, and several other features.")

(Powershell Analyzer seems to use the same components.)

Wrapping this up -- i found an interesting (though not convincing) argument against syntax highlighting.

 

Which came first... the domain model or the human?

I found this article on dzone (and other places) recently... and just wanted to state my counter counter argument argument. The summary at dzone said:

"Never Start With the Data Model

The best systems start with a domain model and work through the various layers of the system down to the database, not the other way around..."

I have a big distaste for thinking of models (Data or Domain models) as something special, or truthful.

Models are just models... shadows, reflections, abstract thought stuff... they aren't the real thing:

Model makers are liars, simplifiers, beautifiers.

Do you want clothes that only fit models?

Software also shouldn't be built just to suit models.

'Models' are a modern spin on that ridiculous old notion of plato's cave. The folly of which is that you end up bending the people to suit the model.

Build on top of models, sure. But expect the model to need many corrections... factor that into your process.

(Breaking news on this subject: Microsoft's SOA vision: 'The model is the application', found via LosTechies, via Interesting Finds)

My preference says -- start anywhere. In fact, you start outside the software. With, you know... real people. The actual software aspect can start anywhere. User interface is a great place to start. So is the business logic layer. So is the database. Everything is open to change.

 

JonGalloway.Equals(Nostradamus)

"Microsoft should ship SubSonic"

Jon Galloway, August 2006

"Microsoft Snags Open-Source Project Lead" (i.e. Subsonic creator, Rob Conery)

Darryl K Taft, eWeek article, Oct 2007

In order to foresee what's happening next month, perhaps we ought to review Jon's blog from September 2006.

Anyway, word is that Rob will help bring MVC to the asp.net framework -- by fleshing out the pre-alpha MVC that ScottGu announced at the ALT.Net conference.

Regarding SubSonic, i've downloaded version 2.03 of Subsonic for a bit of fun. I've got some thoughts -- but they're not ready to share yet, so I'll hold back for now. It's all positive. Go and try SubSonic for yourself.

 

Brisbane's Independent .NET Consultant

Maybe I can help your team, your business, or someone you know?

Currently, I'm free to fulfill any short term consulting needs you might have:

  • Your software architecture needs a review?
  • Your software strategy is falling apart? Maybe you never had one?
  • Development practices need to be refreshed?
  • Feel you're not using the tools you should? Sick of using a screw driver to hammer in nails?
  • Customers and developers just not listening to each other?
  • Need to write a lot of code, and not much time to do it?
  • Need help with a sluggish database?
  • Has your team turned Toxic?
  • Bug count heading north instead of south?
  • Got nasty technical issues that need some serious brain time?
  • Projects never seem to ship?
  • Or (last resort) just need a humour coach?

My resume is online. Contact me by email to LeonBambrick@gmail.com

 

Why Are So Many Dev Tools Orange?

This isn't a comprehensive survey by any means... but the four dev tools I'm using right now all have orange icons...

some orange devtool icons
  • Mozilla
  • Visual Studio
  • Codesmith
  • MS SQL Studio

Just as acronyms all scramble to include the letter 'X' so too, dev tools scramble toward the colour orange.

Note to self: 'OrangeX' would be the ultimate name for a dev tool.

(and if you think Mozilla isn't a dev tool... then you're just not using it right)

 

My First WPF Application - A visual tour

a visual tour of building your first app in WPF a visual tour of building your first app in WPF a visual tour of building your first app in WPF a visual tour of building your first app in WPF
a visual tour of building your first app in WPF a visual tour of building your first app in WPF a visual tour of building your first app in WPF a visual tour of building your first app in WPF
a visual tour of building your first app in WPF a visual tour of building your first app in WPF a visual tour of building your first app in WPF a visual tour of building your first app in WPF

With facebook out of the way, I can get on with more serious geeky pursuits, such as tinkering with WPF.

I've just written what amounts to my first WPF application -- naturally it's another implementation of the world's simplest code generator.

So, come along on a visual tour of thinking and building with WPF.

Worlds Simplest Code Generator -- WPF Edition

Here's some things I learnt along the way:

1. Don't 'Click here'

When the WPF designer says:

'An assembly or related document has been updated which requires the designer to be reloaded. Click here to reload.'

Worlds Simplest Code Generator -- WPF Edition

Don't Trust them!

Clicking there, will cause VS2008 to crash. Instead, save your changes, close the designer (not Visual Studio -- just close the open window with the warning message) then reopen it.

(This is a beta after all, and i expect this problem to be gone in the next release. I remember that VS2005 used to have similar issues in the winforms designer.)

I remember Joseph Cooney giving that exact piece of advice at Tech-Ed. Joe also pointed out how consistent the crashing is, and how quickly VS2008 restarts -- allowing for a much faster, "code -- crash -- restart" cycle than in previous betas. ;-)

Worlds Simplest Code Generator -- WPF Edition

I wanted some simple XAML to create a three pane look... I struggled for a while with a dockpanel, thinking I could dock three of those panels inside another container... ofcourse I had it all backtofront: the idea of a dockpanel is that the things inside it are docked. Intuition is a poor guide.

When I got the dockpanel acting its best, I found it wasn't what I wanted at all: I wanted the three textbox to each take one third of the space.

Turned out the right control to use was the grid. Now I've often heard people say "there's no grid in WPF" -- which seems wrong as there is clearly a grid control. Well I understand the tension now:

Basically there's no datagrid or gridview like control. the 'Grid' control has a fixed number of rows and columns -- unlike a datagrid which will emit as many rows and columns as it's datasource requires.

<Window x:Class="MyFirstWPFApplication.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="World's Simplest Code Generator -- WPF Edition" Height="500" Width="500"
     BorderThickness="0" WindowStyle="ThreeDBorderWindow">
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="1*" x:Name="Row1" />
      <RowDefinition Height="1*" x:Name="Row2" />
      <RowDefinition Height="1*" x:Name="Row3" />
    </Grid.RowDefinitions>
    <Label Content="data" Grid.Row="0" Margin="96.125,-17,0,8" />
    <Label Content="pattern" Grid.Row="1" Margin="32,-17,0,8" />
    <Label Content="result" Grid.Row="2" Margin="32,-17,0,8" />
    <TextBox Grid.Row="0" x:Name="txtData" TextChanged="Generate" />
    <TextBox Grid.Row="1" x:Name="txtPattern" TextChanged="Generate" />
    <TextBox Grid.Row="2" x:Name="txtOutput" />
  </Grid>
</Window>

Intellisense in XAML is a devastating thing. There are eight million options to choose from. I almost wish clippy was there to guide me through it all -- or intelliSEARCH

At first the intellisense was very 'flickery' -- i realised this was the CPU struggling to fade the intellisense in and out. So, as in previous versions of VS, I turned off the animation of screen elements:

Worlds Simplest Code Generator -- WPF Edition

Also -- the intellisense just isn't that intelligent! It shows you all sorts of inappropriate options, furthering the information overload.

For example -- here I am adding content to a Label. Notice that it suggests putting a Window element in there...

Worlds Simplest Code Generator -- WPF Edition

So let's go right ahead and put that Window element in...

Worlds Simplest Code Generator -- WPF Edition

Bad! Window, as it turns out, isn't allowed in that location (it must be the root element). I think the intellisense could've realised this in advance, via some XSD file perhaps. Just seems wrong.

Integration with Blend...

I had this idea that you could right-click a XAML file (in solution explorer) and choose to "Open with..." Expression Blend.

Worlds Simplest Code Generator -- WPF Edition

It's not as simple as that.

I went and added Blend into the "Open with..." list for XAML files -- but this was all wrong. Blend really needs a project file, not just a XAML file in isolation. (Or not this kind of XAML file, with it's Window root element.)

Anyway -- I loaded Blend normally and opened the same project. This worked fairly well. And if I modified the XAML file in one application, I would be prompted to re-load in the other -- which is the behaviour I expected. Very good.

Blend lacks intellisense in the XAML editor. This is a very deliberate choice, as I understand it. They don't want designers f***ing with XAML. They want designers drawing pretty pictures. Fair enough.

From my non-designer point of view, my favourite little usability-gem in Blend is the 'property search' box. I wish they had this in Visual Studio!

Worlds Simplest Code Generator -- WPF Edition

The property editor in VS2008's XAML designer is a poor cousin, even compared to ASP.net property designer. Here's what you get in VS2008 XAML designer:

Worlds Simplest Code Generator -- WPF Edition

It doesn't have that useful 'Events' tab, that you find in the ASP.net and winforms designer (when using C#... it is sadly absent everywhere when using Visual Basic). This is a shame, because I found it a little harder to guess how to wire up an event.

Also, the properties are 'grouped' under fairly haphazard headings. You can't turn the grouping off. (Can you?)

I do like the fact that elements don't have to be named. There is something a little redundant about the way every label in a windows form (for example) had to have a name -- even if it is never referred to in code. It was a little reminiscent of this 20 year old Far-Side cartoon (made famous in geek circles by the Yeggemeister)

Now that should clear up a few things around here

What I really wanted to write about was the way styles work, and to try and get some understanding around event bubbling and tunneling. But we'll have to save that for another day.

Sidenote, regarding WSCG behaviour

As luck would have it, I was creating a new database in SQL Server 2005 this morning, and I noticed a different app that behaved similarly to WSCG. Watch what happens as the name is specified for a new database. Worlds Simplest Code Generator -- WPF Edition

By back-porting the generated script, we can use WSCG in place of SQL Server Management Studio:

Worlds Simplest Code Generator -- WPF Edition

So clearly a day is coming when WSCG will replace all dev tools. Right.

In other news: I look forward to the year 2010. A new millennium for dyslexics.

 

Visual Studio News Channel: Give Hanselman a Go!

The main news channel in Visual Studio must be seen every day by millions of hard working developers.

It sits on the start page, prime real-estate for getting messages to real people who work with the dastardly complex tool that is visual studio.

Now look at how paltry this feed is!

useless msdn feed in vs2005

http://go.microsoft.com/fwlink/?linkid=35587&clcid=409

In six months, they've sent a total of 4 items to this feed! FOUR items!

I can imagine some apologist at MSDN saying "oh yes, but there's all these loopholes to jump through in a company the size of microsoft and a quality bar that..." -- BALONEY!! I ain't buying it.

You can see that they arrive in little bursts, as though it's right down the priority list, as someone's part-time job, when they get around to it..

An audience of millions. Millions. And they do nothing with it.

There could be tutorials on new features, help on under-used features, showcases of great solutions -- basically, you could stick ScottGu's blog in there and get a much better first approximation of the right material.

Check out the settings in Visual Studio that control this:

settings in vs 2005

By default it checks for updates every 60 minutes. At four updates per 6 months, that's about 1 update every 70 thousand minutes.

So let me go ahead and change the polling frequency to "every 70,000 minutes" ... oh wait, it won't let me set a value greater than one thousand. Because like, there's no way the dev-div team who wrote this feature would ever imagine that the MSDN team (who are professional journalists) could ever be so slow at publishing news.

I checked and Visual Studio 2008 seems to have the same feed, and the same settings around it.

three years on... same feed different vs

This Looks Like a Job for Hansel-Man!

So here's my plan: Developer Division should wrest control of this feed away from the MSDN team and into their own hands. In particular, since Scott Hanselman is their new internal professional blogger about town -- I've decided to assign this job to ScottHa himself.

So if you're listening Scott -- here's your challenge: Get control of that feed, and start pumping it full of useful, thoughtful, educational news items. One per day ought to be sufficient. I'll check on your progress in one month.

 

How to block websites that kill your productivity.

Yesterday I wasted about an hour of good time on Facebook. And worse, I found that even when I'd started doing productive work, I kept shifting back to facebook and wasting more of my time. I can't say that I gained anything out of this effort. It was a dead loss. So today, i removed it from my life, in a single step.

Sites like facebook are such effective time-wasters because they relax the 'executive brain'-- the centre responsible for focused decision making, and leave you at the mercy of your impulses and compulsions. Much like watching reality tv shows, or being the subject of hypnosis.

Many of us spend a lot of our time with the 'executive brain' switched off. We become volunatry zombies. Let's say that again, in big writing:

We Are Voluntary Zombies!!

In order to delete Facebook, i opened this file:

C:\WINDOWS\system32\drivers\etc\hosts

and I added this line:

0.0.0.0 www.facebook.com

Now when I go to facebook.com, it gets routed to 0.0.0.0 and the browser shows 'Connection closed by remote server'

I can bring it back of course, by deliberately unblocking the site.

But the key word is 'deliberate'. Giving in to temptation is not usually a deliberate act.

When given the chance to deliberate, i'll need to engage my 'executive brain', and one of two things will happen:

  1. I'll decide i don't really want to visit facebook, or
  2. I'll visit it briefly and conscientiously, then re-block it afterwards.

(note, to unblock it, just add a comment symbol, '#' to the front of that line in the hosts file)

And, at the risk of being tarred, feathered, shot, drawn, hung, quartered and teased -- i only realised I was wasting time at that site because of the concerned intervention of my good and discounted friend, TimeSnapper. Thanks ts for stepping in where others didn't dare!

I'm using TimeSnapper more every day. For monitoring, understanding, accounting, timesheeting... there's so many ways to benefit (yeh, and more to come of course. we never rest... we're like that terminator guy in that movie, what was it? terminator).

Anyway, I block whatever sites I feel I ought to, and I've got some half-formed ideas about a toy to automate the blocking and temporary unblocking. Do you see a need?

Some notes...

I do like some things about facebook: I'm back in contact with people I knew in primary school. This is excellent. I've got slightly better contact with friends of old i wanted to catch up with. If you read this blog, track me down and add me -- i'll sign in briefly and periodically. But mostly all the potential is wasted. Will i really catch up with ned for those beers? i'm afraid i might not. maybe the best possible life would be one where i acknowledge that neither me or ned have time for 237 close friends... and just get on with being good friends to the twenty or so friends we really deserve? i can't help but hear that robot voice from radiohead's OK Computer mockingly begging "keep in contact with old friends..."

Regarding the 'executive brain' -- my own executive brain told me not to waste time researching the best possible link for this topic. I get this concept from lectures i've listened to via a podcast called 'All in the mind' -- but i don't think it's quite the same as that spoken of in the book 'the executive brain'. Also, i'm a little perturbed by the idea that maybe by some definitions it's the executive brain that allows us to visit sites like facebook in the first place. It may be that the so-called 'executive' portion of our mind allows us to ignore other voices that say 'danger! timewaster! real work pending!'

And I recognise that most 'executives' i've known are the most un-inspired, un-productive timewasters of all.

Then again, Charles Darwin published nothing for twenty years as he pondered evolution. I guess we're lucky he wasn't spending the timing joining groups on facebook.

 

Go Don Syme!! Go F#!!

According to the relevant sources, F# is to be productized as a bona-fide language, not just a 'research project'.

I worry as others do that F# will shoot over the heads of too many of us programmers... with PLinq coming to C# mainstream we'll probably avoid needing to think about it all together...

And i fear Steve Thompson has a point with his response:

"likelihood of the average .Net programmer picking up this language is vanishingly remote"

but i disagree on principle with his statement that:

"...syntax a huge obstacle to understanding the fundamental..."

I've seen too many dyed-in-the-wool programmers argue that VB.net or C# is fundamentally superior to C#/Vb.net on such shallow basis.

I'm convinced that syntax is tangential for anyone who *uses* a language in anger. The human brain is far more maleable. After you tackle a few languages we learn to think in a meta-language far richer than what we merely type. (Yeh, 'Why' - I'm throwing down the damn gauntlet to your ridiculous claim, that Ruby is 'the language of our thoughts'.. grow up Why! Get a better set of lungs you wheezing freakazoid! just kidding i love your work, even you're so damn wrong. Yet admirable and funny.. and wrong! damn you, wrong!)

(new sub theory, regarding the age-old question, which is better a terse or a verbose syntax? -- in the early days of learning to program, a verbose syntax is better, but later a terse syntax is better. Hence, more experienced programmers appreciate terse syntax even in languages that are new to them. An ideal language, meanwhile, would allow for both, without causing disadvantrage either group. This is impossible, of course, hence language wars are inexorable.

One respondent, clearly a Pythonista, said, somewhat naïvely:

"This looks like Microsoft's solution to Python."

A fairer comment would've been: 'This looks like Microsoft's response and extension to O'Caml' -- which it is.

Enough on F#... let me say:

if your application has Ugly Corners You Wish to Beautify:
Consider F#.

If you have thoughts too beautiful for your day job:
Consider F#.

If you pose parallel solutions to problems posed in serial:
Consider F#.

If you... want to...

then please...

Consider F#!!!

(ps. It doesn't stand for Fortran.net.)

 

The future of microsoft development

Where is mainline Microsoft development today? Where tomorrow?

Once, mainline Microsoft development was: MFC C++ apps and VB 5 applications. For the windows platform.

Then, for a short while it was Windows Forms applications, in .net, mostly C#, partly VB.net.

For the last several years, ASP.net has had the lion's share of attention from microsoft.

(Compare the data providers in Windows forms versus Web forms... linq support is complete on the web, but patchy on windows)

Where's it headed now? Will it return to the windows platform, with WPF? Or stay web-based with silverlight?

Is WPF "too much too late" for development on the windows platform?

Is asp.net for html now doomed, like MFC or VB 6? Will ajax for asp.net move ahead, or be dropped for silverlight?

Why do we always quit at 90%?

Are microsoft afraid that if they do anything well, it will give them nowhere to go?

Or is the last 10% harder than the first 90% put together?

Did Robert Scoble Die For Nothing?

No, hang on, honestly. Let's try that again. I say: 'Did Robert Scoble Die For Nothing?' and you say, 'But wait. Robert Scoble's still alive,' got it? Okay.

me: Did Robert Scoble Die For Nothing?

you: But wait. Robert Scoble's still alive.

(very good, now i say...)

me: Oh, I hadn't noticed.