Silverlight Brass Tacks

Bill Reiss' Silverlight Ramblings
My upcoming Silverlight book for beginners Hello! Silverlight 2 with Dave Campbell, available online now!



Pages

Recent posts

Navigation

Archive

Blogroll

Tampa Divorce Lawyer

North of Tampa in Lutz, Florida. A Tampa Divorce Lawyer focusing on family, divorce, and real estate law.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Thoughts on the MIX 10K challenge

For those that haven’t heard, Microsoft has announced an interesting contest in conjunction with the MIX09 conference in Las Vegas. The way the challenge works is that you need to create a program where the source code is less than 10K bytes (10240 bytes) in Silverlight or WPF XBAP that will run on the web.

Rules and details are here:

http://2009.visitmix.com/MIXtify/TenKGallery.aspx

These types of competitions have been going on pretty much since computers have been around, and in particular, the Demoscene has some great samples of tiny programs doing amazing things.

The prizes are pretty sweet, including a trip to MIX09, $1500 Visa gift cards, and $500 Visa gift cards.

So a few thoughts on how to cram something into 10K.

First of all, forget a lot of what you learned about good programming techniques. Unless you’re ultimately saving space by breaking something into multiple methods or classes, shove everything together.

Make your variables and methods a single character if possible. You can write using longer names and refactor->rename later if it’s easier.

Reduce whitespace. C# can be written as a single line for the entire file.

Make sure to use using statements to avoid having to specify the namespace, but remove any unused using statements from your source files.

Use the built in .Net framework provided classes whenever possible instead of writing your own.

Consider using F# which can often use less characters for the same logic.

For any graphics, determine whether it’s more efficient to represent it as XAML or a bitmap image. Also consider writing code to create the graphics if it’s less characters than the XAML equivalent.

Anyone else have good suggestions to add to this?

Posted: Dec 04 2008, 03:34 by Bill Reiss | Comments (25) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Related posts

Comments

Tom us said:

TomSadly, they got it backwards with this competition. Instead of optimizing the size of the source code, people should be optimizing the the size of the compiled and packaged program. That's how it works in the demoscene. 8K intro? The EXE is 8K. It doesn't matter what the size of the source code is. Just like in the real world - it's the size of what you store or transfer over the wire that matters, not the size of its source code. (Yes I realize there is some overlap for things like XAML.)

IMO the size limit should've been on the XAP or XBAP file, with provisions for counting additional data towards the limit.

It's also unfortunate that the size limit is not a power of two...

# December 04 2008, 08:10

Bill Reiss us said:

Bill ReissTom,

I do agree with you, but it does get a little murky in Silverlight. If you're going for binary size but you are using something like System.Xml.Linq, should you be penalized because Microsoft made the decision not to include it in the core?

I've seen some C/C++ competitions in the past that have gone off of the size of the source code, so there is some precedent for that. Basically you're going to end up with some unreadable code in this contest.

I think XBAPs may have a bit of an advantage in this contest because there is a more feature laden .Net framework available that can be leveraged.

# December 04 2008, 08:23

Indian Singles us said:

Indian SinglesThis sounds like a great contest, but only for those not faint at heart. I'm still only just a beginner.

# December 05 2008, 12:59

Adam Kinney us said:

Adam KinneyThanks for sharing your thoughts Bill. I'll be sure to link people here for ideas on how to keep file size down.

We went with counting the source code for a few reasons, one because of the murky area you mentioned, especially due to the fact we're supporting different technologies. Also because the contest was inspired by Butterfield's 5k contest, where the focus was on the code written and resources used, not the HTML or JavaScript engine.

Admittedly this is our first attempt at a contest like this and we're keeping notes. If we run it again we'll take what we learned this time going into round 2.

# December 06 2008, 13:17

geekswithblogs.net said:

pingbackPingback from geekswithblogs.net

Silverlight Cream for December 06, 2008 -- #446

# December 06 2008, 17:42

crocusgirl.wordpress.com said:

pingbackPingback from crocusgirl.wordpress.com

MIX 10K Smart Coding Challenge « The daydreaming Crocus

# December 07 2008, 15:45

Alexandre fr said:

AlexandreIt's a great demoscene's like challenge... but it would have been much more logical to compete on the size of a final XAP rather than the size of the source file. It's a surprisingly choice, very limitating (when you build a silverlight C# sample project, there are multiples files App.xaml, App.xaml.cs, the AssemblyInfo.cs ...etc, If we don't provide theses files, how can someone use our code, and if we have to provide theses files, 10Ko source code is too small... unless to just play with a flat xaml file...) and not equivalent between languages (verbosity of some languages, you suggest that F# could be smaller, but this not fair for someone that knows very well VB, because this language is a bit more verbose). One more think i'm not sure : 10Ko, is it the ZIP file containing all the sources? or is it 10Ko uncompressed?

# December 07 2008, 22:13

Adam Kinney us said:

Adam Kinney@Alexandre

Yep, 10k is a challenge which will force you to be creative. We are looking at the file size uncompressed.

# December 08 2008, 13:08

Bill Reiss us said:

Bill ReissThanks Adam for clarifying. What if I download images or video via a Web Service or HttpWebRequest?

# December 08 2008, 16:18

Adam Kinney us said:

Adam KinneyRemotely hosted images don't count against the file size, just the code that makes the request. That's another optimization for your list Smile

# December 08 2008, 16:56

Bill Reiss us said:

Bill ReissHow about remotely hosted XAML? Or XAP files for that matter?

# December 08 2008, 16:58

Adam Kinney us said:

Adam KinneyYou can use Services to fetch data but not functionality, which can be a fine line when it comes to XAML. This is one of the points that moderators check when reviewing entries.

# December 08 2008, 19:56

Mohan Embar us said:

Mohan EmbarHi Adam,

Two questions:

1. Does AssemblyInfo.cs count against the 10K limit?

2. I'm still not clear on what exactly can be retrieved from a web server. In a private email to me, you said that the web server can't execute any functionality (like perform a computation based on input data you pass in). Above, you're saying that you can't <i>fetch</i> functionality. By the above, do you mean precompiled .MET files or any sort of data that might influence the functionality of the calling program?

# December 09 2008, 04:08

Mohan Embar us said:

Mohan Embar>precompiled .MET files

...oops I meant .NET files

# December 09 2008, 04:21

Mohan Embar us said:

Mohan EmbarAnyone home?

# December 12 2008, 04:09

Adam Kinney us said:

Adam KinneyTo tie this end up, Mohan and I ended up getting in touch via email. Thanks for letting us use your post as a support forum Bill!

# December 15 2008, 10:57

Mohan Embar us said:

Mohan EmbarYes, thanks Bill. And thanks to Adam and Amy for answering my questions and organizing this.

Best of luck to all entrants!

# December 15 2008, 11:00

Bill Reiss us said:

Bill ReissMy pleasure, glad I could facilitate it in a small way.

# December 15 2008, 12:11

Bart Czernicki us said:

Bart CzernickiCouldn't the rules be defined a little clearer? To me this is a little convoluted. I HATE contest rules like this.

@Bill,
I had a couple of the same questions you pointed out and still have my own.

# December 16 2008, 18:08

blogs.sqlxml.org said:

pingbackPingback from blogs.sqlxml.org

MIX 10k Challenge Entry - Bryant Likes's Blog

# December 22 2008, 12:39

Vinit in said:

VinitI have an application in silvelright which when compiled produces 9.92Kb of xap file. And my source is larger than the 10Kb, so my question is can I participate. I'm confused between the source file size and xap file size, which is going to be counted for this challenge?

# December 28 2008, 20:33

Vinit Yadav in said:

Vinit YadavHey, I got my answer, its code size which should be less than 10K limit. I was focusing on final outcome of Silverlight applications which is xap file. Although let see whether I can manage my code to fulfill the constants????

# December 29 2008, 07:36

Busby SEO Test gb said:

Busby SEO TestWell this is an awesome challange and the rule is easy to follow and this is must to try, every programmer will be have chance to win !

# January 07 2009, 01:12

Tuomas Hietanen fi said:

Tuomas HietanenIt is a shame that the size is not the zip-file but the plain source code. So, first you should write a zip-decompression program to extract the source, and compile on the fly... Which makes judges hard time to examine if the program is a valid entry.

# January 22 2009, 23:32

Santa Ponsa gb said:

Santa PonsaI've seen some C/C++ competitions in the past that have gone off of the size of the source code, so there is some precedent for that. Basically you're going to end up with some unreadable code in this contest.

I think XBAPs may have a bit of an advantage in this contest because there is a more feature laden .Net framework available that can be leveraged.

# March 08 2009, 02:29

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

said:

# July 04 2009, 13:04