Relevant to today’s WC discussions: The most powerful parts of the web platform are the things that can be done declaratively for common use cases, and augmented imperatively for special cases.
I like the robustness that comes with declarative languages. I also like the power that comes with imperative languages. Best of all, I like having the choice.
audio elements, for example. If you want, you can embed a video or audio file into a web page using a straightforward declaration in HTML.
<audio src="..." controls><!-- fallback goes here --></audio>
Client-side form validation is another good example. For most us, the HTML attributes—
type, etc.—are probably enough most of the time.
<input type="email" required />
<input type="geolocation" />
(And just in case you’re thinking of the fallback—which would be for the
input element to be rendered as though its
type value were
text—and you think it’s ludicrous to expect users with non-supporting browsers to enter latitude and longitude coordinates by hand, I direct your attention to
input type="color": in non-supporting browsers, it’s rendered as
input type="text" and users are expected to enter colour values by hand.)
Anyway, that’s just one example. Like I said, it’s not that I’m in favour of declarative solutions instead of imperative ones; I strongly favour the choice offered by providing declarative solutions as well as imperative ones.
cache APIs, for example. But I think we should be careful that it doesn’t become the only way of exposing new browser features. I think that, wherever possible, the design pattern of exposing new features declaratively and imperatively offers the best of the both worlds—ease of use for the simple use cases, and power for the more complex use cases.
“Adactio: Journal—Declaration” Jeremy Keith shares my fondness of the declarative aspects of web dev. adactio.com/journal/14401
La solidité d’une programmation déclarative + la puissance d’une programmation impérative. J’adhère au point de vue adactio.com/journal/14401
> the design pattern of exposing new features declaratively and imperatively offers the best of the both worlds—ease of use for simple use cases, and power for more complex use cases.adactio.com/journal/14401 e.g. <audio controls> is useful alone, but has APIs if you need them.
Relevant to today’s WC discussions: The most powerful parts of the web platform are the things that can be done declaratively for common use cases, and augmented imperatively for special cases.adactio.com/journal/14401