Tuesday, November 30, 2010

About C / C++ / C#: Programming Contest 42 Published - Fast Cars!

If you can't see this email, click here

About.com

C / C++ / C#

Fundamentals

Tips & Tools

Going Pro



From David Bolton, your Guide to C / C++ / C#
Contest 41 has had a lot of entries and re-entries. We're now up to 16 players and I've extended the deadline to next Sunday. (December 5th). One of the later entries has set a very fast time that's going to be very hard to beat. Meanwhile contest 42 has now been published (details below) and there's one entry in already! See you next week!

Programming Contest 42 Published - Fast Cars!
This time you are given a race track, defined by a series of vectors. Each vector is a pair of numbers, an angle and a distance. When the track changes direction there is a curve with a top speed limit. Your code must accelerate or decelerate your car so it gets round one lap without the car exceeding the curves' speed limits and crashing out. I've kept the maths simple; all curves are constant radius and only change directions in multiples of 30 degrees. I've also provided the 4 equations of motion so your program can easily calculate the new speed and distance traveled of applying acceleration or deceleration to the car for a period of time. You don't have to worry about friction, air resistance, weather, fuel etc. I'll have the track defined before the contest starts as it's not ready yet.

Contest 41 Results Updated
This is a few years old but pretty good, Thierry Berger-Perrin showed how to ray trace a sphere in under 100 lines of C++ code. What's even cleverer is that someone has written a C++ to JavaScript converter called Emscriptem and you can run the ray tracing demo online. Emscriptem takes the output of LLVM bitcode (which can be generated from C/C++, using llvm-gcc or clang, or any other language that can be converted into LLVM) and compiles that into JavaScript. Then you can run it on the web as that demo showed. JavaScript is interpreted so will never be quite as fast as compiled C++ code, but there is an arms race to have the fastest JavaScript interpreter between Firefox, Chrome and IE 9 so expect great things.

XML - Wildly Successful Data Transfer Format
XML emerged back in the mid late 90s and was an overnight success, though it was actually derived from the earlier SGML. It made possible transference of meaningful data that computers could process yet at the same time, it was human readable. This also allowed web services using Soap (Simple Object Access Protocol) to send and receive XML messages. One problem with XML is that it's pretty bloaty compared with pure data. Several methods including compression and binary XML have been tried to reduce the size which also makes it slower to parse. A very fast XML parser is AsmXml. Here's an example of XML borrowed from Wikipedia. <?xml version="1.0" encoding="UTF-8" ?>
<painting>
  <img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>
  <caption>This is Raphael's "Foligno" Madonna, painted in
    <date>1511</date>-<date>1512</date>.
  </caption>
</painting>
XML could be transformed into other XML type languages (including xhtml) through XSLT. HTML 3/4 which was the state of the art at the end of the 90s became xhtml which lasted most of the last ten years. It combined the strict XML typing (all lower case, tags had to have closing tags) with HTML, but with recent developments of html5 instead of xhtml2 and the lighter weight JSON gaining traction instead of XML, the question has to be asked, how long will XML be around?

Other Blogs You might find Interesting
This is a list of Blogs that you might find interesting.

 


C / C++ / C# Ads
Featured Articles
Never Programmed Before? Start Here
Welcome to the C Area with Articles about C Programming
Welcome to the C Sharp Area with Articles about C Sharp Development
Learn about Commercial Software Development
All about Games Programming
Code Library for C, Objective-C, C++ and C#

 

More from About.com

Great Gadget Gifts
iPad or iPod? Kindle or Nook? Point-and-shoot or DIL camera? If you're confused by this year's must-have gadgets, check out our top picks. More>



The Gift of Entertainment
The lowdown on the latest holiday releases, plus recommendations on the best in music, movies and more. More>




This newsletter is written by:
David Bolton
C / C++ / C# Guide
Email Me | My Blog | My Forum
 
Sign up for more free newsletters on your favorite topics
You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter. If you wish to change your email address or unsubscribe, please click here.

About respects your privacy: Our Privacy Policy

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

© 2010 About.com
 


Must Reads
Programming Challenges
About C, C++ and C#
C++ for Beginners
C++ Programming
Intro to OOP

Advertisement

No comments: