Arc Forumnew | comments | leaders | submitlogin
3 points by Pauan 4549 days ago | link | parent

Yes, and rocketnia's point is that this error code checking forces your code into something like SSA or three address code:

http://en.wikipedia.org/wiki/Static_single_assignment_form

http://en.wikipedia.org/wiki/Three_address_code

In other words, you usually won't see this in C, right?

  foo(bar(qux(1, 2, 3)))
Instead, you'd write it more like this:

  x = qux(1, 2, 3)
  if (x == ERR) {
    ...
  }

  x = bar(x)
  if (x == ERR) {
    ...
  }

  x = foo(x)
  if (x == ERR) {
    ...
  }
Because you don't have nested expressions, there's only a single way to indent the code. But in languages like JavaScript, method chaining and nested function calls mean that there's now multiple ways to indent the same code.

Thus, C's syntax isn't actually more uniform than Lisp, it only seems that way because of C's way of handling errors.



1 point by rocketnia 4549 days ago | link

That's exactly what I mean! Thanks!

Hmm, I'm losing track of my point. I prefer writing code so it models all errors explicitly, so I end up with that kind of verbosity in JavaScript too. I only get code like foo(bar(qux(x))) when I'm using lots of function calls that have no errors (or whose arguments can be errors).

EDIT: My use of the term "error code" came about because of this subthread on LtU: http://lambda-the-ultimate.org/node/4606#comment-73197. I probably didn't give the term enough context to have a clear meaning.

-----

1 point by nburns 4542 days ago | link

You've raised interesting issues. I think this thread has digressed a bit, though.

-----

1 point by nburns 4542 days ago | link

>> C's syntax isn't actually more uniform than Lisp

C's syntax is actually less uniform, isn't it?

C isn't a very sophisticated language, but it tends to be readable. At least in the sense of following the flow of control; perhaps things like error handling make it hard to see the forest for the trees.

There may be a fundamental law that the more underpowered the language, the easier it is to read. Sort of like how Dr. Seuss books are more readable than research papers on programming languages theory, right?

-----

3 points by rocketnia 4541 days ago | link

"C's syntax is actually less uniform, isn't it?"

I don't think Pauan was referring to C syntax as a whole. In this subthread, I think we've been specifically talking about whether certain languages have a "single, canonical" indentation style that "falls out naturally."

---

"There may be a fundamental law that the more underpowered the language, the easier it is to read. Sort of like how Dr. Seuss books are more readable than research papers on programming languages theory, right?"

In one sense that's true, since it's easy to make naive improvements to one feature while neglecting another. In another sense, a less readable language is always relatively "underpowered" due to its greater difficulty to use (assuming it's a language we use by reading :-p ).

-----

1 point by nburns 4540 days ago | link

I think C is a great language. It maps straightforwardly onto to the capabilities of the hardware. What I meant by calling it underpowered is that it doesn't do much to increase your power beyond freeing you from having to write assembly language.

Higher order functions and metaprogramming are the sort of things I associate with a powerful language, like Lisp. But sometimes things get so abstract you can't tell what you're looking at.

As you point out, it's easy to ruin something like a programming language while trying to improve it. (I haven't created a programming language, but I've used bad ones.)

I respect C for not trying to be too smart.

-----

1 point by akkartik 4540 days ago | link

> "There may be a fundamental law that the more underpowered the language, the easier it is to read."

That's a lot stronger claim than your original :) Aren't python, ruby, and haskell all high-power but easy to read?

There's the confounding effect of learnability; lisp gets more readable over time. There's also the confounding effect of density or difficulty. This quote captures both:

"If you're used to reading novels and newspaper articles, your first experience of reading a math paper can be dismaying. It could take half an hour to read a single page. And yet, I am pretty sure that the notation is not the problem, even though it may feel like it is. The math paper is hard to read because the ideas are hard. If you expressed the same ideas in prose (as mathematicians had to do before they evolved succinct notations), they wouldn't be any easier to read, because the paper would grow to the size of a book." (http://www.paulgraham.com/power.html)

-----

2 points by nburns 4536 days ago | link

I seem to have overlooked this post until just now...

Incidentally, I've never written python, ruby, or haskell, except for a tiny amount of python.

Good quote. I've been reading a lot of computer science papers lately, and I tend to skip over the math formulas and focus on the text. This could be because I'm reading them for "fun" and not because I have to for a class, or something. But I have always found it hard to take in dense notation, and preferred a conceptual argument. Maybe it's just that I have a deficiency in that area. But I think prose has the potential to carry powerful insights that are out of the reach of formulas; I suspect the problem is that succinct, brilliant prose is just incredibly hard to write. It's probably easier to just list formulas than to get deep ideas into prose. The reverse is also true, of course. Some ideas can only be expressed properly with notation.

But that probably has nothing to do with programming language syntax per se.

-----

1 point by rocketnia 4535 days ago | link

"I've been reading a lot of computer science papers lately, and I tend to skip over the math formulas and focus on the text."

I do that too. :) Unfortunately, at some point it gets hard to understand the prose without going back to read some of the fine details of the system they're talking about. XD

-----

2 points by nburns 4535 days ago | link

I tend to jump around. The introduction is usually boilerplate for the particular area of research, so it can be skipped. (I wonder how many different papers have told the story of the memory hierarchy and how it's getting more and more important as data gets bigger.) Then I try to figure out if the paper has anything important to say, before working on the math. I figure that sometimes the big idea of the paper is in the math, and other times, the big idea is in the text, and the math is just obligatory. (You can't publish a paper on an algorithm without spelling out the precise bounds on time and space, even if the formula contains 15 terms. Not all 15 terms can be important to the performance, but it certainly is important to put them in the paper.) I guess it depends on the field, but in the data structures papers I like to look at, it usually doesn't take a lot of math notation to express the key innovation.

-----

1 point by akkartik 4535 days ago | link

"But that probably has nothing to do with programming language syntax per se."

Why do you say that? Syntax is notation. Check out this paper by the guy who invented APL, when they gave him his Turing award: http://awards.acm.org/images/awards/140/articles/9147499.pdf

-----

2 points by nburns 4535 days ago | link

I don't disagree with you. I was arguing for the value of well-written prose.

Donald Knuth thinks that programs should be more like prose (http://en.wikipedia.org/wiki/Literate_programming) -- not that I've ever tried, or fully understand, literate programming.

-----