Earlier quoted context omitted.
The pipe operator in R (really, tidyverse R, which might as well be its own language) is one of its "killer apps" for me. Working with data is so, so pleasant and easy. I remember a textbook that showed two ways of "coding" a cookie recipe: bake(divide(add(knead(mix(flour, water, sugar, butter)),eggs),12),450,12) versus mix(flour, water, sugar, butter) %>% knead() %>% add(eggs) %>% divide(12) %>% bake(temp=450, minut…
You'd never write that ugly one-liner. Just write the recipe imperatively: dough = mix(flour, water, sugar, butter) dough.knead() dough = dough.add(eggs) cookies = dough.divide(12) cookies = bake(temp=450, minutes=12) Might be more verbose, but definitely readable.
Left to Right Programming
321–330 of 372 posts
Re: Left to Right Programming
#322Re: Left to Right Programming
#323Earlier quoted context omitted.
This was a historical decision because SQL is a declarative language. I was confused for too long, I want to admit, about the SQL order: FROM/JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT As a self-taught developer, I didn't know what I was missing, but now the mechanics seem clear, and if somebody really needs to handle SELECT with given names, then he should probably use CTE: WITH src AS (SELECT * FR…
> This was a historical decision because SQL is a declarative language It would be equally declarative if FROM came first.
Re: Left to Right Programming
#324I guess I’m so old that I remember time without autocomplete. Where programmers just knew what functions existed and how to use them. Usually by looking them up in a manual and then -gasp- remembering them. Languages shouldn’t be optimized for laziness or not using your brain. “Shut up old man” yes yes okay.
Stair steps could be 450 mm high and work, but building codes make them 200 mm for a reason. And you are not "better" by saying that "I am fit enough to climb 450 mm steps, and you are all lazy for wanting stairs built to ergonomic standards".
Re: Left to Right Programming
#325Re: Left to Right Programming
#326Earlier quoted context omitted.
The order should be starting on FROM, followed by any sequences of whatever clauses (except for FROM), always creating an intermediary result-set. FROM table -- equivalent to today's select * from table SELECT a, 1 as b, c, d -- equivalent to select ... from table WHERE a in (1, 2, 3) -- the above with the where GROUP BY c -- the above with the group by WHERE sum(d) > 100 -- the above with having sum(d) > 100 SELECT…
My other big dream would be allowing multiple WHERE clauses that would be semantically ANDed together because that's what would happen if you filtered a result set twice.
Re: Left to Right Programming
#327Earlier quoted context omitted.
What section did you see this? I see GET (i.e. SELECT) first.
Section 3.3. "SELECT" only comes first if you omit "FROM". In SQL, if it allowed, that would be something like: `SELECT table.column`.
I don’t think I see what you see. From 3.3:
RANGE PART P
GET W (P.P#,P.PNAME,P.QOH):(P.QOHRe: Left to Right Programming
#328Earlier quoted context omitted.
The order should be starting on FROM, followed by any sequences of whatever clauses (except for FROM), always creating an intermediary result-set. FROM table -- equivalent to today's select * from table SELECT a, 1 as b, c, d -- equivalent to select ... from table WHERE a in (1, 2, 3) -- the above with the where GROUP BY c -- the above with the group by WHERE sum(d) > 100 -- the above with having sum(d) > 100 SELECT…
My other big dream would be allowing multiple WHERE clauses that would be semantically ANDed together because that's what would happen if you filtered a result set twice.
SQL has a conceptual issue with repeating group by clauses, so maybe not that one (or maybe we should fix the conceptual issues). But any other, including the limiting and offset ones.
Re: Left to Right Programming
#329Earlier quoted context omitted.
Section 3.3. "SELECT" only comes first if you omit "FROM". In SQL, if it allowed, that would be something like: `SELECT table.column`.
Tuple Variables and their Range? I don’t think I see what you see. From 3.3: RANGE PART P GET W (P.P#,P.PNAME,P.QOH):(P.QOH
SELECT p.pnum, p.pname, p.qoh FROM part p WHERE p.qoh
But a more direct translation would look something like: FROM part p SELECT p.pnum, p.pname, p.qoh WHERE p.qoh
Even closer would be: FROM part p; SELECT p.pnum, p.pname, p.qoh WHERE p.qoh
Of course they are different languages so we can only take things so far, but the pertinent bit is that the range specifier is declared first in ALPHA, whereas it is declared later, after the projection is defined, in SQL.Re: Left to Right Programming
#330Earlier quoted context omitted.
> JavaScript has been a backend language long before the web was the dominant platform. I don't think this holds. JavaScript was created as a frontend language specifically for web browsers. It wasn't until 2009 with the introduction of Node.js that JavaScript became a viable option for backend development. The web was already the dominant platform by then.
> It wasn't until 2009 with the introduction of Node.js that JavaScript became a viable option for backend development. JavaScript was used for backend development since the late 1990s via the Rhino engine (the backends wouldn't be pure JS generally but a mix of JS and Java; Rhino was a JS engine for the JVM with Java interop as a key feature.)