7 ms·
This is a matter of opinion. I wrote a set of React components that gets 46,000 npm downloads a month and typescript is a godsend. My library is a bridge betwe
by latchkey 4y ago
This is a matter of opinion.
I wrote a set of React components that gets 46,000 npm downloads a month and typescript is a godsend. My library is a bridge between two heavily popular projects, so my dependency tree is fairly intertwined. The library solves a real user problem and does it efficiently. It isn't totally perfect, but it covers 98% of the use cases.
I wrote comprehensive tests as I developed everything. I have good documentation. I have an example app people can play with. I have codesandboxes. Yes, it was a lot of work, but that's what building products is all about.
I've maintained this library for over 3 years now. I've upgraded it many times as the underlying dependencies have changed. A few times with backwards incompatible changes. I get outside contributors doing great work.
I do releases on a regular basis, without worry, because my test suite is that good and because I know that if the underlying types change, tsc will catch that too. These things have saved me countless hours of work finding bugs and fixing issues.
In other words, I call bullshit on this entire blog post. Ignore it. Typescript is the correct solution. What is the alternative? Just using JS and letting things break without knowing it? Come on.
Learn how to use types. Learn how to use a professional IDE, like IDEA, that shows you what's wrong as you develop. Learn how to write tests. Learn how to use a debugger. These are all things any decent developer should know and practice on a regular basis.
- somenewaccount1 4y ago[flagged]
- latchkey 4y ago> TypeScript is terrible for library developers That's the title. That's the whole premise of the post. > his primary gripe specifically as a library developer - is that the knowledge base for library developers is very sparse. No, it isn't.
- mattmanser 4y agoIt's the first of his 5 gripes. There's only 5 of them and they're titled. A few of the other gripes also mention the lack of documentation, so it definitely appears to be his main gripe. I agree with GP, you don't seem to have read his article and knee jerked a reply. And all you have to do to prove your point is to link some great documentation explaining how to make complex types for libraries and how to test them. Which you haven't.
- latchkey 4y agoWhat I said is that I call bullshit on his 5 points. None of them are valid and they are just opinions of a developer who hasn't put the effort in and isn't providing concrete examples of what is actually wrong. I actually find it difficult to understand why this is even on the front page of HN, maybe it is a slow news day? I feel that my point is proven with a successful multiple year open source Typescript library. Great documentation? That's subjective. I'd start with a deep reading of the official docs as they are quite good: https://www.typescriptlang.org/docs/ https://www.typescriptlang.org/docs/
- westoncb 4y ago> I feel that my point is proven with a successful multiple year open source Typescript library. That only proves that it's possible to do, not that the language facilitates it or that certain modifications to the language/ecosystem wouldn't greatly improve the process. The point of the article is the latter, not the former.
- tstrimple 4y ago> What I said is that I call bullshit on his 5 points. No. What you said was: > In other words, I call bullshit on this entire blog post. Ignore it.
- latchkey 4y agoTrue, I paraphrased what I said so that matt could hopefully understand a bit better that I did indeed read the blog post. I want my 10 minutes back please.
- remram 4y ago
- somenewaccount1 4y agoto be fair to me, i did read them....i just don't care that much.
- nightski 4y agoThere should be another guideline about commenting on whether someone read the guidelines.
- remram 4y agoYes, probably. Then again there is already a downvote for comments that "don't contribute to the discussion", so that probably covers it. I expected to be downvoted with the rest of the thread, but somehow got flagged. That's a first.
- deleted 4y ago[deleted]
- auggierose 4y agoGood for you. I was somewhat disappointed with TypeScript in the beginning, because I tried to use the type system like I would use it in Swift or Scala. That's not really a good idea. If instead, you view TypeScript as a smoother implementation of JavaScript + JSDoc, then it becomes a really powerful tool, which I like more and more!
- david422 4y ago> Just using JS and letting things break without knowing it? And if types change, and it still works, it's basically working by accident.
- latchkey 4y agoIf types change, it doesn't compile and I can't do a release in CI. I don't consider that working.
- david422 4y agoI'm agreeing with you here. If you use plain JS and change the underlying types that are being passed around, but things are still working, you're basically getting lucky.
- latchkey 4y agoOk, got it. Apologies. If you write comprehensive unit tests for your javascript, that should effectively also work too... this is what ruby developers pretty much had to do. We can see that over time based on the decline of ruby popularity in general, that fell out of style though. It is too easy to make a mistake and everyone was just duplicating what a compiler does for us. I can't tell you how many hours I would sit there pair programming with other ruby developers just trying to figure out what 'type' an object is. Mind boggling, but it was good to get those high paid consulting hours.
- 3qz 4y agoDo you get paid for any of this?
- latchkey 4y agoNot directly. I've been developing open source for almost 30 years now (I co-founded Apache Java/Jakarta). I consider that the experience gained from developing extra curricular projects pays for itself in other ways. For example, I've never had to interview or even look for a job and I've never been laid off.
- mmmpop 4y agoInvest in yourself and you'll never work a day in your life.
- fb03 4y agoI really wish I could work in OSS more. Have contributed to several libraries intermittently. How do you find time to do both OSS work and your day job? does your employer allow your OSS contributions to count as work there? I wish I could find the key to that balance. Whenever I find those guys on Github with several maintained multi-thousand star projects, I wonder "how do they do it?" (fund themselves + work on OSS). I am always curious about the underlying life stuff Thanks in advance!
- latchkey 4y agoThe way that I look at it is that the vast majority of developers depend on some open source project. This means that we find bugs or missing features in other peoples code in our day to day coding. That's a perfect excuse to contribute upstream. If your company has legal policies against that, then honestly... there are other jobs out there. I know that sounds kind of blunt, but I've always made it clear to my employers before I start, that I'm going to contribute to the greater good as part of my work. In this case, I needed the code for an internal project and decided that the company would benefit the most from making it a library and getting outside help on it. It was an itch that I knew many other people needed scratched because there was a competing project that had gone silent and was incomplete/poor quality. That justified my time spent... I had to write the code either way, might as well make it open. When I look for people to hire, and I've done a lot of hiring over the years, I primarily look for people like myself who put that extra effort in. Either in their own personal projects or by at least contributing to something upstream. Even just simple documentation changes is something I'd hire over. I fully understand that people have lives outside of work, but honestly... if you're going to be a top developer, you've got to put in a top level of effort, because other people around you are.
- gkiely 4y ago> Typescript is the correct solution. What is the alternative? Just using JS and letting things break without knowing it? Come on. Surely that's not the only alternative. Here's a few off the top of my head: - Being able to write complex types in a syntax that more closely resembles JavaScript. Using Array length for counting or nested ternaries for if logic gets old fast. - Being able to debug types, not console output, a real debugger. See: https://twitter.com/MarcJSchmidt/status/1539787500788613120 https://twitter.com/MarcJSchmidt/status/1539787500788613120 - More comprehensive documentation on writing advanced types - A typescript specification
- latchkey 4y ago> - Being able to debug types, not console output, a real debugger. See: https://twitter.com/MarcJSchmidt/status/1539787500788613120 https://twitter.com/MarcJSchmidt/status/1539787500788613120 That is really nice. I'd love to see that live.
- dvt 4y ago> Being able to write complex types in a syntax that more closely resembles JavaScript Yikes. This is how you end up in preprocessor hell. Macros are generally not a good thing. (Fyi: TS types are already Turing-complete which is arguably a mistake.) > Being able to debug types, not console output Eh. It's not like Java has a "type debugger." Why is this needed? Why are your types so complex? Weird ask. > More comprehensive documentation on writing advanced types Really beating the same drum here. > A typescript specification What does this mean? We have a pretty clear typescript spec[1]. [1] https://github.com/microsoft/TypeScript/blob/main/doc/spec-ARCHIVED.md https://github.com/microsoft/TypeScript/blob/main/doc/spec-A...
- gkiely 4y ago> Yikes. This is how you end up in preprocessor hell. Macros are generally not a good thing. Not suggesting macros, rather an alternative way to define types. A function that accepts and returns types. Seeing as typescript has a JavaScript interpreter I thought it might be feasible but I'm just spitballing it. > Eh. It's not like Java has a "type debugger." Why is this needed? Why are your types so complex? Weird ask. I don't buy this argument. Writing any type of complex types with recursion, arrays or ternaries sucks and it will take more than "this is how Java does it" to convince me otherwise. I like to debug with a debugger, not my head. Take a look at the examples in the article to see some complex types and read some tweets from library authors complaining on twitter. I can find some examples if you're interested. > We have a pretty clear typescript spec I hadn't actually seen this and it looks interesting but seems pretty out of date, Typescript 1.8?
- andrewmcwatters 4y agoWhat package do you publish? https://github.com/lookfirst/mui-rff https://github.com/lookfirst/mui-rff?
- hmsimha 4y ago> In other words, I call bullshit on this entire blog post. Ignore it. Typescript is the correct solution. What is the alternative? Just using JS and letting things break without knowing it? It seems like you and I read a different article. The post I read did not advocate for going back to JS; rather it advocated for better tooling and documentation (with examples, ideally) for library developers Conclusion I love typescript and think the team working on it are incredible. Typescript has completely changed the FE landscape and wouldn't want to dismiss its contributions. But as a library developer, we need: - better documentation, - better tooling, and - to spend less time making tsc happy. I shouldn't have to read the typescript compiler source code in order to figure out why it's resolving a piece of my code to a specific type. I developed a library used by the React app I work on to cache network results in localstorage (to reduce the number of expensive requests made on page refreshes) and generate React-Query query-functions to read the result from localStorage first before fetching from the network as a fallback (if the data is stale or uncached). It's not an especially large library, but I felt all of the pain points the author describes. It's great that you didn't with your library (and I'm sure there are large classes of libraries whose authors wouldn't feel these pain points), but it's a very real issue if your dealing heavily with generics, serialization/deserialization, and/or complex type interactions
- fullstackchris 4y agoDo you have an example? I've seen TypeScript handle crazy nested types (and generics) with ease.
- hmsimha 4y agoPerhaps the React-Query source itself is a good example of when "simple" is still not "easy to read/write": I picked out this file pretty arbitrarily: https://github.com/TanStack/query/blob/main/packages/react-query/src/useQueries.ts https://github.com/TanStack/query/blob/main/packages/react-q... The author of react-query seems to be very clear at communicating how the library works and the library itself provides a great developer experience, but it's also an example of how much work can go into correct typing in library code.
- Shorel 4y agoI agree so much with you. I would even say: most libraries used for just about anything, are written in C/C++/Java, all of which are typed languages. The post's author simply lacks the education and experience to actually have a valid opinion on this topic.
- lelandfe 4y ago> The post's author simply lacks the education and experience to actually have a valid opinion Besides your take being just outrageously exclusionary – the author is Eric Bower, a principal engineer who's also a Redux Saga maintainer. They're more than qualified to weigh in on this.
- UncleEntity 4y agoAnd their opinion is to push the complexities further up the ladder onto the makers of the tooling. I’ve seen some crazy assed stuff they do with C++ templates and my reaction isn’t that they need to be spending their time on writing blog posts to explain the dark mysteries to me but that maybe I’m not the one who should be trying to write a library without spending a massive amount of time learning how this stuff works. Sure, I can beat a template into submission using the famously helpful error messages the compiler provides and some random blog posts by people who actually understand what’s going on and I’m very thankful that they spent the time explaining it. Even having 1000 line long error messages helps once you learn what it is really complaining about. And this isn’t even my literal job, just something I do because I enjoy it.
- lelandfe 4y agoThis is yet another comment indicating the author lacks enough knowledge to even talk about this. Why is this the default response from HN on matters like these?
- bmn__ 4y agoMight have something to how the author chose to express his opinions. FWIW, I got the same impression from the article, but did not bother to write a comment until now. IMO, the author could have done better by providing more concrete examples for the points of criticism, and understating the conclusion or moving it to the end or dropping it entirely, as I think it's better to give the reader the choice to make up his own mind, given the facts and evidence.
- jollybean 4y agoMaybe you missed the point here. "Lean how to use my types!" Any given project uses a large number of libraries. The point of a library is that it's 'useful'. When a large number of libraries use vague and differing typings, it becomes impossible to manage. The fragmentation created by the agile nature of Typescript is, predictably, a giant problem.
- latchkey 4y agoAnyone can write bad software with terrible APIs. That isn't the problem of the language and certainly doesn't make it 'terrible for library developers'. My point is that I've written a library that gets a lot of use. It has decent enough APIs. Nobody is writing blog posts like this about my stuff.
- JimDabell 4y ago> I call bullshit on this entire blog post. How? None of what you are talking about directly relates to the article. It feels like you are just reacting to the title and not the contents. For instance, you say: > I call bullshit on this entire blog post. Ignore it. Typescript is the correct solution. What is the alternative? Just using JS and letting things break without knowing it? Come on. But the article says: > I love typescript and think the team working on it are incredible. Typescript has completely changed the FE landscape and wouldn't want to dismiss its contributions. > But as a library developer, we need: > - better documentation, > - better tooling, and > - to spend less time making tsc happy. This is not an article advocating for “just using JS and letting things break”, so why are you reacting as if it is?
- Aeolun 4y ago> This is not an article advocating for “just using JS and letting things break”, so why are you reacting as if it is? Because the tone of the article seems to be that Typescript is horrible, and the tenor seems to be that the author is blaming his own incompetence on the language. He has a point hidden in there somewhere, but I needed the HN comments to point it out to me.
- acemarke 4y agoThat's... not at _all_ what the author said. Summarizing the sections: - Documentation: there's docs on how to use the language as a whole, but nothing focused on writing libraries (how to build/publish, type tricks that libraries may need that apps don't, etc) - Debugging: debugging types is a nightmare - you basically have to hover over temp variables to see what intermediate values are - Complexity: TS types for real-world lib code can get complicated - Testing: testing types is necessary, and the community has had to invent tools to help with that - Maintenance: maintaining types and responding to issues takes up time None of those are comments that "TS is horrible". Those are all straightforward concerns with the experience of writing and maintaining a TS-typed library, and as a Redux maintainer I can back up every single one of those. I actually did a talk on "Lessons from Maintaining TS Libraries" a few months ago, and I hit all of those points myself: https://blog.isquaredsoftware.com/2022/05/presentations-ts-lib-maintenance/ https://blog.isquaredsoftware.com/2022/05/presentations-ts-l...