News for hackers. Stuff that matters.
Re:Show HN: Bolt – A super-fast, statically-typed scripting ... by thrance on Sunday August 10, 2025 @02:52PM (#44857326)
Function return type inference is funny but I don't think it's that great of a feature. It makes it harder for a library's consumer to know how to properly use a function, and it also makes it harder for the maintainer to not break backwards compatibility inadvertently. Anyway, I'm all for experimenting.
Re:Show HN: Bolt – A super-fast, statically-typed scripting ... by beariish on Sunday August 10, 2025 @02:59PM (#44857372)
There's nothing stopping a library author from explicitly annotating return types wherever a stable interface is important, the idea is more for smaller functions or callbacks to make use of this. Perhaps I'll make the examples clearer to reflect the intention.
Re:Show HN: Bolt – A super-fast, statically-typed scripting ... by flakes on Sunday August 10, 2025 @10:58PM (#44860424)
Perhaps it makes more sense to say that exported function interfaces be explicit. That forces you to document the api and more carefully consider changes.
Re:Show HN: Bolt – A super-fast, statically-typed scripting ... by jitl on Sunday August 10, 2025 @06:28PM (#44858844)
It’s great in TypeScript. In TypeScript your source can have inferred types returned, and then use a build step to produce resolved typings files (.d.ts) for distribution that have the fully specified type.
Re:Show HN: Bolt – A super-fast, statically-typed scripting ... by thrance on Sunday August 10, 2025 @07:36PM (#44859421)
Ah, true, now that you mention it. I feel like it's the best of both worlds, you get type inference and it gets documented automatically.