8 ms·
Aho – a Git implementation in Awk
- artsi0m 3y agoMight be relevant: sed-chess: https://news.ycombinator.com/item?id=37896854 https://news.ycombinator.com/item?id=37896854 awk-raycaster: https://github.com/TheMozg/awk-raycaster https://github.com/TheMozg/awk-raycaster
- erk__ 3y agoThere is also a Google (and more) translate client written in AWK https://github.com/soimort/translate-shell https://github.com/soimort/translate-shell
- artsi0m 3y agoI found an awesome-awk[1] page on github and is seems to be a little empty. Maybe we should contribute to it and bring some examples like subj of this HN post or ahrf[2], dedicated markup language for static site generators based on awk. I've started with adding one true awk and bioawk implementations. [1]: https://github.com/freznicek/awesome-awk https://github.com/freznicek/awesome-awk [2]: https://github.com/Ypnose/ahrf https://github.com/Ypnose/ahrf
- bitwize 3y agoAt first I thought this was named for aho (アホ), Japanese slang for "stupid", then I remembered that Alfred Aho is the 'a' in 'awk'. Or maybe it's both?
- bangonkeyboard 3y agoBoth, I assume. "Git" was already slang for "stupid person," so this is a clever name.
- phkahler 3y agoI always assumed git was a sort of slang for get. So you "git the code" or use git to get code.
- samatman 3y agoThe pun is there for sure, but "git" is British slang for an unpleasant or annoying person. I was introduced to it by The Beatles: "and curse Sir Walter Raleigh, he was such a stupid git". I believe it was Linus himself who quipped (paraphrasing) that he is so arrogant he named two software projects after himself: Linux, and git.
- CharlesW 3y agoMy most recent experience is hearing it in Reservation Dogs: https://en.wiktionary.org/wiki/aho#Navajo https://en.wiktionary.org/wiki/aho#Navajo
- ghc 3y agoI bet it's both. Extremely clever wordplay!
- Towaway69 3y agoGreat project and great idea. Understanding the basics gives one different perspectives for other projects and problems. Back in the day I created a Web-based wiki using awk. Why? Because I was using linksys router with minimal memory. It was a great learning both how wikis work and what can be done with awk. And since there are no libraries to fallback on, I had to implement the basics and gain all the understandings.
- snovymgodym 3y agoAwk is cool. It's a full-fledged programming language that's there in anything remotely unix-flavored, but I mostly see it used in one-liners to grab bits of text from piped stdout. But you can use awk as a general-purpose scripting language [1], in many ways it's nicer than bash for this purpose. I wonder why you don't see more awk scripts in the wild. I suppose perl came along and tried to combine the good features of shell, awk, and sed into one language, and then people decided perl was bad and moved on from that. [1] Random excerpt from NetBSD's source code https://github.com/NetBSD/src/blob/trunk/sys/dev/eisa/devlist2h.awk https://github.com/NetBSD/src/blob/trunk/sys/dev/eisa/devlis...
- smburdick 3y agoDoes that excerpt start with an if-else sequence?
- mksybr 3y agoit starts with the BEGIN block https://www.gnu.org/software/gawk/manual/gawk.html#BEGIN_002fEND https://www.gnu.org/software/gawk/manual/gawk.html#BEGIN_002... https://www.gnu.org/software/gawk/manual/gawk.html#Pattern-Elements https://www.gnu.org/software/gawk/manual/gawk.html#Pattern-E...
- csdvrx 3y ago> then people decided perl was bad and moved on from that. Screw what people think. I found out I like perl. The last thing I wrote is a programmatic partition editor [1] - like how you use sfdisk to zero out the partitions, except I wanted to do more than zap, like having the MBR and GPT partition table to combine them and make hybrids. I was fun, and I will use perl again (I may also use awk at one point now that I see how cool it is) [1] https://github.com/csdvrx/hdisk/ https://github.com/csdvrx/hdisk/
- blacklite 3y agoPerl is a great programming language, unless true.
- sampo 3y ago> I don't plan to add network functionality to this (even though you totally can), so no clone or push. You can also git clone from a repository in a different directory in the same computer. And push to.
- Am4TIfIsER0ppos 3y ago[flagged]
- ambigious7777 3y agoThis is incorrect. First of all, GitHub is a service built upon Git. There is no requirement that you need to use GitHub. And there are other options, what you call "hubs", such as GitLab or SourceHut. Git as a VCS, has the feature to sync with other repositories elsewhere. These can be somewhere else on your computer, someone else's computer, or a server. GitHub happens to be one of those servers. ---- edit: if this was sarcasm, mb
- coolgoose 3y agoSomebody's sarcasm meter is off :-)
- eikenberry 3y agoThey were probably just being a generous reader and assumed the writer wanted to take part in the conversation, not just make fun of it.
- macintux 3y agoWeak snark is something I’m happy to downvote here at every occasion.
- Am4TIfIsER0ppos 3y agoNot my precious internet points! Whatever will I do now?
- amelius 3y agoDoes it solve the large-file bottleneck? Then I might use it for my deep learning models.
- supriyo-biswas 3y agoIt doesn't, since Git's data model has to be changed to content-defined chunks to solve the issue. You should look at git-lfs[1] instead. [1] https://git-lfs.com https://git-lfs.com
- amelius 3y agoI've tried it but it doesn't play nice with git-shell, and thus for me is too much of a hassle to set up. Also, I'm not a huge fan of tools that implement important functionality as an afterthought, especially if those tools deal with my precious data.
- aseipp 3y agoNo, Git's object store was not designed to hold large binary blobs, and no implementation of Git in any language can change this. It's a reasonable request; I mean, Git doesn't even deal with "pretty small" binary files very well, either. But it's all simply a consequence of its design that was thought up all those years ago. The core object storage model and data format (and many, many things on top of those) have to be changed/extended/fixed first, but it's realistically an immense change, so git-lfs and other various solutions are about as good as it'll get in the mean time.
- sodapopcan 3y agoNot the most interesting of questions I have here, but is this indentation style on function definitions a thing or is it just accidental? It's in a few places, mostly before the first arg but sometimes before others. eg: function run_command( c, shortopts, longopts, quiet, directory, path, errors) Just asking as this project has kind of resparked my interest in awk.
- michaelcampbell 3y agoI noticed this too and can't figure it out. Spaces between SOME parameters, not all, and not consistently placed
- rbonvall 3y agoAwk doesn't have a way to define function-local variables. All variables are global, except for function parameters. This spacing convention is meant to clearly separate mandatory parameters and optional parameters that are sometimes only introduced to "declare" a local variable.
- bewuethr 3y agoHere's where the manual introduces the convention: https://www.gnu.org/software/gawk/manual/gawk.html#Variable-Scope https://www.gnu.org/software/gawk/manual/gawk.html#Variable-...
- sodapopcan 3y agoOh cool, thank you!!
- michaelcampbell 3y agoThanks; this may be one of the most weird conventions I've ever come across. Maybe that's a 'me' thing.
- deleted 3y ago[deleted]
- throw0101b 3y agoThe book The AWK Programming Language, Second Edition was released this past September (2023): * https://awk.dev https://awk.dev The first edition was published in 1988, and is available at: * https://archive.org/details/pdfy-MgN0H1joIoDVoIC7 https://archive.org/details/pdfy-MgN0H1joIoDVoIC7 * Discussion: https://news.ycombinator.com/item?id=13451454 https://news.ycombinator.com/item?id=13451454
- smburdick 3y agoAlongside Brian Kernighan, the "K" in K&R C, and much more Unix lore.
- adonovan 3y agoThis 35-year gap is a great story to tell your editor whenever they ask "so how's that second edition coming along...?"
- kazinator 3y agoThe original authors have done next to nothing to improve Awk in those years; it's embarrassing to be writing another book on a subject that they have not advanced. Awk could use improvement in numerous areas. Oh, for instance, you can pass associative arrays into functions, but not return them. Functions that filter array to array have to take an output array parameter. Using extra parameters as the only way to get local variables is also a smell. a[i] syntax cannot index into strings, what the hell?
- dang 3y agoRelated: A Git Implementation in Awk - https://news.ycombinator.com/item?id=28771841 https://news.ycombinator.com/item?id=28771841 - Oct 2021 (96 comments)
- forrestthewoods 3y agoNeat project. It’s always fun to see tools pushed beyond their normal use cases. That said, it should be a criminal offense to write any tool this large and complex in any language that can’t be used in a powerful step debugger. TBH I’m increasingly frustrated by the amount of code written in Bash. I kind of hate Python for various reasons. But if 100% of Bash was replaced with Python I think the world would be a better place.
- riddley 3y agoI'm mostly in concordance, but one thing I think every scripting language got wrong is how painful it is to run external binaries. Sure it can be done but it could be as easy as a shell script.
- forrestthewoods 3y agoAgreed. That said, stdout/stderr is such a bloody, inconsistent nightmare. I’m not totally convinced that “chain small binary programs together” is better than “one language with useful libraries”. Bash is admittedly nice for small things. But it always spirals out of control. And rarely gets ported. Also my life is primarily Windows and if you want everything to “just work” across mac/linux/win it’s easier to just use Python or sometimes even Rust. I often wish I could easily write and run single-file rust scripts.
- wazbug 3y agoRuby is nice in this regard though :-) x = `git --version` puts(x) #=> "git version 2.43.0"
- KerrAvon 3y agoRuby is really nice in this regard, in fact — you’re not limited to backticks; you can use any quote delimiters you want.
- riddley 3y agoRuby is nice in every regard :) Most languages have some form of backticks to run an external binary. When I left my original comment I got a phone call in the middle of it and rushed it, sorry about that. What I really meant was having the versatility of the big 3 file descriptors along with return codes, etc. You can use Open3 (in the ruby case) but it's unwieldy compared to, say bash.
- Keyframe 3y agoThere's this lingering thought in my head that with a bunch of GNU utils/programs and probably not much more one could create these omnipotent databases and processing tools that would surpass in performance and capabilities tools specialized in it. Anyone else feels like that?
- zilti 3y agoOh yes, and a project like this exists/existed: https://en.wikipedia.org/wiki/Strozzi_NoSQL?wprov=sfla1 https://en.wikipedia.org/wiki/Strozzi_NoSQL?wprov=sfla1
- Keyframe 3y agoFantastic, first time I hear about it. So there's _something_ to it, alright.
- Qem 3y agohttps://adamdrake.com/command-line-tools-can-be-235x-faster-than-your-hadoop-cluster.html https://adamdrake.com/command-line-tools-can-be-235x-faster-...
- kazinator 3y agoIf this used cppawk (which didn't exist when this was developed), it could use #include. This is nicely relative to the file; no AWKPATH. Also you can just "build" the preprocessed program into a single file which then doesn't need cppawk. https://www.kylheku.com/cgit/cppawk/about/ https://www.kylheku.com/cgit/cppawk/about/
- xonix 3y agoYou can also implement includes in couple (tens) of lines of AWK: https://maximullaris.com/revamp_define.html#mglwnafh https://maximullaris.com/revamp_define.html#mglwnafh
- freedomben 3y agoWhen people ask me why I say that the linux command line is the best dev environment, Awk is one of the tools I often point to. When you know even basic awk, you can do a lot with a little. IDEs actually start to feel clunky. If you're looking to get into Awk, and you learn well from a lecture style, I put together a talk for Linux Fest Northwest some years ago and recorded it for Youtube: https://youtu.be/E5aQxIdjT0M https://youtu.be/E5aQxIdjT0M
- corytheboyd 3y agoHow does awk replace an IDE? I love awk, I love how powerful it is if you spend the time to learn it, but if I didn’t have an IDE I would be significantly less productive. Most of what an IDE does is help you understand and change code, not text editing operations. Not trying to say you’re wrong, just curious what your angle is with that statement.
- freedomben 3y agoThanks, to clarify, I don't mean that just awk replaces an IDE. I mean that the Linux command line replaces an IDE, specifically the functions like finding references, substitutions, transformations, etc. It doesn't replace syntax highlighting and stuff of course, though I get that from Vim. It's never going to be as powerful as a specialized IDE would for a specific language, but the Linux CLI is language agnostic and even works on just text files, so it's universally applicable and doesn't change depending on the language of the project. For me it's better than an IDE, but YMMV of course because everybody is different.
- brabel 3y agoI don't understand why you're associating AWK with Linux in particular... it seems it's available on Windows, BSD, MacOS and probably more.
- freedomben 3y agoOk yes, point taken, I just meant it as a general expression. I don't mean to imply that it's exclusive to Linux, although I do specifically prefer the GNU flavor of most of the tools (awk an exception where there are multiple interesting implementations), which do tend to be more closely associated with Linux than macos or BSD. A standard installation of any Linux distro will have them all available, whereas in Mac and Windows you have to specifically install them as they aren't part of the standard command line.
- kazinator 3y agoWhen you see code like: function read_objfile(obj, objpath, bytes, end_of_header, header, end_of_type, type, size, bytes_after_header) the parameters separated by the big white space are local variables. It's possible to pass them values, but you're not supposed to. I wrote a patch for GNU Awk to give it a let statement for binding true lexical variables, so that this could be: function read_objfile(obj, objpath) { @let (bytes, end_of_header, header, end_of_type, type, size, bytes_after_header) { } } Unfortunately, this was rejected by the project; I was encouraged to make a renamed fork of GNU Awk, so that's what I did. https://www.kylheku.com/cgit/egawk/about/ https://www.kylheku.com/cgit/egawk/about/
- coliveira 3y agoI feel they have a point, gawk has already too many differences compared to awk. If you introduce even more distinct syntax, it is better just to fork it and call it something else.
- earthboundkid 3y agoThe perfect project name doesn't exi…
- runiq 3y agoYeah, digging the name. For the uninitiated: 'aho' is basically 'git' in Osakan.
- EasyMark 3y agocan be built as a part of busybox too, which I've found useful a few times on embedded linux systems with limited resources/program space
- hajimuz 3y agoAho means dumb ass in Japanese. Haha
- chanux 3y agoIn Sinhala it's Alas!
- Towaway69 3y agoWhat's wrong with hello in pirate speak? ;) https://en.m.wikipedia.org/wiki/Ahoy_(greeting) https://en.m.wikipedia.org/wiki/Ahoy_(greeting)
- kinow 3y agoI thought the same think. And it is super common in manga and anime, so a lot of people know wordslike aho, baka, kuso to have a bad meaning in japanese.
- srean 3y agoThats how you address your significant other in Marathi, so that 'dumbass' maybe all in affection.
- pyuser583 3y agoDear lord, why?
- v3ss0n 3y agoif you are using awk for more than 5 lines of code just use python.it is painfully slow and unreadable, there is no benefit of using it at all. if you are saying awk is fast you yad never benchmarked it against other programming languages. even pyhon is 10-20x faster.
- dexzod 3y agoI don't understand how you can write more that one line long program in a language where all variables are global by default even if they are inside a scope delimited by brackets. You can have local variables but the syntax is weird. https://www.gnu.org/software/gawk/manual/html_node/Variable-Scope.html https://www.gnu.org/software/gawk/manual/html_node/Variable-...