Bootstrapping and Reflections on Trusting Trust

The term “Bootstrapping” comes from the term “pulling yourself up by your own bootstraps” (Wikipedia). In computing parlance, a bootstrap loader is the code that initially runs when a machine starts, whose job is to load the rest of the operating system. [I can remember (just) old mainframes where the bootstrap code was entered by hand using switches on the front panel!]

If you’ve never read Ken Thompson’s “Reflections on Trusting Trust” (his Turing Award acceptance speech), it’s definitely worth reading:

It describes a very clever backdoor mechanism based on the fact that people only review source (human-written) code, and not compiled machine code. A program called a compiler is used to create the second from the first, and the compiler is usually trusted to do an honest job.

Thompson’s paper describes a modified version of the Unix C compiler that would:

  • Put an invisible backdoor in the Unix login command when it noticed that the login program was being compiled, and as a twist
  • Also add this feature undetectably to future compiler versions upon their compilation as well.

http://en.wikipedia.org/wiki/Reflections_on_Trusting_Trust#Reflections_on_Trusting_Trust

How did I get onto this topic? Someone asked the question “How can you write a compiler in it’s own language?”

If you were writing a new C++ compiler, you would just write it in C++ and compile it with an existing C++ compiler. If you were creating a compiler for a completely new language, you would need to write the new compiler in another language first. Usually this would be another programming language, but it can be assembly, or even machine code.

If you want to bootstrap a compiler, you would generally write a compiler for a small subset of the language. Then in this minimal version of the language, you would write a compiler for the full language. This often occurs iteratively rather than in a single pass.

http://en.wikipedia.org/wiki/Bootstrapping_(compilers)

The first self-hosting compiler (excluding assemblers) was written for Lisp by Hart and Levin at MIT in 1962. They wrote a Lisp compiler in Lisp, testing it inside an existing Lisp interpreter. Once they had improved the compiler to the point where it could compile its own source code, it was self-hosting.

There is an interesting article about bootstrapping a compiler from the ground up titled Bootstrapping a simple compiler from nothing.

Measuring/Comparing .NET Performance in Visual Studio

I’m guessing everyone knows that Visual Studio (Premium and Ultimate Editions) has a code profiler built-in. But did you know you can use it to compare and show differences and improvements between profiling sessions?

There are also other commercial code profiling tools available from RedGate and JetBrains, and Eqatec (which has a free version).

SQL Server Migration Assistant (SSMA) v5.2 Released

Microsoft have recently released an updated version of the SQL Server Migration Assistant (SSMA):

SSMA simplifies database migration process from Oracle/Sybase/MySQL and Microsoft Access to SQL Server and SQL Azure. SSMA automates all aspects of migration including migration assessment analysis, schema and SQL statement conversion, data migration as well as migration testing to reduce cost and reduce risk of your database migration project. The new version of SSMA – SSMA 5.2 provides the following major enhancements:

  • Support conversion of Oracle %ROWTYPE parameters with NULL default
  • Support conversion of Sybase’s Rollback Trigger
  • Better user credential security to support Microsoft Access Linked Tables

Download SQL Server Migration Assistant (SSMA) v.5.2
Launch the download of the SSMA for Oracle.
Launch the download of the SSMA for Sybase.
Launch the download of the SSMA for MySQL.
Launch the download of the SSMA for Access.

There are migration whitepapers for each database product available here.

Windows 7 Bins

I love it when Scott Hanselman updates his Ultimate Developer and Power Users Tool List for Windows. I saw Bins and immediately went and purchased it ($4.99 PayPal). For each program pinned to the taskbar, you can create a group and put four shortcuts in the space of just one regular pinned icon. You can even choose which is the default click program, or hover to see all the programs in the group.

[The same author created the very useful (and free) Fences)]

97 Things Every Programmer Should Know

I happened to be on StackOverflow perusing a few questions (not that I spend much time there, ahem!), and I came across this great List of freely available programming books, which includes 97 Things Every Programmer Should Know

A few of my favorites are:

Perth .NET User Group Meeting, Thurs Feb 2nd, 5:30pm: Visual Studio and Team Foundation Server vNext Preview with Anthony Borton

Join us at the Perth .NET user group, Thurs Feb 2nd 5:30pm, where you’ll see what’s coming up in the next version of Visual Studio and Team Foundation Server. Anthony will demonstrate features from the Developer Preview versions of both Visual Studio and Team Foundation Server and whet your appetite for the Beta releases expected in February. Some of the things you’ll see include the new team explorer, code review workflow, exploratory testing, local workspaces and much, much more.

  • TOPIC:  Visual Studio and Team Foundation Server vNext Preview: Anthony Borton
  • DATE:   Thurs Feb 2nd, 5:30pm – 7:00pm
  • VENUE: Enex 100 Seminar Room, Level 3, 100 St Georges Terrace, Perth
  • COST:   Free. All welcome

Anthony Borton is the lead ALM consultant for Enhance ALM Pty Ltd, an Australian consulting and training company specializing in Application Lifecycle Management and Microsoft Visual Studio. He has been working with Visual Studio Team System full-time since 2005 and has worked with a variety of companies ranging up to some of Australia’s largest companies and financial institutions. Anthony is a sought after trainer and has delivered technical training and consulting in the United States and all across the Asia Pacific region. He is a Microsoft MVP (Visual Studio ALM), a Professional Scrum Developer Trainer and a Microsoft Certified Trainer. Anthony also runs the QLD ALM Users Group and the Canberra ALM Users Group.

In addition to the usual JetBrains license raffle prize, Anthony has arranged to provide everyone that attends our February user group meeting with an invitation code for the preview of Microsoft’s Hosted TFS offering.

Windows Azure Training Kit December 2011 Refresh

The Windows Azure Training Kit includes a comprehensive set of technical content including hands-on labs, presentations, and demos that are designed to help you learn how to use Windows Azure.

The December 2011 refresh of the training kit includes the following updates:

  • 33 updated/new PowerPoint presentations
  • [New Hands-On lab] Running a parametric sweep application with the Windows Azure HPC Scheduler
  • [New Hands-On lab] Running SOA Services with the Windows Azure HPC Scheduler
  • [New Hands-On lab] Running MPI Applications with the Windows Azure HPC Scheduler
  • [New Demo] Node.js On Windows Azure
  • [New Demo] Service Bus Relay
  • [New Demo] Service Bus Queues
  • [New Demo] Image Rendering Parametric Sweep Application with the Windows Azure HPC Scheduler
  • [New Demo] BLAST Parametric Sweep Application with the Windows Azure HPC Scheduler
  • [Renamed Lab] Connecting Applications through Windows Azure Service Bus (formerly Introduction to Service Bus Part 1)
  • [Renamed Lab] Windows Azure Service Bus Advanced Configurations (formerly Introduction to Service Bus Part 2)

To coincide with the new Azure web site, Scott Guthrie’s talk is worth watching: Keynote: Getting Started with Windows Azure

Non-Uniform Distribution from a Uniform Distribution

Given a uniformly distributed random variable x (such as the output from a standard Random Number Generator), how do we generate some other non-uniform distribution, q(y)?

Solution: Generate x, and take y = f(x). But how do we calculate f() given q() ?

The required function is the inverse cumulative distribution function given by:

clip_image002[6]

Example: Exponential distribution (to simulate the lifetimes of radioactive nuclei)

clip_image003[4], (τ≥0,and = 0 otherwise)

clip_image004[6]

So inverse is

clip_image001[5]

Ref.

http://en.wikipedia.org/wiki/Cumulative_distribution_function

http://en.wikipedia.org/wiki/Inverse_transform_sampling

Windows 7: Reclaiming Drive Space

Note: Everything that follows is performed at your own risk.

If, like me and may others, you installed Windows 7 Service Pack 1 over Windows 7 vanilla, you probably have quite a bit of wasted space on your primary drive (around 1GB). This is obviously not desirable if you have a relatively small SSD as your primary OS drive.

Given that it is extremely unlikely that anyone would ever remove Service Pack 1 and go back to vanilla, you can quite easily reclaim this space (Note: you will no longer be able to uninstall Windows 7 Service Pack 1):

  1. Open an elevated command prompt (i.e. Run as administrator).
  2. Run this command:  dism /online /cleanup-image /spsuperceded /hidesp