When comparing Haste vs Web Components, the Slant community recommends Haste for most people. In the question“What are the best solutions to "The JavaScript Problem"?” Haste is ranked 3rd while Web Components is ranked 29th. The most important reason people chose Haste is:
Haste was designed to allow both the client and server to be written as parts of the same, type-safe application. This is in stark contrast to most other options, where the client and server are considered two separate entities, resulting in extra manual validation code and more chances for type errors.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Client and Server as the same application
Haste was designed to allow both the client and server to be written as parts of the same, type-safe application. This is in stark contrast to most other options, where the client and server are considered two separate entities, resulting in extra manual validation code and more chances for type errors.
![Anton Ekblad](https://lh5.googleusercontent.com/-3kxnBFS2LzY/AAAAAAAAAAI/AAAAAAAADHQ/QEZEyB0LLYs/photo.jpg?sz=50)
Pro Almost full power of Haskell
Haste supports the Haskell 2010 standard except for Template Haskell as well as most GHC extensions.
![Anton Ekblad](https://lh5.googleusercontent.com/-3kxnBFS2LzY/AAAAAAAAAAI/AAAAAAAADHQ/QEZEyB0LLYs/photo.jpg?sz=50)
Pro Automatic, type safe program slicing
Haste lets you write client and server as a single program, automatically generating code for the server as well as the client, giving you full type safety even across the Internet.
Pro Generates small, reasonably performant code
![Steven Vachon](https://lh3.googleusercontent.com/-wus8nWbN4ZU/AAAAAAAAAAI/AAAAAAAAAWI/IUlXPjBFhj0/photo.jpg?sz=50)
Pro Great for small—likely published—reusable libraries
Very extendable as a single-import base layer for visual controls and probably also something like a react-redux Provider.
![Steven Vachon](https://lh3.googleusercontent.com/-wus8nWbN4ZU/AAAAAAAAAAI/AAAAAAAAAWI/IUlXPjBFhj0/photo.jpg?sz=50)
Pro Works with any framework
Less recreation of the wheel and fewer wrappers.
![Steven Vachon](https://lh3.googleusercontent.com/-wus8nWbN4ZU/AAAAAAAAAAI/AAAAAAAAAWI/IUlXPjBFhj0/photo.jpg?sz=50)
Pro Fallback styling when not yet defined
Before a component's script defines the custom element—either as the page is loading or with JavaScript disabled—it can be temporarily styled via :not(:defined)
. This may prevent the need for SSR.
![Steven Vachon](https://lh3.googleusercontent.com/-wus8nWbN4ZU/AAAAAAAAAAI/AAAAAAAAAWI/IUlXPjBFhj0/photo.jpg?sz=50)
Pro Customizable templates via custom-recognized "slots"
slot="name"
and <slot name="name">
for customizing a component's HTML in specific areas of its shadow DOM. Also fallbacks when not defined.
![Steven Vachon](https://lh3.googleusercontent.com/-wus8nWbN4ZU/AAAAAAAAAAI/AAAAAAAAAWI/IUlXPjBFhj0/photo.jpg?sz=50)
Pro Stylable via custom-exposed "parts"
::part(name)
pseudo-element for styling elements within a component's shadow DOM.
Cons
Con Lacks some minor Haskell functionality
Lacks support for Template Haskell.
![Steven Vachon](https://lh3.googleusercontent.com/-wus8nWbN4ZU/AAAAAAAAAAI/AAAAAAAAAWI/IUlXPjBFhj0/photo.jpg?sz=50)
Con Not well-suited for application wiring
Having to serialize/deserialize data between components is not convenient. You'll probably still need a [light/simple] framework. Some things are still quite nice, such as using the light DOM -- think <option>
with <select>
and <datalist>
.
![Steven Vachon](https://lh3.googleusercontent.com/-wus8nWbN4ZU/AAAAAAAAAAI/AAAAAAAAAWI/IUlXPjBFhj0/photo.jpg?sz=50)
Con SSR is potentially more difficult
…if you need more than CSS' :not(:defined)
, that is.
Check out this video to see how the creator of SkateJS handled it: https://www.youtube.com/watch?v=yT-EsESAmgA
![Vetted.ai illustration](/images/ai/vetted-illustration.png)