Hacker News new | ask | show | jobs
by tlrobinson 2821 days ago
What makes this language "declarative"? It looks pretty imperative to me.
5 comments

@OP/project creator: If your language allows the writer to define a program's control flow, more often than not it's imperative, and not declarative.
I'm not actually seeing much code controlling the flow of the program.
I mean, I can remove control flow constructs from an imperative language and call it declarative, but that wouldn't be very useful.

What is the advantage of it being declarative? At least for the example, the equivalent imperative code is about the same length.

I don't think there is much advantage in being declarative in this case because whenever I need to scrape stuff I have to do a lot of edge case handling and I want to be in control, but it does seem to be a recurring dream to make some sort of web query language (based on my memories of Old Dr. Dobbs issues)
The flow in the example is simple: click -> wait -> process result; but it's still there. Notice that instructions are executed in the order they are defined, that is enough to make it imperative.
yes but I think it could be made truly declarative with very little work. take out the waits, and maybe not carry around the doc all over the place - the context of the page being processed should be figured out by the interpreter.

on edit: although the web interfaces being what they are some things need to be order dependent - like INPUT(google, 'input[name="q"]', "ferret") CLICK(google, 'input[name="btnK"]'), I mean you need to click the button after you fill out the input.

Well, I would say it's more declarative than imperative. There are few differences that make it less declarative - variables and ternary operator.
came to say this. This isn't declarative!
Yeah I opened the page kind of hoping for something GraphQL. Scraping libs are cool but I have absolutely no idea why this is at the top of Hacker News. It's not declarative, it's unnecessarily a language instead of just a library, the only thing it has that HN would love is that it's written in Go and it's kind of an esoteric niche. Is that really all it takes?