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

I often wonder if people who have trouble typing things, or have to us the 'any' type, ever really learned how to program.



Yep, when I hear people say things like "I like $dynamic_language because I don't have to think about what types I'm supposed to put when I write my functions" or similar, I'm just thinking "how the hell can you write a function without knowing what types you want to receive and return?". I do love the "productivity benefits" of having to read entire function bodies to reverse-engineer what types I'm supposed to pass, because the docstring just used vague terms like "file" or "user"


I find that areas that are hard to type are a code smell indicating potentially unstable API design. It can be pretty tricky adding types to a JavaScript project as the lack of types can lead to some very side effecty apis that can be very difficult or impossible to add full type safety to.

My impression is that people running into these problems are trying to add declaration files to JavaScript code, but if you use typescript throughout I've not run into these problems.

Anything I find hard to type is simply a hard problem to solve in the first place and the type system helps me rethink the problem to find safer and more elegant API designs.


So the only real way to learn how to program is to learn typed programming?

Meaning you could create most modern applications (including this very website) without really learning to program...

Fun perspective.


Learn to program [at a high level]. Which means being able to write code with a type checker in a way that makes you faster not slower at producing high quality, maintainable programs.


any (concept not keyword) is useful when you NPM install something without types and just do a define module in a local .d.ts. You are implicitly any-ifying that package.


I'm referring to people who get frustrated and use 'any' as an escape. Especially in programs they write themselves. That's just incompetence.


Yes I haven’t needed to do that. Typescript is very expressive.


Probably true. After 30 years of writing code, I guess I just haven't figured it out yet.

Thankfully you and Typescript are here to show me how to do it right.


Years of experience don't mean much, if you just repeat the same thing over and over again and aren't willing to learn new things and reevaluate your workflows.

I have seen people with decades of experience who remained stuck doing things the same way they first learned to do them and refusing to adapt.


What languages have you written for 30 years? and what about TypeScript is so challenging for you? Especially if you’ve already spent time with other statically typed languages.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: