Are intermediate files a bad practice?

I was recently disconnected (which only a little bothered me :)) for the answer I gave to this question . The man did not offer an explanation for the vote, which made me wonder: "Why would you avoid creating intermediate files?" Especially in a language such as Python, where File IO is ridiculously simple.

There seemed to be consensus that this was a bad idea, but I know that intermediate files are used regularly in practice. I worked in a respected research firm very much (let me say that SO would not have existed without this firm), where it was assumed that your programs would create files as output. We did this because if your program really deserves an independent program, then it will need debug output and some way of transferring its output between processes, which can subsequently be considered if we find an error in our output further downstream.

Is it a bad practice (in case, for example, related to this question) to use intermediate files? Why?

+3
source share
3 answers

One problem with intermediate files is multithreading.

If clients C1 and C2 are processed simultaneously by server process S (which may or may not branch into separate processes, threads used or any other concurrency system ..), you may get strange problems when both try to create the same intermediate file.

, Unix , , , , . / , , , , , .

+2

, , . , .

1) , . ( NFS).
2) .
3) Ctrl-C, , .
4) NFS, .
5) , , , .

, bash - . C, ++ , . , , , . .

+1

If you create temporary files properly (with the "temporary" flags set for the platform, that is, do not flush the cache to disk if there is no urgent need), they are great if the task requires them.

There are practically no things in IT that you cannot use, with good reason. :-)

0
source

Source: https://habr.com/ru/post/1776690/


All Articles