Showing posts with label Programming Tools. Show all posts
Showing posts with label Programming Tools. Show all posts

Wednesday, August 15, 2012

Crusing for Registry Interface Classes for use in win32 C++

I am looking at drragging some old c-ish win32 class that handles my registry IO forward into the current century. My option is either to re-write it, test, debug..etc or find some code that has the job done already.

My criteria would be:

STL aware ( at least for reasonable string type handling )
Fairly modern C++
Not include dependencies for stuff I don't use/want/have (MFC, Managed, .NET, ATL, etc)
Sane Exception design.
Unicode aware or at least cleanly written.
Secure use of std c functions. (_s variants)

My survey of the options is:


http://www.codeproject.com/Articles/14508/Registry-Manipulation-Using-NT-Native-APIs
This is much more functionally complete but needs a complete re-write.  While interesting in that it uses the NTAPI calls.  The Unicode handling is a mess and needs a re-write along with the general structure and error handling philosophy.
No maintenance since 2006

http://www.codeproject.com/Articles/19/Registry-Class
This is fairly rudimentary and uses the Win32API calls. (RegCreateKey etc)
No maintenance since 1999
http://www.codeproject.com/Articles/2521/Another-registry-class
Looks like early Windows Classes Style of code. 
No maintenance since 2003

http://www.codeproject.com/Articles/2916/CRegSettings-registry-helper-class
Written in a kind of C meets MFC style. Very Quick and dirty.
No maintenance since 2002

http://www.codeproject.com/Articles/6676/Access-Registry-Settings-Declaratively
Written in old school MFC/ATL style Macro madness. Nice work back in the day but a pain to maintain or use going forward.
No maintenance since 2004.

http://www.codeproject.com/Articles/10729/A-nother-C-Registry-Wrapper
Written in fairly modern c++. STL aware. Unit tests of some description.  All Win32API, fairly simple design.
No maintenance since 2005

http://www.codeproject.com/Articles/936/Stream-like-operations-for-the-registry
This is an interesing style.  Seems to be fairly simple in terms of functionality. Written in older Win32 style with error codes and error flags rather than exceptions. Basic use of templates.
No maintenance since 2001

http://www.codeproject.com/Articles/3611/Simple-Stack-Based-Wrapper-for-Windows-and-XML-Reg
 This looks nice.
No maintenance since 2004

http://www.codeproject.com/Articles/11913/An-AES-Encrypting-Registry-Class
Registry wrapper with encryption. Interesting but overkill for my needs.
No maintenance since 2007

http://www.codeproject.com/Articles/345/Registry-API-Wrapper
Yet another "simple" wrapper for the Registry. Pre STL and very old school. Not Unicode compliant.
No maintenance since 2000

http://www.codeproject.com/Articles/1031/A-Registry-Class
A bit old school but well written.
Some comments posting fixes in 2009 for Unicode issues.

http://www.codeproject.com/Articles/1108/CPJRegistry-2-0
MFC audience.
No maintenance since 2001

http://www.codeproject.com/Articles/8708/S-I-V-Simple-registry-config-class
Another "simple" class
No maintenance since 2004

http://65.39.148.52/Articles/8953/Registry-Wrapper-Class-CRegistry
Looks a bit MFC style. Some bugs in the comments.
No maintenance since 2005.

http://65.39.148.52/Articles/2535/A-set-of-template-classes-for-working-with-the-reg
Uses templates so there is some hope.  A bit dated as far as functionality goes.
No maintenance since 2002

http://65.39.148.52/Articles/1803/CRegisterEx-a-registry-wrapper-class
Looks like a simple read/write wrapper.
No maintenance since 2002.

http://65.39.148.52/Articles/10046/Registry-Wrapper-to-save-your-Application-settings
Another simple read/write wrapper.
No maintenance since 2005.

http://code.google.com/p/cregistry/
No information that I can find about this.

http://www.engr.sjsu.edu/wbarrett/registry.htm
Very basic functionality. Looks like write only.

http://www.codeguru.com/cpp/w-p/win32/article.php/c1433/Registry-API-Wrapper.htm
No maintenance since 1998.

http://65.39.148.52/Articles/343664/Template-Cplusplus-wrapper-for-Windows-registry
Looks nice, smells nice. Nice. 
Posted 2012. 

I think my search is over.  This is current generation code and frankly there is nothing better out there that I can turn up in this time.  I'm done.




Thursday, January 26, 2012

Article on Macros inC++

http://journal.stuffwithstuff.com/2012/01/24/higher-order-macros-in-c/

Nice explanation...

(bad)Magical game scripting

I have been picking through the quest scripting interface for oblivion and honestly I'm shocked that it works at all.  I get that it's implemented as a fun little dynamic language that anyone can pick up and use... but its also a giant stick to beat yourself with.  Horrible unstructured spagetti code sprayed with pretend objects, magic numbers, state fragments and every other crappy artifact of bad programming you can imagine.  There is only nominal encapsulation, no compile time checking... magic numbers are the order of the day... basically all the bad things that every paid programming tool set has been trying to help prevent for the past 50 years...

It's frustrating that each game platform re-invents the wheel with their scripting languages and re-creates the same set of bugs and flaws. 

That said, I sympathise with the system designers who are tying to balance accessibility and flexibility with function and some measure of protection for their runtime.

If only level designers were highly skilled programmers... lol.

This train of thought leads down the slipper slope of ... "If only..."... and "We could make it better if...".  However, everything has a price.  Raise the feautures and we raise the complexity for the users.  Feature creep in the scripting languages will only increase the debbuging costs and the chance of exploits. 

Look at matlab, labview, eprime, maxscript, (those are just the ones I have used in the past week) etc etc etc... every one of them started with the idea that they could make a simple runtime with a scripting interface and a few tools that would allow novice users to build ... stuff. 

They all have varying learning curves... varying degrees of depth, various mechanisms to help with bug management and usually user scripts with bug counts up the whazoo. (If the ones I have seen are anything to go by...)

I think the problem has been well described in many other places, the users are ignorant, the tools are unfriendly and the language is full of traps.  (Oh and the runtime is probably buggy as a termite nest.)

So... we have a problem... whats the solution? Better educated users? Tools that check and identify common classes of errors (static script analysis anyone?) and a less fragile language.  All the things every language community has been arguing about for years.... Nice to know I'm not cutting any new ground today...

Think laterally... make a graphical programming environment... drag and drop... boilerplate script... templates.. generics... maybe let the users do their own memory allocation... add raw pointers to the scripting language ...lol.  ...hmmmm no.  Is this a hopeless... fluffly problem that has too many dimensions?  No.

The thing is that the scripting languages are not trying to solve low level programming problems.  Usually they're pushing around high level constructs with very clearly defined abstractions.  The game world is very rigidly defined and the need for magic numbers is pretty limited.  Incrementing and decrementing a skill number can be done through a function call to increment() or decrement() rather than passing a raw int to a setter method.  This forces the script writer to play by some clearly defined rules that the interface designer has laid down and write their script at a level of abstraction and in terms of the "game" world... not at the level of raw numbers. 

A scripting language for a defined interface should not support lower level abstractions than are defined in the interface. 

This also means that patching the runtime does not break scripts.  As long as the abstractions in the interface do not change... everyone is fairly happy.  You can even write tests in the scripting language.


If a scripter wants to do something fancy.... let them write it up in a doc, generalise some cases and request a change to the interface... but for Oblivions sake, don't hand the tools and the responsibility to the scripters... its not their job to make the runtime safe.

Thursday, January 19, 2012

Another static analysis experience

http://altdevblogaday.com/2011/12/24/static-code-analysis/

This post by John Carmack speaks with a lot more authority than any of mine on the subject of static analysis.  Its good. Do it.

Monday, October 24, 2011

Compiler as API

http://msdn.microsoft.com/en-us/hh500769

Rosylyn project... . Sort into "Things I have wanted to waste time, which I don't have, on..." category.  Now if only they would do it for the VC++ compiler. 

Thursday, August 4, 2011

GPU programming for .NET

http://www.tidepowerd.com/product

This looks quite handy.

Debugging close to the metal

http://www.woodmann.com/collaborative/tools/index.php/Category:Categorized_by_Tool_Type

This is the collection of tools you want to have when you are debugging at an extreme level. Some of the anti-root kit utils are also useful for diagnostics.  They may not help dis-infect a machine but it gives more clues. I have a suspicious laptop on the todo list at the moment that has symptoms but nothing conclusive.  All the basic scanners are failing.... so the only thing to do is either flatline it and rebuild or go in at a level below the potential rootkits.  As it was riddled with malware... chances are it has either a botnet or rootkit somewhere.

Monday, July 25, 2011

CSS Lint Tool

http://csslint.net/

Clean up all that tangled css you know is lurking around....

Wednesday, June 1, 2011

Analysing Installation Dependencies

My two favorite tools for understanding why an installer is all tangled up are:

Dependency Walker http://support.microsoft.com/kb/256872

and

MSI Explorer http://blogs.technet.com/b/sateesh-arveti/archive/2010/11/21/msi-explorer.aspx

If you want to unpack or understand the activities of the setup.exe or .msi files, these tools are the only ones I know of.

Tuesday, May 31, 2011

Code Bubbles guy

Lots of tasty reading here. Code bubbles looks quite interesting.

http://www.andrewbragdon.com/cv.asp

Wednesday, May 25, 2011

Code Bubbles

http://www.andrewbragdon.com/codebubbles_site.asp

Finally.... why has this taken so long?

Interstingly Microsoft has picked up the idea and is rolling it out for their most useless version of VS2010.  Is this a ploy or just a starting point? Gotta imagine that it will percolate down to the more accessible versions once the tool has been fleshed out. Waiting.....

Funny how something like this generates a vomit of ideas.  Finally all the ideas that I have been half having for years get a new subject to fixate on. 

Friday, March 25, 2011

Testing with Mocks, stubs and an ugly testing framework

http://openmymind.net/2011/3/23/Stop-Using-Mocks

This article provides a good argument about some of the subtle issues with Unit testing. However the points are hard to make out through the vague illustration and the uncommented code polluted with yet another fuggly testing framework.

I am getting to the point where I really cannot look at another framework that introduces yet another sub-dialect of a language in an attempt to "simplify" some aspect of our lives.  Probably started off as a good idea but has then been taken to a point where its inaccessible for new users and casual readers. At least add some fucking comments to the code to help clarify what the fuck you think is going on.  That's the point of comments.  Tell us what you want the code to be doing.... even when its not actually doing it right.  We can read the code all we like and still never get any insight into whats going on in your head.  All we can do is draw our own conclusions about your head, the level of damage it may have suffered and the incompetence its demonstrating and then talk to our friends and accomplices about how to track it down and give it a kicking.  Code is not comments.  Comments are not code.  They have the capacity to tell different stories.
Its good that machines cannot read comments and "help" us by fixing them up and keeping them in sync with the code. Can you imagine just how much of a mess it would be if your IDE 'helped" by re-writing the comments to match the horrible code that some crappy coder turned in?  (you perhaps)  Imagine having to pull old copies of the code from the repository just to verify if the comments have changed and try to recapture the semantics of the original design notes that you wrote when your head was fresh.  What a pain in the arse. Long live stupid IDE's.

Friday, January 28, 2011

Software Testing Stack

http://www.matthewbussa.com/2011/01/evolution-of-automated-testing.html

This is a good article that summarizes the software testing stack as I visualize it.  The problem I keep coming back to is that there are no turn key systems to implement this kind of stack for most developers. You can find fragments of the solution in some languages. Others have much better sets of tools, but they are still not integrated or complete.

As a developer I just want a testing suite that I can turn on, build tests in and run in various obvious ways (selectively, by group, by layer etc), I want a back end reporting system that will give both simple and rich stats, coverage metrics, etc.  And most importantly, I want the system to support my favorite languages, libraries and frameworks.

I figure it should be illegal to use a language/framework/library etc that is not able to be comprehensibly tested to using an open set of tests on a known testing framework. Things like this are just not business ready.

Seems like the .NET testing environment is maturing quickly but its still a bit of a "roll-your-own" mentality which makes portability of the tests between developers less easy.

Thursday, January 20, 2011

Article on source code commenting

http://visualstudiomagazine.com/articles/2011/01/06/to-comment-or-not-to-comment.aspx

There are some good points in here about commenting code. Some fairly obvious.

It does suggest one idea to me that is not covered. If comments on one hand are not part of the run-time construct, while source code is completely part of the run-time construct, what are unit tests and asserts?  They are intermediate between comments and source code. They make assertions that can be interpreted as meaningful commentary on the program, although sometimes cryptic and wrong.

The point being that they are both parsed and evaluated, while not being part of the final run time construct (obviously you could come up with scenarios to prove this wrong... but that misses the point)

I would contest that there is a spectrum between comments, tests and asserts and source code. With human readable at one end and the final compiled construct at the other.  Everything has meaning but there are still differences between what is intended vs what is actually happening in some code.

Thursday, December 23, 2010

Mature Coding Environment

It’s a day for bitching about programming tools again. I have just finished reading a couple of fanboy posts and articles about various programming languages/IDE's etc that are new and hot and just the secret sauce and I am tired of it.

These systems are IMMATURE. They are not only not worthy of production code but they are not worthy of hobby coding. They are to use a technical term... toys.  They are a good idea that is under development and will not be ready for productive use until they have matured.

Why do I bother making what should be a bleedingly obvious comment? Firstly, cause I am sick of the endless spew of new coding stuff and secondly because its clearly not obvious to others. Oh and I'm forcing myself to articulate it because it helps crystallize my thoughts.

So what do I mean by mature? OK. I'll state it up front and then support it rather than trying to build it via subtle and cleaver arguments.... (Never really works anyway)

*** A MATURE PROGRAMMING ENVIRONMENT HELPS THE PROGRAMMER BE EFFECTIVE ***

Yeah? And.... like how?

1. A stable language feature set

2. A state of the art IDE or language support in your favorite text editor

3. Comprehensive RICH support for the major aspects of development (develop, test, deploy, maintain)

4. Has tools to extend the programmer via automation. (Debuggers, Static Analysis, formatters, document extraction, profiling, code generators, macros, Refactoring, GUI Designers, test frameworks and runners)

5. Has high level tools for managing complexity (various file/text/logic/structure views, flowcharts, models etc)

6. Integration with a STABLE ecosystem of components (databases, media libraries, GUI systems)

7. Has a rich knowledge base with both breadth and depth on both core competencies and application to more exotic projects.

8. Has systems of support. (No man is an island... shoulders of Giants etc) Forums, discussions, communities where solutions can be found in a timely fashion.

9. Comprehensive documentation for the tools.

10. Is integrated ( or can be integrated ) into a robust workflow that can be packed up for storage and reopened when needed.

Without getting into stupid methodology arguments, I think these aspects make for an environment that gives the working programmer the best chance of getting from A to B with a project in the most effective way. I'm not talking about the self enrichment that comes from tackling something unknown or hard or only working in assembler or any other side effect of programming. I'm talking about getting a job done effectively so you can get on to the next thing/problem/job/stage whatever. I get that many people enjoy programming and fiddling and wish it would never end. I have those moments and its easy to waste time for little real progress. (Refactoring should be stored in a locked cabinet with the other dangerous drugs...)  I'm talking about getting a specific, bounded job "done" efficiently. (I may be strange in that I am rarely working on a single project at a time, usually there are half a dozen or more in the air at any time in a couple of languages with their own domain issues, so I see patterns develop.)

This then becomes a "how long is a piece of string" discussion about what "efficiently" means.  Well it means the system works, satisfies the criteria I have agreed too, will not embarrass me when its reviewed and will not be a pain in the ass when I inevitably have to come back to it and make some changes.

So what’s with the MATURE shit? Well it goes like this... a software system is an investment... it has costs to create and hopefully will return value to someone in its use, not just its creation. It has a life cycle and some sort of diminishing returns curve. It also potentially has ways to extend its value (maintenance).  If you can conceptualise of software this way, then the economics of the tool set used to create it are an important variable in the value model. Not that hard if you're used to building any financial models or doing basic cost benefit analysis.

So the initial outlay cost of the tools is a fixed amount, but the cost of using the tools is a variable amount, dependent upon both the task its being used for (difficulty) and the time the task takes.  These two will probably have an exponential relationship; simply meaning that the harder the job, the longer it takes. However time is a linear constant, so its will probably not vary too much unless you have an unlimited number of people to throw at the job...(Mythical man month anyone?)

These two variable costs are the ones that make this model suck hardest; but also identify the issues to attack for the maximum gains. (Has anyone profiled the actual activity of programming? I 've certainly tried.)

The time variable can be fiddled with a little but has a ceiling. There is only so much work you can get out of someone in a given time period and adding more people has a diminishing return... so it has some pretty hard limits from the people side of the equation. However... if the tools have an effect on time... then.... ah... you see the point... if you tools are throttling the activity of the people then you are tool bound.... better tools could potentially allow them to reach their maximum productivity.

The other variable is difficulty, which can manifest in all sorts of ways. Difficulty from the platform, from weird API's, from crappy third party support, from ugly documentation, from missing language features, from having to write and test the same boilerplate code over and over again... The point however is that within the activity of programming itself there are only two states... the first is where you are making forward progress toward the project goals(State A) and the other where you are stalled or going backward (State B).  In state B, you are burning time and resources for no gain. These situations can't always be avoided... or could they?
There can be a bit of grey between these two states but forcing myself to make a call between state A or state B can clarify the situation in my own head.

Anyway, so after a brief look at my personal economics philosophy I get back to mature programming environments and how it all relates.

The key point is that a mature programming environment has been optimised to reduce the cost in time and the multiplying effect of complexity/difficulty. This optimising never quite ends but there is a distinction between a well developed, mature environment and the solutions available for a "new" language/tool set.

The thought exercise I always use is to conceptualise a couple of projects, the first is a one-off throw away data solution for a project for a single user of maybe 1kloc, then a simple experiment package of say about 10kloc for a couple of researchers, the next is a more developed multi-part tool set for working with motion capture data of about 70kloc for both internal and external users, the last is a larger package with more history, a huge library of resources, multiple generations in service at once and large body of users of about 750kloc. I mentally try to apply a prospective tool set/language to each of these projects and see if I can imagine using that tool set productively on the projects.

Honestly, most of the languages and tool sets I see talked up fail before the first hurdle. They're not even worth considering for a tiny throw-away project. Why not?  Because their initial setup and investment in the tools is massive in comparison to the time spent on the productive project work!  It takes time to find and assemble all the bits and update to the latest builds and scrounge enough information to build a GUI and you need to hand code everything without any useful samples... etc. Why bother?  For larger projects the initial cost is much less significant, but the other issues start to come into play. How well integrated is the tool set? Will it build with a single button click, will it deploy iteratively, can I build various types of tests (unit, integration, GUI?)  Etc.  How does the tool chain scale? How does it manage complexity and extend the limits of the human brain? Can it graphically express code structures, does it support static analysis tools, are there profilers, debuggers, code formatters, documentation systems, code generators and an API for building your own tools against the exiting toolset. Is there a macro system for the tools?

These are basic features that a working programmer should expect. But so often are lacking.

As such, there are very few systems that can conceivably be described as mature. There are a lot that are moving in that direction and there are an infinite slew that is much closer to toys....
I'm just tired of the illiterate fanboy’s who get lost in the excitement of a shiny new toy without realizing that its got such a long hard way to go before its grown up enough to be a serious contender for anything.  That probably makes me seem quite dated.....

I must build a table of all the contenders one day... Wikipedia maybe....

Wednesday, November 17, 2010

Natural Language Processing

http://nlpwp.org/book/chap-words.xhtml

Good resource both on Haskell and NLP.  Nothing that can't be done in another language. I feel much more comfortable mapping this problem space to C++ than to Haskell, simply because I'm more fluent. I also have a sneaking suspicion that the myths about Functional Programming are less about any intrinsic properties of the language and more about the person holding the hammer....

I have actually done some of this in VBA, which if anyone is interested, is painful due to the ugly data structures and having to build everything yourself. I know I can use .NET containers etc but its still ugly because its not my favorite hammer and its dog slow, hangs unpredictably and ... well its just dog slow(very slow dog... ignore obvious edge cases in this metaphor) I can make any tool work given enough time and energy but some just make the job harder in ways that the word "harder" does not express completely or gracefully. Think of VBA as a plastic toy hammer with an asthmatic squeaker .... C++ on the other hand is a bit like an antique 2T power hammer with a loose linkage in the return spring and a lumpy anvil but damn it can hit the problem hard....

Tuesday, November 16, 2010

Tenacious C IDE

http://tenaciousc.com/

This looks like an interesting product. Need to investigate more at a later date.

Wednesday, November 3, 2010

Clang and LLVM for C++ refactoring

http://clang.llvm.org/

Thank the Assembler, I don't have to do it myself. Not that I'm delusional enough to think that I could have, rather that I could see the need but there appeared to be no solution other than me doing it (somehow) myself.

Finally, I can start to dream of getting some re-factoring tools working for C++ and after that we can talk about high level transformation of code... better static analysis.... design extraction.... whooot!  Well a boy can dream can't he?

Friday, October 29, 2010

Profiler for VBA code in Access

I found a nice little stack style Profiler for VBA from a book called Access Cookbook. Its been very handy for identifying and tracking down a couple of memory leaks (My fault as usual) The Profiler is in a module called basProfiler and is discussed in an article called "Create an Execution Time Profiler" which has been reprinted all over the web. I had to fix a small bug in the code that formatted the output to the log file. Other than that it was good to go out of the box.

My usage of basProfiler

1. Import the module.
2. Set the path to the log file to somewhere conveinent. (I put mine into my working directory for subversion to manage)
2. Instrument the code blocks with the opening and closing lines.

Public Sub Whatever()
     acbProPushStack "Whatever" 'profiler
         'code to be profiled here
         '.....
     acbProPopStack 'profiler
End Sub


I open the log file in Notepad++ on the other monitor and every time I run the code, Notepad++ detects that the file has changed on disk and allows me to reload it. This gives me the power of a real text editor rather than a log window to play with the output.

Simple and elegant. Just the way I like my tools.

I considered hacking it to output a comma delimited file for import into excel for analysis but I ended up not needing that sort of power on this job.

And we are done.