Tuesday, December 29, 2009

About C / C++ / C#: Last Newsletter of 2009

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
It's sometimes easy to forget the pace of progress that impacts our lives. Ten years ago C# didn't exist, seven years ago no Facebook, five years ago there was no Google Maps and the iPhone is only three years old. That was quite a decade for innovation. I just wonder what the next ten years will bring. One thing for sure, people will still be learning C/C++ and C# as well as all the other useful technologies. Anyway don't forget Challenge 30's deadline is next weekend. I'm away until then, have a great week and a Happy New Year! I will still be posting while I'm away...

 
In the Spotlight
Optimizing C++ - an E-Book by Agner Fog
Continuing yesterday's theme on improving C++, here is a 155 page PDF E-Book by Agner Fog of the Copenhagen University College of Engineering on Optimizing software in C++. It's intended to do one thing and that's help speed up your code if it's 32 or 64 bit running on a standard PC platform, irrespective of the OS, be it Windows, Mac or Linux. The author also provides an open source library of fast assembly language routines which are replacements for standard library functions or add extra functionality such as rounding. The download link is on page 13 of the pdf. Although the E-Book is aimed at experienced developers, because of his occasional use of template classes I reckon anyone would benefit from reading it as it's chock full of optimization tips, I know I did and I highly recommend it.



 
           More Topics
An Alternative STL - EASTL
Electronic Arts as a publisher of many games recognized that the STL isn't ideal for their needs so they developed an alternative- EASTL. Though the code for that isn't available, Paul Pedriana of EA has written a very comprehensive document about their version of the STL and why they did it and it's excellent. He justifies this so: "Most significantly, game software requires large amounts of memory but has a limited amount to work with. Gaming software is also faced with other limitations such as weaker processor caches, weaker CPUs, and non-default memory alignment requirements." Changes were done to give higher performance with greater control of allocators, added validation of all containers and allocators made it easier to debug, tagged memory allocations plus lots more, much too much to cover in a quick overview like this. If you code in C++ this is fascinating reading, and don't miss out the appendices. Significant is the fact that they don't use exceptions (same as Google) unless really necessary. Plus there are some improvements which they recommend to STL, eg adding push_back(void) to containers to add an extra (empty) element, ie increase the capacity. A final note on this, they say this about C++. "C++ isn't taught much any more in college. It's hard enough finding people who know C++, and harder finding people who understand templates of the kind you find in STL.". Now there's a big hint to learn C++ if you want to create games!

 
Git, Mercurial or ...
A mate of mine who I've been helping with C# visited last weekend and I suggested to him that we use a distributed VCS so he and I could maintain the code base. Though I've showed him Subversion, it really needs something that he has to use so distributed is better that way. Over a 15 year period, we have developed a program for managing dog shows (in the UK- Kennel Club standards) that started in Turbo Pascal then moved to Delphi and is now C#. I've not done much with any distributed version control system, being a Subversion fan so was keen to try out both Git and Mercurial. Git I found very powerful but it needs to be used from the command line really as the GUI tools provided are distinctly minimal. Mercurial though works with TortoiseHG, similar to Tortoise that I know and love with Subversion. It adds extra commands into Windows Explorer so you just right click on files. I have used command line tools for version control for years and it's easy to make mistakes, miss files etc. On occasions I was checking in 60 odd files and tracking and committing that could easily take 15-30 minutes! Moving to Subversion was an enormous increase in productivity as you could see which files had been changed and folders of files could be selected and checked in en masse in one go. However I've just discovered Git Extensions which provide a Tortoise like experience (in Windows) and also an plugin for Visual Studio. It's a tough choice! And there's also Bazaar (thanks to Pedro for the tip), so it's not settled yet.

 
 
Sponsored Links
 
Feeling Under the Weather?
Evaluating Your Cold Symptoms
How to tell when a runny nose is just a cold, and when it might be turning into something more serious and require a visit to the doctor. More>

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2008 About, Inc.

Tuesday, December 22, 2009

About C / C++ / C#: Weekly Challeng Confirmed - Starts in January

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
No exact date yet as I have to write a sample bot in each language C, C++ and C# but the Weekly Challenge based on playing Sid Sackson's game Acquire will start next month, details below. Only three more working days for me this week then a break until the New Year. I will still be writing the blog, tutorials and the Challenges during this time so no rest for me! Have a Merry Christmas and a Happy New Year.

 
In the Spotlight
Weekly Challenge - Acquire Starts January 2010
The feedback was positive so I've started work on the API for this. Currently it looks like just five main functions are needed to play the game. To help people understand if they haven't played the game I've taken some photos and put up a gallery of common situations. It really is an easy game to play but hard to play well! I've added a more explanatory article. I've also posted a sample c bot skeleton but this is just the skeleton, not a full demo bot (One will appear soon) and the API is about 90% finalized. It's to give you an early heads up. these are the functions you'll need to implement in this version: int PickTile(pgamedata pgame,BufferType buffer) ; void BuyShares(pgamedata pgame,pShares shares) ; int CreateChain() ; int TakeoverChain() ; void SwapSellHold(int * SharesToSwap,int * SharesToSell) ; Plus the usual two for info about the bot.: char * BotNameVersionDate(void) ; char * BotOwner(void) ; I will follow up in the next few days with articles about writing bots in each language as well as a sample bot for each. Look for articles in this folder:

 
           More Topics
Another C# IDE
Screenshot of xacc.ideThe world is a messy, untidy place and I guess that's true in the world of open source. It's the freedom to develop what you want, even if a dozen other people have developed it before. Part of me though wants to knock heads together and say, "if only you'd all put your energy into working on one superlative version instead of a dozen lesser versions, imagine what the world would be like". I do wonder how many versions just get abandoned, forgotten and lost. Of course consolidating and working together will never happen; there are too many issues- personalities and the skill set to manage a team of developers is far removed from working on your own pet project. Also it would be a bit boring if there was only one version of anything but just two or three would be nice. In C++ there are a considerable number of IDEs and the same thing is starting to happen in C#. Not only is there Microsoft's Visual Studio, but Sharpdevelop, Monodevelop and Xacc not to mention the "seem to be no longer developed" x-develop and C# Studio. However xacc, developed solely by Llewellyn Pritchard is an interesting IDE. It's written in C#, is very small with just a 615Kb setup file and yet supports 27 programming languages. It includes an integrated debugger and scripting support as well and feels snappily fast, something more typical of Win32 applications and not my normal experience with .NET editors.

 
A Small Furry Database
Back 20 or so years ago before SQL databases became popular on microcomputers, B-Tree type databases were the in thing. A B-Tree is a data structure that holds data in pages in a tree structure. The B means balanced not binary. Binary trees are tree structures with just two branches per node whereas a B-tree isn't so restricted. As data is added to a b-tree, pages are split to maintain the balance. Generally all data is held in the same depth. You can see an example of a C++ class to maintain a B-Tree. Even in some SQL databases, a B-Tree structure is used to hold the data internally . A good example of an embedded DB (ie one that links into your code rather than running as an external server) written in C is HamsterDB, a cross platform. Dual licensed under GPL or commercial license. Note for non SQL DBs the approach to using the DB is quite different than that of SQL. It's more about retrieving records using a matching key and then doing updates or retrieving data. HamsterDB comes with a number of example programs to get you up and running. At my last job, the database there was Faircom's C-Tree and it was also a B-tree type database though commercial not open source. These types of databases are very fast but much better suited to single user rather than multi user applications.
 
Sponsored Links
 
Feeling Under the Weather?
Evaluating Your Cold Symptoms
How to tell when a runny nose is just a cold, and when it might be turning into something more serious and require a visit to the doctor. More>

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2008 About, Inc.

Tuesday, December 15, 2009

About C / C++ / C#: Not everyone in a Bank is a Banker!

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
IT staff in particular do not usually get whopping bonuses on a par with senior directors or traders! Nor do the cleaning, restaurant, admin staff etc. Because of Tarp etc, banks have not been the most popular and in many cases deservedly so but please don't tar us all with the same brush! That said, IT staff in banks, particularly development staff are amongst the best paid in IT especially compared with defense industries. So I'll say no more! Have a great week!

 
In the Spotlight
Getting Better Pay in IT
In my 28 year career, 6 of the companies I have worked for have gone bust. No I'm not really a jinx, it's just that the IT industry has changed a lot during that time. That means new companies come along and old ones fold in a Darwinian survival of the fittest battle. Names like Digital who grew massively in the 70s but failed to adapt to the PC and were bought by Compaq who were then bought by Hewlett Packard, now known as HP. Until I reached the age of 40, the longest I stayed in a job was 3 years. In the last ten years I worked at three companies, one of them for 7 years. Unfortunately it's the way of the world that changing jobs is the best way to get bigger pay than promotion within a job. I was never driven by money and so chose to stay in programming jobs rather than move up into management apart from a couple of Team Leader/Senior developer roles that were still mostly development. Two of the firms had career paths for techy people such as developers but most companies were small and didn't. Big company culture is different to small and you usually have less freedom and responsibility than in a small company but are more likely to get benefits such as training courses, health care etc.

 
           More Topics
Coding By Numbers
You might remember Painting By Numbers. It's a painting set with pictures built up of areas each with a number that indexed into a color palette.You filled in the area with the paint of that color. My manager at British Aerospace used to talk about the aviation software development there as Coding By Numbers. Luckily him and I worked on the software that tested aviation software so that was real programming! But the developers on the aviation software were given enormous printouts - several feet thick of specifications generated from an object oriented design tool. All the classes and interfaces were generated and they coded the implementation details. Back then in the 90s, Ada was the only game in town, being prescribed for both the US DOD and UK MOD military projects. Since then they relaxed things a little and allowed C++ and other languages. You might find the PDF of Lockheed Martin Corporation's C++ Coding Standards for the System development and Demonstration Program for the Joint Strike Fighter Air Vehicle of interest. I'm not breaking any secrets by linking to this: it's approved for public release! The standards are largely common sense though definitely restricting individual freedom in layout style e.g. AV Rule 59 (MISRA Rule 59, Revised) The statements forming the body of an if, else if, else, while, do...while or for statement shall always be enclosed in braces, even if the braces form an empty block. So it's not the most freedom you'll ever enjoy in a job but working in defense industries (no one ever calls it attack!) is not the worst sort of job you can do. I enjoyed my time working in the Industrial-military complex but the lure of games design pulled me away after two years.

 
How Long is a Piece of String?
C strings are easy to use but they equally easy to misuse with Buffer overflows a consequence of not doing full boundary checking. Companies like Microsoft having been disallowing the use of functions like strcpy as part of their SDL (Security Development Lifecycle) for the past five years. I can't stress the importance of this, just take a look at this page to see what can happen. But applications need string handling and there are a huge variety of replacement string libraries. James Antill is the author of one such library vstr and has compiled a comprehensive list of other libraries that he has compared it against. Whichever library you use, just ask yourself if a user of your applications could be compromised through insecure calls.

 
 
Sponsored Links
 
Feeling Under the Weather?
Evaluating Your Cold Symptoms
How to tell when a runny nose is just a cold, and when it might be turning into something more serious and require a visit to the doctor. More>

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2008 About, Inc.

Tuesday, December 8, 2009

About C / C++ / C#: Now on Challenge 30

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
Speed challenges seem to be the most popular and the new Challenge 30 already has one entry! Thanks to all 13 who entered Challenge 29, and the results are detailed below. It's also encouraging others to enter seeing the updates, so keep entries coming in and remember you can submit multiple entries! Have a great week!

 
In the Spotlight
Challenge 29 Final Results plus Challenge 30
Congratulations to Michael Chock who just beat Pedro Graca. The differences were milliseconds and I reran them a few times to check. Thanks to all 13 who entered and the range of times was pretty narrow.

Challenge 30 Published

You get to zap the surface of a planet from your orbiting spacecraft but the targeting system is broken and so you must define the targeting locations according to the challenge's rules. With five different sizes of targeting areas possible your program must reach every location as economically as possible while not zapping settlers. There is also a file of settler locations consisting of 10 pairs of numbers separated by a comma, each pair on a single line and each value in the range 0-99. E.g. 12,34 45,87 etc etc Good luck!

 
           More Topics
Thinking Outside the Box
Game AI has come a long way from the 80s and computing power has increased several thousand fold. The AI I wrote in assembly language for a simple Empire game was reasonably sophisticated but hardly compares with say AI for a team of soldiers in a 3D shoot-em-up these days. However even learning techniques can sometimes end up with rubbish behavior as witnessed by this video. Part of the joy of game playing is gaming the AI. In anything but the simplest games, humans always have an advantage over an algorithm; they are just too devious, sneaky and prepared to try different approaches. So a newer approach is to do what animators do. Look at a human's behavior and do the same. Animators capture motion with special camera and tracking devices attached to clothing. Researchers Jeff Orkin and Deb Roy are trying to model a waiter's interaction in a restaurant with a simple game that feeds them data. You can participate and help them.

 
MandleBulbs - 3D Fractals
While Mandlebrot sets have been around since the mid 80s, it's only the last few months have seen the emergence of MandleBulbs. These are similar to Mandlebrot sets but in three dimensions and the images are just stunning and look like they were formed naturally. Unfortunately, source code in C, C++ or C# is very thin on the ground, just about non existent, partially because it's new and it also requires a lot of intense processing. The equations are more complicated - see Wikipedia for a discussion. But if anyone has source code, please let me know so I can link to it. I suspect we won't see any for a while because it's so new and more complex because of the 3D rendering involving coloring and shading that it could be commercially exploited. Eventually there is bound to be an open source version.

 
 
Sponsored Links
 
Feeling Under the Weather?
Evaluating Your Cold Symptoms
How to tell when a runny nose is just a cold, and when it might be turning into something more serious and require a visit to the doctor. More>

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2008 About, Inc.

Tuesday, December 1, 2009

About C / C++ / C#: Programming Challenge 29 Updated

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
Well there were a few more entries so I'm finishing marking those today and tomorrow. There isn't a Challenge 30 yet but I'll have one up by Wednesday or Thursday at the latest. Your suggestions for Challenges are always welcomed. Email to Programming Challenge Suggestion. Have a great week!

 
In the Spotlight
Readers Open Source Projects Revisited

As I said a couple of weeks back, if anyone wrote to me about their open source projects in C, C++ and C#, I'd give them publicity and the first three are now up on a new open source projects page and all are in C++. It makes me wonder if this is just a statistical quirk ( that most open source projects are in C++), perhaps because ones in C (Apache, Linux, MySQL) started ages ago and C# hasn't been around as long as C++. Looking at the code library page the ratio is roughly 5:4:3 (C++ to C to C#) but that probably indicates my trying to be even handed. As the numbers increase I'll split them into a page for each language.



 
           More Topics
Fighting Wars With Plastic Bricks

BrikWars ScreenshotMy parents were convinced I would become an architect when I was younger as I had a Lego set and just made houses with it. It's kind of ironic because I used to play wargames and now Lego + wargames = BrikWars! Clearly it's just an excuse for grown men to play with Lego!

BrikWars is a set of rules for fighting tabletop wargames using Lego and Minifigs. This has been coded in the last year in C# for Windows and you can download the GPL'd open source code built using XNA and fight against the computer or other players. No bricks to tidy up afterwards!



 
A Very Clever Web App

The telnet protocol allows you to log onto a remote computer but you should never ever use it (unless protected by a secure session/ VPN etc) because it sends passwords in clear text. That said, FTP also does the same but it's still used widely and email!

The Secure Shell (SSH) alternative to telnet was created in 1995 by Tatu Ylönen, a researcher at Helsinki University of Technology, Finland after a password sniffing attack at his university. This lead to the creation of PuTTY; one of those rare open source utilities that was created for Windows and ported to Linux/Unix systems by Simon Tatham, an English developer who created NASM, the Netwide Assembler. The C games source code library has some of his puzzles.

The PuTTY suite consists of

  • PuTTY (the Telnet and SSH client itself)
  • PSCP (an SCP client, i.e. command-line secure file copy)
  • PSFTP (an SFTP client, i.e. general file transfer sessions much like FTP)
  • PuTTYtel (a Telnet-only client)
  • Plink (a command-line interface to the PuTTY back ends)
  • Pageant (an SSH authentication agent for PuTTY, PSCP and Plink)
  • PuTTYgen (an RSA and DSA key generation utility).
It's a handy and very secure way to remotely connect to another computer that is running a SSH server (typically Unix/Linux boxes) and very popular. For Windows there is also WinSCP which does the sftp/scp with a GUI which I used to use a lot but according to Wikipedia the installer now sends information back to a remote website.

 
 
Sponsored Links
 
Feeling Under the Weather?
Evaluating Your Cold Symptoms
How to tell when a runny nose is just a cold, and when it might be turning into something more serious and require a visit to the doctor. More>

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2008 About, Inc.