I think this is a great initiative! Prioritizing tooling, languages and frameworks that developers are already familiar with is almost always a good thing in my opinion. The cases where I don’t think it’s a good thing are when we limit progress by pigeonholing ourselves into existing patterns or technologies.
It has already been mentioned, but Candid’s support for subtyping helps move us towards a future where open internet services can safely rely on each other without fear of the interface breaking. There are standards and best practices in web2 to avoid breaking changes in APIs, but they exist at a project level, not at a technology level and so they can differ greatly from project to project. Candid takes this concept and introduces it on a technology level, which is progress that I personally think we should find ways to leverage in developer friendly ways, rather than abandon entirely.
I’m a little skeptical about supporting window.fetch
. Achieving this for all possible scenarios with HTTP certification puts an insane amount of work on the HTTP Gateway. The HTTP Gateway is useful for allowing HTTP clients (like a web browser) to talk to the Internet Computer and we have HTTP Certification to facilitate this in a secure and performant way. As already mentioned though, it’s extremely limiting. It works great for static content, but shows it’s limitations as soon as you start adding dynamic content.
A simple GET endpoint returning a list of items that can be filtered, sorted and paginated very quickly generates an infinite number of combinations to certify. Then if you add authentication (the endpoint returns a different list of items depending on who the caller is) the HTTP Gateway also needs to be aware of the authentication mechanism in order to verify this effectively. There is always the option of using the “upgrade to update” feature to handle these cases.
In the future there will be an “upgrade to certified query” feature that would also not require explicit canister-side certification. I don’t know where this sits on the roadmap and I’m also not sure of it’s performance characteristics. We can safely assume it sits somewhere between a normal query call and an update call, but it’s unclear how big the difference will be from a normal query call. So I can imagine some kind of canister framework that would try to certify static data to a point, upgrade to certified queries for dynamic data and then upgrade to update calls for cases where canister state mutation is needed, but I struggle to imagine this framework making all of those decisions automatically. I think developers will still need to learn when to use which flavor of call.
A side note on the authentication mechanism. Secure enclaves will not help with privacy or security here if we’re pursuring window.fetch
support because SSL is terminated on the HTTP Gateway and the gateways can then see the entire response. It’s also possible to add support for secure enclaves in the HTTP Gateways, but I’m personally not a fan of this idea because I really like the idea of having serverless HTTP Gateways running for example on Cloudflare or Fastly and leveraging the same huge CDN infrastructure that web2 gets to take advantage of. Secure enclaves would limit us to only using hardware that supports it.
So even if we don’t follow the idea of supporting window.fetch
, there may still be some value in using JSON as Candid. If a canister only implements the http_request
and http_request_update
endpoints, then you can interact with it using a JS client without needing to generate Candid typings. I put together one such JS client as an experiement here. This does lose the benefits of Candid, but simplifies the developer onboarding experience.
You can then combine this with client side certification, for example with this other (also slightly experimental) lib. This allows certification to remain flexible by allowing applications to define their own mechanisms, rather than trying to make a one-size-fits-all solution on the HTTP Gateway. That of course increases complexity again, but there is always the “upgrade to update” and “upgrade to certified query” options I mentioned above, which can be done locally the same way they are done on the HTTP Gateway.