I just don’t get why they absolutely had to come up with new syntax. All of this would have been possible with standard Typescript, unlocking heaps of existing tooling, editor support, and prior knowledge. But no! Let’s come up with a new language, bespoke compiler, new LSP and IDE integrations, and make developers learn yet a new DSL.
It’s creating changes for the sake of creating changes.
We first tried a TypeScript DSL and I really wish it would have worked for our use cases (e.g. describing complex REST APIs in Azure), but unfortunately it didn't.
Off the top of my head, I don't think you can perfectly describe the type (string format) of an UUID in typescript types, which you can do with OpenAPI. That may be a reason.
> Run the following command in a clean directory to create a new TypeSpec project.
> tsp init
> This will prompt you with a few questions. Pick the Generic REST API template...
I’d just like to interject for a moment. What you’re referring to as REST, is, in fact, JSON/RPC, or as I’ve recently taken to calling it, JSON plus RPC. JSON is not a hypermedia unto itself, but rather a simple data format made useful by out of band information often specified with tools such as your TypeSpec project or similar.
Many computer users work with a canonical version of REST every day, without realizing it. Through a peculiar turn of events, the version of REST which is widely used today is often called “The Web”, and many of its users are not aware that it is basically the REST-ful architecture, defined by Roy Fielding.
There really is a REST, and these people are using it, but it is just a part of The Web they use. REST is the network architecture: hypermedia encodes the state of resources for hypermedia clients. JSON is an essential part of Single Page Applications, but is useless by itself; it can only function in the context of a complete API specification. JSON is normally used in combination with SPA libraries: the whole system is basically RPC with JSON added, or JSON/RPC. All these so-called “REST-ful” APIs are really JSON plus RPC.
AsyncAPI support would make TypeSpec the end-all/be-all API spec tool for a lot of people.
TypeSpec looks amazing - but until we can go "all in" on using it for both our external and internal API, it's difficult for the team to justify yet another new DSL. It's needs to support all of our common API definition woes, and currently it only addresses 50%.
This is part of the Api-First paradigm. Instead of your controllers/handlers being the authoritative "Truth", the API spec is.
You and your team spend time arguing/debating the API from the perspective of a user. "I need X data from Y service", etc. The document then becomes the "blueprint" for your system.
Think of it as TDD but viewed from a different angle. In a microservices system, this has a tremendous amount of advantages, including being able to codegen your handlers and models, maintain consistency across the entire API, unified api documentation, increase testability of your controller/handler interface, and more.
Is there a good UI for this? I want to love OpenAPI but for complex JSON i've found OpenAPI UI's to be unusable. At this point i'd hand write my API specifications if it meant i could have a useful UI.
TypeSpec is a specification document generator - it outputs OpenAPI specification files, which you can feed to any OpenAPI documentation generator, such as Swagger or Redocly.
Oh, so if I want to add a simple checkbox boolean field on a model on a proper best practices Clean Code Uncle Bob-approved code base in 2024, I have to:
- add it in the database model
- make a database migration for the field
- add it in the DTO for the API because we don't want to couple our persistence layer to our business logic or something
- add it to gRPC/Protobuf models so other services can call it
- add it to the new TypeSpec model thing
- update tests of all of the above
I love in tech 2024, it's full of people who talk about "DRY" who force you to repeat the same things over and over again, and this is "clean code", and if you don't like it, fuck you, you aren't a "culture fit". Utterly batshit insane.
I understand your frustration, but this is the price paid for schema compliance across systems.
One qualification: the TypeSpec model should help generate your API DTOs (OpenAPI, Protobuf) etc. So hopefully that saves a step or two.
As an aside, I have tried doing a full stack TypeScript application where database types trickle down to the client, it ended poorly, since the API affordances can and should evolve separately from the database design. Therefore, I do feel that separation of database and API types is necessary.
Unions, generics, required fields, default values, enums that don't pollute the global namespace are things that immediately caught my eye. I assume it also doesn't repeat Protobuf's the mistake of not being able to distinguish between a missing string value and an empty string value.
Protobuf is old, and has some really strange warts that are only explainable historically (for example, by reference to the behavior of C++, which used to be Protobuf's primary target).
I have long used protobuf as the source of truth for API's, but it does have some weird idiosyncrasies since its primarily a binary spec, and doesn't always transfer to json well (e.g optionals, maps, etc).
As someone who works on TypeSpec, my feeling is that they are mostly different things. TypeSpec is a general purpose DSL which supports "emitting" to protobuf and other things, but in and of itself doesn't prescribe any particular protocol or serialization format.
Since Microsoft is one of the offenders, how about any novel type system try and model their own API and only when that's possible should they taut their superiority over the existing, proven standards
[+] [-] 9dev|1 year ago|reply
It’s creating changes for the sake of creating changes.
[+] [-] bterlson|1 year ago|reply
I explained a bit more here last time TypeSpec was on here: https://news.ycombinator.com/item?id=39843184
[+] [-] sixhobbits|1 year ago|reply
This post has a bit more detail about why "we don't need more standards" might not be the correct take here
(Disclaimer speakeasy is a client but I wasn't directly involved in writing this and just figured it's pretty relevant here)
[+] [-] thrance|1 year ago|reply
[+] [-] crowdyriver|1 year ago|reply
[+] [-] pc86|1 year ago|reply
[+] [-] wg0|1 year ago|reply
[+] [-] recursivedoubts|1 year ago|reply
> Run the following command in a clean directory to create a new TypeSpec project.
> tsp init
> This will prompt you with a few questions. Pick the Generic REST API template...
I’d just like to interject for a moment. What you’re referring to as REST, is, in fact, JSON/RPC, or as I’ve recently taken to calling it, JSON plus RPC. JSON is not a hypermedia unto itself, but rather a simple data format made useful by out of band information often specified with tools such as your TypeSpec project or similar.
Many computer users work with a canonical version of REST every day, without realizing it. Through a peculiar turn of events, the version of REST which is widely used today is often called “The Web”, and many of its users are not aware that it is basically the REST-ful architecture, defined by Roy Fielding.
There really is a REST, and these people are using it, but it is just a part of The Web they use. REST is the network architecture: hypermedia encodes the state of resources for hypermedia clients. JSON is an essential part of Single Page Applications, but is useless by itself; it can only function in the context of a complete API specification. JSON is normally used in combination with SPA libraries: the whole system is basically RPC with JSON added, or JSON/RPC. All these so-called “REST-ful” APIs are really JSON plus RPC.
[+] [-] morbicer|1 year ago|reply
https://learningenglishwithoxford.com/2024/02/29/15-modern-e...
[+] [-] Alupis|1 year ago|reply
AsyncAPI support would make TypeSpec the end-all/be-all API spec tool for a lot of people.
TypeSpec looks amazing - but until we can go "all in" on using it for both our external and internal API, it's difficult for the team to justify yet another new DSL. It's needs to support all of our common API definition woes, and currently it only addresses 50%.
[+] [-] bananaquant|1 year ago|reply
According to https://typespec.io/docs/standard-library/built-in-data-type...:
* unixTimestamp32, but no 64-bit version
* plainDate that can be "April 10th" without the year
* DefaultKeyVisibility, OmitDefaults.. what?
I am genuinely curious how did that happen. Design by committee? Some secret use cases that leaked into specification?
[+] [-] meindnoch|1 year ago|reply
[+] [-] otabdeveloper4|1 year ago|reply
It's good enough and these bespoke solutions that add nothing but DSL syntactic sugar are dead on arrival.
[+] [-] agentultra|1 year ago|reply
It’s an evergreen project. I’ve seen various incarnations of this since the 90s.
[+] [-] whynotmaybe|1 year ago|reply
[+] [-] coreyh14444|1 year ago|reply
[+] [-] kingkongjaffa|1 year ago|reply
[+] [-] ActionHank|1 year ago|reply
[+] [-] Alupis|1 year ago|reply
You and your team spend time arguing/debating the API from the perspective of a user. "I need X data from Y service", etc. The document then becomes the "blueprint" for your system.
Think of it as TDD but viewed from a different angle. In a microservices system, this has a tremendous amount of advantages, including being able to codegen your handlers and models, maintain consistency across the entire API, unified api documentation, increase testability of your controller/handler interface, and more.
[+] [-] gjmveloso|1 year ago|reply
[1]: https://smithy.io/2.0/index.html
[+] [-] unshavedyak|1 year ago|reply
[+] [-] Alupis|1 year ago|reply
[+] [-] drewda|1 year ago|reply
Would be compelling to have a way to represent both OpenAPI and GraphQL in a common upstream schema...
[+] [-] bterlson|1 year ago|reply
[+] [-] ChrisArchitect|1 year ago|reply
Introducing TypeSpec: A New Language for API-Centric Development
https://typespec.io/blog/2024-04-25-introducing
(https://news.ycombinator.com/item?id=40206124)
[+] [-] henning|1 year ago|reply
- add it in the database model
- make a database migration for the field
- add it in the DTO for the API because we don't want to couple our persistence layer to our business logic or something
- add it to gRPC/Protobuf models so other services can call it
- add it to the new TypeSpec model thing
- update tests of all of the above
I love in tech 2024, it's full of people who talk about "DRY" who force you to repeat the same things over and over again, and this is "clean code", and if you don't like it, fuck you, you aren't a "culture fit". Utterly batshit insane.
[+] [-] outlore|1 year ago|reply
One qualification: the TypeSpec model should help generate your API DTOs (OpenAPI, Protobuf) etc. So hopefully that saves a step or two.
As an aside, I have tried doing a full stack TypeScript application where database types trickle down to the client, it ended poorly, since the API affordances can and should evolve separately from the database design. Therefore, I do feel that separation of database and API types is necessary.
[+] [-] miohtama|1 year ago|reply
[+] [-] activitypea|1 year ago|reply
[+] [-] unknown|1 year ago|reply
[deleted]
[+] [-] unknown|1 year ago|reply
[deleted]
[+] [-] andremedeiros|1 year ago|reply
[+] [-] codeflo|1 year ago|reply
Protobuf is old, and has some really strange warts that are only explainable historically (for example, by reference to the behavior of C++, which used to be Protobuf's primary target).
[+] [-] frankfrank13|1 year ago|reply
[+] [-] bterlson|1 year ago|reply
[+] [-] afavour|1 year ago|reply
[+] [-] davedx|1 year ago|reply
[+] [-] jjkaczor|1 year ago|reply
[+] [-] miohtama|1 year ago|reply
Any recommendations for Python backend integration?
[+] [-] unknown|1 year ago|reply
[deleted]
[+] [-] that70sshow|1 year ago|reply
[+] [-] mdaniel|1 year ago|reply
I despise "hidden" languages smuggled in string types. Both Microsoft <https://learn.microsoft.com/en-us/graph/filter-query-paramet...> and Google <https://google.aip.dev/160> are terrible about these embedded languages
Since Microsoft is one of the offenders, how about any novel type system try and model their own API and only when that's possible should they taut their superiority over the existing, proven standards