Stringz - tiny implementation of strings in Zig

I spent an hour or two hacking on this today. It’s a teeny strings clone written in less than a hundred lines of Zig. When compiled in ReleaseSmall mode on Void, the binary comes out at 22.6 KB, while GNU strings on my machine is 38.7 KB. This version isn’t as fully-featured, yet, but it was super fun to write.

I want to eventually make it support Unicode, but couldn’t figure out how to wrangle std.unicode into submission.

7 Likes

I searched for “teeny strings” and got adverts for “Teen string bikinis”. I’m not going further down that rabbit hole, so could you give a bit more context. I was expecting a small string library, but it appears to be a CLI tool, so I’m lost.

3 Likes

strings is a cli that prints all ascii strings in a file. It can do things like finding constants embedded in a binary.

From man strings

DESCRIPTION
For each file given, GNU strings prints the printable character sequences that are at least 4 characters long (or the number given with the
options below) and are followed by an unprintable character.

  Depending upon how the strings program was configured it will default to either displaying all the printable sequences that it can find in each
  file, or only those sequences that are in loadable, initialized data sections.  If the file type is unrecognizable, or if strings is reading
  from stdin then it will always display all of the printable sequences that it can find.

  strings is mainly useful for determining the contents of non-text files.
6 Likes

Whoever named that binary wasn’t feeling at their most creative that day

5 Likes

I don’t see anything wrong with the name. It gets "strings out of a binary, after all.

3 Likes

Let me say it like this: it’s like naming a file explorer “File Explorer”.

Sure, you know just from the name what it is, but that doesn’t mean that it’s a good name for a particular piece of software. It’s a software category. Nobody names a car “Car” either.

1 Like

Plenty of software is guilty of this, see also Voice Recorder, calculator, calendar, messages, contacts, etc. Personally speaking, I’ll take a boring name over something poetic that I need a readme to remember what it does, but I also have fun coming up with cute names for software sometimes so I get both sides :smiley:

2 Likes

Car is a generic category, like Unix tools is a category. strings is a program in the Unix tools category. The name is decently detailed and discoverable. You want it to do what it says on the tin.
I’d rather have a boring name, especially for default utilities. For alternatives or specialized program, a unique name can be useful.

3 Likes

I’m fairly confident strings is named in the same vein as other common Unix utilities which are commonly (and purposefully) named in a clear, unimaginative fashion. Just a few similar examples:

  • ls
  • find
  • head
  • tail
  • less
  • mkdir
  • mv
  • cp
  • locate
  • touch

From that perspective, I think strings fits in well.

5 Likes

Great project btw! For Unicode support you may be able to use or take inspiration from zg.

3 Likes

std.unicode is the bare minimum the compiler needs to deal with windows.

It is far from a complete or faithful implementation of Unicode.

I would suggest either zg or uucode libraries

4 Likes