Tuesday, February 14, 2012

Assertion Failed!

Topic: Varia

Assertion: noun. a positive statement or declaration, often without support or reason: a mere assertion; an unwarranted assertion.

In programming, an assertion is an expression which we want to be true always. In fact, usually whenever there is a piece of code of the form "assert(x)", if ever x is false the program will halt, pause at that point, allowing a programmer to examine the code and see what's wrong.

That is where this blog comes in. I'm not an expert programmer (or maybe I am but I don't know it) and I won't pretend to be. I won't pretend to be better than someone. I won't try to push my beliefs on you, and the code I post might be wrong sometimes. This blog is simply a place for me to pause and write my own little opinions and stuff. Things I found interesting, or things I want opinions about.

For those who want to get involved in programming but feel intimidated about online blogs, this is a good place to start reading.

I don't see this blog like a classroom, where I will preach my beliefs. Instead, I see it more like a small café where people can sit around while I rant away, opening discussion. That being said, the topics here will mostly have to do about programming, but may diverge into other computer science-y stuff.

The title of this blog actually refers to a piece of obscure code I ran into. The subroutine in question was never used, and had a single line: "assert(FALSE)". This means that anytime that subroutine would run, the code would crash. I almost felt sad for that subroutine (before I destroyed it), how it was never called and would only cause trouble. Despite all the funny or depressing things I've seen devs (developers) write over the few years I've been programming, this one stands out.

Anyways, I've ranted for long enough. Next post: who am I? Perhaps.

Peace out,
Snowman

2 comments:

  1. assert(FALSE) means scream at me if the method is called during testing, but don't risk screwing up my production code. it's awesome if your tests have 100% coverage, and it's not in some library that someone else might use...so pretty much never.

    ReplyDelete
    Replies
    1. Ah, see, that's also assuming that asserts in the code would only run in debug, which wasn't true. Asserts would trigger anywhere (thus griefing many customers...)

      Delete