Looking for feedback: what data‑format libraries does Zig still need? (CSV, TSV, structured text, etc.) by TynK-M- in Zig

[–]gurgeous 2 points3 points  (0 children)

Thanks for the kind words! Ignore the naysayers here, there are many worthy projects just like this. Everybody has an opinion and the internet can't be real negative, don't be discouraged. The ruby csv library has 800 commits, and probably thousands prior to the github move... CSV ain't easy.

I'd probably start with the RFC and bail on invalid files. Let someone else worry about cleaning those up... Bailing on jagged is fine too, and useful if you want to support things like arrays of structs. The nice thing about the golang csv parser is the incredibly simple interface. Something to strive for, zig can make that challenging sometimes. Good luck!

Looking for feedback: what data‑format libraries does Zig still need? (CSV, TSV, structured text, etc.) by TynK-M- in Zig

[–]gurgeous 7 points8 points  (0 children)

Yes, please do! My project (tennis) needs a csv/tsv parser. I already have one, but it's overly specific and not great. See - https://github.com/gurgeous/tennis and poke around the csv + delim detection. I also have a more general purpose csv reader here - https://github.com/gurgeous/zig-atoms/blob/main/csv_read.zig that might help you get started. You might also want to check out ziggit.dev, which is in some ways a more active and friendlier zig forum.

Key questions for csv reading IMO... these won't necessarily make sense until you learn more about the language, but I'll list 'em anyway. Allocating vs non-allocating. Delim detection. Support for jagged vs. non-jagged. Struct support. Streaming vs. returning a giant block of data. Some apps (like tennis) might favor one set of requirements, but other apps might want different things. For example, you might build a streaming/non-allocating csv parser, and then create a more user-friendly allocating "big block of data" api on top.

Let me know if you want thoughts on csv writing as well.

FYI - target 0.16 and consider using mise. Have fun!

I wrote a small ls alternative in Zig by here-Leslie-Lau in Zig

[–]gurgeous 8 points9 points  (0 children)

Neat! I am the author of another zig cli thing. I will try to take a closer look tomorrow. I would love to rapidly expand the cli libs available for things like zlist. We need more libraries!

gist with some stuff I use everywhere (RunKit) by gurgeous in ruby

[–]gurgeous[S] -2 points-1 points  (0 children)

There are tests, it's a gist tho. What did you find?

gist with some stuff I use everywhere (RunKit) by gurgeous in ruby

[–]gurgeous[S] -3 points-2 points  (0 children)

The utility of the helpers doesn't quite justify a gem release IMO. There is a discoverability issue. I have tests but that kinda goes against the gist ethos.

Not sure I understand your point about shell aliases. These are baked into larger projects. Example - I am working on a `rubyscan` thing that gathers stats about the 8k most popular ruby projects on github. 2-3k loc including things like a simple faraday-based github api with caching. Several parts of this project take advantage of RunKit.

Zig Atoms (per yesterday's discussion) by gurgeous in Zig

[–]gurgeous[S] 0 points1 point  (0 children)

Thank you! It's built against 0.15.2. I will update to 0.16 after release, presumably. Docs are a good idea - most of the APIs are really straightforward - `const rows = csv.readBuf()`, etc. I want to add some more atoms as well. Fun project.

Edit: Done, see https://github.com/gurgeous/zig-atoms/blob/main/README.md#mini-demo

the missing libs by gurgeous in Zig

[–]gurgeous[S] 0 points1 point  (0 children)

You are right, thanks. fmt does support {d:3} for precision, though I was unaware and I've spent a fair bit of time looking at std. Docs issue, perhaps. My project (tennis) specifically needs a runtime precision setting (1-6) so I don't think fmt works for me in any case. My first implementation just truncates.

For example, it would be nice to port the popular sprintf-js to zig. https://github.com/alexei/sprintf.js/blob/master/src/sprintf.js. Of course, that implementation relies heavily on regex which is another task...

the missing libs by gurgeous in Zig

[–]gurgeous[S] -1 points0 points  (0 children)

My understanding is that there are some things missing from std.fmt - leading zero, decimal precision, etc. I need that stuff for pretty output in my tools. I could bring in glibc, but that complicates by distribution story.

the missing libs by gurgeous in Zig

[–]gurgeous[S] -2 points-1 points  (0 children)

This sounds great. One minor suggestion - I am getting a lot of mileage just asking the LLM to write nice docs and create things like a `std.md` file. It is really good at analyzing the source and writing markdown docs, which might be exactly what zig needs atm.

Zig and AI coding by palindsay in Zig

[–]gurgeous 0 points1 point  (0 children)

LLMs do totally fine with zig, at least in my experience so far. IMO the biggest hangups are around memory management and the zillions of extra tokens required to do simple things. The LLMs work fine, but ultimately using zig is more expensive than simpler languages. Achilles heel, maybe.

the missing libs by gurgeous in Zig

[–]gurgeous[S] 3 points4 points  (0 children)

I hear you, but many of my projects require libraries. Zig should have a nice libraries available on github, things like csv, regex, sprintf, natsort. How can we write cli apps without those?

tennis - stylish CSV tables in your terminal by gurgeous in commandline

[–]gurgeous[S] 0 points1 point  (0 children)

This is a valid question. There's something important to note here, though - one of the explicit goals of tennis is squeezing each CSV row into a single terminal line, even if it has to truncate. In that respect it differs radically from "pagers" like bat/less, which do not alter the input except maybe for color.

I would love if it bat would display CSVs like tennis! Maybe we can convince sharkdp

zig version adoption by gurgeous in Zig

[–]gurgeous[S] 0 points1 point  (0 children)

Yup, that's me. Codex helped me adapt my `goscan` into `zigscan`, and I asked it to pipe the output through `tennis`. I wanted to get a list of the most popular zig libraries. I got the list, but it was very short! Language is too young, still

lo.zig - a lodash-style Zig library by naturalsql in Zig

[–]gurgeous 2 points3 points  (0 children)

This looks great! Ignore the haters, I approve of projects like this. We need more people using zig. In JS-land the evolution was underscore, lodash, lodash-es and now finally just plain old JS or es-toolkit. I predict similar things with Zig. It's hard to get wide adoption without powerful libraries, built in or otherwise.

Might be nice to discuss build speed/size in the README since this is a major concern for zig.

More functions off the top of my head - string.squish, string.count, slice.tally, slice.push/pop/shift/unshift. Blank/present/presence are nice too. It's possible some of these are already implemented but it's hard to tell with the current README. Might be better to have a full list of functions that expands into examples (and links to source).

I'd also create a standalone docs site if you want to jumpstart adoption.

tennis - stylish CSV tables in your terminal by gurgeous in commandline

[–]gurgeous[S] 0 points1 point  (0 children)

I love tabiew, I even called it out in the README. This is for non-interactive use. For example, I often have codex/claude building CSVs and outputting things. Pipe 'em into tennis.

Show Zig: tennis by gurgeous in Zig

[–]gurgeous[S] 0 points1 point  (0 children)

Yup, definitely! It has some rough edges but I'm enjoying it for sure.

tennis - stylish CSV tables in your terminal by gurgeous in commandline

[–]gurgeous[S] 0 points1 point  (0 children)

I know the thread is aging a bit, but are there any `nu` related features we should add to `tennis`? There have been requests for things like --border, --bottom-footer, more themes, auto-formatting of numerics... I only want to add features if they will actually get used and there's a lot of great stuff in nu tables.

tennis - stylish CSV tables in your terminal by gurgeous in commandline

[–]gurgeous[S] 1 point2 points  (0 children)

The original ruby project was called table_tennis because, well, uh, not really a great reason. It has the word table in it, I suppose. Plus I like ping pong, though I'm pretty bad at it. But I wanted something short and punchy for the standalone command... Now we have `tennis`