Hacker News new | past | comments | ask | show | jobs | submit login

> That's not really true. If you want an SQL database to back your website, then you'll deal with interface{} with Go's sql package.

True. But for most real world scenarios I only ever use interfaces at the boundaries between APIs and they quickly get asserted into a type after being passed.

Conceptually they're a bit like passing marshalled data between APIs in that sense.




> Conceptually they're a bit like passing marshalled data between APIs in that sense.

That's IMHO a great way to think about when it's Good™ to use them. Yes, there are times when you just have to use the empty interface type but it's really not as bad as everyone makes it out to be.

I love Go because it is explicit and because explicit types make everything easier in the long run. I get tired of seeing Go written like Python/Ruby/$otherDynamicLang with overuse of interface{} and/or reflect.




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

Search: