Live data from Hacker News

The Makefile I use with JavaScript projects

olioapps.com

411–420 of 525 posts

Re: The Makefile I use with JavaScript projects

#411

Earlier quoted context omitted.

On the command line, using spaces to delimit words is also quite natural; that's why they get used as a delimiter: mv old-file new-file Spaces separate the verb, the direct object, and the indirect object. Using commas or colons instead would painfully artificial. So the question is whether you will favor naturalness on the command line or in the GUI. It's no surprise that a Unix build tool favors the command line.

What if your file system didn't distinguish between underscores and spaces, your GUI displayed them as spaces, and your command line displayed underscores? Then this problem goes away entirely and you instead have the problem of not being allowed to have "this_file" and "this file" in the same directory. A problem which probably doesn't matter.

That hides the problem from the user, and will consequently lead to command line users typing spaces where they should be typing underscores.

Re: The Makefile I use with JavaScript projects

#412
post #399
post #387

Earlier quoted context omitted.

And how would you use that in a makefile?

Something like this would be ideal. /mnt/sql/myjoin: echo " " > /mnt/sql/myjoin It's just representing writing and reading a database as file operations, they map pretty cleanly. Keep in mind that Plan 9 has per process views of the namespace so you don't have to worry about other processes messing up your /mnt/sql.

I think you're missing the point. I have a workflow where I have to perform some action if the result of a join on a DB meets some criterion. How does "make" help in that case?

Re: The Makefile I use with JavaScript projects

#413
post #360

Earlier quoted context omitted.

You can do it. The question is whether you should if you can avoid it. When writing a shell script or makefile to deal with repetitive tasks if is easier to assume some things.

I'd prefer it if the writer of the shell or make didn't make too many assumptions about my assumptions. Even bash lets you escape unusual filenames for when you need them. Make will always explode your strings, and doesn't even attempt to let you escape them. I don't think it's unreasonable to expect a time-tested Unix tool dealing with files to actually handle all possible files.

So in order to deal with the real world possibility of spaces in filenames you choose to ditch a real world, useful tool?

Perfectly reasonable if spaces in filenames are a hard req.

In lots of scenarios they are not, and I prefer to assume that filenames have no spaces, and stick to make.

Re: The Makefile I use with JavaScript projects

#414

Earlier quoted context omitted.

> Meanwhile over in Windows land, all tools have been expected to deal with spaces in them for what is approaching 20 years. That is an excellent example that deserves a second look from a different aspect. ... it has trained a crop of computer users that are afraid of command lines and with an attitude of anything beneath the GUI interface is owned by and of someone else's problem. They are scared of computers more…

> it has trained a crop of computer users that are afraid of command lines and with an attitude of anything beneath the GUI interface is owned by and of someone else's problem. There is nothing beneath the Windows UI interface. The GUI is the primary subsystem of Windows, the command line is a separate subsystem. Windows has traditionally been built up around the Win32 API, which is GUI first. It is of course possibl…

> There is nothing beneath the Windows UI interface.

> Windows has traditionally been built up around the Win32 API, which is GUI first.

What did I just read?

Re: The Makefile I use with JavaScript projects

#415
post #390

Earlier quoted context omitted.

Why do it from a makefile instead of a script called by the makefile? This plays well to the strengths of both.

Just because of the dollar? Exactly my point.

No, not just because of the dollar. Because it's easier to test in isolation and allows you to use things like here docs which are useful for dealing with sql.

Re: The Makefile I use with JavaScript projects

#416
post #311

Earlier quoted context omitted.

I'm intrigued. Your first name has two spaces in it? That is, I think it is safe to say that we expect we can include spaces in the names of things. The movie is named "Star Wars", after all. That seems natural. For people, though, we have grown used to someone having multiple parts of their name separated by a space. If given out of order, a comma. Even in the "naming things" category. We are used to having to put q…

> I'm intrigued. Your first name has two spaces in it? No. But my name does. > For people, though, we have grown used to someone having multiple parts of their name separated by a space. If given out of order, a comma. https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-...

Ok. Something about the way I read the first post, I thought you meant your simple name. No reason it couldn't have spaces. My wife knew of someone named 1/2. Insisted it be a single character, too. Was amusing how hard that was for most payroll systems.

And I wasn't saying this isn't allowed. What we are used to is not the total of what is allowed. The fringes are full of mistakes, though. At some point, you make a statistical choice.

Re: The Makefile I use with JavaScript projects

#417
post #306
post #291

Earlier quoted context omitted.

I'm bemused by this repeated insistence that supporting colon in file names is somehow difficult.

Who on earth insists that? Only Windows programmers, I expect! But it's easy: make sure they're expressible in your syntax, then pass them through as part of the file name. Just like spaces. If there's a problem, you'll get an error back from the OS.

Yes, of course you're right. My apologies, it was a stupid comparison.

Though I still feel it's a bit of "choose your poison". In any language, certain symbols will have special meaning. You pretty much have to pick which ones, and come up with rules about how to let their natural meaning bleed through. With unix shells, one such character is the space, and there's a number of rules about how to let their natural meaning bleed through - but they're all somewhat awkward, and they all need special care.

Re: The Makefile I use with JavaScript projects

#418
post #187

Earlier quoted context omitted.

> 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.

But it's not true that everything is a file. A row in a relational database, for example, is not a file, even in unix.

> A row in a relational database, for example, is not a file, even in unix.

Says who? Nothing stops you from creating an interface that maps that row to a file.

That's the whole point of Unix.

Heck, look at the /proc filesystem tree. Even cpu sensor data is available as a file.

Re: The Makefile I use with JavaScript projects

#419
post #412
post #399

Earlier quoted context omitted.

Something like this would be ideal. /mnt/sql/myjoin: echo " " > /mnt/sql/myjoin It's just representing writing and reading a database as file operations, they map pretty cleanly. Keep in mind that Plan 9 has per process views of the namespace so you don't have to worry about other processes messing up your /mnt/sql.

I think you're missing the point. I have a workflow where I have to perform some action if the result of a join on a DB meets some criterion. How does "make" help in that case?

In that case, it doesn't help much. For Plan 9 mk, there's a way to use a custom condition to decide if the action should be executed:

    rule:P check_query.rc: prereq rules
        doaction
Where check_query may be a small shell script:

     #!/bin/rc

     # redirect stdin/stdout to /mnt/sql/ctl
      /mnt/sql/ctl {
            # send the query to the DB
            echo query
            # print the response, check it for
            # your condition.
            cat `{sed 1q} | awk '$2 != "condition"{exit(1)}'
     }
But I'm not familiar with an alternative using Make. You'd have to do something like:

    .PHONY: rule
     rule: prereq rules
          check_query.sh && doaction

Re: The Makefile I use with JavaScript projects

#420

Earlier quoted context omitted.

> 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.

Sometimes things in workflows are sending/retrieving data over a network. It may be turning on a light. It could be changing a database. Make has no way of recognizing those events unless you've tied them to your file system. Do you really want an extra file for every entry or table in a database? It becomes fragile and error prone. A real workflow system should use a database, and not the filesystem-as-database.

> Sometimes things in workflows are sending/retrieving data over a network. It may be turning on a light. It could be changing a database. Make has no way of recognizing those events

Why should Make violate basic software design rules and fundamental Unix principles? Do you want your build system to tweak lights? Setup a file interface and add it to your makefile. Do you want your build system to receive data through a network? Well, just go get it. Hell, the whole point of REST is to access data as a glorified file.

Post reply on HN