官术网_书友最值得收藏!

POSIX

POSIX, the Portable Operating System Interface, defines the standard APIs for Unix. It's adopted in Unix-based operating systems and beyond. The IEEE created and maintains the POSIX standard to enable systems from different manufacturers to be compatible. Write your C program using POSIX APIs on your laptop running macOS, and you'll have an easier time later building it on a Raspberry Pi.

As a common denominator, POSIX is old, simple, and most importantly, well-known to developers of all stripes. To make a new directory in a C program, use this API:

int mkdir(const char *path, mode_t mode);

And here it is in Node:

fs.mkdir(path[, mode], callback)

The Node documentation for the filesystem module starts out by telling the developer, there's nothing new here:

File I/O is provided by simple wrappers around standard POSIX functions.
https://nodejs.org/api/fs.html

For Node, Ryan Dahl implemented proven POSIX APIs, rather than trying to come up with something on his own. While such an attempt might be better in some ways, or some situations, it would lose the instant familiarity that POSIX gives to new Node developers trained in other systems.

In choosing POSIX for the API, Node is in no way limited to the standards from the 1970s. It's easy for anyone to write their own module that calls down to Node's API, while presenting a different one upwards. These fancier alternatives can then compete in a Darwinian quest to prove themselves better than POSIX.

主站蜘蛛池模板: 荔波县| 渭南市| 神池县| 芦溪县| 崇阳县| 武定县| 扶沟县| 闵行区| 台北县| 兴义市| 钟祥市| 旅游| 河源市| 栾城县| 黄平县| 安庆市| 麻阳| 陆河县| 伊吾县| 兴化市| 鄢陵县| 洱源县| 景宁| 本溪市| 肇庆市| 华宁县| 阳高县| 阳西县| 西林县| 仙居县| 黄石市| 平定县| 龙井市| 进贤县| 武宁县| 靖州| 和硕县| 辉县市| 博爱县| 双鸭山市| 贺兰县|