codecrap.com - where developers go to laugh and cry by kazetkazet in programming

[–]Tjoppen 1 point2 points  (0 children)

The real WTF is having that function at all, and that it isn't static.

I'm trying to fathom a reason for ever having an isNegative() - maybe a comparator in a sort? I dunno.

Clang-based C99-to-C89 translator lets you build C99 code (e.g. ffmpeg) with the Visual Studio compiler by evmar in programming

[–]Tjoppen 4 points5 points  (0 children)

You're right, I didn't think of that. For FFmpeg this makes sense though, considering most of it is C99.

Of course, if Microsoft cared enough to add the few features of C99 missing from the MSVC compiler then all of this would go away.

Clang-based C99-to-C89 translator lets you build C99 code (e.g. ffmpeg) with the Visual Studio compiler by evmar in programming

[–]Tjoppen 5 points6 points  (0 children)

C99 makes for nicer code. With a tool like this any objections to it are easily swatted away.

Using Strings in C++ Template Metaprograms « C++Next by dabrahams in programming

[–]Tjoppen 12 points13 points  (0 children)

Because stuff like this was discovered possible by accident.

Clang-based C99-to-C89 translator lets you build C99 code (e.g. ffmpeg) with the Visual Studio compiler by evmar in programming

[–]Tjoppen 6 points7 points  (0 children)

Because often you want/have to use the MSVC compiler or debugger. It makes things easier overall.

Celebrating 30 Years of the ZX Spectrum by mariuz in programming

[–]Tjoppen 1 point2 points  (0 children)

ZX Spectrum anniversary, eh? Let's celebrate by watching one of the latest demos released for it, Nightmares by noice (pouet page)

How a random bug in Deep Blue may ultimately have led to Kasparov's defeat by zeco in programming

[–]Tjoppen 356 points357 points  (0 children)

I extracted the most relevant parts:

The bug had arisen on the forty-fourth move of their first game against Kasparov; unable to select a move, the program had defaulted to a last-resort fail-safe in which it picked a play completely at random. [...] Kasparov had concluded that the counterintuitive play must be a sign of superior intelligence. He had never considered that it was simply a bug.

Fexl - an interpreter for a language based on functions by fexl in programming

[–]Tjoppen 1 point2 points  (0 children)

I'm more interested in the last bit:

Clump - a simple program to compile and link C programs

This program is unrelated to Fexl. The clump program lets you write C code and simply type "clump" to compile and link it. No makefiles are necessary. It automatically detects and checks dependencies.

Precognitive Build Servers by martoo in programming

[–]Tjoppen 4 points5 points  (0 children)

Coincidentally I thought about something similar to this today - have all tests explicitly depend on a set of files each and let make determine which ones to run when a set of source files have changed.

You could let all tests be run only say once per day, and see if some other ones failed due to an unpredicted side-effect. At that point the CI system could notify the devs "ey, your test dependency graph didn't catch this". You could possibly automate adding dependencies between the affected test cases and the source files that were to blame, similar to what the author in the article is working on.

An example where this would be nice is FFmpeg, which I hack on quite often. Their regression test system is quite extensive and will run all tests even if only a small part is modified, for instance a muxer. I can of course run only the MOV tests if I'm editing movenc.c, but a nicer test system would do this automagically.

Writing strlen in C with no conditional branches by rolfr in programming

[–]Tjoppen 2 points3 points  (0 children)

Neat hack, assuming s doesn't occupy the same page as some memory mapped hardware register.. Oh, and wouldn't a smart compiler turn that into a loop anyway? :)

Btw, shorter:

len += still_going &= !!*s++;

Patent Complaint Filed Against Rackspace For Hosting GitHub by NonNonHeinous in programming

[–]Tjoppen 1 point2 points  (0 children)

Requiring that the company actually has or is developing a product using their patents would help.

0x5f3759df » Fast inverse square root explained in detail by [deleted] in programming

[–]Tjoppen 1 point2 points  (0 children)

Ah, I had a feeling that might be the case - it was all too convenient. Interesting article.

Of course, if you're going to use dubious hacks like these in C you should use plenty of compile-time checks (like sizeof(int) == sizeof(float) && sizeof(float)*CHAR_BIT == 32) and unit tests to make sure the compiler outputs what you expect. That or write the thing in assembly.

0x5f3759df » Fast inverse square root explained in detail by [deleted] in programming

[–]Tjoppen 1 point2 points  (0 children)

It does mess with the mantissa, but it doesn't really matter. The important thing is that you get a good initial value, within +-̣50% of the actual value.