A Git Implementation in Awk
github.com
github.com
AWK is for tools less than 20 lines long. Anything more, use Perl, please.
On "big" Unixen (and I am an OpenBSD/Void user), for larger tools, Perl is preferred.
On speed, that doesn't matter. Perl under OpenBSD has a pledge/unveil module, and it's used to write the package manager. Problem solved.
Maybe I'm wrong, but I though perl code tended to be "higher-level", whereas AWK is optimised C throughout?
Perl is widely known as a write once read never language for a reason. In that sense I'll grant you awk is no better, but if you are stepping into scripting land you may as well use something generally readable (e.g. python, or just use bash).
From clueless Z-ers with no actual Perl experience, maybe.
While “write once, read never” is hyperbolic, it captures a real issue for Perl compared to many other competitive languages (of which, to be fair, there were far fewer widely supported for the tasks Perl was most often chosen for 20+ years ago.)
That's not to say I don't find some things nice about Perl, and I’d love to be able to spend more time woth Raku which grew out of it.
I read the book written by the creators and it's pretty clear they never intended it to be a general purpose language lol. I'm paraphrasing but they basically wrote in the book "People are completely mad and are intent on using our DSL as a general programming language so we added half baked functions to it but it's bad and you should feel bad"
I'd get chills too, tbf, but your MIL's gnostic pronouncement is total foofoo
For a fact, Facebook engineering uses mercurial instead of git in their tooling. They are going to do some 'hg rebase' whenever the stars are out of alignment =)
I know about 'shit' (== Shell Git) at https://git.sr.ht/~sircmpwn/shit from last year.
https://en.wikipedia.org/wiki/Git#Implementations lists JGit (<=2012), Go-git (2015), Dulwich (2008), libgit2 (<=2010), and JS-Git (<=2013).
A five-fold increase means at least 30 new implementations. :)
> Mes aims to create an entirely source-based bootstrapping path.
https://savannah.nongnu.org/projects/stage0/
> A class of minimal bootstrap binaries that has a reproducible build on all platforms. Providing a verifiable base for defeating the trusting trust attack.
(and comments at https://news.ycombinator.com/item?id=20264848 ).
HOMM2/3 are my favorite games ever.
HOMM 5 was developed by Nival, a major Russian dev and publisher at that time—though the 4 and 5 games weren't as famed, afaik.
You can already install it from marketplace.
A bit of pdf2txt, awk and some shell scripting, and budgeting becomes very easy...
But ok, we can at least say that awk is the oldest programming language to have associative arrays that's still in widespread use. (Yes, I'm hoping that someone will argue for SNOBOL4's current widespread use. :) )
> However, from the standpoint of manipulating strings with regular expressions, AWK introduced the concept as far as I know.
Two can play at this game! `awk` is really a successor of `sed`, which is all about manipulating strings with regular expressions. sed maybe isn't turing complete though (but someone's gonna prove me wrong here too) or at any rate not convenient to use in as general a way as awk.
Done! :) Since a turing machine has been written in sed, sed is turing complete. [1] [2] (both from Peter of Browserling).
[1] https://catonmat.net/proof-that-sed-is-turing-complete
[2] https://catonmat.net/ftp/sed/turing.txt> Christophe isn't the first person to realize that sed is almost a general purpose programming language. People have written tetris, sokoban and many other programs in sed.
Wow! But clearly, you wouldn't WANT to except for the fun of it.
I agree with him. His book "The Design and Evolution of C++" was a fascinating read. His site has an overview of it.
$ awk 'function f() { a[1]=2; return a } BEGIN { f() }' </dev/null
awk: cmd. line:1: fatal: attempt to use array `a' in a scalar context
You also can't have nested associative arrays, i.e. recursive or cyclic data structures are not allowed.As far as I can tell, this is because a stack frame owns everything allocated within it, and when a function returns the whole stack frame is cleaned up unconditionally. You can pass arrays down but not up. It's very naive memory management (by modern standards; it's probably better than BASIC).
So I'd say it's clearly not expressive enough for general purpose programming. There are Lisps in awk but they do weird tricks with text as far as I remember.
The advantage of awk over python is that it almost always takes < 60 seconds from the point at which you say, "I want to summarize, review, filters, report" on some columnar data to the point at which you have output in front of you.
I"m fast with python doing that - but it's usually a 3-4 minute set of steps.
The only exception being json, which awk is clumsy with. (jq is my goto tool for the simple queries, python for anything that requires more than a minute of thought.)
Also - it's almost always the case that I'm using awk in conjunction with a bunch of other tools, cut/sed/uniq/grep to get what I want.
The problem of persisting arrays usually leads to handling them in bash.
Now you have two problems.[1]
[1] If you paraphrase Jamie Zawinski in an explanation, you then have two things to explain.
And I still think Shell, Awk, and Make Should be Combined. In that world you'd still have one problem :)
https://www.oilshell.org/blog/tags.html?tag=awk#awk
Oil has recursive data structures, although I'm still working out how to compose shell-like "procs" and functions which could return an associative array. We could just add them both naively but I think it would cause many shell programs to be a lot messier.
- they don't have any garbage collection or ref counting
- they don't have recursive data structures
- you can't return any kind of array from a function
In bash you also can't pass an array to a function, but in Awk you can.Not quite -- https://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/... was the first and used two global associative arrays, car[n] and cdr[n], where n is an integer which iirc had to have a particular tag modulo 4, as the type tag. (Much as you'd do it in a lower-level C implementation.) I used almost the same scheme in my later Lisp.
This could be an appropriate software challenge for the Long Now Foundation [0], when they have finished that clock.
I think one of these languages is being insulted. Not sure which...
— which both could play cartridges and had Basic, with absolutely unlicensed Mario sprites in the mem.
But never connected the dots that there was an official thing like that, even though vaguely heard of the Famicom brand's various forays into neighboring markets of the day.
Wouldn’t it be more in the spirit of awk to write this as
editor = config::get("core.editor") || ENVIRON["EDITOR"] || “vi” editor = config::get("core.editor")
if (!editor) editor = ENVIRON["EDITOR"] ? ENVIRON["EDITOR"] : "vi"