Live data from Hacker News

Confess HN: Share your Immoral Hacks, Codes or Tweaks

news.ycombinator.com

21–30 of 70 posts

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#21

Damnit, most of my best hacks could be considered proprietary, though I seriously doubt any of the companies involved would care. One that I can share: I architected a game-creation platform so that all the game runtime code was both legal Flash and legal JavaScript, such that the same code could be inserted verbatim in both the JavaScript editor and the Flash compiled version.

That's a neat one!

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#22
post #18

I am writing PHP in Common Lisp, and my codebase is litered with the following: (defun make-record (&rest args) ; insert &allow-other-keys ;-) (let ((*db-auto-sync* t)) (object (make-instance 'record args))) (when object (update-records-from-instance object)))) Both the LET binding of db-auto-sync and the update-records call do the EXACT same thing. However, due to weirdness I don't grok quite yet, the calls to the d…

I've always wanted to do sort of the opposite... That is to say, I've always wanted to compile Scheme to PHP. I make the claim that PHP is the web's assembly language. Or, at least it's portable assembly language.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#23
post #17

...:: Hacking World Cup Tickets for Germany 06 ::... Australia was a late qualifier for the tournament. The ticket submission was via email. Tickets were allocated on a first email received basis after 09:00. There was a countdown webpage which advertised the time. --- Preparation * I telneted to port 25 of the destination and saw via EHLO that the mail server clock was 1 minute faster than advertised on the webpage,…

Brilliant.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#24
post #22
post #18

I am writing PHP in Common Lisp, and my codebase is litered with the following: (defun make-record (&rest args) ; insert &allow-other-keys ;-) (let ((*db-auto-sync* t)) (object (make-instance 'record args))) (when object (update-records-from-instance object)))) Both the LET binding of db-auto-sync and the update-records call do the EXACT same thing. However, due to weirdness I don't grok quite yet, the calls to the d…

I've always wanted to do sort of the opposite... That is to say, I've always wanted to compile Scheme to PHP. I make the claim that PHP is the web's assembly language. Or, at least it's portable assembly language.

Yeah, "apt-get install php" is much easier to type than "apt-get install sbcl perl ghc python ruby ..."... (The other langauges also all run faster, use less memory, and have more features.)

(And no, you should not compile your app into your frontend webserver. Use FastCGI or a reverse proxy!)

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#25
post #10
post #9

Gotos aren't necessarily bad - for example when you have a large amount of nested loops and need to break out of a certain number of them.

Also good for exception/error handling for languages that don't have that capability built in. E.g. the SQL script I've been working on today has a number of gotos in it.

What you really want are continuations.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#26
post #9

Gotos aren't necessarily bad - for example when you have a large amount of nested loops and need to break out of a certain number of them.

this is solved ore cleanly with escape continuation/exceptions.

Perl also provides 'last LABEL', which is handy (lets you break out of any level of nesting).

I guess in a language like C where you can have neither and function calls are slow so the 'return' escape continuation is also unusable there is a reason to use goto for this.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#27
post #9

Gotos aren't necessarily bad - for example when you have a large amount of nested loops and need to break out of a certain number of them.

In C/C++ I have longed for a parametrized break statement with value indicating number of nested loops to break at once. I'm sure this goes against some kind of lambda calculus CS ethos though.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#28
post #9

Gotos aren't necessarily bad - for example when you have a large amount of nested loops and need to break out of a certain number of them.

What you really want are continuations.

Pardon my presumed ignorance, but how is that?

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#29
I created a callback from PowerBuilder to C++ by using some PBNI (like JNI, but for PowerBuilder) trickery. Basically, the PowerBuilder application ran and loaded the external C++ library to handle expensive calculations. From the C++ DLL, I hooked into the PowerBuilder virtual machine, looked up a particular custom object and method, and then used the method as a callback. This wasn't the evil or immoral part though.

The hack was cool, but utterly stupid and pointless (the C++ was used for speed - calling back into PowerBuilder defeated the purpose). The only reason I did it was because the consultant who originally created the C++ DLL managed to convince my boss that the application would run much faster if PowerBuilder supported callbacks. So naturally my boss instructed me to do the impossible. I didn't complain because it seemed like a fun challenge at the time. I didn't tell him that it actually slowed the app down a bit though >:)

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#30
post #9

Gotos aren't necessarily bad - for example when you have a large amount of nested loops and need to break out of a certain number of them.

What you really want are continuations.

Overkill. Something really simple like Common Lisp's block/return-from would do...
Post reply on HN