Serving the Quantitative Finance Community

• 1
• 2

DominicConnor
Topic Author
Posts: 11684
Joined: July 14th, 2002, 3:00 am

### Better Programming Environment

Someone asked me a hard question yesterday, and I'm blowed if I could think of a good answer.If you had Windows XP as a baseline, what would you have in Vista that would make it a better environment to write code ?There's obvious cheap shots like support Linux of course, but you can now run Linux in a virtual m/c so that's not really it.I couldn't actually think of anything except the virtualisation, and even that's not a very new thing.
Last edited by DominicConnor on April 12th, 2006, 10:00 pm, edited 1 time in total.

nocturne2
Posts: 150
Joined: January 11th, 2006, 5:45 pm

### Better Programming Environment

Without a doubt: better shell. The cmd shell is pretty lame. Adopt bash/cygwin - make it first-class extension of the kernel.

RGB
Posts: 19
Joined: April 11th, 2006, 10:14 pm

### Better Programming Environment

Cuchulainn
Posts: 64996
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Better Programming Environment

QuoteBefore I answer this, let me provide some background on how MS handles memory in .NET. Right now, there are 2 different ways of handling memory allocation. One way is to allocate the memory on the stack. This is very efficient and is used for the built-in types like int, float, double, String, DateTime, etc. and structures defined with the Stuct keyword. The other way is to allocate the memory on the heap. This is done for all objects defined with the Class keyword. A structure can be created using either the Class keyword or the Struct keyword. If the Struct keyword is used, then the structure can only be used within the function that defines it. If the structure is passed to another function, then a "boxing" operation occurs where the structure is copied to the heap and a reference to the object on the heap is then passed to the called function. It is my belief that MS implemented it this way so that it could avoid some of the pitfalls of COM's reference counting scheme. Since boxing is a very inefficient operation, most .NET houses would be well advised to avoid using Structs entirely.In C++, the developer has control over whether a class or variable is instantiated on the heap or the stack. In C++ objects declared on the stack call the object's destructor when the function exits. If a reference to this object is stored in a table or passed to another thread, then this reference becomes invalidated when the function exits. This is a major source of bugs in C++ programs. For C++ objects defined on the heap, it is the developer's responsibility to delete the object at the appropriate time. This is also another major source of bugs. Mostly because the developer forgets to delete the object which results in memory leaks that eventually force a reboot of the computer. But there are also times when the developer deletes the object too soon and when some forgotten little used function tries to access the reference, it crashes the program. So, the .NET platform uses a fairly efficient garbage collector that keeps track of all memory created on the heap and collects it when all references to that memory have gone out of scope. Java also uses a garbage collector and the garbage collector is probably the most significant improvement for developing more reliable code because it reliably releases memory when it no longer is used and all of the C++ pitfalls dealing with memory deletion are avoided.I find this a bit confusing. Are you talking about ISO C++ or C++/CLI? . C++ is a chain saw that can cut your leg off; we know that memory management is difficult. That is not front-page news anymore. This is not a reason to seek refuge in a language that does GC. There are 2 kinds of 'struct', C style and .NET style. They are indeed completely different.. The fact that everything is an object leads to all kinds of funny tricks like boxing and unboxing A possible better design would have been generics, too late. Anyway, we can live with it.
Last edited by Cuchulainn on April 12th, 2006, 10:00 pm, edited 1 time in total.
"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl

Cuchulainn
Posts: 64996
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Better Programming Environment

Quote A better question is probably:What changes would you make in the next version of Visual Studio .NET to make it a better environment to write code?Can a good programmer write good code in any hardware/software environment?It's the same question as "do I need an expensive UML CASE tool to design OO systems". Example: how to design a pen that works in outer space. One can use a pencil.For me, I use VC 6.0 a lot because I can develop algorithms (minus UI and whistles) before going to VS2005, for example. There are too many key strokes and button clicks in the new environment.
Last edited by Cuchulainn on April 12th, 2006, 10:00 pm, edited 1 time in total.
"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl

nocturne2
Posts: 150
Joined: January 11th, 2006, 5:45 pm

### Better Programming Environment

On Visual Studio: VS can take a page or two from Eclipse. Right out of the box Eclipse is feature-packed, whereas VS requires a dozen plugins (unit test, resharper, etc), some of which cost $, to be functional. You can design OO using paper and pencil, but you will have to live without round-trip engineering. As you design and implement, your initial paper UML diagram will be outdated. Good code does not absolutely require good tools. Writing good code _fast_ does require good tools.Paco de Lucia still sounds awesome with a$200 Yamaha, but will he use it?

Cuchulainn
Posts: 64996
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Better Programming Environment

QuoteYou can design OO using paper and pencil, but you will have to live without round-trip engineering. As you design and implement, your initial paper UML diagram will be outdated. Sure.But I meant: some It'ers jump to the screen immediately and start messing around with boxes and lines without having the correct mental model first.In my experience, I have seen few(none?) successful round-trip RUP projects. We prefer Barry Boehm's Spiral Model (risk-driven). RUP tends to produce masses of documents.If you know Brooks' Mythical Man Month: he used a small set of critical design blueprints to drive the s/w process. That's at loogerheads with 'modern' processes which I must (sadly) say have been less than successful.The problem is not tools, but the design models that we first have to specify. Edit: I have made some extensions to my house; do I need to update the original architect's plan??
Last edited by Cuchulainn on April 12th, 2006, 10:00 pm, edited 1 time in total.
"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl

axs
Posts: 82
Joined: February 15th, 2003, 1:14 am

### Better Programming Environment

port valgrind to vistamore debugging tools to see what memory and threads are doing

RGB
Posts: 19
Joined: April 11th, 2006, 10:14 pm

### Better Programming Environment

QuoteI find this a bit confusing. Are you talking about ISO C++ or C++/CLI? . C++ is a chain saw that can cut your leg off; we know that memory management is difficult. That is not front-page news anymore. This is not a reason to seek refuge in a language that does GC. There are 2 kinds of 'struct', C style and .NET style. They are indeed completely different.. The fact that everything is an object leads to all kinds of funny tricks like boxing and unboxing A possible better design would have been generics, too late. Anyway, we can live with it.I'm talking about the standard version of C++. You know, the one that Bjarne Stroustrup wrote the specification about? The point is that whoever first came up with the idea of a garbage collector was brilliant! I encourage anyone doing things in C++ to move to either Java or a .NET programming language that uses safe code and the GC. Most organizations will be much better off afterwards. By the way, the .NET framework 2.0 that was recently released for Visual Studio 2005 now supports generics.

lballabio
Posts: 983
Joined: January 19th, 2004, 12:34 pm

### Better Programming Environment

QuoteOriginally posted by: RGBI encourage anyone doing things in C++ to move to either Java or a .NET programming language that uses safe code and the GC. Most organizations will be much better off afterwards.Or use smart pointers for automatic memory management, or add a garbage collector by means of a library. This, of course, assuming we're talking of finance: there are fields where garbage collection cannot be used (if you're developing for a real-time system with hard deadlines, you can't allow garbage collection to start at unpredictable times and steal precious milliseconds.)QuoteBy the way, the .NET framework 2.0 that was recently released for Visual Studio 2005 now supports generics.Yes, but C# and Java generics are just a pale imitation of C++ templates, as they cannot be specialized.Luigi

RGB
Posts: 19
Joined: April 11th, 2006, 10:14 pm

### Better Programming Environment

RGB
Posts: 19
Joined: April 11th, 2006, 10:14 pm

### Better Programming Environment

QuoteOr use smart pointers for automatic memory management, or add a garbage collector by means of a library. This, of course, assuming we're talking of finance: there are fields where garbage collection cannot be used (if you're developing for a real-time system with hard deadlines, you can't allow garbage collection to start at unpredictable times and steal precious milliseconds.)According to some books I've read, the MS GC is very fast and efficient. MS goal was for the GC to take no longer than it takes for a page fault in memory. However, you make a good point about whether even that would interfere with the real-time operations of an order routing system for example. Since the GC stops all threads while performing its duties, I have often wondered if a real-time socket connection would lose data or the connection if the GC happened to kick in hard. I have never used sockets in .NET, but have used them with VC++ 6.0 for an order routing system some time ago.Can someone with actual experience using the Socket class under .NET shed some light on this subject?
Last edited by RGB on April 13th, 2006, 10:00 pm, edited 1 time in total.

Cuchulainn
Posts: 64996
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Better Programming Environment

QuoteOriginally posted by: RGBQuoteI find this a bit confusing. Are you talking about ISO C++ or C++/CLI? . C++ is a chain saw that can cut your leg off; we know that memory management is difficult. That is not front-page news anymore. This is not a reason to seek refuge in a language that does GC. There are 2 kinds of 'struct', C style and .NET style. They are indeed completely different.. The fact that everything is an object leads to all kinds of funny tricks like boxing and unboxing A possible better design would have been generics, too late. Anyway, we can live with it.I'm talking about the standard version of C++. You know, the one that Bjarne Stroustrup wrote the specification about? The point is that whoever first came up with the idea of a garbage collector was brilliant! I encourage anyone doing things in C++ to move to either Java or a .NET programming language that uses safe code and the GC. Most organizations will be much better off afterwards. By the way, the .NET framework 2.0 that was recently released for Visual Studio 2005 now supports generics.RGBI think you are losing me. It's like a discussion on which kind of coke I should drink. Of course, knowing quite a few ITers I know how these discussions can lead to language wars (BTW happens every few months here on Wilmott). A language is a tool and a means to an end. Most of the people around here are QF quant developers etc. and involved with good solutions in this field. At this moment C++ is the most popular language. Of course C# is nice but it is based on C++ and, as Luigi points outs, it is not as good (yet).QuoteYes, a good programmer can write code in any hardware/software environment. However, I would encourage you to download the C# Express edtion from MS website while it is still free and start playing around with C#. Get a good book on the .NET framework.Unfortunately, most IT books I don't like because 1) not deep enough, 2) sometimes they are 800-page code dumps 3) they are theoretical, no relevance to QF. That's why I decided to write my own books.C++/ISO is a .NET language and supports the holy grail of programming the GC.
Last edited by Cuchulainn on April 13th, 2006, 10:00 pm, edited 1 time in total.
"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl

RGB
Posts: 19
Joined: April 11th, 2006, 10:14 pm

### Better Programming Environment

QuoteOriginally posted by: CuchulainnRGB I think you are losing me. It's like a discussion on which kind of coke I should drink. Of course, knowing quite a few ITers I know how these discussions can lead to language wars (BTW happens every few months here on Wilmott).A language is a tool and a means to an end. Most of the people around here are QF quant developers etc. and involved with good solutions in this field. At this moment C++ is the most popular language. Of course C# is nice but it is based on C++ and, as Luigi points outs, it is not as good (yet).QuoteYes, a good programmer can write code in any hardware/software environment. However, I would encourage you to download the C# Express edtion from MS website while it is still free and start playing around with C#. Get a good book on the .NET framework.Unfortunately, most IT books I don't like because 1) not deep enough, 2) sometimes they are 800-page code dumps 3) they are theoretical, no relevance to QF. That's why I decided to write my own books.C++/ISO is a .NET language and supports the holy grail of programming the GC.Your implication is probably correct - that Quants can and should be free to choose the language of their choice for analyzing models and other work. I am also aware that the QuantLib project is in C++. As you have already surmised, I'm not a quant, but a software developer interested in finance with many years developing software in C++ and C#. At some point in time though, the industry (and employers) will choose the software development tools that yield the quickest development time, highest reliability, and the fastest execute time. C++ is superior when it comes to execution time. But, it lags badly in the other 2 areas. At one point in time, I imagine that most Quants were using Fortran (before C or C++ was developed). Maybe some still are. But, how employable are they? Right now, I think you are right that C++ is the #1 language that Quants should know. But, Hedge funds, large investment banks, and other financial institutions are businesses as well and they will have their way with you some day (hopefully far off in the future...).

Cuchulainn
Posts: 64996
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Better Programming Environment

QuoteBut, Hedge funds, large investment banks, and other financial institutions are businesses as well and they will have their way with you some day (hopefully far off in the future...). Switching from C++ to C# is not difficult. So, the business drives technology, no problem.What I do notice is thet development time in C# is really fast. However, it is not a ISO standard and it could change.Fortran is a great language for number crunching.
"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl