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

I guess it is by far easier to be a puts debugger than a printf debugger (I'm saying that as someone who prefers printf over a debugger but pry on Ruby over simple puts).

You can get a much longer way with what Ruby lets you do with puts than you would with printf in C/C++.

Like the example with `method(:render).source_location` from the article. You can't do that in C/C++ on a general base.

Or pretty printing a struct is cumbersome. In Ruby you just do `puts obj.inspect` and get a readable representation of the object.



__FILE__, __LINE__, __FUNCTION__

Yes, there's no default pretty print for structs, but no sane C programmer would ever expect or want that blubber to come available by default. Mainly because there's very rarely a need to printf-dump anything more than a select variable or a struct field. Different language - different debugging realities.


Those only act on the currently defined context.

Especially __FUNCTION__ is by no means an equivalent to source_location.

__FUNCTION__ tells you, in what function you currently are.

source_location tells you "in what file has this method of this object been defined". Because of duck typing this is much harder to answer in Ruby. But even in C, because of linking it can be non obvious what function actually gets called.




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

Search: