4 ms·
Honest question, why jsx over html/js and why particularly Typescript?
by vagrantJin 6y ago
Honest question, why jsx over html/js and why particularly Typescript?
- madeofpalk 6y agoWhy not Typescript? Using a typed languge is such a productivity boon.
- vagrantJin 6y agoThis a is an answer thats made for those "why you should use Typescript in 2021" medium articles that pop up on my feed ad nauseum. The word productive on its own is wholly meaningless without elaboration. What makes a typed language productive? Does the size of the project matter?, why is vanilla js not productive? Is it a lines of code metric? Is it a test suite efficiency metric? Is it a quality metric?
- Oddskar 6y agoProviding a thorough answer to your question would require a lengthy article. It's a bit much of an ask to have someone do this for you on HN. But very briefly I would say that these are the benefits as I see it: * Access to improved tooling. E.g. refactoring by renaming things is much easier to do without breaking things. Also auto-complete when using third party libraries is a huge benefit. * Some errors are automatically caught during build-time. E.g. checking the data used in a template lines up with what the component should be passing to that template. Without typescript one should probably verify this via unit tests. With TS these tests are superfluous. * Improved documentation. It's a lot easier to understand what the shapes are of data is that is being passed around in the application. It also provides the opportunity to define these in central locations (e.g. in the form of interfaces) which can then have additional documentation added to them. I think the benefits are not so much specific to TS as they are general benefits of using types and a typed ecosystem.
- SCLeo 6y agoI have not used Skruv, but from my experience with vanilla js (document.createElement('div')), hyperscript (h('div')), and jsx (<div/>), jsx is hoesntly much easier to write and to read.