Engwar

Chintana Wilamuna's weblog

Pissing people off

with 20 comments

From time to time, if you feel the need to piss someone off for their own good, let me assure you that it’s a perfectly natural thing. If you see someone living their lives without getting pissed off even for few minutes, do them a favour by pissing them off, at least once. Just like eustress people need eupiss for a long healthy life. Besides, it shakes things a little bit which helps people to bring some variety to their monotonous existence. So, if the conventional wisdom has shown you that pissing people off is bad, well, it’s because it’s conventional. Make a note on your todo lists, or your GTD system and make it an items that you could do in less than 2 minutes. Then do it. After all it’s for their own good.

Now, let me show you a very easy method to piss someone off. This works extremely well if the pissee is a tech guy. More specifically a programmer. It’s a well tested and trustworthy method which people used in mailing lists from time to time to start holy wars. This method is most successful if the pissee uses a big stupid language and actually LIKE it. All you have to do is utter “my language is better than you one” phrase in a slightly offensive tone and throw an example on their face. It’s that simple. Lemme give you one example.

Artificial examples on blogs sucks. So let me take some code which I was playing with today and explain.

I was writing some Ruby code this afternoon with WSF/Ruby. In order to talk to an SSL endpoint you need to supply the CA cert to the client as an option. Rampart expects you give the cert with the certificate delimiters removed (first and the last line of a certificate). WSF/Perl will read the certificate for you and do the right thing when you pass the filename. But not WSF/Ruby (note to self: make this part of the lib).

client = WSClient.new( 
  { "to" => "/your/end/point",
    "ca_cert" => "cert content as a string" }, logfile )

The beauty of the language you’re using spring up in situations like this. Without further ado, here’s the one liner to get the cert content as a string with certificate delimiters removed,

File.open('server.cert').readlines[1..-2].join.gsub(/\n/, '')

You got to appreciate the beauty of the above line. Although I’m quite fond of it I prefer the Python version over it. Here’s one way to do it,

"".join([line.strip() for line in open("server.cert")][1:-2])

Yes, the list comprehension beats it all. It’s simple and elegant. Most importantly beautiful and pleasing to look at. My first exposure to list comprehension has been via Erlang. Purely due to the fact that I started reading about it before Python.

Anyhoo, all you have to do now is find someone who uses a big stupid language and throw an example like above to their face and tell them to beat it. See if they can write it more elegantly using their language. The beauty of the trick is that there’s no way in this world that’s gonna happen. So, you’ve already won. One word of caution though. When taking an example take something slightly more complex than a single function call. Like opening a file. In both Ruby and Python it’s one function call. DON’T take this type of examples. Why? Because there’s a very high probability that the other person, yes, the one who’s using a big stupid language, will get so angry and beat you up. You don’t want this. So, avoid at all costs.

There you go. Do some good to the world by pissing off few people with this technique. It’s good for your karma too. Happy pissing!

Update: Ok, I admit that I got a bit carried away with that example which made it artificial, hence sucked. When you write an SSL client using WSF/Ruby you only have to give the filename of the certificate, none of the certificate delimiter removal plus newline removal is necessary. But, I’ll keep the examples to keep the central theme in alignment. BTW, here’s the correct SSL client example with WSF/Ruby,

client = WSClient.new(
  { "to" =>  "/your/end/point",
    "ca_cert" => "server.cert" }, logfile )

Update 2: Before it gets a bit out of hand, let me reiterate if it was not evident from the first reading. This whole thing was meant to be a joke. Don’t take it too seriously, have a laugh and return to you editors, grow some sense of humour for chrissake. Oh, one more thing, I’m no Erlang wiz. I’m just started to grok the Erlang landscape.

Written by Chintana

August 26th, 2008 at 6:02 pm

Posted in python, ruby, wsf/perl, wsf/ruby

20 Responses to 'Pissing people off'

Subscribe to comments with RSS or TrackBack to 'Pissing people off'.

  1. Here is what it looks like in Java:

    File.open(“server.cert”).readlines(1, -2).join().gsub(“\n”, “”)

    Now, why don’t you show us how it looks in Erlang, since you like that language so much?

    And when you’re done, go look up the difference between a language and an API.

    x

    28 Aug 08 at 3:31 pm

  2. Prove it. Show us what that code would actually look like in Java.

    I make this demand because too often I see “X is better Y” claims where Y is never shown and if it were, the claim would be obviously false.

    Jonathan Allen

    28 Aug 08 at 4:12 pm

  3. @x: I don’t know enough about Erlang to write the equivalent program to the one shown in Python. Still reading Joe’s amazing book about it where I first learned about list comprehension which I mentioned. Dude, good luck doing that with the standard JDK without writing those first and you talk about languages and APIs, sheeez.

    @Jonathan: I have absolutely no interest writing the equivalent thing myself, let alone to “prove” anything. It was meant to be a joke.

    Chintana

    28 Aug 08 at 6:02 pm

  4. @x, @Jonathan – I find it hilarious that you proved Chintana’s post to be dead on with those two comments.

    @Chintana – Interesting article.

    Raju

    28 Aug 08 at 6:15 pm

  5. another problem with these one liners is that they usually have atrocious performances. take a look at http://beust.com/weblog/archives/000493.html to convince yourself that good programming languages are not measured by their terseness.

    steve

    28 Aug 08 at 6:45 pm

  6. @steve: One should not expect code like this to show up on the next shuttle to Mars. Read the article. I’m not convinced. “not measured by their terseness”? That’s bullshit. Read this.

    @Raju: ;-)

    Chintana

    28 Aug 08 at 6:58 pm

  7. Pride goes before the fall. Thanks for letting me watch you fall, I definitely had a laugh.

    Mathias

    28 Aug 08 at 9:56 pm

  8. Looks like you are masturbating. Fun to watch dog fight dog.

    Ruby Monkey

    28 Aug 08 at 11:46 pm

  9. it’s shame that best Ruby IDE is NetBeans or Eclipse (written with big stupid lang – Java),
    the best stable Ruby Web server is Glassfish (written with big stupid lang. – Java), best Ruby interpreter is JRuby (writen with big stupid lang. -Java).

    So far I don’t see any application/IDE/Server can be written in just 1 line code.

    Also the most famous ROR website is Twiter which could not scale.

    All I see Ruby people doing is just rant/fart/poop.

    Ruby Monkey

    29 Aug 08 at 1:39 am

  10. @Mathias: I don’t mind “fall”ing if it makes someone laugh, tis ol gud dude!

    @Ruby Monkey: Ahahaha, indeed, otherwise I might probably kill myself. If you think those are the “best” stuff, well, good for you. I think it’s a shame that people who do deploy Ruby stuff on production systems don’t follow such insightful advice given by people like you. right? right? Also, you don’t seem to have a clue about one liners so read that up.

    I use Emacs exclusively as my editor, haven’t used Netbeans to write Ruby programs. As for farting, Ruby people need to release their gases too man.

    Chintana

    29 Aug 08 at 3:00 am

  11. I am curious about x and what he is playing at. That is not Java and will not produce any results.

    1) There is no open method on java.io.File. So, File.open is not valid.
    2) In Java you need a main method at minimum to put your code in.
    3) To use pretty much anything you need to import classes from packages.
    4) To do *anything* with files in Java you need try catch blocks because of the brilliant exception strategy in Java.

    So, the post by X really just a troll post. There is no one line of java that is executable and can produce a result. It is not a scripting language.

    Jeff

    29 Aug 08 at 2:40 pm

  12. @Jeff: Stephan has missed the whole point of this post for some bizarre inexplicable reason and even blogged about it where he claims to have written a set of Java classes in 20 minutes that does the same thing. I’m quite humbled by the length he went into teach me about method chaining. That’s the post x used to copy and paste the line (as mentioned by Stephan).

    Chintana

    29 Aug 08 at 2:57 pm

  13. Actually I was using VI before I use netbean, I used emacs sometime, but anyway, none of them were written in Ruby, pretty shame, huh?

    Visual Studio 2008 has a Iron Ruby plugin, and that’s not written in ruby too.

    Also Ruby use green thread, so even you use thread in your code, it still a fake one. pretty sad.

    To me Ruby is still a toy. and some dude like you blind with “one line is better than anything else”. wondering before ROR, did you use Ruby?

    I think you are just a Ruby “fan boy”.

    Ruby Monkey

    29 Aug 08 at 3:24 pm

  14. Btw, did you use ruby in any production?
    what kind of system?
    do you use it in Banking system?
    or just a personal website?
    if it’s personal website, I might go PHP first.

    Ruby Monkey

    29 Aug 08 at 3:26 pm

  15. as you said, it just meant to be a joke, why you got soo angry? Is that “Ruby or you or both are sucks, you can use it to write it’s own IDE” offend you?

    Ruby Monkey

    29 Aug 08 at 3:33 pm

  16. Oh, in case you don’t really know why I asked for IDE, IDE is not only the editor, it also has debug, trace, build, syntax validating…

    Ruby Monkey

    29 Aug 08 at 3:35 pm

  17. @Ruby Monkey: Spot on dude, I’m just a “fan boy”, yada yada yada. Sorry, I cannot comprehend some of the sentences.

    Thanks for the IDE lesson, will surely keep that in mind. Yawn.

    Chintana

    29 Aug 08 at 4:18 pm

  18. The whole “lines of code” criteria for programming languages is at best a minor point of style, but this article is quite possibly the stupidest “contribution” to the debate I’ve ever seen. “”.join([line.strip() for line in open("server.cert")][1:-2]) OK, very nice. Nothing wrong with that. Except it has no real meaning for the next developer that comes along, who won’t know the meaning of the -2, for example. In Java, such things might require a method of their own. And that’s a good thing, it means the code will look like: String cert = loadCertFile(); The method will contain handy comments about why, how, and error handling for the event of the file not being there. The calling method will be easier to read. Who could possibly be opposed to that? Oh yes, the kind of pseudo-elitist who spends more time tripping over other developers than actually getting something built.

  19. @To who ever the moron who copied and pasted above from proggit: I don’t wanna discuss/argue stuff that’s posted on proggit on my blog. Please, do your arguments there. This post was not a “contribution to the debate”. You’ll see a very different style of presentation if I was trying to “contribute”. I cannot grasp why these idiots don’t get it no matter how many times I said this is an effing joke. I would not hesitate to delete if anyone copy pasted from proggit with spam links such as above.

    Chintana

    1 Sep 08 at 11:43 am

  20. -_-’
    Well, I thought it was funny . . .

    Panda

    16 Nov 08 at 4:19 am

Leave a Reply