Live data from Hacker News

Left to Right Programming

graic.net

291–300 of 372 posts

Re: Left to Right Programming

#291
the same is my beef with typescript's imports:

import { MyClass } from './lib.ts'

First you need to type what to import and then from where leaving. There is no linear way of discovering import options from the source of imports without extra jumping in the code.

Alternatively linear completion, or (TIL https://en.wikipedia.org/wiki/Progressive_disclosure) would be possible for imports of shape like:

from './lib.ts' import { MyClass }

If course authors of the import syntax had good reasons (which I don't know) to build stuff that way they've built it.

Re: Left to Right Programming

#292

Earlier quoted context omitted.

How did you know it was zip_code and not ZipCode? Maybe in this case you know the same naming conventions are enforced across all tables. But in general it’s difficult to know the exact column name without looking it up first.

> How did you know it was zip_code and not ZipCode? I think you're missing the point; you start off with your goal, regardless of the column name. No one has the goal "we want columsn from this specific table", it's always "we want these columns in the final output".

Right, but which columns? The goal absolutely IS to select columns from a table. ie. my goal is not to select created_at, my goal is to select Foo's created_at.

Re: Left to Right Programming

#293
post #199

This is almost FP vs OOP religious war in disguise. Similar to vim-vs-emacs ... where op comes first in vim but selection comes first in emacs. If you design something to "read like English", you'll likely get verb-first structure - as embodied in Lisp/Scheme. Other languages like German, Tamil use verbs at the end, which aligns well with OOP-like "noun first" syntax. (It is "water drink" word for word in Tamil but "…

> Other languages like German, Tamil use verbs at the end

Doesn't German have the main verb on the second position? (For a simple example, "I drink water" would be "Ich trinke Wasser")

Re: Left to Right Programming

#294
ReScript changed their api from data-last to data-first for this reason. Coupled with amazing type inference you will almost always receive correct autocompletions (that are type valid as well). It is a great experience.

It is sometimes still a problem when you define a function without reference to it (because the types are unnkown ofcourse). You will have to add types to it or call the function before implementing it.

There was also a great blogpost about it: https://www.javierchavarri.com/data-first-and-data-last-a-co...

Re: Left to Right Programming

#295
post #261

Earlier quoted context omitted.

"Reasons, sure, but whether those reasons correlate with things that matter is a different question altogether." Thus my word "suggests". Thus the comprehensive pro/con list. I'm not here to defend tiresome strawmen.

It's not so much a matter of exhaustively listing pros and cons, but more a matter of appropriateness to the desired goal or goals IME. I seriously doubt that a comprehensive pro/con list can even be coherent. Is dynamic typing a pro or a con? Depends on to whom and even in what decade you ask. List comprehensions? Interpreted language? First class OOP? Any cost-benefit anaylsis will be highly context-dependent. > I'…

I don't have anything useful to add per se but I'd like to thank you for validating my intuition that pros and cons lists not only don't generalize as to be useful universally but also that the more "rigorous" you get with it the whole things evolves into an exercise of ridiculousness.

An example I like to give is the wood chipper. Pros it can do a lot of useful things around the yard (that you can list individually), cons it can chop your arm off. How many pros do you need to overcome that con? Though I'll admit there's a difference between "can" and "will", the latter hinging on improper use.

tl;dr I'm a bit tired with people glorifying a semi-useful cognitive device.

Re: Left to Right Programming

#296

Earlier quoted context omitted.

> How did you know it was zip_code and not ZipCode? I think you're missing the point; you start off with your goal, regardless of the column name. No one has the goal "we want columsn from this specific table", it's always "we want these columns in the final output".

Right, but which columns? The goal absolutely IS to select columns from a table. ie. my goal is not to select created_at, my goal is to select Foo's created_at.

> The goal absolutely IS to select columns from a table.

No. The goal is to have an output column $FOO, where $FOO is meaningful and might not even be in the database in the first place.

> my goal is not to select created_at, my goal is to select Foo's created_at.

Then your goal is to get a value out of a specific table, namely `Foo`, presumably because the end-user wants to see some value in the results.

The end-user getting the value has neither an interest in nor knowledge of your schema. `Foo.created_at` is no more meaningful in the result sets than an unadorned `created_at`.

For this specific example, the end-user might want a column in the output called `age` (if it came from an inventory table`, or `duration` (if it came from a metrics tables), or perhaps `expiry` (if it is a table containing perishable stock). These are all a column in a Foo table, but the request that caused you to write the query in the first place does not mention table at all.

You get their requirement as either `age`, `duration`, `expiry` or similar. That is what you are starting from: "a need for a specific piece of data". You are not starting from "a need from a specific table", because the information needed is coming from someone who neither knows nor cares what your schema looks like.

Re: Left to Right Programming

#298

Earlier quoted context omitted.

PSQL (and PRQL) use this ordering, and a similar pipe/arrow notation has recently been added to BigQuery. Check out the DuckDB community extensions: [0]: https://duckdb.org/community_extensions/extensions/psql.html [1]: https://duckdb.org/community_extensions/extensions/prql.html

In duckdb you can also start with `FROM .. SELECT ..` without using the PSQL extension. But I haven't found a good editor plugin that is actually able to use that information to do completions :/ If anyone knows I'd be happy to hear it

The duckdb local ui does that I believe:

duckdb -ui

More here: https://duckdb.org/2025/03/12/duckdb-ui.html

Re: Left to Right Programming

#299
post #78

Earlier quoted context omitted.

I don't know if result = (df .pipe(fun1, arg1=1) .pipe(fun2, arg2=2) ) is much less readable than result fun1(., arg1=1) |> fun2(., arg2=2) but I guess the R thing also works beyond dataframes which is pretty cool

The pipe operator uses what comes before as the first argument of the function. This means in R it would be: result fun1(arg1=1) |> fun2(arg2=2) Python doesn't have a pipe operator, but if it did it would have similar syntax: result = df |> fun1(arg1=1) |> fun2(arg2=2) In existing Python, this might look something like: result = pipe(df, [ (fun1, 1), (fun2, 2) ]) (Implementing `pipe` would be fun, but I'll leave it a…

I find this (hypothetical) syntax *very* elegant.

    result = df
      |> fun1(arg1=1)
      |> fun2(arg2=2)

Re: Left to Right Programming

#300
post #273

Earlier quoted context omitted.

Alternatively, with namespace imports in JS you can write [1]: import * as someLibrary from "some-library" someLibrary.someFunction() Which works pretty well with IDE autocomplete in my experience. [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

This is a non starter for anything you want to publish online, as it breaks tree shaking which will cause size bloat and therefore slow loading.

I don't think this is true. The example from the esbuild docs uses `import * as lib from './lib.js'` in an example for tree shaking.

https://esbuild.github.io/api/#tree-shaking

Although there are associated issues but they may be specific to esbuild.

https://github.com/evanw/esbuild/issues/1420

Post reply on HN