News for hackers. Stuff that matters.
Re:Falsehoods programmers believe about build systems (2012) by sabujp on Saturday July 18, 2020 @03:26PM (#23884079)
I'm no blaze/bazel expert (hopefully someone will add their own thoughts), but:

    1. build graphs are trees/acyclic : bazel enforces this, no cyclic dependencies allowed
    2. Compilers will always modify the timestamps on every file they are expected to output : if a write happens why not update mtime? nanosecond precision, what year is it?
    3. It's possible to tell the compiler which file to write its output to : makes no sense to me, we expect our compilers to be writing to the correct files in the correct directories.
    4. It's possible to predict in advance which files the compiler will update : yes it is, this is how caching works again see (1)
    5. It's possible to determine the dependencies of a target without building it : yes yes it's completely possible given (1)
    6. Detecting changes via file hashes is never the right thing : Bazel i think uses a combination of hashes and stamps, but why would using hashes not work 99.99999999999999998% of the time?
    7. Non-experts can reliably write portable shell script : lol, experts can't reliably write portable shell scripts either
    8. Your build tool is a great opportunity to invent a whole new language: or just coopt pieces of one (python: starlark, skylark)
    9. Said language does not need to be a full-featured programming language : yes, it doesn't (again .bzl files)
   10. Said language should be based on textual expansion : not sure what the alternative to textual expansion (parsing?) is
   11. Adding an Nth layer of textual expansion will fix the problems of the preceding N-1 layers : again how is this different from parsing
Re:Falsehoods programmers believe about build systems (2012) by tzs on Saturday July 18, 2020 @05:54PM (#23885168)
> 2. Compilers will always modify the timestamps on every file they are expected to output : if a write happens why not update mtime? nanosecond precision, what year is it?

It has nanosecond precision, but on most systems it does not have nanosecond resolution.

  $ touch a1; sleep .0001; touch a2; stat a1 a2 | grep Modify:
  Modify: 2020-07-18 21:37:56.421487075 +0000
  Modify: 2020-07-18 21:37:56.421487075 +0000

  $ touch a1; sleep .0001; touch a2; stat a1 a2 | grep Modify:
  Modify: 2020-07-18 21:37:57.397502229 +0000
  Modify: 2020-07-18 21:37:57.397502229 +0000

  $ touch a1; sleep .0001; touch a2; stat a1 a2 | grep Modify:
  Modify: 2020-07-18 21:37:58.273515840 +0000
  Modify: 2020-07-18 21:37:58.277515902 +0000

  $ touch a1; sleep .0001; touch a2; stat a1 a2 | grep Modify:
  Modify: 2020-07-18 21:41:00.736348218 +0000
  Modify: 2020-07-18 21:41:00.736348218 +0000

  $ touch a1; sleep .0001; touch a2; stat a1 a2 | grep Modify:
  Modify: 2020-07-18 21:41:01.708363288 +0000
  Modify: 2020-07-18 21:41:01.708363288 +0000

  $ touch a1; sleep .0001; touch a2; stat a1 a2 | grep Modify:
  Modify: 2020-07-18 21:41:02.504375653 +0000
  Modify: 2020-07-18 21:41:02.508375715 +0000
Note that the difference is either 0 or 0.004000062. This is on a Debian 9 system running on an Amazon Lightsail instance with an ext4 filesystem.

Here's a quick and dirty script to play with this:

  C=0
  R=0
  while :
  do
    R=$((R+1))
    touch a1; sleep $1; touch a2
    T1=$(stat a1 | grep Modify | sed -e 's/.*://' | sed -e 's/ .*//')
    T2=$(stat a2 | grep Modify | sed -e 's/.*://' | sed -e 's/ .*//')
    if [ $T1 != $T2 ]; then
        dc <<HERE
  20k $T2 $T1 - p
  HERE
        C=$((C+1))
        if [ $C -eq 100 ]; then
            echo "$R runs"
            exit 0
        fi
    fi
  done
Output on the above system:

  $ bash t.sh 0.001 | sort | uniq -c
        4 .004000061
       83 .004000062
       13 .004000063
        1 222 runs
and on a VMWare Fusion VM running Debian 8 on my Mac:

  $ bash t.sh 0.001 | sort | uniq -c
       29 .003999599
       44 .003999600
       27 .003999601
        1 323 runs
Re:Falsehoods programmers believe about build systems (2012) by sabujp on Sunday July 19, 2020 @07:04AM (#23888519)
ahh yea thanks for the reminder, i think bazel also hashes all inputs and outputs
Re:Falsehoods programmers believe about build systems (2012) by CuriousSkeptic on Sunday July 19, 2020 @03:46AM (#23887738)
> not sure what the alternative to textual expansion (parsing?) is

Just realized they other day that PowerShell does this (parsing instead of expansion). Which means much less worrying about escaping output of arguments.

Re:Falsehoods programmers believe about build systems (2012) by tzs on Saturday July 18, 2020 @05:31PM (#23885015)
OT: when did HN start wrapping long lines in indented text?
Re:Falsehoods programmers believe about build systems (2012) by SilasX on Saturday July 18, 2020 @05:52PM (#23885151)
It's not because the lines are long but because they're prefixed by four spaces (and for anyone reading, please don't do that unless it's actual code).
Re:Falsehoods programmers believe about build systems (2012) by tzs on Saturday July 18, 2020 @06:02PM (#23885218)
It's wrapping lines prefixed with two spaces now. The comment I just posted a couple minutes ago with indented shell input and output definitely used two spaces and it is wrapping on my phone and on my desktop if I narrow the window enough.