Rick Minerich's Development Wonderlandhttp://www.atalasoft.com/cs/blogs/rickm/default.aspxA Software Engineering, Algorithms and Programming Language BlogenCommunityServer 2.1 SP1 (Build: 61025.2)More Cores Requires More Abstraction, What Does This Mean For Image Processing?http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspxThu, 04 Dec 2008 19:47:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:16755RickM0http://www.atalasoft.com/cs/blogs/rickm/comments/16755.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=16755http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=16755<p>Compilers and programmers are good at very different things.&#160; This is why they must come together in order to build software.&#160; The programmer has the vision and the intention, the compiler keeps track of all of the small machine related details and optimizations.&#160; Unfortunately, this is not an ideal world.&#160; At any given time a programmer will be worrying about any number of insignificant platform details while working.&#160; However, intelligent platforms that take care of many of these details are on the way and they are coming hand in hand along with functional programming and the many-core revolution.</p> <p>&#160;</p> <h3>Introduction</h3> <p>Recently, Steve Hawley built a <a href="http://www.atalasoft.com/cs/blogs/stevehawley/archive/2008/12/04/more-image-processing-with-c-lambdas.aspx">Lambda expression interface on top of our existing ImageCommand infrastructure</a>.&#160; However, he ran into a few roadblocks.&#160; The two biggest of which were performance and flexibility.&#160; It turned out that given our existing very mutable and very object oriented infrastructure, it is all but impossible to be flexible enough to implement all of our image commands as lambdas without severe performance costs.&#160; These performance costs were directly due to having to pass back and forth a great deal of semantic information about the particular changes to each pixel.&#160; I see this as a direct result of trying to graft on functional programming onto a very procedural API.</p> <p>The next big programming revolution will be one of having intelligent systems deal with the details.&#160; Things like managing threads and wiring complex objects together will disappear from the lives of the average developer and will instead be left to those developing the platform those programmers are using.&#160; We will move from describing how to do things at a low level and instead use abstractions to describe what we want to be done.&#160; This is all necessary to for the production of software on the very complex and very distributed hardware platforms that are coming.&#160; </p> <p>&#160;</p> <h3>Performant Complexity Works Well in Non-Distributed Systems</h3> <p>Our own representation of an image is very complex.&#160; By this I mean it has a large number of properties.&#160; This is necessary because we have many customers all of which have slightly different goals.&#160; We need to be able to support anything our customers might need to do.&#160; They must be able to directly access the underlying memory that represents an image for the fastest image processing possible.&#160; This type of implementation is performant on the dual to quad core environments people are dealing with today.&#160; However, as the number of cores increase it becomes much more important for processing to distribute quickly instead of being heavily optimized for operation on a single processor.&#160; </p> <p>This may sound like a really awful burden but in reality it is a huge boon to the average programmer.&#160; What it means is that we will be working at a much higher level of abstraction than we are today.&#160; Because of all of these extra cores, we will have platforms which will optimize our abstractions on the fly without us having to handle the messy details.&#160; This is much like what modern compilers and runtime environments do today, however it will be to a much greater extent.</p> <p>Mathematica has been successful with an interesting approach for abstraction. Usually in the math world an image bitmap is just a integer matrix.&#160; However, In it’s most recently release Mathematica has taken the abstraction even further; <a href="http://blog.wolfram.com/2008/12/01/the-incredible-convenience-of-mathematica-image-processing/">unless you need deeper access, an image is just an image</a>.&#160; This allows mathematicians and computer scientists to not worry about the underlying code, much of what is desired is inferred.&#160; It’s this kind of innovative development that will be driving the future of our programming languages.</p> <p>&#160;</p> <h3>An Inferred World</h3> <p>We are all moving in the direction of inferred programming.&#160; By this I mean, systems are getting intelligent enough that they can make very accurate estimations of what you want without you explicitly asking for it.&#160; They may not always be correct, but they are in the vast majority of cases and when they aren’t you can correct them.&#160; For example, <a href="http://devhawk.net/2007/11/29/F+Hawkeye+Type+Inference.aspx">F# has very intelligent and integrated type inference</a>.&#160; I have found that it takes much of the type safety burden off of the programmer and still enforces compile time type checking.&#160; However, I believe this is just the tip of the iceberg.&#160; </p> <p>Part of the reason for the shift to inference is that <a href="http://www-i2.informatik.rwth-aachen.de/Forschung/FP/">functional programming lends itself to this type of analysis</a>.&#160; Similarly, if we wish for image processing to move in this direction we must change the level of abstraction we work at in order to provide an environment similarly amenable to analysis.&#160; This can be broken down into two parts: how we represent the image and how we deal with processing an image.</p> <p>The first part of this would be to change how we think about storing images in memory.&#160; To do this it will be necessary to to design an image property manager which will take care of the messy details for you. In image processing, is it necessary to have a static height, width and pixel format?&#160; All of these decisions should be inferred.&#160; In a cleverly designed system these properties would be given values behind the scenes in whichever way would lose the least precision.&#160; This can be done by deferring fixing the properties of an image until output time.&#160; In other words, lazy decision making.&#160; If they are required they should be stated as constraints instead of procedures.</p> <p>The second part is to change how we define our image manipulations to be in terms of transformations instead of procedures.</p> <p>&#160;</p> <h3>Transformations not Procedures</h3> <p>Along with inference and functional programming will come the idea of using transformations on data instead of procedures.&#160; In the Microsoft world, this is mainly evidenced by LINQ.&#160; In LINQ one describes the transformation of a data set instead of describing the steps needed to change that data. </p> <p>Right now our commands for processing an image are defined by a set of ordered steps.&#160; This comes directly from the heritage of our API which sprung directly from procedural programming.&#160; If instead, we were to view image processing as a set of transformations we would do a great number of things to speed up processing.&#160; </p> <p>For instance, many image processing commands can be simply <a href="http://www.codeproject.com/KB/GDI-plus/matrix_transformation.aspx">represented as matrices</a>.&#160; These matrices can then be combined into a single matrix for almost no cost.&#160; This new combined matrix can be applied once for the same result of applying each matrix that came before.&#160; In this way many different processing commands can be combined and done all at once.&#160; This is much more efficient than doing each command separately over any image of significant size.&#160; </p> <p>Some types of image processing cannot be represented as a single matrix. This could be for a great number of reasons. In some cases it is because they perform a great deal of processing in order to decide on the actual transformation; processing that would be directly affected by previous transformations.&#160; In other cases the transformation is not uniform over the entire image.&#160; However, to represent them as transformations would at the very least make them easier to parallelize.</p> <p>Also, this type of abstraction could have significant overhead at the single core level.&#160; However, when looking at the vastly many-core world coming, these types of optimizations could produce a result much faster than would be possible by simple procedural case handling. </p> <p>&#160;</p> <h3>Conclusion</h3> <p>The programming world is about to change in a way that will make it extremely difficult for even a very savvy programmer to hand optimize software.&#160; Even today an <a href="http://www.ddj.com/development-tools/212201710">article by Michael Swaine on the Dr. Dobbs portal</a> proclaimed that it’s time to get ready for this and learn functional programming.&#160; Instead of mourning this change, we should embrace it as it will come along with a new layer of abstraction which will, in the end, make our lives easier and our software more performant.&#160; As for image processing, it’s important to keep the ideas of inference and transformation in mind as we head into a multi-cored future.&#160; We need to focus on defining problems in a way that makes them easily parallelizable, instead of focusing on specific CPU level optimizations.</p> <p>Yes, bits will be wasted, and so will overall processor time, but get over it.&#160; In a hugely parallel system, what counts is the time it takes to achieve the needed result, not the amount of work done to get there.&#160; A five fold performance decrease is a worthwhile parallelization cost when dealing with an order of magnitude increase in the number of processing cores.&#160; </p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx&amp;;subject=More+Cores+Requires+More+Abstraction%2c+What+Does+This+Mean+For+Image+Processing%3f" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx&amp;;title=More+Cores+Requires+More+Abstraction%2c+What+Does+This+Mean+For+Image+Processing%3f" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx&amp;title=More+Cores+Requires+More+Abstraction%2c+What+Does+This+Mean+For+Image+Processing%3f" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx&amp;;title=More+Cores+Requires+More+Abstraction%2c+What+Does+This+Mean+For+Image+Processing%3f" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx&amp;;title=More+Cores+Requires+More+Abstraction%2c+What+Does+This+Mean+For+Image+Processing%3f&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/12/04/more-cores-requires-more-abstraction-what-does-this-mean-for-image-processing.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=16755" width="1" height="1">Processes in .NET Part 1 – Launching Processes and Managing the Schedulerhttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspxTue, 25 Nov 2008 19:07:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:16615RickM3http://www.atalasoft.com/cs/blogs/rickm/comments/16615.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=16615http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=16615<p>This is the first in a series of articles relating to the management of external processes from within .NET.&#160; In my first article I will start with the basics: using the Process class to launch external processes and play with Priority and Process Affinity. </p> <p>&#160;</p> <h3>Safely Launching Processes</h3> <p>It has always been very simple to launch a fresh process in .NET:</p> <pre style="border-right:#cecece 1px solid;padding-right:5px;border-top:#cecece 1px solid;padding-left:5px;min-height:40px;padding-bottom:5px;overflow:auto;border-left:#cecece 1px solid;width:450px;padding-top:5px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;"><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;">Process notepadProc = System.Diagnostics.Process.Start;</pre></pre> <p>Now as far as best practices go, Process.Start will throw an exception if it for any reason can’t open the file you specify.&#160; Because of this, you should always wrap your call to Start() in a try-catch block.&#160; In most cases a Win32Exception will be thrown and in order to tell what really happened you will need to inspect it’s NativeErrorCode property:</p> <pre style="border-right:#cecece 1px solid;padding-right:5px;border-top:#cecece 1px solid;padding-left:5px;min-height:40px;padding-bottom:5px;overflow:auto;border-left:#cecece 1px solid;width:450px;padding-top:5px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;"><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 1: <span style="color:#0000ff;">const</span> <span style="color:#0000ff;">int</span> ERROR_FILE_NOT_FOUND = 2; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 2: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 3: <span style="color:#0000ff;">string</span> processName = &quot;<span style="color:#8b0000;">notepad.exe</span>&quot;; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 4: Process notepadProc = <span style="color:#0000ff;">null</span>; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 5: <span style="color:#0000ff;">try</span> </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 6: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 7: notepadProc = System.Diagnostics.Process.Start(processName); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 8: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 9: <span style="color:#0000ff;">catch</span> (Win32Exception ex) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 10: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 11: <span style="color:#0000ff;">if</span> (ex.NativeErrorCode == ERROR_FILE_NOT_FOUND) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 12: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 13: Console.WriteLine(&quot;<span style="color:#8b0000;">Error! </span>&quot; + processName + &quot;<span style="color:#8b0000;"> Not Found!</span>&quot;); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 14: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 15: <span style="color:#0000ff;">else</span> </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 16: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 17: Console.WriteLine(&quot;<span style="color:#8b0000;">System level error has occured: </span>&quot; + ex.NativeErrorCode); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 18: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 19: <span style="color:#0000ff;">return</span>; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 20: }</pre></pre> <p>For more information on Win32Exception and a list of all possible NativeErrorCodes see the <a href="http://help.netop.com/support/errorcodes/win32_error_codes.htm">this very daunting list</a>.</p> <p>&#160;</p> <h3>Changing Priority</h3> <p>At this point you now have a launched instance of notepad and have a handle to it’s process.&#160; Using this handle you can do almost all of the same things available to you in the Windows Task Manager.&#160; In particular it’s very easy to change a process’s priority:</p> <pre style="border-right:#cecece 1px solid;padding-right:5px;border-top:#cecece 1px solid;padding-left:5px;min-height:40px;padding-bottom:5px;overflow:auto;border-left:#cecece 1px solid;width:450px;padding-top:5px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;"><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;">notepadProc.PriorityClass = ProcessPriorityClass.AboveNormal; </pre></pre> <p>It is also very easy to toggle if a Process’s priority is boosted when it has desktop focus:</p> <pre style="border-right:#cecece 1px solid;padding-right:5px;border-top:#cecece 1px solid;padding-left:5px;min-height:40px;padding-bottom:5px;overflow:auto;border-left:#cecece 1px solid;width:450px;padding-top:5px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;"><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;">notepadProc.PriorityBoostEnabled = <span style="color:#0000ff;">false</span>; </pre></pre> <p>&#160;</p> <h3>Changing Affinity</h3> <p>It can also be very useful to change the CPU affinity of a process.&#160; This allows you to determine which Virtual CPUs or Cores a process is allowed to run on.&#160; To do this you need to create a bit mask where each bit represents one of the processors on your system.&#160; By toggling each bit you are controlling the ability of the process or use that Core.&#160; For example, to only allow access to the first Core on the system:</p> <pre style="border-right:#cecece 1px solid;padding-right:5px;border-top:#cecece 1px solid;padding-left:5px;min-height:40px;padding-bottom:5px;overflow:auto;border-left:#cecece 1px solid;width:450px;padding-top:5px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;"><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;">notepadProc.ProcessorAffinity = <span style="color:#0000ff;">new</span> IntPtr(0x001); </pre></pre> <p>Allowing access to the first two cores would require setting the first two bits of the IntPtr:</p> <pre style="border-right:#cecece 1px solid;padding-right:5px;border-top:#cecece 1px solid;padding-left:5px;min-height:40px;padding-bottom:5px;overflow:auto;border-left:#cecece 1px solid;width:450px;padding-top:5px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;"><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;">notepadProc.ProcessorAffinity = <span style="color:#0000ff;">new</span> IntPtr(0x003); </pre></pre> <p>Setting CPU affinity is useful in many cases.&#160; First of all, many older pieces of software have problems on new, multi-core CPUs.&#160; Secondly, you may not want to allow a mutli-threaded process to bog down all of your cores.&#160; For more information on CPU Affinity see <a href="http://blogs.techrepublic.com.com/programming-and-development/?p=691">Edmond Woychowsky’s blog on the topic</a> as well as <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.processoraffinity.aspx">Microsoft’s MSDN documentation on the property</a>.</p> <p>&#160;</p> <h3>Doing the Same For Each Individual Thread</h3> <p>For a deeper level of control you can reach into a process via the Process object’s Thread property and gain direct access to a <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processthread.aspx">ProcessThread</a> object for each of it’s threads.&#160; In this way, you can externally micromanage the priority and affinity of each of the threads.</p> <pre style="border-right:#cecece 1px solid;padding-right:5px;border-top:#cecece 1px solid;padding-left:5px;min-height:40px;padding-bottom:5px;overflow:auto;border-left:#cecece 1px solid;width:450px;padding-top:5px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;"><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"><span style="color:#0000ff;">foreach</span> (ProcessThread thread <span style="color:#0000ff;">in</span> notepadProc.Threads) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;">{ </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> thread.PriorityLevel = ThreadPriorityLevel.AboveNormal; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> thread.PriorityBoostEnabled = <span style="color:#0000ff;">true</span>; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> IntPtr threadAffintiyMask = <span style="color:#0000ff;">new</span> IntPtr(0x003); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> thread.ProcessorAffinity = threadAffintiyMask; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;">}</pre></pre> <p>&#160;</p> <h3>Full Source</h3> <p>Now to bring it all together, here is a little program that will first fiddle with process priorities and thread priorities and then finally loop to display memory and thread usage information while the program is executing:</p> <pre style="border-right:#cecece 1px solid;padding-right:5px;border-top:#cecece 1px solid;padding-left:5px;min-height:40px;padding-bottom:5px;overflow:auto;border-left:#cecece 1px solid;width:450px;padding-top:5px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;"><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 1: <span style="color:#0000ff;">using</span> System; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 2: <span style="color:#0000ff;">using</span> System.Diagnostics; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 3: <span style="color:#0000ff;">using</span> System.ComponentModel; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 4: <span style="color:#0000ff;">using</span> System.Threading; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 5: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 6: <span style="color:#0000ff;">namespace</span> ProcessFiddler </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 7: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 8: <span style="color:#0000ff;">class</span> Program </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 9: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 10: <span style="color:#0000ff;">const</span> <span style="color:#0000ff;">int</span> ERROR_FILE_NOT_FOUND = 2; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 11: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 12: <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Main(<span style="color:#0000ff;">string</span>[] args) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 13: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 14: <span style="color:#0000ff;">string</span> processName = &quot;<span style="color:#8b0000;">notepad.exe</span>&quot;; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 15: Process notepadProc = <span style="color:#0000ff;">null</span>; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 16: <span style="color:#0000ff;">try</span> </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 17: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 18: notepadProc = System.Diagnostics.Process.Start(processName); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 19: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 20: <span style="color:#0000ff;">catch</span> (Win32Exception ex) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 21: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 22: <span style="color:#0000ff;">if</span> (ex.NativeErrorCode == ERROR_FILE_NOT_FOUND) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 23: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 24: Console.WriteLine(&quot;<span style="color:#8b0000;">Error! </span>&quot; + processName + &quot;<span style="color:#8b0000;"> Not Found!</span>&quot;); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 25: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 26: <span style="color:#0000ff;">else</span> </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 27: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 28: Console.WriteLine(&quot;<span style="color:#8b0000;">System level error has occured: </span>&quot; + ex.NativeErrorCode); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 29: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 30: <span style="color:#0000ff;">return</span>; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 31: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 32: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 33: notepadProc.PriorityClass = ProcessPriorityClass.AboveNormal; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 34: notepadProc.PriorityBoostEnabled = <span style="color:#0000ff;">true</span>; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 35: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 36: IntPtr affintiyMask = <span style="color:#0000ff;">new</span> IntPtr(0x003); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 37: notepadProc.ProcessorAffinity = affintiyMask; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 38: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 39: <span style="color:#0000ff;">foreach</span> (ProcessThread thread <span style="color:#0000ff;">in</span> notepadProc.Threads) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 40: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 41: thread.PriorityLevel = ThreadPriorityLevel.AboveNormal; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 42: thread.PriorityBoostEnabled = <span style="color:#0000ff;">true</span>; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 43: IntPtr threadAffintiyMask = <span style="color:#0000ff;">new</span> IntPtr(0x003); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 44: thread.ProcessorAffinity = threadAffintiyMask; </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 45: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 46: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 47: <span style="color:#0000ff;">while</span> (!notepadProc.HasExited) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 48: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 49: System.Console.WriteLine(processName + &quot;<span style="color:#8b0000;"> currently has </span>&quot; + notepadProc.Threads.Count + &quot;<span style="color:#8b0000;"> threads.</span>&quot;); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 50: System.Console.WriteLine(&quot;<span style="color:#8b0000;">Overall Memory Usage: </span>&quot; + notepadProc.WorkingSet64.ToString()); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 51: <span style="color:#0000ff;">foreach</span> (ProcessThread thread <span style="color:#0000ff;">in</span> notepadProc.Threads) </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 52: { </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 53: System.Console.WriteLine( &quot;<span style="color:#8b0000;">Thread </span>&quot; + thread.Id + &quot;<span style="color:#8b0000;"> Total Processor Time: </span>&quot; + thread.TotalProcessorTime ); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 54: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 55: Thread.Sleep(1000); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 56: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 57: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 58: System.Console.WriteLine(&quot;<span style="color:#8b0000;">Process exited. Hit enter to continue.</span>&quot;); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 59: System.Console.Read(); </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 60: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 61: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 62: </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 63: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#ffffff;"> 64: } </pre><pre style="font-size:12px;margin:0em;width:100%;font-family:consolas,'Courier New',courier,monospace;background-color:#fbfbfb;"> 65: </pre></pre> <p>&#160;</p> <h3>Conclusion</h3> <p>I have only just scratched the surface here on what is possible with the Process class. Almost all of the information and functionality in the <a href="http://en.wikipedia.org/wiki/Windows_Task_Manager">Task Manager</a> is available for quick and easy access.&#160; I encourage you to explore the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx">MSDN documentation</a> further.&#160; It’s also possible to interact with and control processes directly.&#160; As for that, I will be going through it in future posts.</p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx&amp;;subject=Processes+in+.NET+Part+1+%e2%80%93+Launching+Processes+and+Managing+the+Scheduler" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx&amp;;title=Processes+in+.NET+Part+1+%e2%80%93+Launching+Processes+and+Managing+the+Scheduler" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx&amp;title=Processes+in+.NET+Part+1+%e2%80%93+Launching+Processes+and+Managing+the+Scheduler" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx&amp;;title=Processes+in+.NET+Part+1+%e2%80%93+Launching+Processes+and+Managing+the+Scheduler" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx&amp;;title=Processes+in+.NET+Part+1+%e2%80%93+Launching+Processes+and+Managing+the+Scheduler&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/25/playing-with-external-processes-in-net-part-1-basic-task-management.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=16615" width="1" height="1">Windows Live Writer Makes Blogging Less of a Hasslehttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspxFri, 14 Nov 2008 19:23:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:16588RickM3http://www.atalasoft.com/cs/blogs/rickm/comments/16588.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=16588http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=16588<p>The blog CMS we use is great in a lot of ways but it’s built in editor is really, really bad. Initially, I had used Microsoft Word to fill the gap, <a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx">with disastrous results</a>. Since then I have moved to using our blog software’s horribly antiquated text editing system but that has limited my formatting options quite considerably. Now, after a recommendation from a friend, I am giving Windows Live Writer a shot. This blog post is a recursive review of my experience writing this blog post in Windows Live Writer.</p> <p>&nbsp;</p> <h3>Full Featured Editing</h3> <p>Here is a screenshot of Windows Live Writer:</p> <p><a href="http://www.atalasoft.com/cs/blogs/rickm/windowslivewriter_110DC75D.png"><img src="http://www.atalasoft.com/cs/blogs/rickm/windowslivewriter_thumb_12DE1D24.png" title="windowslivewriter" style="border-width:0px;display:inline;" alt="windowslivewriter" border="0" height="418" width="416"></a>&nbsp;</p> <p>Windows live writer has everything you would expect from a html based text editor. This includes font formatting and paragraph formatting, colors, block quotes and alignment. </p> <p>For comparison, this is what the Community Server 2.0 interface I have been using looks like:</p> <p><a href="http://www.atalasoft.com/cs/blogs/rickm/communityservereditor_4CCACF5F.png"><img src="http://www.atalasoft.com/cs/blogs/rickm/communityservereditor_thumb_3CBE9159.png" title="communityservereditor" style="border-width:0px;display:inline;" alt="communityservereditor" border="0" height="510" width="416"></a>&nbsp;</p> <p>It is not resizable and it has no undo between saves. Also, it has a feature set right out of the HTML 1.1 spec:</p> <ul> <li>Bold, Italics, Underline, Strikeout, </li> <li>Indenting and Outdenting </li> <li>Linking </li> <li>Pictures </li> <li>Tables </li> <li>What, no blink? </li> </ul> <p>It lacks such basic 1990s era formatting as text size and alignment. This can make creating blog posts with any kind of real formatting really time consuming.</p> <p>It’s a huge difference.</p> <p>&nbsp;</p> <h3>Content Made Easy</h3> <p>While I came for the the easy text editing interface, I stayed for the slick client-server integration and simple content management. Windows Live Writer has a number of wizards each of which take the hassle out of adding a type of content to your blog. For example, here is a screenshot of its GIS integration:</p> <p><a href="http://www.atalasoft.com/cs/blogs/rickm/wlwmap_48F68EF7.png"><img src="http://www.atalasoft.com/cs/blogs/rickm/wlwmap_thumb_31CB1479.png" title="wlwmap" style="border-width:0px;display:inline;" alt="wlwmap" border="0" height="420" width="537"></a>&nbsp;</p> <p>As Windows Live Writer completely manages the process for you, inserting non-text content is extremely easy. For images, you can just add them your post using the insert picture wizard and it will handle the thumbnailing, uploading and linking for you. It has native <a href="http://youtube.com">youtube</a> and <a href="http://soapboxteam.spaces.live.com/">sopebox</a> support as well as the ability to add your own local video via a wizard. As shown in the screenshot, it has out of the box integration with windows live maps for quickly inserting interactive maps into your post. </p> <p>It also has a plugin interface so other types of content integration can be added. When you click on “Add a Plug-in” Windows Live Writer will actually take you to a <a href="http://gallery.live.com/">list which currently contains 105 different live plugins</a>. I haven't yet tried to implement my own content integration but if 105 different plugins already exist, it can’t be too difficult.</p> <p>&nbsp;</p> <h3>The One Downside: High Resource Demands and Sluggishness</h3> <p>This seems to me to be the biggest problem with Windows Live messenger:</p> <p><a href="http://www.atalasoft.com/cs/blogs/rickm/wlwresources_47FDA200.png"><img src="http://www.atalasoft.com/cs/blogs/rickm/wlwresources_thumb_39BF2910.png" title="wlwresources" style="border-width:0px;display:inline;" alt="wlwresources" border="0" height="23" width="429"></a> </p> <p>That’s about 253 Megabytes of peak memory usage for what is essentially a text editor. Maybe it’s just that I once had a functional computer with 64 k<u>ilo</u>bytes of ram but I find this kind of memory usage from a blog editor to be absurd. That amounts to about 15% of your ram if you have 4 gigs in your box.</p> <p>On my Intel Core 2 6600 @ 2.4 Ghz with 2 gigabytes of ram I have found Windows Live Writer to often be sluggish. When I click to move my cursor or highlight text it can take what seems like a whole second to respond.&nbsp; When typing or deleing text it sometimes will lag slightly behind my input. </p> <p>Performance issues are forgivable considering that it is still a beta software package. I do hope that the development team is able to take some time to try and work through these issues. </p> <p>&nbsp;</p> <h3>Conclusion</h3> <p>Although it has some problems, Windows Live Writer is by far the easiest and most convenient blog editor I have ever had the pleasure to use. The tight client-server integration means that in the future I will be able to avoid all of the tedious resizing, uploading and pasting of html snippets and instead be able to concentrate on content. I can only hope that by the time it gets out of beta some of the memory issues and sluggishness will be worked out as otherwise this is an amazing piece of software. </p> <p>I’m not the only one who thinks so. If you want to read some other opinions, you should check out a Phil Wainewright article entitled <a href="http://blogs.zdnet.com/SAAS/?p=199">“Writer is Microsoft’s first Live Killer app”</a> and <a href="http://paulstamatiou.com/2006/08/14/review-windows-live-writer-beta">Paul Stamatiou’s Review</a>.</p> <p><b>Edit:</b> After I posted this blog I noticed that its formatting looked remarkably similar in both Internet Explorer 7 and Firefox 3.0.</p> <p>Pros:</p> <ul> <li>Slick looking. </li> <li>Everything would expect in terms of text editing features. </li> <li>Direct Community Server integration. </li> <li>Conveniently manages inserted content for you. </li> <li>Its output looks great in both Firefox and Internet Explorer.</li> </ul> <p>Cons:</p> <ul> <li>Keyboard input can be sluggish. </li> <li>Huge memory footprint. </li> <li>Beta software. </li> </ul> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx&amp;;subject=Windows+Live+Writer+Makes+Blogging+Less+of+a+Hassle" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx&amp;;title=Windows+Live+Writer+Makes+Blogging+Less+of+a+Hassle" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx&amp;title=Windows+Live+Writer+Makes+Blogging+Less+of+a+Hassle" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx&amp;;title=Windows+Live+Writer+Makes+Blogging+Less+of+a+Hassle" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx&amp;;title=Windows+Live+Writer+Makes+Blogging+Less+of+a+Hassle&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/11/14/windows-live-writer-makes-blogging-less-of-a-hassle.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=16588" width="1" height="1">internettechnologyBlogsbloggingMuch ado about nullityhttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspxFri, 24 Oct 2008 14:07:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:16287RickM4http://www.atalasoft.com/cs/blogs/rickm/comments/16287.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=16287http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=16287<p>I read an interesting article this morning by <a href="http://www.zwitserloot.com/2008/10/23/non-null-in-static-languages/">Reinier Zwitserloot on the topic of null subtypes in statically typed languages</a>. The issue is that in Java and C# there are a number of different type modifiers for dealing with the concept of nullity. Because of this even a simple base type can be one of three separate somewhat incompatible subtypes.<br></p><ol><li>Can be set to null, can return null.<br></li><li>Can be set to null, returns default value.<br></li><li>Can never be null.</li></ol><p>I'm still not sure why we would want or need defaults for nullable types. It seems like a hack used to avoid null reference exceptions when they really should be happening. Perhaps we would all be better served by having all types be nullable and adding some precondition syntactic sugar for method definitions. <br></p><p>If we had two new features, we would be able to kick default and non-nullable types to the curb:</p><ul><li>Syntactic sugar for null checks.&nbsp;</li></ul><p>As long as the method is not being dynamically invoked, a compiler would be able to infer that the type was not supposed to be null and still throw errors at compile time. As for a dynamic invocation, there would be a type mismatch at call time in any case. There is no need for us as programmers to manage this at a type level. I understand that no one likes writing tons of NullArguementException checks but this is a problem which could be solved in many better ways. </p><ul><li>Syntactic sugar for parameter defaults.</li></ul><p>One of the features I miss most while working in C# is <a href="http://msdn.microsoft.com/en-us/library/91563f79%28VS.80%29.aspx">parameter defaults</a>. However, I do understand why they decided to not add it to the language. If a parameter down the list somewhere needs to be set, so do all of it's predecessors. However, it would be possible to use a new keyword (like default) that could be placed where you wanted the default value and this issue could be avoided entirely. <br><br>It seems to me though that the reason we need defaults for nullable types is because of the lack of parameter defaults. With the current move towards dynamic types and invocation, it may be necessary to add a little bit of highly optimized reflection so that questions about the nullity of method parameters could be asked easily. However, with parameter defaults and a little bit of highly optimized reflection it would be easy to enforce nullity while avoiding all of these different base subtypes. <br><br><br></p><p>&nbsp;</p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx&amp;;subject=Much+ado+about+nullity" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx&amp;;title=Much+ado+about+nullity" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx&amp;title=Much+ado+about+nullity" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx&amp;;title=Much+ado+about+nullity" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx&amp;;title=Much+ado+about+nullity&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/24/much-ado-about-null-types.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=16287" width="1" height="1">programmingC#object orientedcode.NETnullitylanguagesThe Future of Programming Languageshttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspxWed, 15 Oct 2008 14:18:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:16086RickM12http://www.atalasoft.com/cs/blogs/rickm/comments/16086.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=16086http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=16086<p>Yesterday, my coworker <a href="http://www.atalasoft.com/cs/blogs/loufranco/default.aspx">Lou Franco</a> pointed me to a fantastic talk by Anders Hejlsberg <a href="http://blog.jaoo.dk/2008/10/07/the-future-of-programming-languages/">on the future of programming languages</a>.&nbsp; In this talk Anders argues that the future of programming language development will be focused on three events: the explosion in the use of Dynamic Languages, the creation of many new Domain Specific Languages and the rising need for Concurrency.&nbsp; </p><p>In this article I'm going to focus on Dynamic Typing and Metaprogramming in particular.&nbsp; It's interesting to consider what the impact on the maintainability of our code from their increased prominence might be.<br></p><p><br></p><p><b>Dynamic vs Static Typing</b><br></p><p>Over the last decade the use of dynamic programming languages has exploded.&nbsp; Working at the higher level of abstraction that dynamic languages provide allows the programmer to spend much more time building things and much less time worrying about the details.&nbsp; For sure, when prototyping or experimenting the speed of dynamic languages is a huge boon.&nbsp; However, without type checking at compile time the potential for really difficult to track down bugs is huge. <br></p><p>Just think about the kinds of strange bugs that can happen when any type can be passed into any argument of any method.&nbsp; It gets even worse when you consider that these types may be silently converting themselves.&nbsp; Without great care, the number of potential execution paths in your program could skyrocket.&nbsp; </p><p>This can be offset by really strict unit testing and extremely high code coverage.&nbsp; However, I have yet to see a large real world project that had this level of testing.&nbsp; <br></p><p>For these reasons I find the new C# "dynamic" keyword rather worrying.&nbsp; It allows the programmer to declare variables which are only type checked at runtime instead of at compile time. I would hate to have to maintain a code base where it was liberally used. <br></p><p>Anders also mentions F#'s static but implied typing system.&nbsp; He talks a bit about the two worlds of static and dynamic meeting in the middle in this kind of way.&nbsp; I agree, this is really the best of both worlds.&nbsp; You gain the "dynamic feel" but get almost none of the downsides.&nbsp; The security of static types without all the extra typing. <br></p><p>&nbsp;</p><p><b>Metaprogramming</b></p><p>I agree that Metaprogramming is a powerful tool, especially for testing.&nbsp; In a ecosystem designed around objects having meaning, it only makes sense to be able to ask questions about those objects and be able to dynamically manipulate how they operate.&nbsp; However, I am worried that it may in some cases become a substitute for well designed architecture. </p><p>Also, because of it's nature, in many cases Metaprogramming necessitates the use of strings to represent information about the application.&nbsp; Strings whose contents will not be checked at compile time.&nbsp; Because of this it is very easy to make breaking changes to an application which won't be caught when the program is compiled. </p><p>Take for example the idea of a class with a single property.&nbsp; In the code for the application in which that class lives, a code branch depends on reflection to check if that property exists.&nbsp; If you were to rename that property that path would no longer be taken and a bug would result.&nbsp; If the creator of that code had used an interface instead of reflection it would have broken at compile time. <br></p><p><br></p><p><b>Conclusion </b><br></p><p>I'm not saying that these kinds of powerful tools shouldn't exist. They are extremely useful in many cases.&nbsp; We just need to be very careful in their use.&nbsp; As <a href="http://www.atalasoft.com/cs/blogs/stevehawley/default.aspx">Steve Hawley</a> likes to say, when you have a shiny new hammer everything starts to look like nails.</p><p>&nbsp;</p><p><b>Edit</b>:&nbsp; I want to note that I had intended to include a subsection on the direct modification of abstract syntax trees but ran out of time.&nbsp; Also, a good friend of mine also pointed out to me that Lisp style macros actually do let you work with the underlying code in a much more meaningful way than C++ style text manipulation.&nbsp; <br></p><br><br> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx&amp;;subject=The+Future+of+Programming+Languages" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx&amp;;title=The+Future+of+Programming+Languages" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx&amp;title=The+Future+of+Programming+Languages" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx&amp;;title=The+Future+of+Programming+Languages" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx&amp;;title=The+Future+of+Programming+Languages&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=16086" width="1" height="1">programmingF#C#concurrencyobject oriented.NETtalksreflectionTidying Up Old Blog Entrieshttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspxThu, 09 Oct 2008 17:41:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:16007RickM4http://www.atalasoft.com/cs/blogs/rickm/comments/16007.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=16007http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=16007<p>Looking back it seems like complete lunacy.&nbsp; For a period of time my method of choice to create blog entries was to write them out in Word 2003 and then export html.&nbsp; The almost unreadable text has been haunting me for a long time and I've finally gone back and fixed them.&nbsp; Along the way I built a small utility for doing this and I thought I would share it.</p><p>&nbsp;</p><p>It almost makes sense to me now.&nbsp; Our blog software features a very tempting "paste from word" button (see the paste icon with a little W?). <br></p><p><img src="http://www.atalasoft.com/cs/photos/rickm/images/16008/original.aspx" border="0"><br></p><p>In order to write blogs while still getting work done it's necessary for the process to be as painless as possible.&nbsp; Besides that button, Word 2003 had two features that really drew me in, the ability to easily change text size and the ability to retain the color in my code samples from Visual Studio.&nbsp; </p><p>The problem was always that it filled my posts with strange proprietary html tags.&nbsp; Also, the formatting in Firefox always looked kind of off.&nbsp; The text would overlap just a bit.&nbsp; The font was also pretty terrible looking...Ok, it was just plain ugly. <br></p><p>I'm not the only one who suffered from these issues.&nbsp; <a href="http://www.codinghorror.com/blog/archives/000485.html">Even Jeff Atwood of Coding Horror has experienced this</a>.&nbsp; He wrote a little utility to clean up Word's html but it didn't work well for me.&nbsp; Probably because our CMS does some sort of voodoo when the "Paste from Word" button is pressed.</p><p>So in the end, with some help from <a href="http://www.atalasoft.com/cs/blogs/dterrell/default.aspx">Dave T the regex ninja</a>, I was able to throw together a conversion app in C#.&nbsp; The goal of this app was to preserve three things while removing everything else:</p><ol><li>The Links</li><li>The Coloring<br></li><li>The Text Size</li></ol><p>It's not perfect but with 9 transforms I was able to get the documents into a state where they were easily be reformatted.</p><p><a href="http://www.atalasoft.com/cs/blogs/rickm/attachment/16007.ashx">You can grab the project here if you are interested. </a></p><p>&nbsp;</p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx&amp;;subject=Tidying+Up+Old+Blog+Entries" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx&amp;;title=Tidying+Up+Old+Blog+Entries" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx&amp;title=Tidying+Up+Old+Blog+Entries" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx&amp;;title=Tidying+Up+Old+Blog+Entries" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx&amp;;title=Tidying+Up+Old+Blog+Entries&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/09/tidying-up-old-blog-entries.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=16007" width="1" height="1">C#.NETVisual StudioReformattingWord 2003WordBlogsAvoiding the Dangers of Ambiguously Defined Data-Typeshttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspxFri, 03 Oct 2008 15:10:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:15911RickM10http://www.atalasoft.com/cs/blogs/rickm/comments/15911.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15911http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15911<p>When you are handed a string, integer, or any value type, can you know what it really represents?&nbsp; Can you define the range of appropriate behaviors for that data?&nbsp; Can you tell if it's formatted correctly?&nbsp;&nbsp; The problem is, in all of these cases, you can't.&nbsp; You can't be sure of it's meaning, it's format or even how to treat it.&nbsp; This is why ambiguous types break the <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented programming paradigm</a> and should be avoided whenever possible.<br></p><p>&nbsp;</p><p><b>Forward</b><b><br></b></p><p>It's laughable to think that a Physical Engineer or Physicist would work without the aid of units. This is because, when you have undefined units, you can't verify that the thing you get at the end of a computation is defined in a consistent way. &nbsp; </p><p>In computing, the counterpart to the Physical Engineer is the Software Engineer.&nbsp; Why is the Software Engineer not held to the same type of design integrity?&nbsp; The use of ambiguously defined variables is one of the largest sources of bugs in modern software development and yet we ignore it.&nbsp; In fact, with many dynamically typed languages we are moving in the direction of more and more ambiguity.<br></p><p>In C# and Java, strings and value types are defined only in terms of their lexical and mathematical operations.&nbsp; Except from the context in which they are used, they carry no additional information about the meaning of their content.&nbsp; In order to perform any non-trivial operation on that data, you have to make assumptions about it's meaning, which in turn leads to bugs.&nbsp; <br></p><p>&nbsp;</p><p><b>Is what you are writing really object oriented?</b></p><p>This may seem like a silly question to ask in the modern programming era.&nbsp; Almost everyone is using an object oriented language these days and its mostly taken for granted.&nbsp; However, as any beginning programmer knows, it is very easy to program in an object oriented programming language while completely ignoring the underlying paradigm.</p><p>We don't use OO because it's an agreed standard for implementing a programming language, we use it to solve a specific set of problems.&nbsp; These problems are directly related to the modeling of data and data manipulation.&nbsp; Groups of data subtypes are classified into a larger object and operations on that data are defined in such a way as to model behavior in terms of that classification.&nbsp; If the paradigm is ignored these issues become manifest as ambiguity and disorganization.&nbsp; </p><p>It follow that using ambiguous data-types in a public API goes directly against not only the object oriented paradigm but also the broader goal of data classification and program integrity.</p><p><br></p><p><b>Why not pass strings and value types as arguments to public methods?<br></b></p><p>Using an ambiguously defined data type instead of a well defined object means that the domain and formatting of that data is left open to question.&nbsp; It also means that if a user of that data formats it inappropriately it may find it's way into an operation for another type of data and cause havoc. <br></p><p>For a programmer that is familiar with object oriented programming it often comes down to a choice of encapsulation versus convenience.&nbsp; I know as well as anyone that having to define an object to carry your data when you could just pass in a string and a couple of integers can feel tedious.&nbsp; However, by taking the easy way out, you are setting things up to fail down the road.<br></p><p>Consider, is it possible that sometime in the future someone will be using the API you are defining?&nbsp; Will the person looking at that code know the specific format you chose for that string?&nbsp; What about the range of valid values for those integers?&nbsp; What kinds of assumptions about that data will be made that you may have not considered?&nbsp; If they mess up that format or get the range wrong, at what point will it become obvious?&nbsp; <br></p><p>There are a lot of advantages to using objects instead:&nbsp; An object which was designed to carry that same data could verify that it is well defined when it is constructed.&nbsp; It can hand back that data formatted or manipulated in many different ways.&nbsp; You can well defined questions which can be asked about that data which makes program control flow more obvious.&nbsp; Best of all, the code for all of these things is centralized and up to the discretion of the designer of said object.&nbsp; Using a well defined object, two people with different assumptions about that data but asking the same question will get the same result.&nbsp; </p><p>Of course, at the lowest level a CPU will be operating on basic value types and so our code will always reflect that to some degree.&nbsp; However, because ambiguous types are extremely dangerous, they should almost always be encapsulated and well defined.&nbsp; </p><p>&nbsp;</p><p><b>What tools are available to me in .NET?<br></b></p><p>If you are a .NET programmer the best thing you can do right now is to become familiar with the already existing classes available for making your strings more well defined such as <a href="http://msdn.microsoft.com/en-us/library/system.uri%28VS.80%29.aspx">System.Uri</a> and <a href="http://msdn.microsoft.com/en-us/library/system.io.fileinfo%28VS.80%29.aspx">System.IO.FileInfo</a>.&nbsp; I've put up a <a href="http://stackoverflow.com/questions/168732/what-are-some-string-encapsulation-classes-which-specify-both-meaning-and-behav">question on stackoverflow</a> in order to try to build up a list of available container classes.<br></p><p>Beyond the use of predefined classes, it's best to make your own encapsulation objects with heavy up front validation.&nbsp; You can then use extension methods to make native .NET classes take your new validated type.&nbsp; It would be worth putting together a library of free encapsulation classes, structs and extension methods to allow for easy interoperability.<br></p><p><br></p><p><b>Beware, the .NET Framework encourages ambiguous types.</b></p><p>Unfortunately, as well designed as it is for many things, the .NET Framework is pretty bad about ambiguity.&nbsp; Based on classes such as System.IO.Path and System.IO.FileStream which for some reason take paths represented as strings,&nbsp; you might even say that ambiguity is encouraged.&nbsp; Consider the vast number of methods in .NET classes which take unencapsulated strings and scalar types. <br></p><p>The most unfortunate side effect of this design is that users of the .NET API may come to believe that this is the way things should be in a proper object oriented API.&nbsp; Also, as a consequence, if you want your own product's API to be easily understood by a .NET user you have to follow the same destructive conventions.<br></p><p>&nbsp;</p><p><b>F# helps to solve this problem with Units of Measure.<br></b></p><p>In most object oriented languages, if you were to encapsulate every single scalar value that was passed into a method, it would be quite a lot of extra coding.&nbsp; Microsoft's newest programming language, F#, has a feature called <a href="http://blogs.msdn.com/andrewkennedy/archive/2008/08/20/units-of-measure-in-f-part-one-introducing-units.aspx">Units of Measure</a> which allows a programmer to optionally specify both meaning and behavior for classes of scalar types.&nbsp; </p><p>A scalar with a unit of measure is a real type which is enforced by the compiler.&nbsp; When an operation is performed the resulting type is that of the combined units used for the calculation, just as they would be in physics or engineering.&nbsp; This is because F# is designed in part to be used by engineers and scientists.&nbsp; As a side effect we as programmers get to reap the same benefit.<br></p><p>This type of scalar type classification has long been missing from object oriented languages.&nbsp; It's a huge step forward and I hope other programming languages move to adopt it quickly.</p><p>&nbsp;</p><p><b>Addendum</b></p><p>@Mark and Jon:</p> <p>I think I may not have fully expressed what I meant by "handed a string or integer". The context am talking about is post-compilation when variable names no longer have real meaning. In this context (discounting reflection on variable name) all you can tell about an integer is where it is coming from and it's value. An executing program does not have access to documentation.</p> <p>It's also important to consider reflective programming. It is generally agreed that reflective programming is where the object oriented world is headed. However, when you have a scalar value, you can tell very little about it through reflection. While it is possible to retrieve the variable's name using reflection, actually using the name of said variable to carry type information is a methodology which is extremely prone to errors from mistyping. Errors which will not be caught at compile time and which may lead your program to incorrect paths of execution.</p><p>Also, I want to note that while a string is not a scalar value it does suffer from the same type of ambiguity. For this reason it, and other "base" types, should be handled similarly.</p><p>&nbsp;</p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx&amp;;subject=Avoiding+the+Dangers+of+Ambiguously+Defined+Data-Types" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx&amp;;title=Avoiding+the+Dangers+of+Ambiguously+Defined+Data-Types" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx&amp;title=Avoiding+the+Dangers+of+Ambiguously+Defined+Data-Types" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx&amp;;title=Avoiding+the+Dangers+of+Ambiguously+Defined+Data-Types" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx&amp;;title=Avoiding+the+Dangers+of+Ambiguously+Defined+Data-Types&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15911" width="1" height="1">programmingmetaF#C#object orientedcodeideas.NETC++fsharpjavascripttechnologyF# at Code Camp 10 In Waltham, MAhttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspxFri, 19 Sep 2008 20:02:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:15719RickM1http://www.atalasoft.com/cs/blogs/rickm/comments/15719.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15719http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15719I'll be at <a href="http://blogs.msdn.com/cbowen/archive/2008/09/15/code-camp-10-the-schedule.aspx">New England Code Camp 10</a> tomorrow giving another talk about functional programming and concurrency in F#.&nbsp; It will be fairly similar to my previous talks in terms of ideas and content, however, I have put a lot of work into making the functional programming ideas easier to understand. The code samples have also been updated and are now 100% compatible with the F# CTP Release. <br> <p><strike>Our internet connection is going down soon for testing. I'll be updating this post later on tonight with more information. I'll be posting my slides and updated code examples.</strike></p><p>I did manage to get my slides and new code samples uploaded on Friday but I didn't have time to change my blog text. You can find them <a href="http://www.atalasoft.com/cs/blogs/rickm/attachment/15719.ashx">here</a>. <br></p> <p>The sites of interest for my presentation:<a href="http://msdn.microsoft.com/en-us/fsharp/default.aspx"><br>Microsoft's F# Developer's Center</a><a href="http://research.microsoft.com/fsharp/fsharp.aspx"> </a>( Download F# here. )<br><a href="http://research.microsoft.com/fsharp/fsharp.aspx">F#'s Microsoft Research Site</a> <br><a href="http://cs.hubfs.net/">hubFS: THE place for F#</a> ( The forums here are a great resource. )<br></p> <p>Here are some additional links you might find interesting:<a href="http://blogs.msdn.com/dsyme/"><br>Don Syme's Blog</a><br><a href="http://www.strangelights.com/blog/">Robert Pickering's Blog</a><br> <a href="http://podwysocki.codebetter.com/">Matthew Podwysocki's Blog</a><br><a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/04/25/10-hours-in-fsharp-exploring-concurrency-through-an-ant-colony-simulation.aspx">My F# Ant Colony Work</a></p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;;subject=F%23+at+Code+Camp+10+In+Waltham%2c+MA" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;;title=F%23+at+Code+Camp+10+In+Waltham%2c+MA" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;title=F%23+at+Code+Camp+10+In+Waltham%2c+MA" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;;title=F%23+at+Code+Camp+10+In+Waltham%2c+MA" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;;title=F%23+at+Code+Camp+10+In+Waltham%2c+MA&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15719" width="1" height="1">programmingF#functionallambaconcurrencycode.NETCode Campfsharptalksmicrosoft researchHow to set up your own free VSLab-based Matlab/Mathematica replacementhttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspxMon, 08 Sep 2008 14:48:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:15531RickM1http://www.atalasoft.com/cs/blogs/rickm/comments/15531.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15531http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15531<p>VSLab has <a href="http://www.codeplex.com/vslab/Release/ProjectReleases.aspx?ReleaseId=15329">just been updated</a> with full support for <a href="http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx">Visual Studio 2008 Shell</a> and the F# CTP release. It has been a <a href="http://cvslab.di.unipi.it/vslab/blog/post/2008/09/07/September-CTP-and-VSLab-again.aspx">rough couple of weeks</a> for the VSLab team as F# CTP <a href="http://cvslab.di.unipi.it/vslab/blog/post/2008/09/06/F-September-CTP-and-VSLab.aspx">changed a number of things</a> and they have been working hard to put together a compatible release. In this article I talk about a bit about what exactly VSLab is and walk you through creating a free VSLab installation.<br></p><p>&nbsp;</p><p><b>What is VSLab? </b><br></p><p>VSLab is a Matlab-like interactive environment which is implemented on top of Visual Studio 2008 and F#. It is designed to speed the development of scientific applications and make visualizing data quick and easy. One of the great benefits, besides being free, is that VSLab allows you to compile your applications into binaries which can be easily redistributed. Also, because the code is being run on the CLR it is, in most cases, much faster than the notoriously slow Matlab and Mathematica. <br></p><p>The <a href="http://www.microsoft.com/downloads/details.aspx?familyid=61ad6924-93ad-48dc-8c67-60f7e7803d3c&amp;displaylang=en&amp;tm">F# CTP</a> was updated a few days ago in order to fix a <a href="http://blogs.msdn.com/dsyme/archive/2008/08/29/detailed-release-notes-for-the-f-september-2008-ctp-release.aspx">number of bugs</a>. Even if you aren't interested in VSLab, now would be a great time to update your CTP installation. <br></p><p>&nbsp;</p><p><b>VSLab Quick Installation Instructions </b><br></p><p>With these two releases it's very easy to create your own free Matlab-Like Visual Studio environment. It's important that these steps are performed in order as each step depends on the previous step. Installing Managed DirectX is not strictly necessary but you will not be able to use the VSLab visualizations without it.<br></p><p><b>Prerequisites</b><br>If you already have a version of Visual Studio 2008 installed, it must be updated to SP1 before you can continue. <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E%20&amp;displaylang=en">The SP1 update package is available here</a>.<br>All previous versions of F# and VSLab should be uninstalled as well. I had some problems because I didn't start fresh.<br></p><p><b>1) </b><b>Install Visual Studio 2008 Shell.<br></b>1a) <a href="http://www.microsoft.com/downloads/details.aspx?familyid=2e9a8c35-eb3d-43eb-9122-a5ec195cd7bb&amp;displaylang=en">Download Visual Studio 2008 Shell (integrated mode).</a><br>1b) Run the installer to Extract VS 2008 Shell Package to a temporary directory.<br>1c) Inside that directory, run <i>vside.enu.exe</i> to launch the actual VS2 2008 Shell installer.</p><p><b>2) Install F# CTP</b><br>2a) <a href="http://www.microsoft.com/downloads/details.aspx?familyid=61ad6924-93ad-48dc-8c67-60f7e7803d3c&amp;displaylang=en&amp;tm">Download F# September 2008 Release Installer</a> (InstallFSharp.msi)<br>2b) Run the F# September CTP Installer, the default settings work great. <br></p><p><b>3) Install VSLab</b><br>3a) <a href="http://www.codeplex.com/vslab/Release/ProjectReleases.aspx?ReleaseId=15329">Download VSLab<br></a>3b) Run the VSLab Installer, the default settings work great here too.</p><p><b>4) Install Managed Direct X</b><br>4a) <a href="http://www.microsoft.com/downloads/details.aspx?familyid=c1367bc3-4676-481a-bfaa-5c15d1d7199d&amp;displaylang=en">Download the latest DirectX End-User Runtimes (August 2008)</a><br>4b) Run the installer to extract the DirectX End-User Runtimes to a temporary directory.<br>4c) Inside that directory, Run DXSETUP.exe to update your DirectX drivers.<br></p><p>You now have a complete VSLab installation.&nbsp;</p><p><br></p><p><b>Quick Start Information</b></p><p>1) First off, launch Visual Studio 2008 to get started. <br>2) Go to File-&gt;New-&gt;Project<br>3) Select Project Type: Visual F# and the VSLab Template<br>4) Hit Shift+Alt+V To activate the VSLab Interface<br>5) Right Click on your project and Click Add-&gt;New Item<br>6) On the left select the VSLab Category and Select the a the Viewer3D template.</p><p>Select all of the code before the calls to Close() and hit Alt-Enter to execute.<br></p><p><img src="http://www.atalasoft.com/cs/blogs/rickm/attachment/15531.ashx"><br></p><p>The real version is even animated.<br></p><p>Congratulations, you are now all set up to play with VSLab and F#. <br></p><p><b>Keys: </b><br>Shift+Alt+V: Starts The VSLab Interface<br>Alt-Enter: Send selected code to the F# interactive tool window<a href="http://cvslab.di.unipi.it/vslab/blog/page/Visual-Tutorial.aspx"></a></p><p><b>References: </b><a href="http://cvslab.di.unipi.it/vslab/blog/page/Visual-Tutorial.aspx"><br>The VSLab Tutorial</a> is a great resource but has not yet been updated for the new VSLab release. Note that the key bindings have changed as mentioned above and keep an eye on the <a href="http://cvslab.di.unipi.it/vslab/blog/">VSLab Blog</a> for updates.</p><p>&nbsp;</p><p>edit: fixed a link and added a picture from VSLab. <br></p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;;subject=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;;title=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;title=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;;title=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;;title=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15531" width="1" height="1">F#functional.NETTutorialsfsharpDebuggerVS2008Visual Studiomicrosoft researchVisual Studio ShellVSLabVisual Studio Shell 2008: Bringing More .NET Languages into the Visual Studio Foldhttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspxThu, 28 Aug 2008 18:29:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:15388RickM9http://www.atalasoft.com/cs/blogs/rickm/comments/15388.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15388http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15388<p>Visual Studio Shell was released in January of 2007 without much fanfare.&nbsp; Even though it's free to download, at the time it was not very useful for most developers as few packages had yet been written for it.&nbsp; Now eight months have gone by and quite a few projects are sporting free Visual Studio interfaces.&nbsp; In this article I discuss Visual Studio Shell itself as well as several of the languages which are currently developing shells.<br></p><p>&nbsp;</p><p><b>About Visual Studio Shell </b><br></p><p>When Microsoft released <a href="http://msdn.microsoft.com/en-us/vstudio/bb510103.aspx">Visual Studio Shell</a> many non-Microsoft based .NET languages had, or were working on, their own IDEs.&nbsp; This was a big problem as even though there are a very large number of .NET languages, integrating them required juggling different IDEs and moving around assemblies manually.&nbsp; The core promise of Visual Studio Shell is simple: every .NET language can easily have a Visual Studio 2008 environment.&nbsp; </p><p>This means a familiar, easy to use environment for those used to working with .NET as well as access to all of the tools we are used to.&nbsp; And so, by building a Visual Studio Shell implementation, a language project is much more likely to see existing .NET users try it out and maybe even stick around if they like the language.&nbsp; At the same time Microsoft gains much more here than encouraging .NET language projects and in so doing growing the .NET platform.&nbsp; When a language project builds a Visual Studio shell package it automatically gains integration with all of the pay versions of Visual Studio as well.&nbsp; It's a big win for everyone involved. <br></p><p>Visual Studio Shell does much more than helping new .NET languages to integrate.&nbsp; It takes the whole<a href="http://www.code-magazine.com/Article.aspx?quickid=0710032"> Visual Studio environment</a> and turns it into a platform which is easy to extend and develop tools for.&nbsp; With this ideal in mind Microsoft created two versions of Visual Studio Shell: Integrated mode and Isolated Mode. Integrated mode is designed to integrate new languages while Isolated mode was designed around creating external tools. The technical difference between the two versions is that integrated mode integrates with existing Visual Studio 2008 while isolated runs in it's own separate instance.<br></p><p style="font-weight:bold;">&nbsp;</p><p><b>Visual Studio Shell Implementations&nbsp; </b><br></p><p><b>F#</b><br>Although <a href="http://www.google.com/search?q=F%23+%22Visual+Studio+Shell">only sparse documentation exists</a>, the current <a href="http://research.microsoft.com/fsharp/release.aspx">F# install package</a> has built in support for Visual Studio Shell.&nbsp; It includes IntelliSense, debugging and interactive mode, all for free.&nbsp; Even better, you can install the <a href="http://www.codeplex.com/vslab">VSLab project</a> on top of that and get a full interactive Matlab-like F# development environment.&nbsp; Tutorials and documentation are available on the <a href="http://www.codeplex.com/vslab">VSLab CodePlex</a> page. <br></p><p><b>IronPython </b><a href="http://codeplex.com/IronPythonStudio"><br>IronPython Studio</a> is the first and generally the most well known Visual Studio Shell implementation.&nbsp; Version 1.0 was released in March and from all accounts is quite stable and usable.&nbsp; One of the coolest things about it is that it lets you use the WPF editor to build interfaces right inside your IronPython project.&nbsp; Being able to leverage already existing features like that is what makes Visual Studio Shell much better than custom IDE implementations.&nbsp; <br></p><p><b>IronRuby</b><br>A company by the name of <a href="http://www.sapphiresteel.com/">SapphireSteel</a> has created a visual Ruby on Rails .NET workbench called Ruby In Steel.&nbsp; Recently added to the Text Edition was support for Visual Studio Shell allowing it to be sold to those without Visual Studio.&nbsp; It is interesting to note the commercial implications here: Huw Collingbourne of SapphireSteel was <a href="http://dotnet-developments.blogs.techtarget.com/2008/01/08/ironruby-and-rubynet-or-a-tale-of-two-rubies/">quoted as saying</a> Visual Studio Shell will finally allow them to compete with Eclipsed-based Ruby on Rails IDEs.<br></p><p><b>Nemerle</b><br>The <a href="http://nemerle.org">Nemerle</a> installer comes with Visual Studio 2005 and 2008 integration as well as a free Visual Studio 2008 Shell implementation called NemerleStudio. The <a href="http://www.rsdn.ru/article/nemerle/Nemerle.VsIntegration-en.xml">only documentation</a> on Nemerle's Visual Studio integration I could find was for Visual Studio 2005 and seems to suggest broad-ranging support for many features, including code completion and the WinForms designer.&nbsp; If you speak Russian and have a few extra minutes I would love to see a translation of a more recent feature list.<br></p><p><b>Boo<br></b>Boo has been traditionally known to have tight integration with <a href="http://sharpdevelop.net/OpenSource/SD/">SharpDevelop</a> and so SharpDevelop is what most of the Boo developers are currently using.&nbsp; However, <a href="http://www.codeplex.com/BooLangStudio">BooLangStudio</a> Alpha 1 offers integration with Visual Studio 2008 Standard Edition (and better) via a VSIP package and is still under very active development.&nbsp; Hopefully BooLangStudio will soon move to Visual Studio Shell and open the door to a free Boo Visual Studio edition.&nbsp; If this were to happen it is likely that Boo would see a large influx of users as <a href="http://en.wikipedia.org/wiki/Language-oriented_programming">language oriented programming</a> is all the rage with the academic types. <br> </p><p><b>World of Warcraft?!</b><br>Over a <a href="http://www.codeplex.com">CodePlex</a> there is a "<a href="http://www.codeplex.com/WarcraftAddOnStudio">AddOn Studio for World of Warcraft</a>" project.&nbsp; It's a&nbsp; Visual Studio Shell package designed for writing World of Warcraft Addons in lua.&nbsp; I must say, even though I don't play WoW, this looks really impressive.</p><p>&nbsp;</p><p><b>References</b> </p><p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=40646580-97fa-4698-b65f-620d4b4b1ed7&amp;displaylang=en">Microsoft Visual Studio 2008 Shell (Integrated Mode) Download</a><br> <a href="http://www.microsoft.com/downloads/details.aspx?familyid=ACA38719-F449-4937-9BAC-45A9F8A73822&amp;displaylang=en">Microsoft Visual Studio 2008 Shell (Isolated Mode) Download</a><br> <a href="http://msdn.microsoft.com/en-us/vstudio/bb510103.aspx">Microsoft Visual Studio 2008 Shell Landing Page</a> <br></p><p><a href="http://www.code-magazine.com/Article.aspx?quickid=0710032">CoDe Magazine: Introduction to the Visual Studio 2008 Shell</a><br><a href="http://msdn.microsoft.com/en-us/library/bb165336.aspx">MSDN: Visual Studio Integration SDK Documentation</a><br></p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx&amp;;subject=Visual+Studio+Shell+2008%3a+Bringing+More+.NET+Languages+into+the+Visual+Studio+Fold" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx&amp;;title=Visual+Studio+Shell+2008%3a+Bringing+More+.NET+Languages+into+the+Visual+Studio+Fold" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx&amp;title=Visual+Studio+Shell+2008%3a+Bringing+More+.NET+Languages+into+the+Visual+Studio+Fold" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx&amp;;title=Visual+Studio+Shell+2008%3a+Bringing+More+.NET+Languages+into+the+Visual+Studio+Fold" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx&amp;;title=Visual+Studio+Shell+2008%3a+Bringing+More+.NET+Languages+into+the+Visual+Studio+Fold&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/28/visual-studio-shell-2008-is-bringing-more-net-languages-into-the-visual-stuido-fold.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15388" width="1" height="1">programmingF#lists.NETTutorialsfsharpVS2008Visual StudioBooVisual Studio ShellWoWIronRubyIronPythonRuby on RailsNemerleChanging Your Garbage Collector Settings on the Fly (.NET Memory Management: Part 5)http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspxWed, 20 Aug 2008 20:39:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:15313RickM6http://www.atalasoft.com/cs/blogs/rickm/comments/15313.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15313http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15313<p>It has come to my attention via a recent <a href="http://dotnet.dzone.com/news/low-latency-gc-net-35">DZone article</a> that .NET 3.5 and 2.0 SP1 jointly included a new feature which lets you manipulate the way your garbage collector acts programmatically.&nbsp; This can be done through changing the value of a new property of the System.Runtime.GCSettings class named LatencyMode. In this article I will walk you through this new property and the different effects of each of it's possible settings.</p><p><b>Other Articles in This Series<br></b></p><p><a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/04/03/net-memory-managment-part-1-basic-housekeeping.aspx">Part 1 – Basic Housekeeping</a><br><a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/04/15/improving-performance-through-stack-allocation-net-memory-management-part-2.aspx">Part 2 – Improving Performance Through Stack Allocation</a><br><a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/04/22/increasing-the-size-of-your-stack-net-memory-management-part-3.aspx">Part 3 – Increasing the Size of your Stack</a><br><a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/05/14/choosing-the-right-garbage-collector-settings-for-your-application-net-memory-management-part-4.aspx">Part 4 – Choosing the Right Garbage Collector Settings</a><br><a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx">Part 5 – Changing Your Garbage Collector Settings on the Fly</a><br></p><p>&nbsp;</p><p><b>LatencyMode</b> <br></p><p>The new LatencyMode property accepts three different enumerated values.&nbsp; The first two of which are Batch and Interactive which correspond to turning &lt;gcConcurrent&gt; on and off inside of your application configuration.&nbsp; However, the effects of the third value, which is named LowLatency, were previously unavailable by any means.&nbsp; By setting this the LatencyMode to LowLatency you can now put the Garbage Collector in an ultra-conservative mode which will insure the application will be interrupted as infrequently as possible.&nbsp; <br></p><p>There are a couple of things you should take note of before changing your Garbage Collector's LatencyMode:<br></p><ul><li>LatencyMode settings are process-wide and so all of the threads in your application will be effected.</li><li>Changing LatencyMode will have no effect if your application has &lt;gcServer&gt; mode set in its configuration file.<br></li></ul><p>Now, let’s explore each of the possible values of LatencyMode in detail:<br></p><p>&nbsp;</p><p><b>Batch </b><br></p><p>When it’s useful: &nbsp;<br>It’s useful in applications without a UI and in Server Based Software.&nbsp; It may also be useful to switch your garbage collector into Batch latency mode if your application has a data crunching mode which occurs after a user interface.<br></p><p>What it does: <br>This is the most intrusive setting.&nbsp; Garbage Collection is done non-concurrently in one big batch call. Your program will be suspended while garbage collection takes place.<br></p><p>Defaults:<br>This is the default value when &lt;gcConcurrent&gt; is disabled.<br></p><p>Notes:<br>Even though this will be the enumeration which will be set if &lt;gcServer&gt; is enabled, the garbage collector will act as described in my <a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/05/14/choosing-the-right-garbage-collector-settings-for-your-application-net-memory-management-part-4.aspx">previous article</a>.&nbsp; In fact, if you have your application defined to be in &lt;gcServer&gt; mode the LatencyMode property cannot be changed from its default of “Batch”.<br><br></p><p><b>Interactive</b><br></p><p>When it’s useful:<br>It’s the best mode for most any UI-based application. <br></p><p>What it does:<br>This is the most balanced setting.&nbsp; Garbage Collection happens concurrently with your application.&nbsp; Most of the work is done in a separate thread and although your application will be suspended it will not happen very often and for only very short periods of time. <br></p><p>Defaults:<br>This is the default value for garbage collection on workstations.&nbsp; If &lt;gcConcurrent&gt; is left at its default value, this is the type of garbage collection that will occur.<br><br></p><p><b>LowLatency</b><br></p><p>When it’s useful:<br>It’s useful for time sensitive applications such as 3d rendering or data acquisition.<br></p><p>What it does:<br>This is the least intrusive mode the Garbage Collector can be set to.&nbsp; As in Interactive, garbage collections happen concurrently with your application.&nbsp; However, collection of older objects will only happen when memory pressure becomes high.&nbsp; Collection of generation 2 objects is kept to a bare minimum.<br></p><p>Defaults:<br>This is never the default setting.<br></p><p>Notes:<br>LowLatency mode was designed for short time use only during time-critical sections of your application.&nbsp; Leaving an application in LowLatency mode for an extended period of time will cause unused objects accumulate.&nbsp; Before using low latency mode, you should take a look at the guidelines laid out at the bottom of the <a href="http://msdn.microsoft.com/en-us/library/bb384202.aspx">MSDN Latency Modes page</a>. <br><br></p><p><b>References</b><br><a href="http://msdn.microsoft.com/en-us/library/bb384202.aspx">MSDN Visual Studio 2008 Developer Center – Latency Modes</a><br><a href="http://msdn.microsoft.com/en-us/library/system.runtime.gclatencymode.aspx">MSDN .NET Framework Developer Center – GCLatencyMode Enumeration</a><br><a href="http://dotnet.dzone.com/news/low-latency-gc-net-35">DZone - Low-Latency GC in .NET 3.5</a></p><p>&nbsp;</p> <div class = "shareblock"><strong>Share this post:</strong> <a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;;subject=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx">email it!</a> | <a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;;title=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx">bookmark it!</a> | <a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx">digg it!</a> | <a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;title=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx">reddit!</a> | <a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;;title=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx">kick it!</a> | <a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;;mkt=en-us&amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;;title=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)&amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx">live it!</a></div><img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15313" width="1" height="1">F#C#codeoptimization.NETC++VB.NETTutorialsmemorygarbage collectiongcasp.netfsharpMore F# At Code Camp Hartfordhttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/16/f-at-code-camp-hartford.aspxSat, 16 Aug 2008 18:03:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:15261RickM5http://www.atalasoft.com/cs/blogs/rickm/comments/15261.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15261http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15261I am down in Bloomfield, CT today at Hartford CodeCamp which has been put on by the Connecticut .NET Developer's Group . I just gave a very similar version my talk on the 5th. The room was completely full and I was a bit weak and foggy from my recent...(<a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/16/f-at-code-camp-hartford.aspx">read more</a>)<img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15261" width="1" height="1">programmingF#functionalexperiences.NETCode Campfsharptalksmicrosoft researchTalkin Bout' F# - Presenting at the Western Mass .NET Users's Grouphttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/05/giving-a-f-presentation-at-the-local-net-users-s-group.aspxTue, 05 Aug 2008 13:36:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:15166RickM0http://www.atalasoft.com/cs/blogs/rickm/comments/15166.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15166http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15166I'm going to be giving a presentation at the my local .NET User's group tonight. The goal of my talk will be to expose the audience to F# as well as some Functional Programming Ideas. Here's a basic rundown of what the talk is about (in order): - What...(<a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/05/giving-a-f-presentation-at-the-local-net-users-s-group.aspx">read more</a>)<img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15166" width="1" height="1">programmingF#functionalexperiences.NETfsharptalksmicrosoft researchIPCV 08' Part 2 - Novel Approaches http://www.atalasoft.com/cs/blogs/rickm/archive/2008/07/17/ipcv-08-part-2-novel-approaches.aspxThu, 17 Jul 2008 17:15:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:14962RickM0http://www.atalasoft.com/cs/blogs/rickm/comments/14962.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=14962http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=14962I've managed to rig up Steve's cell to my laptop and I once again have Internet Access. From the time of my last post, most of the talks have been about applications of machine learning. This usually involves a neural network, PCA (Principle Component...(<a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/07/17/ipcv-08-part-2-novel-approaches.aspx">read more</a>)<img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=14962" width="1" height="1">tradeshowexperiencesideasipcvworldcompconferencempegTchebichefMSTcurvesIPCV 08' - Day One Through One Point Five Rundownhttp://www.atalasoft.com/cs/blogs/rickm/archive/2008/07/15/ipcv-08-day-one-through-one-point-five-rundown.aspxTue, 15 Jul 2008 18:03:00 GMT647108ca-f046-4d8d-9feb-a7fbd2049b37:14941RickM0http://www.atalasoft.com/cs/blogs/rickm/comments/14941.aspxhttp://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=14941http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=14941As you might have seen in Steve's Blog , we ended up getting stranded in Milwaukee overnight and missed most of the keynotes. We did manage to catch the last one which was on a company called Element CXI's very interesting reconfigurable hardware model....(<a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/07/15/ipcv-08-day-one-through-one-point-five-rundown.aspx">read more</a>)<img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=14941" width="1" height="1">tradeshowexperiencesideasipcvworldcompconference