L
Forgot the xkcd explanation:
http://www.explainxkcd.com/wiki/index.php?title=1270
Ugh. (a) Does the a.f.c. crowd need functional programming explained,
and (b) is a joke funnier when it's analyzed into its components?
Jorgen Grahn said:[1] Or /were/ fashionable 20 years ago. I have some indications that
they are more interested in point-and-click programming nowadays.
I don't see what this has to do with C, though.
Forgot the xkcd explanation:
http://www.explainxkcd.com/wiki/index.php?title=1270
Ugh. (a) Does the a.f.c. crowd need functional programming explained,
and (b) is a joke funnier when it's analyzed into its components?
I studied at gu.se where functional languages and research into type
systems are fashionable[1]. Many students didn't get the point at
all. I did, and I think it's a good tool for teaching and for niche
applications ... but I still don't see how it applies to most
real-world problems, without simulating imperative programming and
ending up with the same problems. There's more to programming that
factorials and sorting algorithms.
Well, yes, but .... If the data you're working on is arranged in
some recursive form, it seems to me to be natural to process it using
recursion. Examples that come to my mind are filesystems and XML. ?
Forgot the xkcd explanation:
http://www.explainxkcd.com/wiki/index.php?title=1270
Ugh. (a) Does the a.f.c. crowd need functional programming explained,
and (b) is a joke funnier when it's analyzed into its components?
I studied at gu.se where functional languages and research into type
systems are fashionable[1]. Many students didn't get the point at
all. I did, and I think it's a good tool for teaching and for niche
applications ... but I still don't see how it applies to most
real-world problems, without simulating imperative programming and
ending up with the same problems. There's more to programming that
factorials and sorting algorithms.
/Jorgen
[1] Or /were/ fashionable 20 years ago. I have some indications that
they are more interested in point-and-click programming nowadays.
XML has a recursive definition, but the files themselves seldom haveWell, yes, but .... If the data you're working on is arranged in
some recursive form, it seems to me to be natural to process it using
recursion. Examples that come to my mind are filesystems and XML. ?
Malcolm McLean said:XML has a recursive definition, but the files themselves seldom have
nesting of arbitrary depth. So you can parse them slowly using a
general-purpose recursive descent parser, like the vanilla XML parser
(advertising feature, on my website). Or you can write a format
-specific parser, which will probably execute faster an in less memory
but which won't be recursive.
No, because typically it goes like this:Wouldn't that break as soon as you feed it an XML document that happens
to be one level deeper than what you anticipated?
Keith Thompson said:(snip)
Wouldn't that break as soon as you feed it an XML document that happens
to be one level deeper than what you anticipated?
The question is whether you need to parse recursively.Well, for one, when I program for a "known" small size I usually
round up, a lot. So if I expected a depth of three or four, I might
program for 10 or more.
However, one of the features of XML is that a parser should ignore
tags that it doesn't recognize. That allows for forward compatibility.
(New features to be added, without invalidating old programs.)
The new tags might have more depth, but if you properly ignore them,
you can parse them, and ignore them, without any problems.
Malcolm McLean said:The question is whether you need to parse recursively.
Say we've got xml like this:
<employee> Obama
<subordinate> Joe </subordinate>
<subordinate> Hilary
<subordinate> Bill
<subordinate> Monica </subordinate>
<subordinate> Socks </subordinate>
</subordinate>
</subordinate>
</employee>
It's hard to parse that non-recursively, because sub-ordinates can have sub-
subordinates in a whole hierarchy, we need to match the opens and closers.
But that's rare. Normally we'll want to present the data like this
<employee> Obama
<subordinates> Joe, Hilary </subordinates>
</employee>
<employee> Hilary
<subordinates> Bill </subordinates>
</employee>
<employee> Bill
<subordinates> Monica, Socks </subordinates>
</employee>
Given this, and given that our program understands employee names but not
hierarchies, we can just chug through ignoring the subordinate tags. We
don't need to keep track of anything except the closing tag.
XML is a sort of accepted standard for information exchange. IIf your data is not inherently recursive, perhaps XML is not the best
way to represent it.
I wrote a vanilla xml parser (http://www.malcolmmclean.site11.com/www).In any case, it seems wasteful to write a custom parser that handles a
*subset* of XML when there are so many open source full XML parsers out
there. A custom parser might be smaller in terms of total code size,
but a full parser is much smaller in terms of code *that you have to
write and maintain*.
Malcolm said:XML is a sort of accepted standard for information exchange. I
use if for the Baby X resource compiler, not because the data is
complex or recursive - essentially it's just a list of files to
pack into a compileable C source - but because it's easier than
defining a custom convention.
Whilst you can represent trees or other recursive structures in
XML directly, most XML files aren't like that.
I wrote a vanilla xml parser (http://www.malcolmmclean.site11.com/www).
There were other parsers available on the web, but I didn't like
any of them. The snag is that to support the full xml spec you need
lots of complex code, and then to load in a massive file you have to
devise a complex system for keeping most of it on disk. The XML people
call it a "pull parser". This is all overkill if you just want a crossword
file containing a 15x15 grid and maybe thirty one-line clues, or a
list of maybe a dozen files.
You can't give a program that depends on LibXML to a Windows userMalcolm McLean wrote:
LibXML is pretty universal. Any platform with PHP or (I think) Python
installed will already have it.
Malcolm said:You can't give a program that depends on LibXML to a Windows user
and expect them to compile it. The Windows machine I'm typing this
on doesn't have it. In half an hour I'll turn on a Linux machine
then it's as simple as typing "app-get". But the world doesn't use
Linux or corporate development Windows machines with all the bits
and bats installed.
Windows users might want the resource compiler. Probably not for WindowsMalcolm McLean wrote:
So you expect windows users to be using your X toolkit?
Seriously, if every piece of software that uses XML included its own
parser, half the programming world would be writing XML parsers. That's
why we have libraries.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.