4 ms·
Typescript is for me one of the most overengineered programming languages. Why did JS not follow the way python and php did? Integrate types in the main languag
by ulrischa 2y ago
Typescript is for me one of the most overengineered programming languages. Why did JS not follow the way python and php did? Integrate types in the main language but make it optional.
- BoorishBears 2y agoThank god they didn't follow the way Python did.
- adhamsalama 2y agoPython keeps the types at runtime, that's why no TypeScript framework will have a developer experience anywhere near something like FastAPI.
- code_biologist 2y agoFirst party runtime types would be nice, but zod has become pretty much the standard answer for projects that need it. Not complicated.
- adhamsalama 2y agoTell me how to have automatic documentation and validation like FastAPI using anything in Node.js and I will use it immediately. Note: NestJS isn't it.
- code_biologist 2y agoDo OpenAPI Swagger docs count? That seems to be the route a ton of the ecosystem takes. trpc, ts-rest, and express-zod-api all explicitly build on zod and can do validation + Swagger UI generation. hono looks like it doesn't do that by default, but single-source-of-truth validation + Swagger UI are available as middleware via `@hono/zod-openapi`.
- BoorishBears 2y agoIt's doable if you really want to: https://docs.nestjs.com/openapi/cli-plugin#overview https://docs.nestjs.com/openapi/cli-plugin#overview (Also doable without a compiler step, but since it's TS one more compiler step isn't the end of the world: https://docs.nestjs.com/techniques/validation#auto-validation https://docs.nestjs.com/techniques/validation#auto-validatio...)
- adhamsalama 2y agoI do use this. It's not as seamless as using FastAPI. Also not as type-safe as FastAPI. You can simply type a class variable as an int while the validation decorator works on a completely different type. It's an illusion of type safety.
- esailija 2y agoTypescript does support it. You can do everything ts can in js with just jsdoc style comments. I actually prefer it.
- zachrip 2y agoWhen typescript came out, you were seen as weird for wanting such a thing. I once had a VP of engineering dm me to tell me to stop discussing typescript in the company dev channel around 2015 (if you're reading this, that was a dick move). Nowadays you're kinda odd man out if you don't want types. So the idea of adding types even optional ones probably wouldn't have gone down well. The closest we ever came was es4 which of course never landed: https://evertpot.com/ecmascript-4-the-missing-version/ https://evertpot.com/ecmascript-4-the-missing-version/