4 ms·
And I completely agree with you here. The progress in programming language design is going to come from eliminating human unfriendly syntax. The closer you can
by joe_the_user 16y ago
And I completely agree with you here.
The progress in programming language design is going to come from eliminating human unfriendly syntax. The closer you can get to something that let's someone express their intentions without restrictions, the better. The computer is, uh, servant of a human.
There are many barriers in the way of programming languages or computers in general adapting to human functioning. But whenever someone takes the line that says humans must-adopt-to-computers, it is a fail. And that fail is going to be swept away by the next technology which just works.
- antichaos 16y agoProgramming languages force programmers to think clearly and express ideas unambiguously. It's not a bad thing we should avoid; it helps us write robust software.
- Zak 16y agoBoth points are valid. Programming languages should be designed for people to use, and only secondarily for machines to execute. However, they should be designed so as to encourage clear expression of ideas when practical. I think whether a general-purpose language should discourage or prevent unclear thinking is an open question. I don't think I've seen an example of a language doing so without being somehow crippled, and that's a Bad Thing.
- binaryfinery 16y ago" Programming languages should be designed for people to use" Exactly. Which means that it must be tool friendly, hence LALR/LL(k). Unless you want to do all your refactoring yourself.
- singular 16y agoI don't think LALR/LL(k) implies automated refactoring is easy and anything else does not!! Obviously non-context-free grammars are a problem, but a GLR or PEG grammar is still perfectly refactorable. You forget that refactoring an intuitive grammar to LALR involves totally mangling that grammar and making it more difficult for everyone. If the language is expressed as a GLR or PEG grammar then tool makers have it easier I reckon - easier to understand grammar. The way to really ensure it's easy for everyone is for the compiler write to provide some abstract yet intuitive representation of the underlying grammar. It really isn't an either/or, it's a case of both at once, I think!
- binaryfinery 16y agoI think you hit the nail on the head there. "Context-free" is more of a requirement than LALR or LL. The author clearly isn't a parser writer. I am, but I've yet to try a PEG grammar because ANTLR does such a great job. But this doesn't change his point (or mine): languages should be created that are easy to write parsers for, so that its easier to write good tools. And I think this applies to the grammar too: ANTLR's .g files are a good grammar language because its easy to write tools for - hence AntlrWorks.
- beza1e1 16y agoI'm the author and i did write some parsers. However i'm more in the write-parser-by-hand camp and context-free is not so hard here. ANTLR needs strange hacks to parse Python with its whitespace indentation. A handwritten parser just needs some context within the lexer. In my eyes a parser generator is the solution, if you want to trade efficiency for cross-language-portability. ANTLR is probably the best solution at this point, though the C backend is quite wierd.
- binaryfinery 16y agoI like to get shit working first, and then downcode if the PG does a horrible job. Nothing better than a hand-written anything, but I like the options of tools. Stange hacks for python supports your original argument I believe.
- joe_the_user 16y agoThere's no language of higher order than machine code that allows you to specify computer behavior unambiguously (even that's doubtful). In fact, any entity abstract enough to be called "an idea" is going to be ambiguously specified. The question is what sort of ambiguity is most useful - ambiguity about about which object shows itself on the screen is great in an object-orient window manager. Ambiguity about which memory location to read when dereferencing an uninitialized pointer is less useful.
- brazzy 16y agoThe progress in programming language design is going to come from eliminating human unfriendly syntax. The closer you can get to something that let's someone express their intentions without restrictions, the better. The computer is, uh, servant of a human. And a servant isn't very useful if he can't understand its master. Ignoring machine-friendliness in language design just leads to worse and more buggy tools (including compilers). whenever someone takes the line that says humans must-adopt-to-computers, it is a fail. And that fail is going to be swept away by the next technology which just works. Except the "just works" is far more likely to be actually achieved if it's easy to make it work as well as easy to understand. Besides, "human-friendly vs. computer-friendly" is a false dichtomy. There are certainly things that are good for one and bad for the other, but language features can also be good for both, or very good for one while incurring very small disadvantages to the other.
- singular 16y agoBut don't forget that we don't have to limit ourselves to LALR or LL(k). Approaches like GLR allow the user to be happy as well as the tool writers. And again, don't forget, the tool writers have a harder time if they have to mangle their grammar to fit LALR, then write a bunch of hacks around it to get stuff to work. Working around an algorithm which can't express usable languages properly is a bit silly I think. It's better to improve the algorithm in the first place and keep everybody happy!!
- beza1e1 16y agoI do not know a single editor which does syntax highlighting by actually parsing (including semantic analysis) the code. Most of them use regular expressions at most.