Anteru's blog
  • Consulting
  • Research
    • Assisted environment probe placement
    • Assisted texture assignment
    • Edge-Friend: Fast and Deterministic Catmull-Clark Subdivision Surfaces
    • Error Metrics for Smart Image Refinement
    • High-Quality Shadows for Streaming Terrain Rendering
    • Hybrid Sample-based Surface Rendering
    • Interactive rendering of Giga-Particle Fluid Simulations
    • Quantitative Analysis of Voxel Raytracing Acceleration Structures
    • Real-time Hybrid Hair Rendering
    • Real-Time Procedural Generation with GPU Work Graphs
    • Scalable rendering for very large meshes
    • Spatiotemporal Variance-Guided Filtering for Motion Blur
    • Subpixel Reconstruction Antialiasing
    • Tiled light trees
    • Towards Practical Meshlet Compression
  • About
  • Archive

Development fun

December 28, 2006
  • Programming
approximately 2 minutes to read

Yeah, you read right, developing software can be fun :) Especially if you stop walking the old roads and try new stuff.

Template metaprogramming

This can be real fun, seriously, as long as your compiler keeps up with you. I can recommend the MSVC++ 8.0 compiler (although, it generates sometimes very weird code) and an EDG based one, preferably the Intel C++ 9.1 compiler. It really kicks ass, provides meaningful messages in most cases and does proper template checking (not that lazy check when you instantiate which MSVC++ does). I’ve been playing around with those two compilers and some template metaprogramms lately, and I have to admit once you find a good problem domain then it can really suck you in.

Finally, you can generate huge amounts of boilerplate code in basically no time. Even if you wind up writing 100 lines of templates, it is still better than 50 lines of boilerplate - if you ever need to change the boilerplate, you will have to rewrite it from scratch, while you should be able to avoid it with the template route. Moreover, the tougher the problem, the merrier :) As an entry, try to write the “dot” product function for a 16 element vector (and using a for does not count, we want HPC style “all-inline” code), and then tell me which way was more fun :). I’ve rewritten most of niven’s math library using some rather heavy template code, and so far I’m very pleased with the results.

Testing

In each book about software development, you get told that tests are the most important thing in a good software. If you don’t believe the books (or you don’t read any ;) ), then believe me: Tests are the most important thing in software development. The immediate pay-off is usually close to null, you spend some time writing them, in exchange you catch more bugs earlier.

But the real killer argument is that if you ever come to the point where you are about to change some larger piece, the tests become an invaluable source of information. First of all, they catch bugs, but second, you have to think twice about the interface of your new stuff, and this is more important than I thought. Point in case: In niven, matrices used to provide no special means to access their data (and exposed a pointer to it directly), whereas vectors encapsulated them (yeah, I know, bad design, that’s why I’ve rewritten it). The first rewrite though used vector [1] and matrix (row, column) for accessing. After taking a look at the unit tests, I also added support for vector (1) just to be consistent with the matrices. Without having quite a lot of test code in place I’d probably never spotted this.

Previous post
Next post

Recent posts

  • Data formats: Why CSV and JSON aren't the best
    Posted on 2024-12-29
  • Replacing cron with systemd-timers
    Posted on 2024-04-21
  • Open Source Maintenance
    Posted on 2024-04-02
  • Angular, Caddy, Gunicorn and Django
    Posted on 2023-10-21
  • Effective meetings
    Posted on 2022-09-12
  • Older posts

Find me on the web

  • GitHub
  • GPU database
  • Projects

Follow me

Anteru NIV_Anteru
Contents © 2005-2025
Anteru
Imprint/Impressum
Privacy policy/Datenschutz
Made with Liara
Last updated February 20, 2019