News for hackers. Stuff that matters.
Re:On the Complexity and Performance of Parsing with Derivat... by zeroxfe on Saturday June 25, 2016 @02:24PM (#11977363)
> Text parsing for programming languages is NOT a difficult problem.

That depends entirely on 1) what grammar you're parsing, 2) what memory pressure you're in, 3) how fast you want to do it, and 4) how comprehensive you want the error handling. It's actually quite difficult to parse C++ on a low-memory embedded device without resorting to clever techniques.

Re:On the Complexity and Performance of Parsing with Derivat... by kazinator on Sunday June 26, 2016 @10:10AM (#11980841)
Ideally, you don't even target a low-memory embedded device with C++, let alone process C++ on it.

Anyway, C++ is just a strawman that seems to have been contrived deliberately in order to wreck most of the rational arguments defending "programming languages are easy to parse".

Parsing as programming language is exactly as difficult as the hole we dig ourselves into. Programming language parsing isn't some information processing problem that exists in the world, or in another domain, that computer science is tasked with to solve; it's a problem that computer scientists and software people inflict on themselves.

By making languages hard to parse by machine, we are also making them hard to use by humans. Humans need to parse the language also, and not have a magic oracle for doing so. (Indentation only goes so far, and can tell a lie).

Still, there aren't actually difficult problems in parsing C++. It's more of a "death by a thousand blows". There is just the sheer size of it alone. The C++ parser source file in GCC is larger than some programming language implementations: their parsers, interpreters/compilers and all intrinsic routines combined. It's hard to comprehend the C++ grammar so that you can identify where the ambiguities lie, and form a strategy to deal with them, so as not to be surprised later.

Re:On the Complexity and Performance of Parsing with Derivat... by wofo on Saturday June 25, 2016 @02:45PM (#11977438)
> It's actually quite difficult to parse C++

This is a specific problem of C++ though, given the fact that its grammar is extremely complex.

Re:On the Complexity and Performance of Parsing with Derivat... by comex on Saturday June 25, 2016 @02:56PM (#11977492)
I'm pretty curious what kind of project gave zeroxfe experience with parsing C++ on low-memory embedded devices.
Re:On the Complexity and Performance of Parsing with Derivat... by chubot on Saturday June 25, 2016 @02:52PM (#11977473)
It also depends on what functionality you want your parser to support. In theory, parsing just means "accept or reject". In practice, you need to do something like build a tree, and there are many different possible tree representations depending on what you want to do.

Clang aims to support very general transformation of C++ with their parser and AST. I was shocked to learn that Clang's AST has 60K lines of header files! That's not including the code, and it's not templates! That's class definitions!!! (wc -l include/clang/AST/*.h)

Re:On the Complexity and Performance of Parsing with Derivat... by sklogic on Sunday June 26, 2016 @03:11AM (#11979749)
This is not because of a parsing complexity, it is only because C++ is an awful language for writing ASTs and parsers. Without all the boilerplate, an AST can be much smaller.
Re:On the Complexity and Performance of Parsing with Derivat... by ksk on Monday June 27, 2016 @06:19PM (#11989974)
You haven't said much, because you can say that about anything. "Drinking water from a glass is a hard problem when you have to drink it through this straw that is 1 mm wide and you're blindfolded"

> It's actually quite difficult to parse C++ on a low-memory embedded device without resorting to clever techniques.

Compiling C++ programs on low-memory embedded devices is not a mainstream use-case. Unless you can demonstrate that it is, your point is moot.

Re:On the Complexity and Performance of Parsing with Derivat... by sklogic on Sunday June 26, 2016 @03:07AM (#11979740)
Why would you parse C++ on a low memory device anyway? What are you going to do with it? Anything that follows the parsing would require far more memory.