View Full Version : Programming Help
The Pig
19th September 2006, 01:13 PM
I haven't done any programming since I dropped out of college (early 90s). Back then, the only languages I knew in depth were BASIC & COMAL.
What is a good language for writing programs to work through fairly simple algorithms? I'd be mainly looking to calculate odds and probabilities, nothing fancy, I don't care how it looks.
I assume I can get the relevant book at the library. I'm running XP, what exactly will I need to do to get started? What software will I need to buy, and how much approx?
Grateful for any advice, thanks.
IllegalArgument
19th September 2006, 01:15 PM
Dirt simple would be javascript. You can run it your browser.
A real language, Java or C#, probably overkill.
Do you have performance requirements?
The Pig
19th September 2006, 01:21 PM
Dirt simple would be javascript. You can run it your browser.
A real language, Java or C#, probably overkill.
Do you have performance requirements?
Thanks for that.
I won't be doing anything complex enough to worry about performance.
SkepticScott
19th September 2006, 01:38 PM
Python is probably the easiest to write in. It's a free download from http://www.python.org/ . The documentation is online too. For example, here's a Python program to calculate the number of outcomes when rolling 2d6. It's not written elegantly, but it shows what Python is like.
# initialize the results array
results = [0]*13 # entries 0-12 are set to zero
# generate the die rolls
for d1 in range(1,7) :
for d2 in range(1,7) :
total = d1 + d2
results[total] = results[total] + 1 # one more of this total
# print the outcomes
print "Total Outcomes"
for i in range(2,13) :
print " %2d %d" % (i, results[i])
Orangutan
19th September 2006, 01:39 PM
You will also want a nice text editor.
I would recomend ConTEXT.
http://www.context.cx
It's so handy I keep a copy of it on my USB key!
:)
The Pig
19th September 2006, 02:09 PM
Thanks for the advice. If only I'd kept my ZX Spectrum.
JamesM
19th September 2006, 03:03 PM
I second Python; or Ruby.
Stimpson J. Cat
19th September 2006, 03:11 PM
If you are on a budget, C++ is the way to go. You can get a compiler for free. For XP I would either grab the free version of VC++, or go with MinGW, which is the port of gcc to Win32.
There are also a ton of free libraries for math programming. Check out, for example, the gnu scientific library (GSL). For that matter, I even wrote a C++ math library.
The point is, while C++ is not the easiest language for math programming, it is the most powerful (which is to say, it is equally as powerful as anything else available), and you can do pretty much anything you need for free.
Dr. Stupid
Almo
19th September 2006, 03:20 PM
Context is the daddy.
I'd personally recommend a version of BASIC, as it's very easy to use, and you'll never dereference a null pointer with it. :)
I know a load of languages, and I always seem to get things done fastest in BASIC. Visual Basic is good, and so is REALbasic.
zizzybaluba
19th September 2006, 03:32 PM
I'm aghast no one mentioned Perl (http://www.perl.org/get.html)!
I hope I can say this without starting a Holy War: I find Perl much easier to code in than Python because I find Python's use of whitespace as delimiters rather annoying.
Worm
19th September 2006, 04:22 PM
I use perl alot too, but I always had the impression that it's handling of details maths was somewhat questionable.
I have no real evidence for that, it's just a general impression.
I use VB for most things, in fact, often VBA cos it's handy. :)
T'ai Chi
19th September 2006, 04:26 PM
I'd be mainly looking to calculate odds and probabilities, nothing fancy, I don't care how it looks.
Download R for free.
(GNU version of S+)
Has BASIC-like language.
Paul C. Anagnostopoulos
19th September 2006, 06:16 PM
Python is probably the easiest to write in.
But Python is a whitespace language, which is the work of the Devil.
I hope I can say this without starting a Holy War: I find Perl much easier to code in than Python because I find Python's use of whitespace as delimiters rather annoying.
You are correct about Python, but Perl is the work of the Devil's Mentor.
~~ Paul
JayT
19th September 2006, 06:20 PM
I haven't done any programming since I dropped out of college (early 90s). Back then, the only languages I knew in depth were BASIC & COMAL.
What is a good language for writing programs to work through fairly simple algorithms? I'd be mainly looking to calculate odds and probabilities, nothing fancy, I don't care how it looks.
I assume I can get the relevant book at the library. I'm running XP, what exactly will I need to do to get started? What software will I need to buy, and how much approx?
Grateful for any advice, thanks.
If you have a web site, I would recommend PHP. And it's free to get and royalty free to use and most web hosts support it. There are countless PHP tutorial sites on the web - no need to buy PHP books unless you want to.
In fact, this forum we are using was written in PHP.
I'm addicted to PHP. For years I wrote PC software in C, C++, Java, Visual BASIC and several other versions of BASIC, but the programs would only run on Windows. Java was too low level for my needs and the learning curve was too high.
If you are running XP (other than the home edition) you should have a web server on your CD called IIS (Internet Information Services). You can then install PHP to run on the web server. Then you can write and test your programs locally and when done, put your programs on the web for all to use with their browsers.
PHP is not severely difficult to learn. It can be frustrating at first, like any new language until you learn to master it, but it is not too difficult.
The main reason I like it is because PHP can create programs that run on the web or locally, so that you can share your programs with the world without needing any special browser add-ons or any particular operating system. Anyone with a standard web browser can run the programs because it's platform independent. People running Windows or LINUX or MACs, etc. can run the programs equally well.
As a simple example, here's a link to one of the web sites I programmed in PHP. It gives some idea what PHP can do on the web.
http://www.neoprogrammics.com/astronomy/
It performs high-precision astronomical computations, but that's only scratching the surface of its potential.
I can do numerical calculus, trig and all sorts of high-level math, even relativity computations, which is another important reason why I adopted it - I'm heavily involved in math and science, especially physics.
For example, you can do arbitrary precision arithmetic to any number of decimals, even into the thousands of decimals if you wish.
If I wanted the square root of 2 to 100 decimals:
The PHP program code
print bcSqRt("2", 100);
would print the result
1.414213562373095048801688724209698078569671875376 94807317667973799073247846210703885038753432764157 27
For more normal computations, PHP contains all the essential math and trig and log functions too.
I also have PHP installed on a web server running on my PC so I can run PHP programs locally as well.
Millions of web sites use PHP.
With PHP, you are not restricted to any one specific operating system.
Paul C. Anagnostopoulos
19th September 2006, 06:29 PM
I've never written anything in PHP, but I've heard good things about it. I would learn it, but I'm addicted to Gossip.
~~ Paul
JayT
19th September 2006, 06:35 PM
Context is the daddy.
I'd personally recommend a version of BASIC, as it's very easy to use, and you'll never dereference a null pointer with it. :)
I know a load of languages, and I always seem to get things done fastest in BASIC. Visual Basic is good, and so is REALbasic.
I like Visual BASIC too. I still use VB6 for some of my work. I also use Real BASIC sometimes because I can compile programs for MAC, Linux and Windows.
But when it comes to the web, I prefer PHP.
One problem is that VB is losing support from Microsoft and I have no idea if the programs I made in VB will run on the new Vista OS.
kevin
19th September 2006, 06:40 PM
You are correct about Python, but Perl is the work of the Devil's Mentor.
Wouldn't, biblically speaking, the Devil's Mentor be god?
Unnamed
19th September 2006, 06:59 PM
I use Octave (http://www.gnu.org/software/octave/) for anything related to Mathematics. It has a command-line interface, so you can try things out before (or while) writing the code. Any Matlab tutorial can get you started (the languages are very similar).
I second T'ai Chi's suggestion of R (http://www.r-project.org/). I never used it but I hear good things about it.
Unnamed
19th September 2006, 07:06 PM
I've never written anything in PHP, but I've heard good things about it. I would learn it, but I'm addicted to Gossip.
It's not the first time you mention that (Gossip), but Wikipedia and Google came empty again. Where can I find information about it?
phildonnia
20th September 2006, 03:24 PM
I have to second Javascript. Being able to get a free compiler is nice, but with Javascript, you don't have to get it, you already have it.
Paul C. Anagnostopoulos
20th September 2006, 04:22 PM
Wouldn't, biblically speaking, the Devil's Mentor be god?
No, a guy much more screwed up than that. I think his name is Wall or some such.
~~ Paul
Paul C. Anagnostopoulos
20th September 2006, 04:24 PM
It's not the first time you mention that (Gossip), but Wikipedia and Google came empty again. Where can I find information about it?
You can't. Well, if you PM me I'll send you the spec. It's my own language, which compiles to TAWK. TAWK is an extended version of AWK produced by Thompson Automation. Unfortunately, they don't support it any longer.
~~ Paul
zizzybaluba
21st September 2006, 10:58 AM
You are correct about Python, but Perl is the work of the Devil's Mentor.
Purely out of curiosity, why such disdain for Perl?
I'd never use it for a major project, but I find its easy to learn the basics and there's more free documentation than you can shake a stick at. I use it much in the same way I'd use a Swiss Army knife, handy and great for small and/or repetitive tasks.
Almo
21st September 2006, 11:16 AM
I've used some Python for writing build scripts using SCons. SCons is a daddified build system, BTW. I'll never use make again, if I can help it.
I like Python a lot. I REALLY like it that indent determines scope. No sloppy indenting in code, since it wouldn't even work that way. I've had a much easier time reading Python code because of that.
Oh yeah, and I've used AWK... that's some weird (but powerful) stuff.
JamesM
21st September 2006, 11:27 AM
Purely out of curiosity, why such disdain for Perl?
I'd never use it for a major project, but I find its easy to learn the basics and there's more free documentation than you can shake a stick at. I use it much in the same way I'd use a Swiss Army knife, handy and great for small and/or repetitive tasks.
Conversely, I found Perl had a very steep learning curve initially. It's fine if you're already familiar with the stuff it's designed to replace like sed, grep and awk, but otherwise, it takes a bit of getting used to.
For small tasks like extracting information from text files, I now use Ruby exclusively. The problem with Perl is that simple tasks often become somewhat less than simple, and with any sort of structured data, you end up juggling arrays of hashes of hashes and whatnot. Ruby makes this all so much easier to deal with.
JamesM
21st September 2006, 11:30 AM
I like Python a lot. I REALLY like it that indent determines scope. No sloppy indenting in code, since it wouldn't even work that way. I've had a much easier time reading Python code because of that.
I've started using Python as a replacement for Java for some small projects. It has some very annoying quirks (especially compared to Ruby), but it's mature and fast (and even faster if you can JIT it with Psyco). I never find myself using it for scripting, though, It falls down on regex support - if you don't have baked-in regex support like =~ in Perl and Ruby, it hurts.
rockoon
21st September 2006, 12:20 PM
Microsoft now offers free versions of most of their compilers in a promotion called "Express" - available for download.
VB.NET 2005 Express
C#.NET 2005 Express
VC++ 2005 Express
and so forth
If you are fairly familiar with BASIC then VB.NET might not be that big of a step for you (truthfully, making the step from old BASIC to any windows development platform wont exactly be trivial but its not something that cant be overcome in your case with an hour spent with the tutorials getting a simple console application up, running, and calculating.)
zizzybaluba
21st September 2006, 01:26 PM
Conversely, I found Perl had a very steep learning curve initially. It's fine if you're already familiar with the stuff it's designed to replace like sed, grep and awk, but otherwise, it takes a bit of getting used to.
Fair enough-- I'm a life-long UNIX geek and its easy for me to forget that not everybody is familiar with grep, sed, and awk.
xenxabar
21st September 2006, 04:21 PM
If you're looking for a quick and dirty solution for simple math, why not just use Excel? It has VBA behind the scenes if you have logic that can't easily be done in spreadsheet.
Unnamed
21st September 2006, 05:06 PM
You can't. Well, if you PM me I'll send you the spec. It's my own language, which compiles to TAWK. TAWK is an extended version of AWK produced by Thompson Automation. Unfortunately, they don't support it any longer.
Thanks for the offer, but I was just curious to see an example.
It's cool that you have a language. I always wanted to design one, but never learned enough to actually do it. My compliments.
rockoon
21st September 2006, 05:35 PM
If you're looking for a quick and dirty solution for simple math, why not just use Excel? It has VBA behind the scenes if you have logic that can't easily be done in spreadsheet.
Well if hes going to be using VBA then he might as well just use the built-in VBScript (http://en.wikipedia.org/wiki/VBScript) that is on every windows platform since I guess Windows 95, and not bother with a 2nd program such as Excel.
Paul C. Anagnostopoulos
21st September 2006, 05:48 PM
Purely out of curiosity, why such disdain for Perl?
It's a classic example of some guy's twisted language design that he foisted on the world. Anyone who can't tell me the collective term for the characters $, @, %, and & has no business using the language. And even with that, Wall misused the term. It's an abomination of hacks and kludges. Maybe the total redesign that is Perl 6 will be better.
I'm an old-school language guy. I like some formality to my languages.
~~ Paul
Paul C. Anagnostopoulos
21st September 2006, 05:59 PM
Thanks for the offer, but I was just curious to see an example.
Here's some code that gets a list of files in a directory (all_files), builds a set of the .pdf files (pdf_file), determines a special sort order for the files (pdf_sort) along with an explanatory note, and then lists the files in that order. determine_file_note() is an example of a function that returns multiple values. You need to know that in a function, undefined names of 1 or 2 letters* are automatically defined as local variables.
#macro emit (rest body)
format(#body, standard_output)
#mend
constant file_format = " ~18S ~S\n";
function file_report ()
{
local all_files := directory_files(pdf_file_dir);
foreach f in all_files do
pdf_file[downcase(file_name(f))] := nil if file_ext(f) = "pdf";
foreach f in pdf_file do {
(pdf_file[f], s) := determine_file_note(f);
pdf_sort[s] := f;
}
if empty? pdf_file then fatal("No PDF files in the directory.");
foreach s in alphameric_order pdf_sort do
emit(file_format, pdf_sort[s], pdf_file[pdf_sort[s]]);
}
* This is controlled via a pragma.
Segnosaur
22nd September 2006, 01:29 PM
Personally, I'd recommend using Visual Basic 6.0.
VB6 can be considered a bit 'outdated', but since this doesn't sound like a program that has to be leading edge, it will do you fine. And your past experience with Basic will help.
You can actually get a free version of the VB compiler in various text books. (It has a complete interface, and can do virtually everything but create a stand-alone executable. You can run the program from the development environment.)
One book that I used when I taught college was VB6 How to Program by Deitel.
http://www.amazon.ca/Visual-Basic-6-How-Program/dp/0134569555/sr=1-37/qid=1158956649/ref=sr_1_37/702-0864852-3465613?ie=UTF8&s=books
marting
22nd September 2006, 04:20 PM
Religion, programming language, religion, programming language.
Who says programmers don't have enough sects?
Skylark
22nd September 2006, 04:24 PM
If you are on a budget, C++ is the way to go. You can get a compiler for free. For XP I would either grab the free version of VC++, or go with MinGW, which is the port of gcc to Win32.
There are also a ton of free libraries for math programming. Check out, for example, the gnu scientific library (GSL). For that matter, I even wrote a C++ math library.
The point is, while C++ is not the easiest language for math programming, it is the most powerful (which is to say, it is equally as powerful as anything else available), and you can do pretty much anything you need for free.
Dr. Stupid
I personally would _not_ recommend C++ at all. I vastly prefer C; it's a lot less obfuscated. If you need object oriented programming, use C#; it performs this task a lot more sanely. This is my personal preference though, obviously.
If you decide to program in C, Dietel and Dietel's "How to Program in C" is absolutely excellent. You can set yourself up with Cygwin or MinGW; I personally use the Cygwin package.
If you want to learn C#, use the free online Visual C# Express. I personally prefer C (only because it isn't Microsoft's .NET; for no other reason), however Visual C# Express has an excellent debugger, and it is much easier to make GUI's through forms using the windows API than it is manually making one using SDL with C (Ironically, I do the latter anyway, since it is more portable). These are just my suggestions; sorry about the lack of links... 13 more posts to go :P
EDIT: Also please don't use visual BASIC, or anything with the word BASIC in it for that matter. In words of one greater than I, "It is practically impossible to teach good programming style to students that have had prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." (Edsger W. Dijkstra: Selected Writings on Computing: A Personal Perspective)
That might seem a little dank considering you've already used BASIC in depth, however there is still hope for you! :P
JamesM
22nd September 2006, 05:00 PM
If you decide to program in C, Dietel and Dietel's "How to Program in C" is absolutely excellent.
Just to stick my oar in one more time: The D&D book is entirely adequate if you like textbook-style books - it has more coloured boxes and checklists (and questions, if you like that sort of thing) than you can shake a stick at. It also rejoices in what seems like a billion different typefaces to illustrate the different parts of a program. This has the opposite effect of what's intended - making it harder to read the code than if it was unadorned.
Also, it's about twice as expensive as similar books (e.g. Stephen Kochan's book), twice as heavy, and only half of the book is actually about C - the rest of it being an entirely pointless excursion into C++ and Java. I can't imagine what sort of a person could expect to learn all that from one book. I would consider it if money was no object, or you can get it from a library.
To be honest though, I wouldn't bother with C at all (although I do agree it's probably a better choice for what the OP is wanting than C++).
Paul C. Anagnostopoulos
22nd September 2006, 06:25 PM
Who says programmers don't have enough sects?
But at least no crusades or jihads yet. :D
It also rejoices in what seems like a billion different typefaces to illustrate the different parts of a program. This has the opposite effect of what's intended - making it harder to read the code than if it was unadorned.
Absolutely right on, man! I often ask authors why they want to use bold for language keywords. "It helps to read the programs." If the reader doesn't understand the language well enough to recognize the keywords, he's got bigger problems, my friend.
~~ Paul
rockoon
22nd September 2006, 08:20 PM
EDIT: Also please don't use visual BASIC, or anything with the word BASIC in it for that matter. In words of one greater than I, "It is practically impossible to teach good programming style to students that have had prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." (Edsger W. Dijkstra: Selected Writings on Computing: A Personal Perspective)
Take everything Dijkstra writes with a grain of salt. Hes an extremist language bigot.
This is the same guy who absolutely refuses to use a GoTo even when a GoTo is the best tool for the job. He would have had a point if languages offered a flow control paradigm for every job.. but they don't.. and he has absolutely no point in regards to modern Basic designs which is actualy forgivable considering he wrote all that junk prior to modern Basic design.
Paul C. Anagnostopoulos
23rd September 2006, 09:43 AM
This is the same guy who absolutely refuses to use a GoTo even when a GoTo is the best tool for the job. He would have had a point if languages offered a flow control paradigm for every job.. but they don't.. and he has absolutely no point in regards to modern Basic designs which is actualy forgivable considering he wrote all that junk prior to modern Basic design.
For example, a tokenizer with state transition logic. Jump around between those states, baby!
Without gotos you have to use an outer loop with a case statement in it. Not that bad, really, but rather artificial.
That said, I haven't used a language with goto in about 20 years.
~~ Paul
Skylark
24th September 2006, 04:49 AM
Take everything Dijkstra writes with a grain of salt. Hes an extremist language bigot.
This is the same guy who absolutely refuses to use a GoTo even when a GoTo is the best tool for the job. He would have had a point if languages offered a flow control paradigm for every job.. but they don't.. and he has absolutely no point in regards to modern Basic designs which is actualy forgivable considering he wrote all that junk prior to modern Basic design.
As a C programmer, even though goto is available I have NEVER had to use it. If you find yourself in a position where goto is necessary when programming in a structured or object-oriented language, then you have made a serious error in you original algorithm, and probably need to redesign it.
I completely agree with him about BASIC; otherwise I would not have posted the quote. BASIC encourages programming practises which are... well, frankly, bad.
Just to stick my oar in one more time: The D&D book is entirely adequate if you like textbook-style books - it has more coloured boxes and checklists (and questions, if you like that sort of thing) than you can shake a stick at. It also rejoices in what seems like a billion different typefaces to illustrate the different parts of a program. This has the opposite effect of what's intended - making it harder to read the code than if it was unadorned.
Also, it's about twice as expensive as similar books (e.g. Stephen Kochan's book), twice as heavy, and only half of the book is actually about C - the rest of it being an entirely pointless excursion into C++ and Java. I can't imagine what sort of a person could expect to learn all that from one book. I would consider it if money was no object, or you can get it from a library.
To be honest though, I wouldn't bother with C at all (although I do agree it's probably a better choice for what the OP is wanting than C++).
Of course, I would never buy such a book; I borrow all my textual references from a library, including fictional time passers. I'm pretty tight-fisted though, being an unemployed university student. ^^ However, the section of the book I was reffering to (that is, the entire section of the book on C) is very useful.
It goes quite a bit further into linked lists, stacks, queues, etc than Al Kelley and Ira Pohl's book, "A Book on C", although it covers bit fields in less detail. I recommend both books though, for anyone wishing to learn C. And I would recommend C over C++ from a purely experienced point of view; I simply prefer working in C. I can program in C, C++ and C#, and if object-orientation is required, I would definitely choose C# over C++. I do not like C++ at all, in case you haven't noticed. ^^
This is all personal preference though, but since C is my forte, I thought I'd point out that it would probably cover everything that he needs, and he'd pick up some good programming practices along the way (to make up for his exposure to BASIC :P). In any case, no matter what language you wish to learn, I would highly recommend you read "Code Complete" by Steve McConnell. It is a fantastic resource that in my opinion every programmer should read.
JamesM
24th September 2006, 07:58 AM
As a C programmer, even though goto is available I have NEVER had to use it. If you find yourself in a position where goto is necessary when programming in a structured or object-oriented language, then you have made a serious error in you original algorithm, and probably need to redesign it.
What sort of gotos are we talking about? The use of break and continue in loops? I use them all the time. What about something like callcc in Scheme?
It goes quite a bit further into linked lists, stacks, queues, etc than Al Kelley and Ira Pohl's book, "A Book on C", although it covers bit fields in less detail.
This is part of my problem with C as a beginner's language. In Java, books show off how cool the language is with Swing GUI apps. In Python and Ruby, books show off how cool the language is by implementing a web service in five lines. In C, books show off how cool the language is by... implementing a linked list.
This is far too low level for a beginner. Yes, a person should know about the speed implications of different data structures. But do they really need to build their data structures from scratch? Not unless you're a budding computer scientist or a complete geek. I am slowly becoming the latter (I have the Cormen et al algorithms book in my to-read pile in my bedroom), but I have used a whole bunch of different data structures in a variety of languages without feeling even the slightest twinge of shame about not knowing how they're implemented.
In any case, no matter what language you wish to learn, I would highly recommend you read "Code Complete" by Steve McConnell. It is a fantastic resource that in my opinion every programmer should read. I'm reading that book right now! Spooky.
marting
24th September 2006, 08:13 AM
As a C programmer, even though goto is available I have NEVER had to use it. If you find yourself in a position where goto is necessary when programming in a structured or object-oriented language, then you have made a serious error in you original algorithm, and probably need to redesign it.
I completely agree with him about BASIC; otherwise I would not have posted the quote. BASIC encourages programming practises which are... well, frankly, bad.
One would be hard pressed these days to find a "BASIC" that had any relation to the GOTO and parameter-less GOSUB strewn language of yesteryear. Even the scripting languages now usually provide object oriented grammar and they all provide structured programming. vb.net and c#.net, though Microsoft specific, have evolved into quite useful languages.
Still, I prefer C++ for certain kinds of programs. I have a set of templated fixed point routines that makes simulating digital dsp hardware as easy as just writing standard float expressions. The C++ code that is generated is very efficient and faster than the equiv in fp.
JamesM
24th September 2006, 08:34 AM
Still, I prefer C++ for certain kinds of programs. I have a set of templated fixed point routines that makes simulating digital dsp hardware as easy as just writing standard float expressions. The C++ code that is generated is very efficient and faster than the equiv in fp.
Does it use that crazy template metaprogramming?
marting
24th September 2006, 08:49 AM
Does it use that crazy template metaprogramming?
A little. Mostly to determine various useful "constants" related to frac bit length and max/mins at compile time without having to include them in the instantiation. The code is still pretty readable.
rockoon
24th September 2006, 12:45 PM
As a C programmer, even though goto is available I have NEVER had to use it. If you find yourself in a position where goto is necessary when programming in a structured or object-oriented language, then you have made a serious error in you original algorithm, and probably need to redesign it.
I completely agree with him about BASIC; otherwise I would not have posted the quote. BASIC encourages programming practises which are... well, frankly, bad.
You are wrong about GoTo.
Please tell me how you break out of nested loops in your imaginary perfect algorithm world... do you check for the break condition in each and every nest? Do you throw an exception? Do you use code-duplication?
All of these are inappropriate to the problem and could increase the algorithms complexity considerably. Further, in the case of the multiple-tests for the break condition at every nest you have abandoned good scoping. The GoTo, in the absence of the correct flow control paradigm for this sort of problem, is the simplest most appropriate solution.
No language that I am aware of has all the necessary flow control constructs.
And in regards to Basic, do you program in Basic? Have you ever programmed in Basic? Modern Basic is a structured object oriented language.
The difference between C# and VB.NET? The semi-colon. Thats it.
Are you saying the semi-colon is what its really all about, or are you saying C# encourages bad programming?
Skylark
24th September 2006, 03:12 PM
You are wrong about GoTo.
Please tell me how you break out of nested loops in your imaginary perfect algorithm world... do you check for the break condition in each and every nest? Do you throw an exception? Do you use code-duplication?
All of these are inappropriate to the problem and could increase the algorithms complexity considerably. Further, in the case of the multiple-tests for the break condition at every nest you have abandoned good scoping. The GoTo, in the absence of the correct flow control paradigm for this sort of problem, is the simplest most appropriate solution.
No language that I am aware of has all the necessary flow control constructs.
And in regards to Basic, do you program in Basic? Have you ever programmed in Basic? Modern Basic is a structured object oriented language.
The difference between C# and VB.NET? The semi-colon. Thats it.
Are you saying the semi-colon is what its really all about, or are you saying C# encourages bad programming?
Haha, ha ha ha ha... I haven't laughed that hard in a while.
I have used Visual Basic, and it is VERY different to C#. Have you ever used C#?
Like I said, I have never had to use the "goto" statement (I have used "break" in switch statements, especially for event polling when I toy around in SDL, but never "continue" either). I will reiterate what I said, in that if you find you need to ruin the flow of control with a break statement, then your original algorithm off which your program is created must be flawed.
JamesM: C isn't low level! D:
And I do have a penchant for coding things from the ground up :P But seriously C would be all this guy really needs. It's very simple to write an i/o program quickly, and since he doesn't want to get into complicated data structures anyway, that would hardly be a problem. Besides, an understanding of fundamental data types is obviously beneficial, even if you don't ever use it again.
Also try directly accessing the pixel data of a surface or the contents of the sound buffer through the windows API. Good luck too. :P
JamesM
24th September 2006, 03:54 PM
I will reiterate what I said, in that if you find you need to ruin the flow of control with a break statement, then your original algorithm off which your program is created must be flawed.
What about continuations? They're basically dressed-up gotos.
Skylark
24th September 2006, 04:04 PM
What about continuations? They're basically dressed-up gotos.
Urgh, that was a mistyping.. I meant foc-breaking statements, like goto.
Break statements are necessary for the use of switch. I have never used goto or continue in the 6 years I have been programming in C, and I have never used break for anything other than switch statements. I also do not simply flag the iteration terminator when I want to break out of a loop; if your code is well structured you simply will never have to do this.
But you're reading code complete, so you would know what I'm talking about.
JamesM
24th September 2006, 04:23 PM
Break statements are necessary for the use of switch. I have never used goto or continue in the 6 years I have been programming in C, and I have never used break for anything other than switch statements. I also do not simply flag the iteration terminator when I want to break out of a loop; if your code is well structured you simply will never have to do this.
I know this argument, but it's not very convincing to me, because if you keep your methods (or functions or whatever) short, the chance of confusion is pretty small. And the 'well structured' way is a lot more cumbersome than just busting out of the loop. Consider the two simple chunks of Java below, for returning a Thingy object from a collection of some kind. The first one obeys the rules about not breaking out of a loop, and the second one doesn't:
boolean foundWhatIWant = false;
int i = 0;
Thingy item;
while (!foundWhatIWant && i < myList.size()) {
item = myList.get(i);
if item.doesWhatIWant()
foundWhatIWant = true;
++i;
}
return item;
and:
for (int i = 0; i < myList.size(); ++i) {
Thingy item = myList.get(i);
if item.doesWhatIWant()
return item;
}
I don't know about you, but I like the second one better, and well-structured be damned. If I was to use a foreach loop in the second example (and I would), the second one is even shorter. Maybe your situation is different, but it's in these sorts of loops that I most commonly come across people refusing to break early, and I must say, I take great delight in refactoring that code out of existence... let's hope we never have to work together!
69dodge
24th September 2006, 04:33 PM
Here's Dijkstra's famous paper: Go To Statement Considered Harmful (http://www.acm.org/classics/oct95/).
It's not very long. If y'all are going to argue about it, at least read it. :D
JamesM
24th September 2006, 04:43 PM
I wonder if he thought he'd be spawning an 'X considered harmful' industry when he wrote that paper.
It's such a cliche, that "considered harmful considered harmful" has entered the lexicon.
But how far can one go?
A google search reveals 162 mentions of "considered harmful considered harmful considered harmful" - a bizarrely large amount, if you ask me.
But only one person has ever opined that "considered harmful considered harmful considered harmful considered harmful", according to the mighty Goog.
And no-one has ever bothered to type "considered harmful considered harmful considered harmful considered harmful considered harmful" anywhere google can find it.
Until now.
Paul C. Anagnostopoulos
24th September 2006, 04:43 PM
If you read some of the spagetti code people wrote back then, you'd consider it harmful, too. And toss in a little instruction modification just for good measure.
But a few breaks, continues, exits, iterates, nexts, restarts, and returns are not going to kill us. It's still structured. And code like this is not easy to read:
loop {
if condition_1_okay then
if condition_2_okay then
if condition_3_okay then
important part of loop;
}
I'd rather see:
loop {
if not condition_1_okay then next;
if not condition_2_okay then next;
if not condition_3_okay then next;
important part of loop;
}
The paradigm is: get the hell out if there are any issues; do the work. Who wants to write a function with a half dozen checks at the beginning and the real stuff buried deep inside IFs and boolean variables all the hell over the place?
~~ Paul
Skylark
24th September 2006, 06:08 PM
I know this argument, but it's not very convincing to me, because if you keep your methods (or functions or whatever) short, the chance of confusion is pretty small. And the 'well structured' way is a lot more cumbersome than just busting out of the loop. Consider the two simple chunks of Java below, for returning a Thingy object from a collection of some kind. The first one obeys the rules about not breaking out of a loop, and the second one doesn't:
boolean foundWhatIWant = false;
int i = 0;
Thingy item;
while (!foundWhatIWant && i < myList.size()) {
item = myList.get(i);
if item.doesWhatIWant()
foundWhatIWant = true;
++i;
}
return item;
and:
for (int i = 0; i < myList.size(); ++i) {
Thingy item = myList.get(i);
if item.doesWhatIWant()
return item;
}
I don't know about you, but I like the second one better, and well-structured be damned. If I was to use a foreach loop in the second example (and I would), the second one is even shorter. Maybe your situation is different, but it's in these sorts of loops that I most commonly come across people refusing to break early, and I must say, I take great delight in refactoring that code out of existence... let's hope we never have to work together!
You have completely missed what I am saying - how far into code complete are you? O_o
I also do not simply flag the iteration terminator when I want to break out of a loop; if your code is well structured you simply will never have to do this.
I'm talking about control breaking structures, not the return statement. Your second method of a linear search is simple modularisation, and obviously a good thing. I'm talking about people that, rather than seperating their code into modules, create spaghetti code by cutting the control from one section to another, bypassing a loop that normally would take place. BASIC (and other variants similar to BASIC) encourage this.
I am specifically talking about the use of "continue" and "goto" statements in C, and in some cases, "break" too.
JamesM
24th September 2006, 06:38 PM
I'm talking about control breaking structures, not the return statement.
But the point of the return statement in the second example is that it breaks out of the loop early, exactly like a break statement would. It is a control breaking structure.
If you want, remove the return statement in the first example, and replace the return with a break in the second - they still have the same form.
Your second method of a linear search is simple modularisation, and obviously a good thing. I guess I am confused. The first and second methods are both terminated by return statements - they're both modularisation, they're functionally identical. But one uses return to break early, which you said was bad practice, and the other checks a boolean and uses a while loop, which I assumed you would have considered to be superior, as it doesn't violate the norms of structured programming.
I am specifically talking about the use of "continue" and "goto" statements in C, and in some cases, "break" too. But I'm pretty sure that continue and break can't be used outside of loop constructs? Can you give a short example of the bad use of continue?
I'm talking about people that, rather than seperating their code into modules, create spaghetti code by cutting the control from one section to another I agree that using goto to create multiple entry points to a block of code is a truly terrible idea. But you never see that in modern languages like Java, C++, Python and Ruby. And if you create small methods (which most books recommend), then there's really no harm in having multiple exit points from a block of code. So I really think that insisting on not using break and continue (which do exactly the same thing in those other languages as they do in C) makes code harder to read. It certainly does in my experience.
rockoon
25th September 2006, 12:39 AM
I'm talking about people that, rather than seperating their code into modules, create spaghetti code by cutting the control from one section to another, bypassing a loop that normally would take place.
You were not talking about people. You were talking about GoTo and Basic.
Neither are people.
Is your problem with People, or GoTo and Basic?
BASIC (and other variants similar to BASIC) encourage this.
No they don't. You are wrong. If you can't program in Basic without writting spagetti code, then thats your deficiency. Why would that deficiency not carry over to other languages??? Is it because you were told that Basic does that and then you proceed to fullfill the prophecy?
rockoon
25th September 2006, 12:47 AM
I have used Visual Basic, and it is VERY different to C#. Have you ever used C#?
Now I am certain that you are completely uninformed (as in ignorant)
Both VB.NET and C# share the same features. They differ only in SYNTAX. Semi-Colons and different keywords. Its not debatable. It is exactly what Microsoft intended (their goal is to eventualy move everyone to the same language, controlled by them)
Angus McPresley
25th September 2006, 02:28 AM
For example, a tokenizer with state transition logic. Jump around between those states, baby!
Nah, that's what function pointers are for. :D
I've used goto's once in the last 15 years, and that was for an Obfuscated C (http://www0.us.ioccc.org/years.html#1998_schnitzi) entry.
rockoon
25th September 2006, 03:02 AM
Nah, that's what function pointers are for. :D
Of course, a function implies a return (and stack usage.)
The anti-goto crowd is going against the godfather of algorithms, Donald Knuth.
He gives examples of two algorithmic situations where the common flow control methods (If, For, Do, Continue, Break, Case, etc..) are insufficient: http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf
He also mentions a bit of trivia in this paper about Dijkstra's paper.
A nice little quote from Knuth's paper:
We've already mentioned that go to's do not have a syntactic structure
that the eye can grasp automatically; but in this respect they are no
worse off than variables and other identifiers. When these are given a
meaningful name corresponding to the abstraction (N.B. not a numeric
label!), we need not apologize for the lack of syntactic structure.
Stimpson J. Cat
25th September 2006, 04:22 AM
Skylark,
I personally would _not_ recommend C++ at all. I vastly prefer C; it's a lot less obfuscated. If you need object oriented programming, use C#; it performs this task a lot more sanely. This is my personal preference though, obviously.
I have heard this type of argument many times, and I simply do not understand it. With a few very minor exceptions, any C code is also valid C++ code. So what advantage does C give over C++? If there are aspects of C++ that don't appeal to you, simply don't use them. All C++ does is give you more tools to work with. You don't have to actually use them.
I personally think that C++ is far superior to C for mathematical and scientific programming, because it provides a very efficient way to deal with the deficiencies that C has for those types of tasks. In fact, I don't even use the object oriented aspects of C++ for most of my work. My programs are procedural. But I use classes to build the specialized data types I need to work efficiently. One of the strengths of C++ is that it doesn't tie you down to an object oriented approach. Your program can very easily lie anywhere between being procedural and object oriented.
Dr. Stupid
Segnosaur
25th September 2006, 09:10 AM
Skylark,
I have heard this type of argument many times, and I simply do not understand it. With a few very minor exceptions, any C code is also valid C++ code. So what advantage does C give over C++? If there are aspects of C++ that don't appeal to you, simply don't use them. All C++ does is give you more tools to work with. You don't have to actually use them.
Definitely true.
Of course, one big advantage that C++ has over C is when dealing with basic user input; using Cin is much easier than dealing with things like scanf. Not a big deal when dealing with GUI programming, but when you're trying to do something basic (using command line input), being able to read simple input easily is a good thing.
MortFurd
25th September 2006, 11:14 AM
Download R for free.
(GNU version of S+)
Has BASIC-like language.
I second R.
Never mind all the esoteric stuff.
R includes all the statistics functions, has built in graph and plot functions, and has a very simple mechanism for reading data from flat text files (comma separated values.)
It also includes a lot of other mathematical functions. Very cool, and just the tool for doing statistical analysis.
Put it this way:
Would you rather write a routine to calculate cross correlation, or just do a three line program to read two data files and plot the cross correlation?
PS:
If you are doing any kind of heavy statistics, then it does matter whether you are using an interpreted langauge or not. If you don't think so, calculate the cross corellation of two data sets with 10000 points each and see how long Python or Java takes. Then do the same task with R. R is interpreted, but the routines that do the heavy lifting are built in an compiled from C. Worlds faster.
DRBUZZ0
26th September 2006, 10:26 AM
If your algorithm is simple, VB can work pretty well. VB is really not a very powerful or effecient language (it's decent for mathmatical stuff, but you wouldn't want to do heavy duty stuff in it).
It's advantage is that it makes nice shiny graphic-interface stuff. C, C++ and those sort of languages mostly are good for commandline stuff or non-interface parts of the program. You *can* do gui in them, but it's not especially easy or well optomized for that.
VB, you can create programs really quickly and have windows, buttons, dropdowns, text boxes, images. It's kinda nice for windows programming, because most people expect the programs they use to be button and menu based.
Otherwise, C and C++ are good for more havy stuff, like custom databases. C is especially effecient.
Pyton is supposedly pretty easy, from what I hear. Perl and PHP are also very easy, but they are designed mostly for CGI and server scripting.
Javascript is for webpages. And Java is for people who want to torture themselves with the most godaweful painful programing languge ever created.
IllegalArgument
26th September 2006, 10:32 AM
VB, you can create programs really quickly and have windows, buttons, dropdowns, text boxes, images. It's kinda nice for windows programming, because most people expect the programs they use to be button and menu based.
Pyton is supposedly pretty easy, from what I hear. Perl and PHP are also very easy, but they are designed mostly for CGI and server scripting.
Javascript is for webpages. And Java is for people who want to torture themselves with the most godaweful painful programing languge ever created.
Java, godawful? Compared to what? Perl? Perl has some of the most arcane syntax of any language I have ever used. And I like Perl!
JamesM
26th September 2006, 11:25 AM
Java, godawful? Compared to what? Perl? Perl has some of the most arcane syntax of any language I have ever used. And I like Perl!
Dr Buzz0 has commented on his antipathy towards Java before, which I also find intriguing, especially considering he describes C++ as 'good' in two places in his last post. I've got nothing particularly against C++, but it's the very definition of painful.
Come on Doc, share with us your traumatic Java experience. I'm sure it'll be cathartic.
Almo
26th September 2006, 12:19 PM
EDIT: Also please don't use visual BASIC, or anything with the word BASIC in it for that matter. In words of one greater than I, "It is practically impossible to teach good programming style to students that have had prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." (Edsger W. Dijkstra: Selected Writings on Computing: A Personal Perspective)
What a massive load of BS. I programmed for YEARS in various forms of BASIC, and my evaluations here at Ubisoft always talk about how I'm good with code structure and making things nice and object oriented. If anything, working in BASIC on the C64 taught me to organize things myself because I couldn't rely on the language to do it for me.
Use whatever language will work best for your task.
marting
26th September 2006, 02:04 PM
What a massive load of BS. I programmed for YEARS in various forms of BASIC, and my evaluations here at Ubisoft always talk about how I'm good with code structure and making things nice and object oriented. If anything, working in BASIC on the C64 taught me to organize things myself because I couldn't rely on the language to do it for me.
Use whatever language will work best for your task.
Today's BASIC bears little to no resemblance to the original. If you try to port an early BASIC program to VB.NET you will quickly go nuts. OTOH, FORTRAN and C have evolved in ways that are largely backward compatible. This is because these languages had (and have) programs written long ago that are still in use today. Look at the BLAS and the stuff built using it to see how long FORTRAN has survived largely intact.
xenxabar
26th September 2006, 08:09 PM
A week has passed since the OP. The Pig, have you decided on a language/solution?
rockoon
27th September 2006, 05:35 PM
OTOH, FORTRAN and C have evolved in ways that are largely backward compatible.
Not to knock your point (I agree with it) bit just a little bit of a correction:
There are 2 "common" dialects of C in use .. K&R (developed while ansi was screwing around trying to define a standard), and ANSI (the final standard.)
I don't know jack about Fortran so hum...
As far as BASIC .. There are at least two ANSI Basic standards but I am unaware of a single existing implimentation due to the shortcommings of the definitions.
Going over this thread.. I didnt see anybody mention Delphi. Borland has released a free version of their Delphi compiler and since its based on Pascal, its got a fairly strong language definition (Wirth had plenty of experience developing languages by the time he developed Pascal)
DRBUZZ0
27th September 2006, 07:28 PM
Dr Buzz0 has commented on his antipathy towards Java before, which I also find intriguing, especially considering he describes C++ as 'good' in two places in his last post. I've got nothing particularly against C++, but it's the very definition of painful.
Come on Doc, share with us your traumatic Java experience. I'm sure it'll be cathartic.
Well, I'm pretty much a C person, however CPP has some advantages for certain things like making database programs or for certain programs that involve passing complex data between things.
Java? Java is damn ugly. It makes you do a lot of stuff, even if you don't need it for your program. It's extremely strict. If you say "Hmm..for this program, I think I'm going to do things *this* way and since it's just a small program, I won't bother doing *this* because it's really not necessary"
And in reply Java says "NO! YOU CANT DO THAT! YOU MUST DO AS I SAY AND BE LIMITED AND WRITE YOUR PROGRAMS LIKE THIS!" Then it destroys all your will to live and mocks you.
Also, C is a well balanced language, it is effecient but not overly low-level. Java is slooooooooooooooooow. Java is designed to run on different machines and be cross-platform. You *can* compile it to an executable, but it's not as optomized for that. Hence, instead of running on one system well, it runs on all systems, badly....very very badly. It's like Esperinto: nobody speaks it natively. It would be better to make a cross-platform compilable package.
C is not good for gui interface, but is good for speed. VB is great for making a nice interface, but isn't very effecient for heavy stuff.
Java can be used for both and sucks equally at each. Java won't allow you to use stuff liek OpenGL, because that's platform-based. You could put it in the VM, if you don't mind even more overhead.
java programs are huge...actually....massive. If you want to write a hello-world program, you need to make sure your PC has at least a few gigs to hold the files in.
But it's not the programs I really hate. It's the language. I hate java so goddamned much.... I would *never* take a job where I'd work with it. You may say "Well, that would limit your job options and pay." Okay, that may be true, but there are certain things that I just won't do to myself. I wouldnt want a job as an undertaker either.
IllegalArgument
28th September 2006, 04:16 AM
But it's not the programs I really hate. It's the language. I hate java so goddamned much.... I would *never* take a job where I'd work with it. You may say "Well, that would limit your job options and pay." Okay, that may be true, but there are certain things that I just won't do to myself. I wouldnt want a job as an undertaker either.
Take a deep breath and repeat "The right tool for the right job, the right tool for the right job...".
I work at a application company that must run on Windows and four favors on Unix. We need Java because it's cross-platform and we run with a very large memory footprint, so it's auto garbage collection is very useful. My company does enterprise monitoring, plus a lot of other functions, lots of real time objects.
Java is the best language for the work I do. It's wasn't designed for HelloWorld apps, it's design for enterprise apps.
So, it's overkill for most stuff, but it's not god awful. :)
DRBUZZ0
28th September 2006, 06:58 PM
Take a deep breath and repeat "The right tool for the right job, the right tool for the right job...".
I work at a application company that must run on Windows and four favors on Unix. We need Java because it's cross-platform and we run with a very large memory footprint, so it's auto garbage collection is very useful. My company does enterprise monitoring, plus a lot of other functions, lots of real time objects.
Java is the best language for the work I do. It's wasn't designed for HelloWorld apps, it's design for enterprise apps.
So, it's overkill for most stuff, but it's not god awful. :)
I really feel for you. I know that there is a version of Object Pascal which can generate byte-ciode stuff. I'm not sure what else you could do. Create compilable packages?
I guess you could overhall the system. Perhaps that would be expensive, but can you put a dollar cost on ending the agony of java?
Jekyll
29th September 2006, 06:22 AM
I really feel for you. I know that there is a version of Object Pascal which can generate byte-ciode stuff. I'm not sure what else you could do. Create compilable packages?
I guess you could overhall the system. Perhaps that would be expensive, but can you put a dollar cost on ending the agony of java?
Well if you're really reaching for solutions, CLISP http://clisp.cons.org/ offers transferable byte code (I think), and parrot might become usable at some point http://www.parrotcode.org/ .
Not that I'm recommending that someone should ditch java mid project on the say so of a bunch of people who don't have anything to do with it.
Almo
29th September 2006, 06:29 AM
Today's BASIC bears little to no resemblance to the original. If you try to port an early BASIC program to VB.NET you will quickly go nuts. OTOH, FORTRAN and C have evolved in ways that are largely backward compatible. This is because these languages had (and have) programs written long ago that are still in use today. Look at the BLAS and the stuff built using it to see how long FORTRAN has survived largely intact.
But the quote is...
It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.
Your statement is true, and reasonable, but not relevant to the quote. I had lots of exposure to BASIC, and I've easily learned proper code structure.
roger
29th September 2006, 06:33 AM
Heck, my first language was assembly code, and I write very structured programs. It's just a silly argument.
marting
29th September 2006, 08:55 AM
But the quote is...
Your statement is true, and reasonable, but not relevant to the quote. I had lots of exposure to BASIC, and I've easily learned proper code structure.
My point is that the BASIC that was originally slammed bears virtually no resemblance to those currently extant. This quote re today's BASICS is not valid in my view:
It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.
That said, it was also an overstatement at the time. I too started with Assembler, Fortran, and BASIC but for anything complicated used RatFor which wrapped Fortran with structured programming constructs. Most all BASIC programs written back then with "GOSUB," parameterless calls were re-written or scrapped when parametered BASIC calls were introduced in language variants.
IllegalArgument
29th September 2006, 12:51 PM
I really feel for you. I know that there is a version of Object Pascal which can generate byte-ciode stuff. I'm not sure what else you could do. Create compilable packages?
I guess you could overhall the system. Perhaps that would be expensive, but can you put a dollar cost on ending the agony of java?
I'm sorry but now you are just being silly. ObjectPascal!
Java, despite your hatred of it, is a fine and useful lanuage. The publically available libraries are worth it alone.
Paul C. Anagnostopoulos
29th September 2006, 01:50 PM
Nah, that's what function pointers are for.
It's the tokenizer, man! Next to the source character fetcher, the tokenizer is the most frequently called function in a compiler, say. I want speed. Remember speed? There is no advantage to invoking functions for tokenizer states, and only the very cleverest of compilers is going to figure out to transform function calls to gotos in this situation.
~~ Paul
hodgy
5th October 2006, 02:06 PM
I would recommend Java on the basis that it freely available, ubiqutous, relatively easy, mostly OO and stands a good chance of helping your career prospects (assuming you are a programmer, not a male stripper).
Its the best all-rounder.
DRBUZZ0
9th October 2006, 09:19 PM
Well if you're really reaching for solutions, CLISP http://clisp.cons.org/ offers transferable byte code (I think), and parrot might become usable at some point http://www.parrotcode.org/ .
Not that I'm recommending that someone should ditch java mid project on the say so of a bunch of people who don't have anything to do with it.
I'd recomend you ditch Java mid-project. I'd recomend you ditch java after completing 90% of the project. Hell...I'd recomend you ditch java reguardless of your situation.
Java is one of the things that has made me wonder if the IT industry is really where I belong because it's sometimes hard to avoid it.
I think Java might actually be against the Geneva convention....I'll have to double check that one.
Wavicle
9th October 2006, 09:54 PM
Urgh, that was a mistyping.. I meant foc-breaking statements, like goto.
Break statements are necessary for the use of switch. I have never used goto or continue in the 6 years I have been programming in C, and I have never used break for anything other than switch statements. I also do not simply flag the iteration terminator when I want to break out of a loop; if your code is well structured you simply will never have to do this.
But you're reading code complete, so you would know what I'm talking about.
Okay, I'll bite. I have been programming for 15 years now, with a substantial portion of that in C. I have worked on projects from a few 10s of thousands of lines of code up to a couple million. I have used goto... a lot. In nearly every case, it has been for error handling. So for the sake of argument, let's say you have the following code:
while(condition1) {
if (condition2) {
for ( i = 0; condition3; i++ ) {
val = networkOperation(&data[i]);
if ( val == -EHOSTUNREACH ) {
// catastrophic router failure outside our system!
retVal = -EHOSTUNREACH;
goto err_exit;
}
}
}
}
err_exit:
if ( resource1 ) free( resource1 );
if ( resource2 ) free( resource2 );
return retVal;
How do you efficiently (both in terms of maintenance and code execution speed) handle a deeply nested catastrophic error that can only be caught at runtime (in this case I'm supposing that the network went down in the middle of a series of transactions)?
If you're lucky, you're using a language with exceptions... but exceptions are goto's with a little more structure. In plain C, how do you handle that? I'm very curious because I'm overseeing about 100,000 lines of code right now, and hardware failures in the middle of your program are expected. I don't particularly like goto's, but they are the cleanest way to deal with code that looks a lot like what is above.
rockoon
9th October 2006, 10:27 PM
How do you efficiently (both in terms of maintenance and code execution speed) handle a deeply nested catastrophic error that can only be caught at runtime (in this case I'm supposing that the network went down in the middle of a series of transactions)?
I am going to assume that he is using a boolean flag of some kind, presuming that he bothers to write error-safe code (many programmers choose not to, or are expressely told to allow a different development team to handle that)
The problem with such a method is that it is not functionally equivilent, nor is it easier to read. There remains no 'visual' clue to the flow regarding such booleans. The method you bring up does give visual clues, however:
If you're lucky, you're using a language with exceptions... but exceptions are goto's with a little more structure.
Exceptions in my experience are really really really slow gotos. Again, not functionally equivilent. Exceptions are meant for exceptional cases and in your example that is definately the case. It is not meant as a general flow control method.
jeremyp
10th October 2006, 12:35 PM
for (int i = 0; i < myList.size(); ++i) {
Thingy item = myList.get(i);
if item.doesWhatIWant()
return item;
}
I don't know about you, but I like the second one better, and well-structured be damned. If I was to use a foreach loop in the second example (and I would), the second one is even shorter. Maybe your situation is different, but it's in these sorts of loops that I most commonly come across people refusing to break early, and I must say, I take great delight in refactoring that code out of existence... let's hope we never have to work together!
I prefer
for (i = 0 ; i < myList.size () && !myList.get(i).doesWhatIWant () ; ++i) ;
if (i < myList.size ())
{
return myList.get(i) ;
}
else
{
// however you report not found
}
The reason is that you can tell at a glance what the exit condition of the loop is. That's not so important in your case, but if the loop is long and complicated it makes it easier to maintain.
IMO, break and continue should never be used within a loop since they disguise complexity.
jeremyp
10th October 2006, 12:42 PM
Okay, I'll bite. I have been programming for 15 years now, with a substantial portion of that in C. I have worked on projects from a few 10s of thousands of lines of code up to a couple million. I have used goto... a lot. In nearly every case, it has been for error handling. So for the sake of argument, let's say you have the following code:
while(condition1) {
if (condition2) {
for ( i = 0; condition3; i++ ) {
val = networkOperation(&data[i]);
if ( val == -EHOSTUNREACH ) {
// catastrophic router failure outside our system!
retVal = -EHOSTUNREACH;
goto err_exit;
}
}
}
}
err_exit:
if ( resource1 ) free( resource1 );
if ( resource2 ) free( resource2 );
return retVal;
How do you efficiently (both in terms of maintenance and code execution speed) handle a deeply nested catastrophic error that can only be caught at runtime (in this case I'm supposing that the network went down in the middle of a series of transactions)?
If you're lucky, you're using a language with exceptions... but exceptions are goto's with a little more structure. In plain C, how do you handle that? I'm very curious because I'm overseeing about 100,000 lines of code right now, and hardware failures in the middle of your program are expected. I don't particularly like goto's, but they are the cleanest way to deal with code that looks a lot like what is above.
In your example, you are using gotos to simulate exceptions. That's OK because you don't really have a choice in C. It's pretty much the same as using gotos to simulate while loops in assembler language.
JamesM
10th October 2006, 01:25 PM
I prefer
for (i = 0 ; i < myList.size () && !myList.get(i).doesWhatIWant () ; ++i) ;
if (i < myList.size ())
{
return myList.get(i) ;
}
else
{
// however you report not found
}
The reason is that you can tell at a glance what the exit condition of the loop is.
I have to say, I'm not so keen on that (but then I would say that, wouldn't I?)
I think empty loop statements are something to be avoided. As is cramming too much into the loop initialisation statement. Taken together, those are pretty good symptoms that the wrong loop construct is being used.
Also, using the loop index after the loop has finished is a pretty dodgy practice.
That's not so important in your case, but if the loop is long and complicated it makes it easier to maintain. That's true, but then I try and avoid long and complicated loops in the first place. I do scientific computing, so I see such monstrosities in half-baked conversions of Fortran-to-Java a lot, but they can be wrestled under control in most cases.
IMO, break and continue should never be used within a loop since they disguise complexity. This means you can never use continue. I think one should cast a critical eye over the use of breaking statements, but not rule them out outright.
BTW Skylark, if you're still reading, I finally read the chapter on loops in Code Complete, and it seems to me that Steve McConnell recommends almost the opposite of what you've been advocating.
Wavicle
10th October 2006, 02:19 PM
In your example, you are using gotos to simulate exceptions. That's OK because you don't really have a choice in C. It's pretty much the same as using gotos to simulate while loops in assembler language.
Yes, in my mind a goto is the only clean way to handle this. I was just trying to figure out where Skylark was coming from such that he has NEVER had to use a goto, or use a loop termination flag, and has been programming in C for 6 years.
Unfortunately I didn't slow down enough to notice that he hasn't posted to this thread in a long while and has probably given up.
Jekyll
11th October 2006, 05:53 AM
Yes, in my mind a goto is the only clean way to handle this. I was just trying to figure out where Skylark was coming from such that he has NEVER had to use a goto, or use a loop termination flag, and has been programming in C for 6 years.
Unfortunately I didn't slow down enough to notice that he hasn't posted to this thread in a long while and has probably given up.
I suppose if you absolutely had to do it with out using gotos you could go for something like this:
inline int ItsAllGoneWrong(int ErrorNo, CustomType *resource1, CustomType *resource2){
if ( resource1 ) free( resource1 );
if ( resource2 ) free( resource2 );
return ErrorNo;
};
with it being called like this:
return ItsAllGoneWrong (-EHOSTUNREACH,resource1,resource2);
Classes or namespaces would remove the need to pass pointers to the resources without cluttering up the global namespace. However people who object to gotos often object to sticking a return in the middle of code so you still can't win.
Wudang
12th October 2006, 05:29 AM
Amen wavicle, it's apalling how many people quote "GOTOs considered harmful" without reading or understanding the damned thing.
rockoon
12th October 2006, 09:22 AM
Classes or namespaces would remove the need to pass pointers to the resources without cluttering up the global namespace. However people who object to gotos often object to sticking a return in the middle of code so you still can't win.
I think the biggest complaint (and I have it as well) would be that you are hiding the cleanup code for one function inside another function for no obvious reason.
Oh, that and its not functionally equivilent.. but I suspect you already knew that.
Jekyll
14th October 2006, 08:26 AM
I think the biggest complaint (and I have it as well) would be that you are hiding the cleanup code for one function inside another function for no obvious reason.
Absolutely, but in my defence the question was, "How can I do this without gotos?" Not, "Should I do this with out gotos?"
Oh, that and its not functionally equivilent.. but I suspect you already knew that.
Actually I didn't. What definition of functionally equivalent are you using? I'd normally say that (2x)(x) and (x + x)(x) are functionally equivalent but that's clearly not what your talking about.
Paul C. Anagnostopoulos
14th October 2006, 05:06 PM
if ( resource1 ) free( resource1 );
What does it mean to free a boolean? :D
~~ Paul
Jekyll
14th October 2006, 05:54 PM
What does it mean to free a boolean? :D
~~ Paul
Oh I'd never free any old boolean, only the truth.
And what you've got to realise, like, man, is that none of us could own the truth, so, like, maybe, it was already free, and it just needed to be told.
logical muse
14th October 2006, 08:19 PM
I like C.
rockoon
15th October 2006, 01:02 AM
Actually I didn't. What definition of functionally equivalent are you using? I'd normally say that (2x)(x) and (x + x)(x) are functionally equivalent but that's clearly not what your talking about.
Well, it would be functionally equivilent iff the inline directive was respected.. know any C compilers like that? They inline whatever they damn well please in my experience.
I don't mean 'not functionally equivilent' in the 'works-like' sense but rather in the sense Knuth would mean: They literally do different things! You would not expect a compiler to produce the same instructions which means different performance.
Jekyll
16th October 2006, 10:13 AM
Well, it would be functionally equivilent iff the inline directive was respected.. know any C compilers like that? They inline whatever they damn well please in my experience.
I don't mean 'not functionally equivilent' in the 'works-like' sense but rather in the sense Knuth would mean: They literally do different things! You would not expect a compiler to produce the same instructions which means different performance.
I was kicking some code about with one of the other guys in my department today and playing with the disassembly of inline functions. The current edition of Visual Studio seems quite respectful of inlines.
Angus McPresley
17th October 2006, 05:20 AM
Oh I'd never free any old boolean, only the truth.
No, my friend, it is the truth that shall set YOU free.
SpeederA
17th October 2006, 03:06 PM
Aiya.
Typical programmers...
This guy asks
"What is a good language for writing programs to work through fairly simple algorithms?"
and you all go off on tirades about which language is "better". Argh!
Okay, this is directed at you pig.
The language FOR YOU with the; EASIEST syntax, simplest to use interface, which is built to run on WINDOWS XP will probably end up being Visual Basic.Net. Pick up the FREE "express" version right here: msdn.microsoft.com/vstudio/express/ (Sorry if I'm breaking any rules by posting a link. I don't see any way around it in this paricular message)
As for books, I can't really recommend any beginner ones as I have yet to come across a decent "you program this way" one. Most superb books in the computer industry happen to be more language reference than programming concepts. The absolute best thing you can do to learn is what I did many-a-years ago.... Learn the absolute basics and then screw around until stuff actually works. Start by doing a google search for something like "Visual Basic.NET 2005 Beginner" (without the quotes). The great thing is that, these days, you can go to internet forums and ask questions if in the end you can't figure out some obscure detail.
So forget all these guys, grab some free and easy to use development software, and start PLAYING!!
Speeder
(Sorry about the generalization of "all", but I'm not ready to commit to the time needed to respond to each and every one of you. ;o)
(Since I'm under 15 posts the BB software is making it to much of a pain to use quotes)
FreeChile
18th October 2006, 03:45 PM
Well if hes going to be using VBA then he might as well just use the built-in VBScript (http://en.wikipedia.org/wiki/VBScript) that is on every windows platform since I guess Windows 95, and not bother with a 2nd program such as Excel.
The VBA option is a great idea for him. I don't think VB script offers the IDE benefits you get from the Microsoft Office Suite. You could do any of the programming through Excel, Access, Word, or PowerPoint, or even Visio.
FreeChile
18th October 2006, 03:54 PM
EDIT: Also please don't use visual BASIC, or anything with the word BASIC in it for that matter. In words of one greater than I, "It is practically impossible to teach good programming style to students that have had prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." (Edsger W. Dijkstra: Selected Writings on Computing: A Personal Perspective)
That might seem a little dank considering you've already used BASIC in depth, however there is still hope for you! :P
Dijkstra was talking about BASIC or BASICA not Visual Basic which is object-based nor about Visual Basic.NET which is fully object-oriented.
SpeederA
18th October 2006, 03:54 PM
VBA is essentially VB6 with major limitations. Unless you're using it specifically because you need to interact with Word or Excel in a way that is distributable to other users as a single file, I would not really recommend it....
Better to go with VB.Net 2005 Express Edition and get a somewhat full featured IDE geared towards programming. The VBA IDE is pretty lacking. Especially when it comes to telling a novice user why their application won't compile.... :(
FreeChile
18th October 2006, 04:07 PM
VB.NET has the following inherent goto statements.
Exit Do
End
on error goto
error
goto
return
stop
FreeChile
18th October 2006, 04:14 PM
VBA is essentially VB6 with major limitations. Unless you're using it specifically because you need to interact with Word or Excel in a way that is distributable to other users as a single file, I would not really recommend it....
Better to go with VB.Net 2005 Express Edition and get a somewhat full featured IDE geared towards programming. The VBA IDE is pretty lacking. Especially when it comes to telling a novice user why their application won't compile.... :(
The Pig has not yet expressed any of those concerns. So far, I get the impression that his needs are very basic. What would satisfy his needs with the least amount of complication? The answer would entail what is most readily available and something he can experiment with quickly enough. Since he has XP he could easily enable the .NET framework on his system from the CDs or download it from MSDN and start using some of the fancy languages there. But it would be overkill for his needs.
What is a good language for writing programs to work through fairly simple algorithms? I'd be mainly looking to calculate odds and probabilities, nothing fancy, I don't care how it looks.
SpeederA
18th October 2006, 04:53 PM
Bah, this forum software just wiped out my response and I don't feel like retyping it even though it was short.
Here's the gist...
Visual Basic Express Edition is free and has a fairly full featured, simple to use IDE for a beginner.
http://msdn.microsoft.com/vstudio/express/vb/download/
The full version of Visual Studio would be overkill.
In the end he can probably do what he is looking for with just Excel functions. No "programming" needed at all. But that is only if he already has Excel.
He is probably not reading this thread anymore anyway so it does not matter. ;o)
FreeChile
18th October 2006, 05:06 PM
Now I am certain that you are completely uninformed (as in ignorant)
Both VB.NET and C# share the same features. They differ only in SYNTAX. Semi-Colons and different keywords. Its not debatable. It is exactly what Microsoft intended (their goal is to eventualy move everyone to the same language, controlled by them)
This is not entirely true. There are two features in particular I can think of that are missing in Visual Basic.NET
There is no Lock statement in Visual Basic.NET, yet.
In Visual Basic.NET you can not write the following because you cannot overload the + and = operators.
if (3 + Imaginary(2)) = (3 + Imaginary(2)) then
msgbox "The two imaginary numbers are the same."
end if
SpeederA
18th October 2006, 05:49 PM
aiya....
Operator overloading was implemented in VB.Net 2005 and VB.Net's SyncLock is equivilant to C#'s lock.
Currently the biggest, typically encountered, differences between the two languages are; VB.Net's My namespace (not CLS compliant), C#'s implementation of anonymous methods/delagates (CLS compliant), and C#'s easy access to delegate covariance/contravariance (CLS compliant).
It's mostly a question of syntax preference these days.....
FreeChile
18th October 2006, 06:21 PM
Well, I'm pretty much a C person, however CPP has some advantages for certain things like making database programs or for certain programs that involve passing complex data between things.
Java? Java is damn ugly. It makes you do a lot of stuff, even if you don't need it for your program. It's extremely strict. If you say "Hmm..for this program, I think I'm going to do things *this* way and since it's just a small program, I won't bother doing *this* because it's really not necessary"
And in reply Java says "NO! YOU CANT DO THAT! YOU MUST DO AS I SAY AND BE LIMITED AND WRITE YOUR PROGRAMS LIKE THIS!" Then it destroys all your will to live and mocks you.
Every programming language forces a grammatical or canonical structure. This is no different in C or C++. The point of Java is to take away the lower level details of C++ and provide higher lever structure. So in many ways, C++ is more complex than Java. For example, you don’t have to deal with pointers and memory management, you have an array type and bounds checking, you have string types, a Boolean type, multi-threading, etc.
Also, C is a well balanced language, it is effecient but not overly low-level. Java is slooooooooooooooooow. Java is designed to run on different machines and be cross-platform. You *can* compile it to an executable, but it's not as optomized for that. Hence, instead of running on one system well, it runs on all systems, badly....very very badly. It's like Esperinto: nobody speaks it natively. It would be better to make a cross-platform compilable package.
C is not good for gui interface, but is good for speed. VB is great for making a nice interface, but isn't very effecient for heavy stuff.
Java can be used for both and sucks equally at each. Java won't allow you to use stuff liek OpenGL, because that's platform-based. You could put it in the VM, if you don't mind even more overhead.
What is this heavy stuff you are talking about? Are you talking about business applications, Internet applications, Web Services, off-the-shelf programs like Word, Exel, etc., or Gaming software, something else?
Aside form questioning your claim that Java is inefficient, I would like to inform you that efficiency is not always the most important thing. That is why many development environments give you the option not to do it. For most applications, programmers should not focus too much on efficiency at the low level but at the higher, algorithmic level making sure to select the right approach. Efficiency for the business application developer would be defined differently as it is for those developers creating the algorithms for a database engine.
Your analogy with Esperanto is way off. Esperanto happens not to be the language of choice except for a very limited number of linguistics researchers. Whereas Java is a language of choice—especially where there is a very possible need to have something run on multiple platforms. Think of what you are doing right now: surfing the net. You will find that the vast majority of applications on the Internet have Java and not C nor C++ as their underlying language. Go ahead and do a right-click on your browser right now and view the source code behind the web page. You will likely find scripting code. It is probably Java Script or VB Script and your Windows environment probably has a Java virtual machine.
So that all depends on your point of view. Welcome to this world!
java programs are huge...actually....massive. If you want to write a hello-world program, you need to make sure your PC has at least a few gigs to hold the files in.
I guess you consider a “hello world” program to be heavy stuff. In some cases Java programs are wordier than C++ programs. Of course, the “hello world” program is not one of those cases. How would you do it in C++.
http://en.wikipedia.org/wiki/Java_programming_language
// Hello.java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
Also read the part on performance on the Wikipedia.
But it's not the programs I really hate. It's the language. I hate java so goddamned much.... I would *never* take a job where I'd work with it. You may say "Well, that would limit your job options and pay." Okay, that may be true, but there are certain things that I just won't do to myself. I wouldnt want a job as an undertaker either.
So the tool is more important to you than its use. Interesting!
However, to be completely fare to you. Your C++ skills may come in handy in the world of .NET where you are again re-integrated into the world. But if you want to continue to progress in the computer industry, I would pay some attention to C# or something new if I were you.
FreeChile
18th October 2006, 06:38 PM
aiya....
Operator overloading was implemented in VB.Net 2005 and VB.Net's SyncLock is equivilant to C#'s lock.
Currently the biggest, typically encountered, differences between the two languages are; VB.Net's My namespace (not CLS compliant), C#'s implementation of anonymous methods/delagates (CLS compliant), and C#'s easy access to delegate covariance/contravariance (CLS compliant).
It's mostly a question of syntax preference these days.....
Thank you. You are correct and I remember now the SyncLock statement. The one time I tried before I actually used the framework itself to lock. However, I had not realized overloading had been incorporated into the language.
SpeederA
18th October 2006, 06:56 PM
np.
The 2005 version of .NET happens to be absolutely amazing. If you have not had the chance, I would check out some of the new features. Things like generics (sort of like C++ templates but with many added features), partial classes, and full implementation of windows ACLs have made it my #1 choice for almost all of my commercial programming projects. And that's a very small part of everything that has been added. VB.Net also happens to be CLS compliant now which is a huuuge plus. Performance is stellar as well.
FreeChile
18th October 2006, 07:05 PM
Just browsed through the new features of the language and you're right, it is quite impressive. Does the language also treat statements like expressions like in C and I possibly Java and C++? That would be the only difference between the languages.
Also, did you download the refactoring add-in. It is great stuff.
The next thing to come would be some aspect-oriented tools as extensions to the Generics or attributes features.
SpeederA
18th October 2006, 07:24 PM
Just browsed through the new features of the language and you're right, it is quite impressive. Does the language also treat statements like expressions like in C and I possibly Java and C++? That would be the only difference between the languages.
I don't quite get you. I think you accidentally deleted a sentence or two somewhere in there..... Can you clarify?
Also, did you download the refactoring add-in. It is great stuff.
Most definitely. Everyone was ecstatic when Refactor! became free.
The next thing to come would be some aspect-oriented tools as extensions to the Generics or attributes features.
I believe there are already several implementations but AOP is not currently my cup of tea so I can't comment. A google search should yield ample results.
rockoon
18th October 2006, 07:43 PM
np.
The 2005 version of .NET happens to be absolutely amazing. If you have not had the chance, I would check out some of the new features.
Indeed!
Things like generics (sort of like C++ templates but with many added features)
I would hardly call generics 'sort of like' templates. Generics end up being productive. Templates end up being retarded :) Basically, generics is 'the important stuff' from templates, without all the retardation. For sure they arent as powerfull.. but then thats not the point. Templates should have never been added into the C++ definition as there literally isnt a single 'fully compliant' C++ compiler due to the addition.
Performance is stellar as well.
They need to do better function inlining. Small functions that take reference types (where efficiency usualy isnt a concern) seem to be inlined while small functions that take non-native value types are hit or miss (more miss than hit in my experience so far)
Also, it would be nice if they offered a better optimiser for non-jit cases. I can understand a jit optimiser not being as good as a regular optimiser due to jit compilation speed considerations .. but it would be nice if there was an alternative that didnt make sacrifices.
A glaring example of the JIT 'missing' an obvious optimisation that even VS98 didnt miss is cases where you need both division and modulus of the same values... the jit doesnt 'know' that the processors integer division instruction computes both values simultaneously. Clearly this is only of 'minor' importance... but just the same..
SpeederA
18th October 2006, 08:12 PM
Indeed!
I would hardly call generics 'sort of like' templates. Generics end up being productive. Templates end up being retarded :) Basically, generics is 'the important stuff' from templates, without all the retardation. For sure they arent as powerfull.. but then thats not the point. Templates should have never been added into the C++ definition as there literally isnt a single 'fully compliant' C++ compiler due to the addition.
Comparing languages features in a negative way usually leads down a slippery slope. I try to stay away....
They need to do better function inlining. Small functions that take reference types (where efficiency usualy isnt a concern) seem to be inlined while small functions that take non-native value types are hit or miss (more miss than hit in my experience so far)
A procedure is guaranteed to not be inlined when any of the following conditions are met under the current version of the runtime:
Method:
is greater than 32 bytes of IL.
is Virtual.
has complex flow control.
has a try/catch block.
has a parameter that is a structure. :(
In most cases it should not be a significant performance issue. And in those where it is, you'll just have to restructure your code for the time being.... :(
Also, it would be nice if they offered a better optimiser for non-jit cases. I can understand a jit optimiser not being as good as a regular optimiser due to jit compilation speed considerations .. but it would be nice if there was an alternative that didnt make sacrifices.
A glaring example of the JIT 'missing' an obvious optimisation that even VS98 didnt miss is cases where you need both division and modulus of the same values... the jit doesnt 'know' that the processors integer division instruction computes both values simultaneously. Clearly this is only of 'minor' importance... but just the same..
That's the beauty of .NET. As the JIT gets upgraded, new optimizations can be applied to your application by simply binding it to a newer version of the CLR. (After thoroughly testing for introduced bugs of course). I've been very happy with .NET performance to date in %99.9999 of cases.
Also, in terms of JIT speed, you always have the option of using NGEN to "pre-compile" your application. However you must do this on the computer which the application is being run on (in actuality a good thing as it creates an image specifically optimized for the current system) and it can take a bit for larger apps. Luckily you only have to do it once every time you distribute a new version of the application. The nice thing is that in .NET 2005, all the pain in the ass work of recompiling executables and referenced assemblies is done for you automagically. Use this tool wisely though. Sometimes it is just not worth it....
FreeChile
18th October 2006, 08:54 PM
I don't quite get you. I think you accidentally deleted a sentence or two somewhere in there..... Can you clarify?
An assignment statement is actually an expression that evaluates to a value than can also be used or assigned. For example,
in x = (Y = 5)
Y = 5 is an assignment that also evalutates to 5 by its meaning in the language. So that value is then assigned to x. So in essense you end up assigning 5 to both x and y in a single line of code.
SpeederA
18th October 2006, 09:19 PM
ah, you didn't say that.
You said:
statements like expressions like in C and I possibly Java and C++?
;)
Always been supported in C#.
Can't be implemented in VB.NET syntax without a breaking change as = is both for equality and assignment. So the statement is equivalent to Dim x as Integer = y.Equals(5) in vb....
It doesn't matter much though. You save two or three characters but end up with the same IL code. I personally shy away from multiple assignments on the same line whenever I can. It can make code confusing to other programmers who end up reading my code. (Not to mention me when I read my code months or years later. ;o)
rockoon
18th October 2006, 11:52 PM
A procedure is guaranteed to not be inlined when any of the following conditions are met under the current version of the runtime:
Method:
is greater than 32 bytes of IL.
is Virtual.
has complex flow control.
has a try/catch block.
has a parameter that is a structure. :(
What is the source for this info? I tried and tried to find it on the WEB MSDN and couldnt :( Resorted to running a debugger and 'guessing' :(
SpeederA
19th October 2006, 08:50 AM
MSDN
Will find the article for you later today if I have the chance.
© 2001-2009, James Randi Educational Foundation. All Rights Reserved.
vBulletin® v3.7.5, Copyright ©2000-2010, Jelsoft Enterprises Ltd.