Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Hidden Features Of Perl, PHP, Javascript, C, C++, C#, Java, Ruby, Python, Others (beerpla.net)
40 points by archon810 on June 29, 2009 | hide | past | favorite | 7 comments


I just eyeballed Ruby and C, and I think you're better off not knowing a lot of this, and just keeping a whiffle bat next to your desk to use on any teammate that uses them.

For instance, the highest-ranked Ruby "hidden features" are one-liners that aren't faster than their multiline equivalents, but are incomprehensible if you don't understand obscure syntax.

The highest-ranked C features include Duff's Device, which, if one of your teammates tries to bust it out, go find a real bat. Others are GCC-specific. One overloads the preprocessor to define domain-specific languages for FSMs.


That's not quite true -- Adam Dunkels' protothreads make very good use of Duff's Device. They enable you to write event-driven code in a more or less thread-style way. That said, Mr Duff is kind of hidden inside the protothread macros -- one never actually has to make eye contact with him.

Original link: http://www.sics.se/~adam/pt/

Protothreads in C++: http://blog.brush.co.nz/2008/07/protothreads/

Also, a lot of the "hidden" Python are fine, and to be used. Though I didn't know about ... (Ellipsis)


"I just eyeballed Ruby and C, and I think you're better off not knowing a lot of this, and just keeping a whiffle bat next to your desk to use on any teammate that uses them."

Some of the Ruby things are quite useful and not all that obscure for many of us. Others are fugly, or clever for the sake of it. In any event, it's good to know why these things work, even if you don't use them.


For instance, the highest-ranked Ruby "hidden features" are one-liners that aren't faster than their multiline equivalents, but are incomprehensible if you don't understand obscure syntax.

This is why they say Ruby is the new Perl.


No, they say Ruby is the new Perl because of the "TIMTOWTDI" paradigm.

http://en.wikipedia.org/wiki/Theres_more_than_one_way_to_do_...


Some of these are pretty scary. In particular, the c++ analog literals http://www.xs4all.nl/~weegen/eelis/analogliterals.xhtml, multidimentional to boot.


I thought that the C# list was pretty good. There's lots of little tips in there that you might not pick up without experience (so it's a good read for those learning the language).




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: