News for hackers. Stuff that matters.
Re:Using Unix as an IDE (2012) by rbc on Wednesday June 20, 2018 @07:47PM (#17360933)
It's not for everyone, but the Unix/BSD/Linux shell is still my favorite command invocation environment. Despite their simplicity, pipelines are a really handy way to pass data between programs when solving certain kinds problems. It also provides a cheap way of providing some parallel processing.
Re:Using Unix as an IDE (2012) by zrobotics on Wednesday June 20, 2018 @08:46PM (#17361175)
The other thing I absolutely love about pipes is the ease of writing custom utilities. I'd refactored a filetype for use with a game last week, and needed to insert several lines into ~1.5k ASCII files. 1/2 hour to make a hacked c++ program to make the changes, and pass the outputs of grep to that.

Although I'm unfamiliar with using pipes to provide parallel processing, could you elaborate? If you can pass to another thread I will be kicking myself for missing that.

Re:Using Unix as an IDE (2012) by flukus on Wednesday June 20, 2018 @08:56PM (#17361211)
> Although I'm unfamiliar with using pipes to provide parallel processing, could you elaborate? If you can pass to another thread I will be kicking myself for missing that.

You didn't miss it, each stage in the pipeline runs in it's own process so you're already using it. With say "grep -r foo ./ | do-something | do-omething-else" the second and third stages will be operating on the data from grep while grep is still running.

In addition to that you can get more parallelism pretty simply with xargs (http://offbytwo.com/2011/06/26/things-you-didnt-know-about-x...). If that's not enough then check out gnu parallel (https://www.gnu.org/software/parallel/).

While we're talking about unix as an IDE I want to put in a plug for inotifywait (https://linux.die.net/man/1/inotifywait). Combining this with a makefile you can get some very fast builds with near instant feedback everytime you save a file. I have one that executes units tests and valgrind every time for instant memory leak detection. Another great use case is getting WYSIWYG like features with latex files.

Re:Using Unix as an IDE (2012) by harry8 on Wednesday June 20, 2018 @11:54PM (#17362027)
using make -j $num is another way to go to get parallelism that is sometimes convenient.
Re:Using Unix as an IDE (2012) by flukus on Thursday June 21, 2018 @01:59AM (#17362500)
Just make sure $num is set, otherwise it tries to do everything it can at once. I found out the hard way compiling gcc last week, system was unresponsive so I reset, but I'm curious if it would have worked eventually.
Re:Using Unix as an IDE (2012) by btschaegg on Thursday June 21, 2018 @02:18AM (#17362579)
This is a pet peeve I have had for a while now. I still have a definition for MAKEFLAGS (with -j [# of cpus-1]) in my profile and rc files and had to learn that if you allow make to start too many things at once, the whole machine would hang. Even switching to a different TTY took ages.

To me, it sounds like a tremendous scheduling issue if a build job can drown a whole system like that. Shouldn't there be some emphasis on non-waiting threads/processes that haven't done much over those who have hogged the CPU in the past without me having to manually adjust the niceness of every build task?

Re:Using Unix as an IDE (2012) by __blockcipher__ on Thursday June 21, 2018 @02:48AM (#17362707)
I can’t offer specifics, but it’s probably at the point that you’d compile a different scheduler?
Re:Using Unix as an IDE (2012) by jcelerier on Thursday June 21, 2018 @05:32AM (#17363439)
IIRC make -j is equivalent to make -j256...
Re:Using Unix as an IDE (2012) by benchaney on Thursday June 21, 2018 @06:31AM (#17363701)
From the man page:

> If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously.

Although other implementations might be different of course.

Re:Using Unix as an IDE (2012) by JdeBP on Thursday June 21, 2018 @07:28AM (#17364033)
It's not a notion that I carried into my implementation of redo, for example.

    % redo --jobs
    redo: ERROR: jobs: missing option argument
    %
Re:Using Unix as an IDE (2012) by flukus on Thursday June 21, 2018 @07:55AM (#17364258)
What made you go with that rather than trying to pick a sensible default like the number of cores available? Or was it just a general goal to require explicitness?
Re:Using Unix as an IDE (2012) by JdeBP on Thursday June 21, 2018 @10:30AM (#17365460)
It was simplicity, of design, implementation, use, and indeed explanation. There's only one default, the default if the --jobs option is not used; rather than there being two defaults, one for not having the option and another for having the option but not the option argument.

More generally, I try to avoid optional arguments to command options, in line with the guideline in the Single Unix Specification. (I actually picked such ideas up many years ago, before the first POSIX specification, from a book by Eric Foxley titled Unix for Super Users, where there was an appendix on command line option syntax.)

* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_...

Of course, if the user wants to use the number of cores available, then xe can work that number out and pass it as an argument; and indeed I have done that very thing in some of the package/make scripts that I have published.

Re:Using Unix as an IDE (2012) by pjmlp on Thursday June 21, 2018 @07:30AM (#17364058)
You mean function composition on Lisp Machines REPL and Smalltalk Transcript, with the benefit of structured data.
Re:Using Unix as an IDE (2012) by rbc on Thursday June 21, 2018 @08:41AM (#17364532)
I've used guile to do pipeline like transformations of data by using multiple function calls. It has the advantage of a more consistent api to do the transformations on the stream of data and surely better type checking. The syntax is different but I think about it as being similar.

Despite its messiness, doing ad-hoc integration of command line tools to transform text is really handy. It also spreads the cpu utilization and memory usage across the commands that you use in the pipeline.

Re:Using Unix as an IDE (2012) by rbc on Thursday June 21, 2018 @08:54AM (#17364614)
I'll add that I enjoy using Common Lisp and Scheme REPL environments. I also really like Squeak as an interactive programming environment. Neither has replaced the old school Unix shell as my preferred command invocation environment, at least in my professional life.
Re:Using Unix as an IDE (2012) by madhadron on Thursday June 21, 2018 @01:04PM (#17367014)
I have the same experience, and I suspect it's because we haven't replicated the utilities in these environments. No one uses them as a replacement for shell because no one has done the work to use them as a replacement for shell.

Personally, I think Prolog is the right way to go, but I have this idea that I don't want to spend the rest of my life typing into a teletype emulator.

Re:Using Unix as an IDE (2012) by pjmlp on Thursday June 21, 2018 @02:40PM (#17368075)
We kind of do on Windows, thanks PowerShell and PowerShell IDE.
Re:Using Unix as an IDE (2012) by pjmlp on Thursday June 21, 2018 @09:01AM (#17364657)
> It also spreads the cpu utilization and memory usage across the commands that you use in the pipeline.

For example with Clojure you can use pmap and pcall to achieve that.

Re:Using Unix as an IDE (2012) by rbc on Thursday June 21, 2018 @09:12AM (#17364726)
That's cool. I'll have to try it out.
Re:Using Unix as an IDE (2012) by coatmatter on Thursday June 21, 2018 @02:33PM (#17368010)
Which is your favourite shell? bash, oh-my-zsh, fish?