Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you think this is good, wait until you find out about statically typed languages and IDEs with code navigation features.


No, you can do this sort of madness in C too via function pointer tables. Give the function pointer field in your struct a commonly-grep-spammed name like "close" and watch your readers go mad trying to figure out what xxx->close() does.


Virtual tables are not quite the same thing.

You can grep for every instantiation of the struct in the code-base.

If anything, macros are more problematic:

  #define VTABLE_INIT(prefix) \
    (struct vtable){ .add = &prefix##_add, .sub = &prefix##_sub, and so forth }


I've done a bunch of work with statically typed languages and am not about to argue that dynamic languages can be as easily navigated or statically analyzed by IDEs as statically typed ones can.

That said, dynamic languages still have a great deal of value, and a significant portion of the programming population uses them, so I still think it's worthwhile to set down some useful rules of thumb.


> dynamic languages still have a great deal of value

I used to think this too.


If you think that is good, wait until you find out that Lisp has similar code navigation features under SLIME and yet is a dynamically typed language.




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

Search: