The Difference Between Programmers….

I posted this on slashdot, but I thought it was just too good not repeat here.

The difference between a competent and an incompetent programmer is that an incompetent programmer thinks his/her crap code is the best, while a competent programmer knows that his/her code is crap.

Sure this is funny, but there’s an underlying truth to this. Someone that knows what he/she is doing, knows all the ways the code could fail and all the the checks and exceptions that should be there, but aren’t, and how the assumptions of the underlying algorithm may not be strictly guaranteed, and so the code is just waiting to break. Someone that doesn’t know what his/she is doing thinks everything is great since it passed his/her incomplete unit test.

Or to put it another way: Ignorance is bliss.

tech

Permalink

OCaml Can Byte My Shiny Metal Ass

Not only does it have incredibly pedantic type checking, but EVERY “variable” is immutable, but of course you can make variable that is immutable to a reference that you change! So you’re left with:
let x = ref 0;;
x.contents = x.contents + 1;;

It has a syntax where nothing is grouped, so instead of making things “natural language like,” it just makes everything ambiguous. Sometimes you need a semicolon, sometimes parenthesizes. You never know which, and if you use them when you don’t need them, it complains.

It is so hard to do such simple things.

Apparently this language is only good for implementing crappy toy languages for research projects.

Bravo.

Fuck OCaml. Lisp is soooo much easier.

Others that think OCaml sucks:
Sucks
More sucks

tech

Permalink

I Hate Unicode

I’m sure I told you this a few months ago, but I REALLY hate unicode. Sure it’s cool tto support all the languages. Yes, One (err Two… No Wait! Three!) Encoding(s) to Rule Them All is better than a billion simlar and incompatable encodings, but it really is a pain in the ass to use.

I’ve got a bunch of XML files that are encoded in bunch of different things, and I’m having a hell of time to get perl to convert them all from whatever (ascii, windows-1252, big5, shift-jis, etc) to utf-8. It will read them, imply that unicode is how they’re being represented internally, and then prompty output them back in their original encoding.

And of course LibXML refuses to use anything but unicode. Why? Because. I’m sure there’s some reason, but let’s face it. All encodings are ASCII compatable, so just deal. Why it even cares what encoding the file is in I don’t know. Just match on the byte sequence and be done with it.

This whole thing seems to be more trouble than what it’s worth.

Your unicode related QOTD:

ISO-8859-8-1 [Hebrew]
None of the Encode team knows Hebrew enough (ISO-8859-8, cp1255 and MacHebrew are supported because and just because there were mappings available at http://www.unicode.org/). Contributions welcome.

ISIRI 3342, Iran System, ISIRI 2900 [Farsi]
Ditto.

Thai encoding TCVN
Ditto.

– http://perldoc.perl.org/Encode/Supported.html

qotd
tech

Permalink

Your Code Makes Baby Jesus Cry

Javascript:

if (!totCnt > 0)

This code properly evaluates as “if totCnt is not greater than zero.” Why?

When the greater comparison is evaluated, both sides of the comparison must be evaluated. Evaluating the left side, we see that the logical not operator is applied to totCnt, an integer. This means that totCnt must be typecast to boolean prior to the application of the operator. When the typecast is carried out, if totCnt is zero, then totCnt is converted to false. The logical not operator is applied, and so totCnt now has the value true. The comparison requires an integer, so the boolean true must be typecast back to an integer, which in this case happens to be MAX_INT. MAX_INT is greater than zero, and so the condition is satisfied.

If totCnt is greater than zero, when it is typecast from an integer to a boolean, its value becomes true, since the integer is non-zero. Negating this, the value of totCnt becomes false. This is typecast back to an integer, which in this case is zero. Zero is not greater than zero, and so the condition is not satisfied.

So the code works, but not for any of the reasons the person who wrote it thought. The code the person wanted to write was:

if (!(totCnt > 0))

or better yet:

if (totCnt == 0)

tech

Permalink