11 ms·
Dt: Duck tape for your Unix pipes
- deleted 3y ago[deleted]
- theobreuerweil 3y agoIt wasn’t mentioned on the landing page (I think) but is this a concatenative programming language?
- tgv 3y agoIt's stack based, like Forth and RPN. So 1 2 3 * + means something like push(1); push(2); push(3); multiply-top-of-the-stack(); add-top-of-the-stack(); So `status pls` means: call the function status (which leaves its results on the stack) and print the top of the stack with new-lines (multiple lines if it's an array). Then `status upcase pls` would do something like the above, but it calls a "to uppercase" function before printing.
- theobreuerweil 3y agoGot it cheers
- mst 3y agoWhile I think 'pl' and 'pls' for print line and print lines is probably an excellent choice overall I can't help but see 'pls' and try and parse it as an abbreviated INTERCAL.
- buildbot 3y agoThis is really interesting and fills a nice niche for when you don’t want to reach for python or whatever. As an aside, I wish I was cool enough for lobste.rs!
- buildbot 3y agoThank you to the two people who sent me invites, that was very kind :)
- Jolter 3y agoTitle edit: original title is “duct tape for your unix pipes”
- namaria 3y ago[flagged]
- someweirdperson 3y agoEarly ones at least had some parts from ducks, but there's no relation to ducts at all. Ducts are not sealed using duct tape. Language should be updated to call it reinforced self-adhesive tape or something.
- greenyoda 3y ago"Duck Tape" is actually one brand of duct tape: https://www.duckbrand.com/products/duck-tape https://www.duckbrand.com/products/duck-tape
- boffinAudio 3y agoDuck tape is a thing: https://www.walmart.com/ip/Duck-Brand-1-88-in-x-55-yd-Silver-Original-Duct-Tape/591736470 https://www.walmart.com/ip/Duck-Brand-1-88-in-x-55-yd-Silver...
- nargek 3y agoStraight from the link : > Excuse me, is it "duct" or "duck" tape? > I mean sure, "duct tape" and "duck tape" are both fine. "Duct tape" is the more common name today. The older name is "duck tape" after the duck cloth under the adhesive.
- arcanemachiner 3y ago> During World War II, Revolite (then a division of Johnson & Johnson) developed an adhesive tape made from a rubber-based adhesive applied to a durable duck cloth backing. This tape resisted water and was used to seal some ammunition cases during that period. > "Duck tape" is recorded in the Oxford English Dictionary as having been in use since 1899 and "duct tape" (described as "perhaps an alteration of earlier duck tape") since 1965. https://en.wikipedia.org/wiki/Duct_tape https://en.wikipedia.org/wiki/Duct_tape
- namaria 3y ago
- dimator 3y agoI read the page a few times but I'm still scratching my head. How is this intended to be used?
- stingraycharles 3y agoYeah, the examples are focused on dt’s internal state and features. A few real world practical examples of what you can do with it would be much better.
- quench 3y agoFor example I am trying to figure out how I would split each line on a delimiter. I cant figure out what the syntax is dt [ "," split ] pls prints split dt [ "," split ] map pls prints stack underflow I think I could definitely use this if it had better docs and I could figure out how to.
- acqq 3y agoI don't know what that is intended with that, but for simple line splits I'd use awk, which is typically everywhere, and its parameter -F (F there stands for field separator) that is, given the file L with the lines hello,world,one maybe,baby,you awk -F, '{ print $2 }' L should give world baby (tested on https://busybox.net/live_bbox/live_bbox.html https://busybox.net/live_bbox/live_bbox.html )
- bvanderveen 3y agoPresumably it's meant to be used when you're writing a shell script and you have some problem in front of you that would be trivial to solve in a real programming language and you find yourself saying a sentence starting with "I just wanna…" and rage-googling or asking ChatGPT or whatever.
- stingraycharles 3y agoWould be great if it could show some things it can do that awk can’t. Because awk is typically my Swiss Army knife if I run into these situations.
- gnfargbl 3y agoThis article links to https://en.wikipedia.org/wiki/Vesta_Stoudt https://en.wikipedia.org/wiki/Vesta_Stoudt, which links to https://en.m.wikipedia.org/wiki/Cotton_duck https://en.m.wikipedia.org/wiki/Cotton_duck, which explains that the word "duck" here comes from the Dutch doek, or "linen canvas".
- reportgunner 3y agoYeah which explains that duck tape is not for ducts (or pipes) since it's made of fabric. > She is often misattributed as the inventor of duct tape. However, numerous variations of adhesive cotton duck tape had existed for decades, nor did she invent the specific formulation of the popularized duct tape.
- dynisor 3y agoThat is not what the thing you quoted says, or even correct. All duct tape is made of fabric and it is… well duct tape, so ducts were the intended use case when the name was created. Duct tape has kinda become a general term for all cloth-based tapes though, so you can indeed find duct tape not intended for ducts, but the fact the name was originally “duck tape” has nothing to do with that.
- jbverschoor 3y agoGaffer tape Gaffer Duck Donald Duck These toons stick together
- ndsipa_pomu 3y agoI always believed that the name "duck tape" was given because it is waterproof as in "water off a duck's back" and duct tape was just an eggcorn.
- seemaze 3y agoASHRAE/UMC actually specify tape 'for ducts' to be UL 181A-P/181B-FX [0] which is commonly made of metal foil and not cloth. [0] https://tapeuniversity.com/products/foil-tapes/ul181ap-ul181bfx/ https://tapeuniversity.com/products/foil-tapes/ul181ap-ul181...
- alxmng 3y agoNushell has filled this void for me. It elevates pipes by structuring them into lists or tables. It has all sorts of goodies for manipulating those data structures like inserting/updating rows and cells, better string interpolation, useful utility functions like case transformation, and more.
- p-e-w 3y agoAgreed. Nushell fulfills the Unix philosophy promise that the standard Unix tools have been breaking since forever. Traditional Unix commands feel like a hodgepodge of hacks by comparison, that only work together occasionally, and even then mostly by accident.
- imiric 3y agoThe Unix philosophy doesn't dictate any specific data format to interoperate between commands, besides this being data streams, and typically text. Commands are free to interpret these streams however they want, which is why this seems like "hodgepodge", but in no way were tools breaking any sort of promise. FWIW I've been using *nix machines for decades, and very rarely have I had the need to use structured data between commands. Yes, it would make things cleaner or more robust in certain cases, but in practice there are common ways of handling this. E.g. most tools support outputting or inputting null-terminated lines.
- regularfry 3y agoNull separators between fields is structured data. It might just be the simplest that can possibly work (because the null character is outside the normal data range for text, unlike the newline, which demonstrably doesn't work in that sense) but it is structure. A list structure, specifically. The world would be a much happier place if -print0 (or whatever) was universal, but no such luck.
- imiric 3y agoSure, but the reason it works with any tool is because it's generic and simple. If each tool had to implement anything more sophisticated like a JSON parser and serializer, it would be a nightmare to maintain. Projects like Nushell essentially need to handle every type of output from any command, and every type of input to any command, which is an absurd amount of work, and just not scalable. Subtle changes in this strict contract means that pipelines will break, or just not be well supported[1]. If programs simply input and output unstructured data, it's up to the user to (de)structure this data in any way they need. The loose coupling is a feature, not a bug. [1]: You can see this in Nushell's issue tracker[2]. I'm not judging the amount of issues, as any healthy OSS project will have many issues, but some of these are critical bugs related to command handling and interop. I'm not blaming the Nushell team either, my hat's off to them, but just pointing out that the nature of the project will inevitably lead to a neverending stream of these types of issues. [2]: https://github.com/nushell/nushell/issues https://github.com/nushell/nushell/issues
- lionkor 3y agoTitle should be > Dt: Duct tape for your Unix pipes ^^^^
- ly3xqhl8g9 3y agoCuriously enough, not really, from the post: Excuse me, is it "duct" or "duck" tape? I mean sure, "duct tape" and "duck tape" are both fine. "Duct tape" is the more common name today. The older name is "duck tape" after the duck cloth under the adhesive. As an aside: If you care about such things, make sure to read up on how today's common version became popular. A 51-year-old woman named Vesta Stoudt, mother of 8, mailed her idea for a better ammunition box seal to the president (who approved production) after her bosses didn't do anything with the suggestion.
- wizofaus 3y agoBarely a day goes by I don't learn something surprising on HN that's entirely unrelated to IT/software dev.
- ly3xqhl8g9 3y ago"I suggested we use a strong cloth tape to close seams, and make tab of same. It worked fine, I showed it to different government inspectors they said it was all right, but I could never get them to change tape." Vesta Stoudt to President Roosevelt, February 10, 1943 [1]. History is full of "never get them to change" stories, probably one of the more famous is Napoleon's dismissal of the steam engine, although the story is a bit more complicated, "Fulton (and his design) failed at the worst possible time" [2]. As we found out recently, submarines are hard. And on a completely unrelated note, one of the greater stories of quasi-forgotten sacrifice of a mother for her son is the story of a woman in 1850s travelling around 2,000 kilometres by foot, by horse, by any means to get her son enrolled into university, dying shortly after: her name was Maria Dmitrievna Mendeleeva, her son's name was Dmitri Ivanovich Mendeleev [3], that Mendeleev. [1] https://en.wikipedia.org/wiki/Vesta_Stoudt https://en.wikipedia.org/wiki/Vesta_Stoudt [2] https://hsm.stackexchange.com/a/13154 https://hsm.stackexchange.com/a/13154 [3] https://chemaust.raci.org.au/article/julyaugust-2019/mother%E2%80%99s-love-maria-dmitrievna-mendeleeva.html https://chemaust.raci.org.au/article/julyaugust-2019/mother%...
- mgaunard 3y agoI either use Bash (which is actually a decent programming language if you spend the time to learn it properly) or Python.
- john-radio 3y agoI use Python's `fileinput.FileInput()` a lot for ad hoc scripts, because its behavior is to read from STDIN if available, or to attempt to open a file from `sys.argv[1]` (possibly `[1:]`?) if not, which covers a ton of this kind of use cases.
- Aerbil313 3y ago> Bash (which is actually a decent programming language) How so? I tried to seriously learn Bash a few days ago, and once I learned about word splitting, [[ ]] vs. [ ], "${MY_VAR}" just to properly reference a variable it seemed even more full of technical debt that Wat-full [1] Javascript. I figured it would be obsoleted by a modern shell language alternative by the time I will be 30 (currenty 18), it's not worth it, and gave up. I think the bar should not be Turing completeness for a programming language to be decent. 1: https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- tpoacher 3y agoFor me, somewhat surprisingly, the best bash resource I've come across is the manpage. If you haven't read this and have instead relied on any other resource, I would recommend spending some time to read the bash manpage before deciding to give up on it. To me this has transformed bash from what I once considered a cryptic ugly mess to one of my favourite languages to write even relatively general-purpose code on. The help command is the only other resource you need, imo.
- mgaunard 3y agoLearning a programming language properly usually takes 5 years of daily practice using it to solve real problems. There is no 'wat' situation for a tool you really are proficient with.
- 3y ago
- dejj 3y agoup: Ultimate Plumber for shell https://github.com/akavel/up https://github.com/akavel/up
- jeromenerf 3y agoNice one. There have been so many nice CLI tools these last 10 years. Quality of life kind of nice. ag/rg, fzf, entr, up, lf... Go and rust have been appreciated enablers, even though ruby/python/js demonstrated the concepts, with somewhat poor performances and UX.
- booniepepper 3y agoOh my!
- artemonster 3y agoForth/Joy/Factor vibes
- frameset 3y agoIn my profressional life I have cause to work with Powershell a great deal, and I love the object oriented pipelines that it has. Being able to filter, sort, or transform properties of the objects passed over makes it much more straightforward to work with than bash et al.
- brazzledazzle 3y agoI’m with you here. Once you get the hang of it you even miss the most awkward pipelines once they’re gone and you’re just passing around single dimensional strings. The memory overhead with sets of objects and their properties vs vanilla strings is significant though and easy to bump up against when working with large data sets. Best to try to keep all of the processing for that dataset in a single pipeline if you can. But that’s tradeoffs.
- frameset 3y agoYeah the memory usage of the pipeline is real. Often using foreach instead to save memory is needed. Or good old fashioned array chunking.
- brazzledazzle 3y agoExactly. If you really have to you can take advantage of its ability to use .net libraries directly and force immediate cleanup/gc of variables but it's super hacky and always found pipelining to work better once you get the hang of processing data in flight.
- shortrounddev2 3y agoPersonally I only use shell scripting for simple tasks, not anything that would run into a memory limit. If it requires more heavy lifting, I'll write it in a programming language like C#. Nothing we do in production relies on shell scripts, they exist only as shortcuts for our workflow
- brazzledazzle 3y ago
- einpoklum 3y agoI don't really see why existing shell tools and scripting languages are missing, that this project provides. Especially if you consider the expressive range from, say, grep/bc/tr, through sed, through awk, to perl or python.
- mst 3y agoI write a lot of perl -e pipeline members for this sort of thing and I can absolutely see dt producing something that's easier to skim read for somebody who only really knows shell. (I got sufficiently competent at perl before really noticing sed and awk existed that I'm pretty terrible at the latter two, so YMMV etc.)
- yunohn 3y agoMaybe I’m not the target audience, but this README is very light on real usecases and examples to help me understand when I would need this.
- quectophoton 3y agoTrivia: "DT" is Japanese slang for "dōtei" ("童貞", means "virgin"). Names are hard.
- p-e-w 3y agoThere's a fairly successful version control system whose name is an insult in British English. And wait until you hear what the most popular open source alternative to Photoshop is called...
- mst 3y agoIt's generally considered a feature for your pipeline to -not- be screwed, after all.
- alexvoda 3y agoIs it nailed?
- booniepepper 3y agoThere are 5 pages of entries in Urban Dictionary for "DT" -- there is no winning with short names.
- hiccuphippo 3y agoWhat do the -- in the documentation mean? Also why does one command use double backslash (\\word) while others only a single one (\word)?
- reportgunner 3y agoIsn't it the bash double dash[0] that signifies the end of cli options? [0] https://unix.stackexchange.com/a/11382 https://unix.stackexchange.com/a/11382
- WaitWaitWha 3y ago"Duck Tape" (versus duct tape) is a trademark of Manco, now Henkel Consumer Adhesives.[0] Did some fancy DB work for them on OS/2 and early AS/400s in the '90s. [0] https://www.duckbrand.com/about https://www.duckbrand.com/about
- pmarreck 3y agoSo this is basically just Forth. I'd suggest that a functional shell like es-shell is more interesting than this experiment =) https://wryun.github.io/es-shell/ https://wryun.github.io/es-shell/