A Silly C# Programming Puzzle!
# define i
using System;
using System.Text;
namespace ex11
{
class Program
{
static void Main(string[] args)
{
int i = 8;
# line hidden
++i;
# line 5
# pragma disable
# warning reverse execution is noitucexe
# line 4
# line 12
System.Console.WriteLine("i = {0}", i) ;
}
}
}
Answer tomorrow!
MyGeneration - Open Source C# O/R Mapping
The code generator takes the tables for a wide variety of databases (12!) and produces the class code. It's template driven (not C++ type templates) so the code generator can output code for JScript, VBScript, C# or VB.NET. It's worth a look not just because it's open source but because of the architecture. This is what the C# looks like for accessing an employee record. (This code example is similar to one on the MyGeneration website).
Employees emps = new Employees() ;
if(emps.LoadByPrimaryKey(31))
{
emps.LastName = "Bowman";
emps.Save() ;
}
// Add one new record for Mr Archer
Employees emps = new Employees() ;
emps.AddNew() ;
emps.FirstName = "Mr.";
emps.LastName = "Archer";
emps.Save() ;
// get the last record index
int i = emps.EmployeeID;
Not a sql statement in sight! You'll find mygeneration here and the code on sourceforge. Note, you'll need another sourceforge project- the free 7z archive utility to extract the source code files.
Boost 1.36.0 released - With Four New Libraries
The quality of Boost software is kept deliberately high; Ten Boost Libraries are included in the C++ Standard Library's TR1 (The next version) and getting your code accepted into Boost is by no means easy. If you want to become a better C++ programmer, develop an understanding of how and where you might use some of the Boost libraries. It's free with full source code and an extensive list of libraries. Highly recommended.
- Link to C++ Programming Tutorials
- Link to C++ Code Library
Programming Challenge 17 - Implement the Cellular Automaton known as Life.
This isn't due until the end of October but as I thought of it the other day, I thought it best created before I forgot about it. Nearly 40 years ago a British mathematician John Horton Conway devised three simple rules which defined a cellular automaton that he called Life. It runs on a 2d grid with each point being clear or set. The rules determine what points are cleared (die) or are set (born) according to three simple rules.
- A set point surrounded by 2 or 3 other set points survives to the next generation.
- A set point dies if there are less than 2 other set points or more than 3 around it.
- A clear point becomes set if there are exactly three set points around it.
Implementing it so that it runs fast is an interesting challenge. So this challenge is to create code that will implement Life according to those three rules and process a long lived shape of just five dots for 1,000 generations as quickly as possible. By the way, Challenge 15 hasn't had any entries yet!
- Link to Programming Challenge Fifteen Create a Dungeon
- Link to Programming Challenge Seventeen Implement Life, to run as quick as possible
Buying an iPhone and learning Objective-C/C++
I've made the decision to not only buy a 3G iPhone, but a Mac Mini as well so I can try my hand at developing for it. Why? Well I'd been considering getting an iPhone for a while and 8 of my colleagues at work (out of 27) bought one last month. Two of them have even started developing apps for it. In July 2008 the App Store opened and took about $1 million each day of which it passed 70% back to the developers. Many apps are provided free with others ranging from 1$ to $10 or more. It's a bit of a gold rush for developers!
There are non-Apple iPhone development tools and you can compile Objective C/Objective C++ with the GNU Compiler Collection (aka GCC) but I suspect (tell me If I'm wrong) that that restricts you to 'Jail Break' applications. These are unapproved applications which only run on an unlocked iPhone.
There is a cat and mouse game between Apple, because rightly or wrongly Apple insists on controlling applications that run on an iPhone. You have to pay $99 to join and Apple has to approve your application but so long as you play nice by their rules I gather this is a formality.
One aspect of Apple that many iPhone developers hate is the NDA. It restricts what people can publish and many are hoping it will be eventually waived. So even if I wanted to (and you wanted me to), I'm not sure just yet how much I can publish about it though I can certainly add Objective C/C++ if you are interested in it. So tell me!
- Link to C Tutorials
- Link to So you want to be a games developer article?
Have You got a Cuda System?
The whole point of CUDA is to turbo charge your time critical or CPU intensive applications by offloading the number crunching onto the GPU in your graphics card which uses highly parallel operations to do crunch 10 or even 100 times faster than the CPU. Nvidia have been pushing this and you can now find a whole series of free video casts from the University of Illinois as well as other technical resources on the Nvidia site.
- Link to C Tutorials
The Disruptive Nature of Open Source- Asterisk
What would appear to be something more in the domain of big telephone companies has become a software success story. It is a world leader when used as a switch (PBX), gateway, replacement for old PSTN systems letting calls be connected over IP, normal telephone cable and digital connections. Even call center systems have been built around it. The fact that it runs on GNU/Linux for various hardware platforms and is also part of Debian probably helps. As with much Linux software it's written in C and has a very large number of features, particularly with VOIP where no additional hardware is needed. A permanent link has been added in the C Code library.
- Link to C Code Library
Answer to C Programming Puzzle
If you want to see more examples of obfuscated code (I know I don't!) take a look at the past entries to the IOCCC website. This is the home of the International Obfuscated C Code Contest. If anyone want to send in their own original obfuscated code I'll put them on a special page in the C (or C++) code library.
- Link to C Code Library
- Link to C++ Code Library
Microsoft Releases SP1 for .NET/Visual Studio 2008
I installed the Visual Studio 2008 SP1 update which was just a 0.6MB download followed by a much larger one and pulled down the .NET SP1 update as well. That took 6 minutes (fast Internet helps!) but the installation part took about 15 minutes. You can read what's new in the .NET Framework 3.5 SP1 as well as download it. Note that if you have installed any related beta products then you may have to remove them. there is a full download link near the bottom of the page. There are two download links; one for just the .NET Framework SP1, or one for Visual Studio 2008 SP1 which includes the .NET Framework.
An Interesting C Program and Puzzle
#include <stdio.h>
_(__,___,____){___/__<=1?_(__,___+1,____):!(___%__)?_(__,___+1,0):___%__==___/
__&&!____?(printf("%d\t",___/__),_(__,___+1,0)):___%__>1&&___%__<___/__?_(__,1+
___,____+!(___/__%(___%__))):___<__*__?_(__,___+1,____):0;}main(){_(100,0,0);
}
It should compile (really!) and run but you may find it crashes. So the puzzle is, what do you need to do to make it run. Here's a big clue. Don't change any of the source code! You can search wikipedia but that won't tell you what's wrong... Answer on Wednesday. Have fun!
- Link to C Tutorials

