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

I'd actually argue that var makes it easier to read and understand code. Most of the time, an explicit type on a variable declaration is just noise, because it's a repetition of what we already know from the same line of code. The main place where this doesn't apply is when the variable is initialized from a method call, but even then I tend to find that it's usually quite easy to infer the result type based on context (variable or method name), even without using IDE features. It's definitely different and requires some getting used to, but I personally see a lot more positives than negatives from it.

RE your sibling comment about dynamic: I primarily use it with json. It's useful for things like one-off error responses where you just need to grab a message or code to return/throw and there's really no benefit from introducing a class for that one usage. I did once work on a project where that was attempting to re-use some awful legacy code in a new app, and they leaned on dynamic a lot to make the legacy code work without to re-architect it correctly. It was about as terrible as you're imagining.



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: