|
|
|
|
|
by dmitriid
2526 days ago
|
|
My personal opinion is that tagged template literals are the worst addition to Javascript [1] As HN user stevebmark said [2]: --- start quote --- …we’ve learned not to write code in strings. You’d think this would be a fundamental law of software engineering … Writing code, not strings, means you can do everything to it that you can do to code. You can type check code. You can lint it. You can optimize it, compile it, validate it, syntax highlight it, format it with tools like Prettier, tree shake it… --- end quote --- [1] https://dmitriid.com/blog/2019/03/tagged-template-literals/ [2] https://news.ycombinator.com/item?id=18511943 |
|
Agreed, but not for the reasons you quoted.
It should be a law of software engineering because when you're writing code, you aren't writing strings, you're writing a serialized and prettified form of a tree. So when you have two pieces of code you want to join together, you should join trees, not strings.
Breaking this law is precisely why things like SQL Injection even exist in the first place.