hypothetical

Lots of the tests in the test suite are failing! Any advice on debugging it?

I already solved this but thought I'd ask anyway... I have a large application with a reasonably comprehensive test suite and unit test system. I was working on it and made a change that shouldn't have broken anything and suddenly dozens of test are failing. What should I do? I'm looking for a list of things that help isolate bugs. Tip...

Will reassigning a variable in every iteration of a loop affect performance?

Consider the following two ways of writing a loop in Java to see if a list contains a given value: Style 1 boolean found = false; for(int i = 0; i < list.length && !found; i++) { if(list[i] == testVal) found = true; } Style 2 boolean found = false; for(int i = 0; i < list.length && !found; i++) { found = (list[i] == testV...

Is there an MD5 Fixed Point where md5(x) == x?

Is there a fixed point in the MD5 transformation, i.e. does there exist x such that md5(x) == x? ...

How can you concatenate two huge files with very little spare disk space?

Suppose that you have two huge files (several GB) that you want to concatenate together, but that you have very little spare disk space (let's say a couple hundred MB). That is, given file1 and file2, you want to end up with a single file which is the result of concatenating file1 and file2 together byte-for-byte, and delete the origina...

Alternative to Filename Extensions?

Since reading this question, I'm wondering: What would be the Right ThingTM to do to associate a UNIX file (ie, blob of data) with a file type? We have file extensions (DOS), data/resource forks (Apple) and ... err, file extensions and file(1) (UNIX), and MIME types (html et. al.). Given all your griefs about handling files of various...

Is the PHP file instantiated on every AJAX call?

I was just wondering how the PHP is behaving in the background. Say I have a PHP which creates an array and populates it with names. $names = Array("Anna", "Jackson" .... "Owen"); Then I have a input field which will send the value on every keypress to the PHP, to check for names containing the value. Will the array be created on e...

What would a multithreaded UI api look like, and what advantages would it provide?

Or, equivalently, how would you design such an API. Expected/example usage would be illustrative as well. My curiosity comes directly from the comments (and subsequent editting on my part) of this answer. Similar questions/discussions in the past provide a bit of inspiration to actually asking it. Executive summary: I don't feel a mu...

Creating a cout function in C?

This is a totally hypothetical question, but I have to know the answer. I assume most C++ compilers are written in assembly. Which makes them different languages entirely (I could be wrong). That being said if I were going to create a cout style function for plain old C, how would I do it? cout has some very impressive features take thi...

Programming an infinitely fast machine with infinite memory

That is a hypothetical question. If there existed a machine with infinite memory that could execute any set of instructions within the blink of an eye, what would programming that machine be like? I remember the old days, when i wrote x<<8 + x<<6 instead of x*320 because multiplying was a little more expensive than performing two bit sh...

Variable Assignment and loops (Java)

Greetings Stack Overflowers, A while back, I was working on a program that hashed values into a hashtable (I don't remember the specifics, and the specifics themselves are irrelevant to the question at hand). Anyway, I had the following code as part of a "recordInput" method. tempElement = new hashElement(someInt); while(in.hasNex...

Would it be possible to have a UTF-8-like encoding limited to 3 bytes per character?

UTF-8 requires 4 bytes to represent characters outside the BMP. That's not bad; it's no worse than UTF-16 or UTF-32. But it's not optimal (in terms of storage space). There are 13 bytes (C0-C1 and F5-FF) that are never used. And multi-byte sequences that are not used such as the ones corresponding to "overlong" encodings. If these h...

Convincing management to rewrite a product

A hypothetical organization (we'll call them Sprockets Incorporated) spent millions of dollars to rewrite a product. The rewrite ended with lost time, more bugs, and a harder to maintain version of the product. Does anyone here have anecdotal precedence for convincing upper management to support a rerewrite? Or even a rewrite? How can su...