Live data from Hacker News

The Makefile I use with JavaScript projects

olioapps.com

171–180 of 525 posts

Re: The Makefile I use with JavaScript projects

#171

I'm not a web dev, but this article has uncovered yet another thing in the js ecosystem that just seems crazy to me. This makefile snippet: lib/index.js: src/index.js mkdir -p $(dir $@) babel $ The source and the output are both called index.js? Why, God, WHY???

It's because there is always lag between the latest .js spec and what is supported by browsers. So transpilers (like babel) have to dumb it down from fancyNew.js to somethingIE6MightRun.js

It is not realistic/optimal to try to write your javascript to be supported by all browsers or runtime clients. It's better to write using the latest spec, and just have it dumbed down for you by transpilers at build time

Some more explanation here: https://www.excella.com/insights/typescript-vs-es6-vs-es2015

Re: The Makefile I use with JavaScript projects

#172

A long time ago, in a developer's paradise called the 1970's there was an automated build tool called "make". It had this and only this syntax: If a line begins at character 0, that is a list of files whose timestamps should be checked, if any are 'old', then execute the series of command lines beneath, identifying them as starting with a tab character. That was it, the entire syntax of "make", and it was complete. T…

I once (back in the mid-1980's) spent several weeks hunting down a makefile bug. In the end it turned out to be a SPACE character that preceded a TAB character. It's some weeks of my life I will never get back. I hate make and it's 'entire syntax'.

Back in that 1970's developer's paradise, it was not possible to lose a space next to a tab, because we did not have WYSIWYG editors, we had "vi" which has an easy toggle to show white space characters. "Back in the day" everything had a command line interface, and non-developers were afraid of computers. Ah, the good old daze...

Re: The Makefile I use with JavaScript projects

#173
post #158

I think the reason make is both so controversial and also long-lived is that despite how everyone thinks of it, it isn't really a build tool. It actually doesn't know anything at all about how to build C, C++, or any other kind of code. (I know this is obvious to those of us that know make, but I often get the impression that a lot of people think of make as gradle or maven for C, which it really isn't.) It's really…

> It's really a workflow automation tool, That's true. > and the UX for that is actually pretty close to what you would want. That is so not true. Make has deeply woven into it the assumption that the product of workflows are files, and that the way you can tell the state of a file is by its last modification date. That's often true for builds (which is why make works reasonably well for builds), but often not true f…

> but often not true for other kinds of workflows.

Examples? I mean, there are some broken tools (EDA toolchains are famous for this) that generate multiple files with a single program run, which make can handle only with subtlety and care.

But actual tasks that make manages are things that are "expensive" and require checkpointing of state in some sense (if the build was cheap, no one would bother with build tooling). And the filesystem, with its monotonic date stamping of modifications, is the way we checkpoint state in almost all cases.

That's an argument that only makes sense when you state it in the abstract as you did. When it comes down to naming a real world tool or problem that has requirements that can't be solved with files, it's a much harder sell (and one not treated by most "make replacements", FWIW).

Re: The Makefile I use with JavaScript projects

#174
post #158

I think the reason make is both so controversial and also long-lived is that despite how everyone thinks of it, it isn't really a build tool. It actually doesn't know anything at all about how to build C, C++, or any other kind of code. (I know this is obvious to those of us that know make, but I often get the impression that a lot of people think of make as gradle or maven for C, which it really isn't.) It's really…

> It's really a workflow automation tool, That's true. > and the UX for that is actually pretty close to what you would want. That is so not true. Make has deeply woven into it the assumption that the product of workflows are files, and that the way you can tell the state of a file is by its last modification date. That's often true for builds (which is why make works reasonably well for builds), but often not true f…

> Make has deeply woven into it the assumption that the product of workflows are files

You're referring to a standard Unix tool, an operating system where EVERYTHING is a file.

Re: The Makefile I use with JavaScript projects

#175

A long time ago, in a developer's paradise called the 1970's there was an automated build tool called "make". It had this and only this syntax: If a line begins at character 0, that is a list of files whose timestamps should be checked, if any are 'old', then execute the series of command lines beneath, identifying them as starting with a tab character. That was it, the entire syntax of "make", and it was complete. T…

I did not use Make at this time (I wasn't alive!), but it seems that you'd have to declare dependencies too. How did you determine if it was "old"?

the first file in the list is the one whose timestamp is compared against all the other files in the list after it. If the timestamp of any file is newer than that first file, the following lines starting with a tab are executed.

Re: The Makefile I use with JavaScript projects

#176

Earlier quoted context omitted.

> They must have got something good though. Else why would there entire families of C-like languages ? Network effect. If you wanted to write for unix, you almost had to use C originally. > Plus, to me C syntax is particularly good. It's meh. It's not the most straightforward when defining complex types like arrays or function pointers. > You're writing real words and the computers does the things you tell it to. To…

Everybody I know found it confusing at first, but its logical, and modular . I don't know a language with a better type declaration syntax. It gets impractical when you define function that return functions that return... because these expression grow on the left and right simultaneously. But realistically, you don't do that in C, and other than that, I find it easy to read the type of any expression... const int *x[…

I'm really not sure what you mean by "modularity". There's a lot of languages with much more readable and composable type declarations than C. For example in OCaml:

  let x : (int list ref, string) result option =
    let x1 : int = 0 in
    let x2 : int list = [ x1 ] in
    let x3 : int list ref = ref x2 in
    let x4 : (int list ref, string) result = Ok x3 in
    Some x4
The declaration of List.map:

  val map : ('a -> 'b) -> 'a list -> 'b list

Re: The Makefile I use with JavaScript projects

#177
post #119

Earlier quoted context omitted.

Nowadays there are build tools that can determine dependencies automatically, by running the compilers inside a sandbox (e.g. linux strace).

strace? I was under the impression strace is used to monitor system calls, how does this related to compilers inside a sandbox?

It's not technically a sandbox, but monitoring syscalls is very closely related.

Re: The Makefile I use with JavaScript projects

#178
I used make heavily in the 80s and 90s, but haven't much since then. Recently I started a project that had source files getting processed into PDF files, for use by humans. Since this is the 21st century, those files have spaces in their names. At a certain point, I realized that I should be managing this processing somehow, so I thought of using a simple Makefile. A little searching reveals that the consensus on using make with files with spaces in their names is simply "don't even try." In the 21st century, this is not an acceptable answer.

Re: The Makefile I use with JavaScript projects

#179

Earlier quoted context omitted.

It's not like C is famous for having particularly good syntax. If anything, it's the worst thing about it.

Isn't C just following the syntax of ALGOL? Or are we referring to the parts specific to C?

C is a simpler Algol, yes. It messed up the dangling-else problem, and lost nested procedures, among other things.

Re: The Makefile I use with JavaScript projects

#180

Earlier quoted context omitted.

They don't though. Vanilla Vim/Vi doesn't for instance. Regardless of whether the editor can or not, I just don't see how insisting on tab and not space is remotely defensible.

> Vanilla Vim/Vi doesn't for instance. Vim does handle this. Here is Vim (and I've removed my .vimrc file, so this is not a setting I have set personally), on a Makefile where the third line erroneously uses spaces: https://i.imgur.com/xMHXeL4.png > I just don't see how insisting on tab and not space is remotely defensible. This is like insisting that people haven't been having religious wars over this sort topic for…

If someone is really paranoid about white space issues in a file you’re editing on vim, you can can always use `:set list` to display those characters.
Post reply on HN