Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't like C-like syntax in Unix tools, as the shell isn't C-like, and it's not clear that it's possible to make it C-like without sacrificing writing speed (lots of parentheses are hard to wrangle interactively); and awk is nice and efficient for some things the shell can't easily do, but it's its own world with a different set of variables and overlapping functionality, and you can't easily stick a pipe in the middle of an awk program. My ideal redesign would take the shell, make the syntax for iteration, pattern matching, arrays, etc. much simpler (integrating the functionality of awk), and (most importantly?) unify the ways various commands expect to receive data and take arguments representing parts of that data (fields, lines)... while still being the shell.

Dunno about sed - once I wrote a Brainfuck interpreter in it for fun, but I see it as a Turing tarpit - for things more complicated than "/a/s/a/b/" I prefer awk, though I wish awk had the succinct "s/a/b/", and I wish either of them had a quick way to extract a capture group from a match. (vi was a teenager when I was born, so I personally don't care about adhering to ed.)

I've never tried any APL-like languages and am therefore somewhat scared of them... but most of the programs I write outside of the interactive shell are non-throwaway and/or the kind of glue code that uses lots of random system functions, which decreases the value of extreme terseness. (But I prefer anything over Java and dislike the inflexibility of languages without macros, so perhaps it's only logical for me to go ahead and learn an array language.)



I too write mostly throwaway stuff. Obviously, terse languages are better suited for that than others.

Java makes me cringe. But my understanding is Java programmers use IDE's with autocomplete. They don't do much typing.

As for your pipe comment, are you a whiz with passing file descriptors? What do you think about chaining programs together in this way? Would that solve your pipe needs?

Maybe you could accomplish what you want using lex? The general paradigm is pattern-action, just like awk. Lots of flexibility in what you can create. You could create your own interpreter.

I like writing simple filters. I guess I have succombed to the UNIX voodoo. I think of everything as a stream of text.

I'd be interested to take a crack at your "capture group" problem, if you can give me an example of what it looks like.


Capture group would be something like

    /the number is ([0-9]+)/ { print $1; }
There are many ways to do this (gawk sorta supports it, perl can do it easily enough with

    perl -pe 'print "$1\n" if /the number is ([0-9]+)/'
but it's a bit cumbersome), but it would be much nicer if awk directly supported it.

Not sure what you mean about lex; if I decide to go ahead and write my ideal shell I could use it, but that's A Project, a large part of which is designing the syntax and deciding what commands to implement. And I'm lazy. :)


Can you give an example of some sample input and how you want the output to look? I'm stupid and this is the only way I can be sure I know what you're trying to do.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: