utils: add len() using __len() or stringified, and handling nil as empty