Programming thread

  • 🇵🇦 Nuestro primer dominio localizado está en español en kiwifarms.pa. Our first localized domain is on Spanish on kiwifarms.pa.
  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
It's all fun and games until somebody has a different delimiter than a comma like those shitheads in europe.
There's also the big question about how you quote the delimiter, with one school saying you enclose the entire field in doublequotes (God help you if the field also contains a literal doublequote, because you now have the issue of whether to allow Pascal-style quoting or C-style quoting or maybe both), another school saying you enclose the entire field in singlequotes, another school saying doublequotes and singlequotes are both good as long as the opening and closing delimiters match, and the other school saying you escape it with a backslash.

The best way is to probably just use the old /etc/passwd format, where fields are separated by colons (or whatever you like), and literal separators or backslashes are quoted by preceding them with a backslash, since that's at least simple and consistent.
 
There's also the big question about how you quote the delimiter, with one school saying you enclose the entire field in doublequotes (God help you if the field also contains a literal doublequote, because you now have the issue of whether to allow Pascal-style quoting or C-style quoting or maybe both), another school saying you enclose the entire field in singlequotes, another school saying doublequotes and singlequotes are both good as long as the opening and closing delimiters match, and the other school saying you escape it with a backslash.
I'm personally fond of how APL does it, a less common style:
Kod:
  'test''ing'
test'ing
  'look at that '''
look at that '
  ''''
'
I prefer to think about it as the concatenation of two strings joined by the delimiter. This is one subtle way in which APL is even nicer than Common Lisp, as it avoids the reverse solidus for escaping, such an arbitrary character to use for this. It's a shame this style is so rare.
 
i think we should use proper american quotation marks instead
Podobny do C:
const char* str = “some string with “inner” quotes”;
 
> be me
> writing script
> need to check flags for program
> be lazy
>
:r! head --help

Kod:
  ^[]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#head-c^[\^[[1m-c, --bytes=[-]NUM^[[0m^[]8;;^[\

What the fuck, Stallman?
If you were a Real Programmer™, you'd recognize ANSI escape codes at a glance. Actual ANSI standards cost $$$, but fortunately they were also adopted as an ECMA standard so you can get it for free. Those of us who have been around since at least the glory days of Gopher will also remember this cheat sheet from the infamous Wiretap Online Library, which also contained non-standard codes specific to the DEC VT100.

edit:
The best way is to probably just use the old /etc/passwd format, where fields are separated by colons (or whatever you like), and literal separators or backslashes are quoted by preceding them with a backslash, since that's at least simple and consistent.
I actually just remembered that ASCII defines special codes for this sort of thing that never get used anywhere outside of MARC records:
'\x1F' US (unit separator) - used to separate fields within a record
'\x1E' RS (record separator) - used to separate records
'\x1D' GS (group separator) - used to separate groups of related records within a file ("file" in the database sense)
'\x1C' FS (file separator) - used to separate files (in the database sense) within a file (in the disk structure sense)
 
Ostatnio edytowane:
sentinel separation is big gay and I wonder if we have opcodes for run length in x64 and RISC yet
Sentinel values are best avoided, but occasionally there are cool ways to handle it. As an example, I've given consideration to the problem where one needs to chain values together, think integers to integers, where the problem space is small enough for a table approach to work. The obvious solution is to use indices into this table for the links, and to chain values in whatever order for this. Now, the main issue here is each integer would be a valid value, so how should lists be terminated? If every list is made circular, then there's no need. Values in their own lists would use their own indices as the link. That's fun.
 
If you were a Real Programmer™, you'd recognize ANSI escape codes at a glance.
Escuse me.

$ ls -al > tmp.txt

ls knows when it's not connected to a terminal and doesn't shit out any ^[[1;34m garbage. Any command line utility worth using has a --color option (which defaults to "never" to avoid shitting up the place with escape sequences). ls even has a --hyperlink equivalent.

(extra fucked because bold, apparently my font size is too small)
2026-07-03-024332_242x39_scrot.png

I swear this is a new thing, I've grep'd help before, and piped into less, and I don't remeber ever having this trouble.


My terminal doesn't even seem to support OSC 8 hyperlinks; I've tried every combination of modifier key and mouse button. I assume that the escape sequences are still being output to the terminal (the bold is) and just being ignored, but how could I know?

(thanks google)
2026-07-03-011150_649x444_scrot.png

I've heard that Google is intentionally making the regular search shit in order to push people towards their AI, so I thought I'd give it a go. It does indeed say that urxvt does not support osc 8, however, their citations for this are an article giving an overview of xterm (notably, _not_ the article from the very same site giving an overview of urxvt...), the iTerm2 documentation, a github issue for ghostty, and the hterm.js source code.
2026-07-03-014310_694x343_scrot.png
2026-07-03-014343_688x437_scrot.png

Along with a couple of useless suggestions:
2026-07-03-014601_655x131_scrot.png
2026-07-03-014856_652x361_scrot.png

And the worst part of all; The AI didn't even mention that Alacritty is written in Rust! 🔥🚀
 
Any command line utility worth using has a --color option (which defaults to "never" to avoid shitting up the place with escape sequences).
I was going to reference that one venture to have a NO_COLOR environment variable become a pseudo-standard more thoroughly, but its website is down. :story:
I hate this trend to have a fucking website for everything, with its own domain name and all. This evidence alone makes my point.

Now, this reminds me of something funny I once read in the Suckless mailing list:
Bogaty (BBCode):
This is because color is not part of Posix, but a GNUism. For column
views, use the cols(1) utility that is shipped with sbase. There is no
reason to implement that in each single utility. Just invoke

        ls | cols

as you already found out yourself. The Unix philosophy states that you
should have one tool that does one thing and does it well; in this case
this is cols(1) whose only job is to columnize output. ls(1) is complex
enough already, so we really don't want to worry about columnizing
output as well.

> I have never had ls without color or column included (i'm spoiled) and
> google isn't being overly helpful at the moment. I found the cols
> command and ls | cols solved that so i can just create an alias, what
> about getting color? Is there a suckless solution?

The suckless solution is just not to use color at all. It takes a while
to get used to, but it's really not necessary. It's like syntax
highlighting.
This isn't exactly the message I'm remembering, but the gist is that the ECMA-48 colour control sequences must be handled by any program that gets them. The Suckless fuckwits are UNIX cultists, so they don't have programs columnate their output, that duty is given to the cols program. Well, now cols has to understand the control sequences or it won't fulfill its duty properly, because it will read the control sequences as part of the visible data and calculate lengths accordingly.

The Suckless answer to this little hole in their philosophy is to declare colours bloat and move on, unawares of anything that interferes with their worldview like any proper cult. :story:

I'm reminded of one last little thing: I was once auditing someone's Common Lisp code, and the guy had written a C language binding for isatty(). Common Lisp of course has a facility that accomplishes this already, INTERACTIVE-STREAM-P, but the guy didn't really know Common Lisp so he didn't use it. :bossmanjack:
 
All characters should be 24 bits, with the lower 21 bits specifying a Unicode character and the upper 3 bits being display flags for boldface, reverse video, and Netscape-style <blink>ing. This will satisfy people who want at least some amount of syntax highlighting, people who want to be able to trivially strip out syntax highlighting, people with monochrome monitors, and the color-blind, but will not satisfy the epileptic, just as God intended.
 
All characters should be 24 bits, with the lower 21 bits specifying a Unicode character and the upper 3 bits being display flags for boldface, reverse video, and Netscape-style <blink>ing. This will satisfy people who want at least some amount of syntax highlighting, people who want to be able to trivially strip out syntax highlighting, people with monochrome monitors, and the color-blind, but will not satisfy the epileptic, just as God intended.
Thank god that this would never happen.

Might as well use some more bits to encode some more useful info in the text. Like, what OS the user was using while typing his shitty code. What is the user's preferred color scheme. Maybe even his favourite color. I mean, we have space for that don't we?

I myself would like to encode the png image of my parents into each character that I type, because I love and respect them that much.

And we shouldn't stop at pngs. We can encode mp3 if we want. Imagine how cool it would be to see the "Jesu, Joy Of Man's Desiring" in the encoding of each letter. You would effectively praise the Lord with every keystroke - that's profound.
 
Ostatnio edytowane:
Wstecz
Top Na dole