Categories
Uncategorized

Intel/Microsoft Parallel Programming One-Day Course: September 20th in Montreal

Xzibit: "Yo dawg, I heard you liked processors, so we put processors in your processor so you can process while you process!"(If you don’t get the joke, here’s a little explanation.)

Moore’s Law isn’t dead; it just ended up taking on a new form. Named after Intel co-founder Gordon Moore, it refers to the observation that for the same amount of money, the number of transistors that can be place on a chip would double every 18 months. Moore described this trend in 1965 and expected it would continue for at least a decade; it’s held true for almost 50 years.

For a while, this doubling of transistors translated into a doubling of processor speed. We entered the 1990s with 286 processors running at about 10 MHz and left the decade with chips closing in on the 1 Ghz mark. But we didn’t get that hundredfold speed increase in the following decade; those extra transistors became multiple cores, so instead of speed, we got parallel processing engines.

To take advantage of these cores and get the speed increases that we’d grown accustomed to, it’s going to take parallel programming. It’s tricky to get right, and I have personally ruined some good programs with some bad threads, and you might have too. That’s what Parallelism Techdays (no relation to the TechDays conferences we’re putting on across Canada) are all about.

Parallelism TechDays: Developers -- Learn from Intel and Microsoft - Free 1-day course on parallelism and threading

Parallelism Techdays is a FREE one-day course taught by Microsoft and Intel where you’ll learn about parallelism and threading. This is your chance to learn about threading your applications for multi-core platforms.

This course is aimed specifically at Windows C++ programmers using Visual Studio. You don’t need to be familiar with threads, but it’ll help. If you’ve got beginning to intermediate experience with threads in C++, this course is for you!

Here’s the agenda for the day:

  • Thinking in Parallel
    • Why go parallel?
    • Types of parallelism
    • Task-based parallelism vs. traditional methods
  • Getting Started with Parallelism
    • Approaches to converting serial code to parallel
    • Approaches to creating parallel code from scratch
    • Intel Parallel Advisor with test application
  • Implementing Parallelism
    • Choosing a parallelism environment
    • Reasons we will focus on Intel TBB/Microsoft PPL in this class
    • Overview of TBB/PPL
  • Debugging and Correctness (Introduction)
    • Overview of special bugs and parallel programs (deadlocks, data races)
    • Debugging a parallel program (demos of Microsoft Visual Studio 2010)
    • Correction of data races (demo of Intel Parallel Inspector)
    • General guidelines for parallel processing
  • Tuning
    • Understanding parallel performance
    • Performance tuning process
    • Demos: Intel Parallel Amplifier, Microsoft Visual Studio 2010
    • General strategies for solving parallel performance issues

The course starts at 9:00am and concludes at 4:00pm, with 6 hours of instructional time, plus breaks and lunch. Register now – the Montreal event is happening soon!

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

Andrew Stellman’s C# “Inner Circle” Discussion, Game Challenge and C# Video Q&A

The Week-Long Discussion

Cover of the book "Head First C#"Andrew Stellman, co-author of O’Reilly’s excellent and easy-to-read C# intro, Head First C#, is holding a week-long “Inner Circle” discussion on C# and .NET 4.0 in the forums for O’Reilly’s “Head First” book series. In this discussion, he plans to cover a wide range of topics, including:

  • Why use C# instead of any other language?
  • C# best practices
  • Becoming a better C# developer
  • Dealing with objects
  • Productivity hints
  • The best of C#

If you want to follow the discussion, simply point your browser at the Head First Labs Forums’ “Head First C#” section and look for topics started by Andrew Stellman. You don’t have to log in to just read, but you’ll have to register for the forum if you want to join in the discussion and comment back.

The Challenge

Charlie Chaplin and the original IBM PC

In his first discussion topic, Andrew issues a challenge: build an old-school, text-mode game in C#! In the 1980s, the computing world was seen through the command line in an 80-character by 24-line grid (40 characters if you were on an Apple ][, Commodore 64 or Atari 400/800, even fewer if you were on a VIC-20), and that’s how we played a lot of games, whether they were commercial or typed in from source code in magazine or books like the ones scanned into the Atari Archives.

If you’ve never written a text-mode game before (or in my case, if it’s been a long, long time), he’s written an article to help out — Understanding C#: Use System.Console to Build Text-Mode Games.

Your efforts in building an old-school text-mode game will not go unrewarded. Submit a text-mode game and you can win a prize! He’ll judge them on the following criteria:

  • Game play
  • Fun
  • Technical coolness
  • General awesomeness
  • “Retro nostalgia” for extra point

The winner will receive five O’Reilly eBooks of his or her choice. He’ll also choose runners-up who will get a free O’Reilly eBook.

If you’re looking for ideas for an old-school text-mode game, check out these books at Atari Archives, with source code written in old-school line-numbered BASIC. Some of these take me back to my high school days:

Video Q&A: Stellman on C#

As a prelude to the discussion, Andrew recorded videos of his answers to questions about the C# programming language and the second edition of Head First C#

Why should developers learn C#?

What kind of applications can you build with C#?

How hard is C# to pick up?

What’s the toughest thing to learn in C#?

What’s new in the second edition of Head First C#?

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

“C# in Depth” and “Azure in Action” for the Price of One Book–Today Only (August 15th)!

csharp in depth azure in action

For today only (that’s Sunday, August 15th), Manning is offering the pair of their books, C# in Depth, Second Edition and Azure in Action for the price of one! Just use the discount code dotd0815 in the Promotional Code box when you check out. You can order the final book in either dead-tree or PDF format.

Both these books are MEAP books – that’s short for Manning Early Access Program, a chance for you to get in-progress and final editions of books currently being written.

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

Discuss C# with the “Head First C#” Author, Save Big Bucks on “Head First C#” Too!

Cover of "Head First C#, Second Edition"Want to learn C# or brush up on it? From Wednesday, August 18th through Tuesday, August 24th, you can join Head First C# co-author Andrew Stellman and other techies in a week-long exchange about C# in an O’Reilly “Inner Circle” discussion, where he’ll talk about C#, .NET 4.0 and Visual Studio 2010.

(If you’re a new programmer just getting started, Head First C# is a great book that will keep you engaged, even in those parts where the going gets a little tricky. If you’re an experienced programmer who’s new to C# – or like me, hadn’t used it in ages – it’s still a great read; just skip the basic parts and enjoy the “Head First” style in which it’s written. And yes, if you want to developer for Windows Phone 7, you’re going to need to know C#. Want to get Head First C# at a discounted price? See below for details.)

The discussion will span a wide range of topics, including:

  • Why use C# instead of any other language?
  • C# best practices
  • Becoming a better C# developer
  • Dealing with objects
  • Productivity hints
  • The best of C#

If you want to join in (I’ll be participating), register for the Andrew Stellman on C# discussion at O’Reilly. See you there!

Save Big Bucks on Head First C#!

O’Reilly have a deal on Head First C#, Second Edition (published this May, and it covers C# 4.0 and Visual Studio 2010): use the discount code BKCBD when ordering online from O’Reilly and save 40% off the dead-tree edition and 50% off the ebook!

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

Windows API Code Pack for .NET Framework Released

Windows 7 logo and Microsoft .NET logoUntil now, taking advantage of the UI improvements in Windows 7 (and even some features in Vista) took a fair bit of work – there was a lot of stuff that wasn’t available through the .NET Framework. You’d have to either switch to C++ or resort to hacks in order to access these goodies.

That’s all changed with the newly-released Windows API Code Pack for Microsoft .NET Framework. Written in C# – with some DirectX stuff written in C++ – this library acts as a wrapper that gives managed code access to features including:

  • Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars.
  • Windows 7 Libraries, Known Folders, non-file system containers.
  • Windows Shell Search API support, a hierarchy of Shell Namespace entities, and Drag and Drop functionality for Shell Objects.
  • Explorer Browser Control.
  • Shell property system.
  • Windows Vista and Windows 7 Common File Dialogs, including custom controls.
  • Windows Vista and Windows 7 Task Dialogs.
  • Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs. (DirectWrite and WIC have partial support)
  • Sensor Platform APIs
  • Extended Linguistic Services APIs
  • Power Management APIs
  • Application Restart and Recovery APIs
  • Network List Manager APIs
  • Command Link control and System defined Shell icons
  • Shell search API support
  • Drag and drop functionality for Shell objects
  • Support for Direct2D/Direct3D interoperability
  • Support for typography and font enumeration DirectWrite APIs

The system requirements are:

We’ll cover the Windows API Code Pack for Microsoft .NET Framework over the next little while in a couple of places – certainly on this blog, as well as at the TechDays 2009 cross-Canada conference in the Optimizing Your Apps for the Windows 7 Experience session.

Down arrow

Download Windows API Code Pack for Microsoft .NET Framework (v1.0)

 

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

My Interview at MeshU

No tech workshop is complete without a little goofing around on an accordion, and I certainly didn’t want the MeshU day of workshops (which preceded the Mesh Conference) to be incomplete. I did a quick interview with Anita Kuno in which I performed a classic computer programmer song parody and promoted The Empire, which you can see in the video below:

Categories
Uncategorized

Default and Named Parameters in C# 4.0 / Sith Lord in Training

Round Trip

sith_lord_in_training Back when I was working for OpenCola (from January 2000 through January 2002), the start-up cofounded by Cory Doctorow, I was doing a lot of work using beta versions of C# to build prototype peer-to-peer applications that got demoed to some large companies, including Microsoft, who were kind enough to provide us with betas of Visual Studio .NET and Windows XP.

I graduated to the 1.0 version when it came out. Even during the year after I left OpenCola (or more accurately, got the boot), I continued to write applications in C#, from things like a sales app for people who were selling practice certification tests to a trivia game for a company that was pitching it to Maxim. I do manage to land some interesting jobs from time to time.

That changed on Bastille Day 2003, my first day as Tucows’ Technical Evangelist, or as the title originally read, “Technical Community Development Coordinator”. Tucows’ client base were people who wanted to resell things like domain names and email, and as such were largely hosting companies. This in turn meant that they were using languages that you might consider “webbier”: open source dynamically-typed languages like Perl, PHP, Python and Ruby. I did what I could to stay away from Perl, I’d coded in PHP and Python for work before, and I picked up Ruby along the way.

Feeling a bit restless, I left Tucows in late 2007 to do Ruby on Rails development at what turned out to be Toronto’s worst-run startup, possibly ever. After that, it was project management at b5media, where I used Ruby to implement some “housekeeping” scripts. Although I hit up Microsoft Evangelist David Crow for a copy of Visual Studio so I could try out XNA, I really didn’t pay too much attention to C#. I installed it on my machine, wrote a lazy “Hello, World” app – a single WinForm with a button that displayed a MessageBox with the word “poop” when you clicked it – and promptly forgot about it.

The situation changed when I got laid off in September and then got hired as a Developer Evangelist for “The Empire” in October. Suddenly, I’m back in a world with a three-versions-later Visual Studio and a two-and-a-bit-versions-later of C# and .NET. I’ve got the programming know-how and the language basics down cold; it’s the changes in the language and library – generics, LINQ and a bunch of 2- and 3-letter acronyms beginning with “W” – that keep catching me by surprise.

Luckily, management is cool with my first year being a “learning journey”. They’re really interested in how I mix my schmoozing and community-building skills with a love of technology and programming and don’t mind that my first year is a “learning journey”. They especially don’t mind if I share what I learn along the way, which is what this series of articles, Sith Lord in Training, is all about. As I learn more about C# and the .NET framework, both present versions and the upcoming 4.0 versions, I’ll write about them here.

Default Parameters in C# 4.0

Suppose that you’ve got a method that takes a single boolean argument. Here’s how the argument affects what the method does":

  • If the argument is anything other than true or if no argument is provided, the method performs its normal task.
  • If the argument is true, the method performs its task, plus some additional stuff.

Here’s the Ruby implementation:

# Ruby

def myMethod(doSomethingOptional = false)
    puts "Doing my regular thing."
    if doSomethingOptional
        puts "Doing the optional thing."
    end
end

doSomethingOptional is a parameter with a default value. If myMethod is called without any parameters, doSomethingOptional is given the default value of false.

Unfortunately, the current 3.0 version of C# doesn’t support parameter defaults. The way to emulate this behaviour is to use method overloading:

  • One method to handle cases where no parameter is given
  • Another method to handle cases where a parameter is given

Here’s the implementation in C# 3.0:

// C# 3.0

public void MyMethod()
{
    MyMethod(false);
}

public void MyMethod(bool doSomethingOptional)
{
   Console.WriteLine("Doing my regular thing.");
   if (doSomethingOptional)
   {
       Console.WriteLine("Doing the optional thing.");
   }
}

That’s a bit long-winded for something that should be pretty simple. Luckily, this has been fixed in C# 4.0:

// C# 4.0

public void MyMethod(bool doSomethingOptional = false)
{
   Console.WriteLine("Doing my regular thing.");
   if (doSomethingOptional)
   {
       Console.WriteLine("Doing the optional thing.");
   }
}

And with that, the long-winded (and unnecessary, at least to my mind) method overloading workaround vanishes. Yay!

Named Parameters in C# 4.0

Named parameters make the meaning of the parameters explicit, as long as the parameter names themselves are pretty meaningful. Contrast the following call:

drawCircle(100, 200, 200, "yellow")

with this, which is supported in Python:

drawCircle(radius = 100, x = 200, y = 200, color = "yellow")

C# 3.0 doesn’t support named parameters, but C# 4.0 does. Here’s how you’d call MyMethod in C# 4.0 using them:

myMethod(doSomethingOptional: true)

As for the Python drawCircle method in the example above. here’s how you’d call it in C# 4.0:

DrawCircle(radius: 100, x: 200, y: 200, color: "yellow")

If this syntax is giving you some deja vu, it might be because it’s reminding you of Objective-C, where the call would look something like this:

[someObject drawCircleWithRadius:100 x:200 y:200 color:"yellow"]

See the Video

If you’d like to see more about default and named parameters in C# 4.0, there’s a video on the Chanel 9 site that covers them quite extensively. Go check it out!