4 ms·
I would much rather deal with an xml file than a makefile.
by GFK_of_xmaspast 10y ago
I would much rather deal with an xml file than a makefile.
- Annatar 10y agoXML files cannot be easily processed with standard UNIX tools like grep, sed, and AWK. XML requires specialized libraries and tools to process correctly, making it an extremely poor choice for... well, just about anything. It's a markup format for text, not a programming language. Building software is a programmatic process. No XML please! We're decidedly not on Windows, and since I have the misfortune of fitting such square pegs into round holes, please don't use XML for applications which must run on UNIX. It's a nightmare. It's horrible. No!!!
- qwertyuiop924 10y agoIf you must have structured data, use a lisp program. Congratulations on using a format that was designed to be executable. and if it's a build tool, you better believe it's executable. I suspect that Annatar is a Murray Hill purist (I don't know for sure), so he may disagree with me. Of course, like any real programming language, it's hard to process with regex, but then again, I don't want to process makefiles with regex. And you might have some luck coaxing AWK or the SNOBOL family to parse it, and it would be far easier than doing the same with XML. >please don't use XML for applications which must run on UNIX. It's a nightmare. It's horrible. No!!! I'd disagree with you there. DocBook, HTML, and friends, are all good applications of XML (or near XML), doing what XML was designed for: Document Markup. Seriously people, when you're writing a program in a language that has "Markup Language" in the name, does that not ring any alarm bells?
- GFK_of_xmaspast 10y agoAre you seriously suggesting that you can awk a makefile and get anything useful out?
- Annatar 10y agoWhy would I need to AWK a Makefile, when make will take macro definitions as arguments on the command line?
- GFK_of_xmaspast 10y agoYou were the one complaining that you couldn't awk an xml file in the context of "xml versus makefile".
- Annatar 10y agoNo, I wrote that XML for use in applications is bad, as it cannot be easily processed with standard UNIX tools. And it's most definitely bad for building software, as it is limited by what the programmer of the build software thought should be supported. A really good example of that is ANT/NANT. make, on the other hand, doesn't limit one to what the author(s) thought should be supported. Need to run programs in order to get from A to B? No problem, put whatever you need in, and have it build you the desired target.
- qwertyuiop924 10y agoYes. Don't use XML as an exchange format. Use JSON or DSV instead. Yes, I said JSON. JSON is very easy to parse, and you can grab unique key/values, which are most of them, with this regex: /(,|\{)\w*\"<key>\"\w*:\w*(.*?)\w*(,|\})/
- Annatar 10y agoPCRE. So now you have to use Perl? And what happens when your single JSON record spans multiple lines, and has recursive structures?
- qwertyuiop924 10y agoFirst off, I simply used some of PCRE for the syntax, as it's what I'm familiar with. \w could be easily replaced, and non-greedy matching is a relatively common extension. As for when your record spans multiple lines, with recursive structures, the previous regex is for extracting simple atomic data from a json file, which is usally what you want in these cases anyway. If not, the json(1) utility can, I believe, extract arbitrary fields, and composes well with awk, grep, etc.
- nradov 10y agoThere is no particular relationship between Windows and XML. And just to play devil's advocate, is the lack of XML support in grep, sed, and awk a problem with the data format or with the tools? Why can't we have new standard tools that operate on hierarchical formats such as XML / JSON / YAML? Current standard Unix tools have plenty of flaws and as forward thinking developers we shouldn't be afraid to replace them with something better.
- Annatar 10y agoI have noticed a particular relationship between Windows, Java, and XML: all Java programmers nowadays seem to come from Windows (and then I end up with ^M CR characters in all the text files, even shell scripts!), use Java, and write configuration in XML. YAML doesn't need any special tools - it's ASCII and can easily be processed with AWK, for example. I don't know about you, but the last thing I want is to have to have a whole new set of specialized tools, just so somebody could masturbate in XML and JSON. XML is a markup language. That means it's for documents, possibly for documents with pictures, perhaps even with audio. It's not and never was meant for storing configuration or data inside of it. XML is designed to be used in tandem with XSLT, and XSLT's purpose is to transform the source XML document into (multiple) target(s): ASCII, ISO 9660, audio, image, PDF, HTML, whatever one writes as the transformation rules in the XSLT file. XML was never meant to be used standalone. If you really want to put the configuration into an XML file, fine, but then write an XSLT stylesheet which generates a plain ASCII .cf or .conf file, so its processing and parsing can be simple afterwards. XML goes against the core UNIX tenet: keep it simple. Do you like complex things? I do not, and life is too short.
- mcguire 10y agoBut I'd rather deal with a porcupine dipped in curare than XML.
- qwertyuiop924 10y agoYeah, I mean, you CAN at least parse a porcupine dipped in curare with Regexes.