Hacker News new | ask | show | jobs
by copsarebastards 4186 days ago
> The proof being that none of the more or less serious languages created in the past few decades dared to adopt e.g. begin ... end again.

facepalm Except Ruby, OCaml, Erlang, Lua, etc.

Frankly, if verbosity is a significant limiting factor on your creativity, a) C is not the solution to your problem, and b) you weren't trying to solve any hard problems anyway.

Seriously, if you're doing anything really hard, stuff like thread management and algorithmic complexity is a way bigger limiting factor than minor syntactic differences.

5 comments

Syntax limits everything, it only becomes more important as you're doing hard things. Being able to fit 10% more code on screen is a lot like being 10% smarter, which is the kind of thing you need to make the hard problems even possible.
"Being able to fit 10% more code on screen is a lot like being 10% smarter"

Makes me wonder how I ever wrote anything on a 80x24 serial terminal in the 1980s....

i used to switch our Vt100's to 132 line mode
> Syntax limits everything, it only becomes more important as you're doing hard things. Being able to fit 10% more code on screen is a lot like being 10% smarter, which is the kind of thing you need to make the hard problems even possible.

Yes, syntax limits everything, and being able to fit 10% more on the screen is a lot like being 10% smarter. But libraries, available techniques, and built-in features limit everything a lot more. Being able to do 500% more with the same amount of code is a lot like being 500% smarter. If you're piddling around with 10% increases like a switch from Pascal to C, you're wasting everyone's time. Switch to a higher-level language that's more closely suited to the problem you're trying to solve and you'll trivially be writing a fifth of the code you'd be writing in C[1]. So like I said: C is not the solution to your problem.

And that's being generous to your assumption that Pascal -> C actually even does give you a 10% boost: I think given that you'll be writing the same bounds-checking incantation everywhere in C which you wouldn't be writing in Pascal, the semantics probably negate the syntax very easily.

[1] There's one exception: where C is the language most closely suited to your problem. However, this exception is much more rare than most people think.

What is a hard thing that requires better syntax?

I would argue that hard things require clarity, and syntax can often reduce clarity.

I think this is all somewhat related to how much you can keep in your head at once. More code -> less expression -> less that you can keep in your head -> you can solve smaller problems.

If a problem requires that you keep all of it in your head then being able to express that problem concisely will aid in solving it.

The poor mans solution is to reduce the scope: chop the problem into sub-problems that you can solve individually.

Divide and conquer is the most powerful tool in a programmers arsenal because it allows you to use the worst languages to solve some of the most complicated problems.

But there may be a subset of problems where that strategy no longer works and for those problems the more compact languages may have a very strong advantage.

It's a double-edged sword, though : your compact, clever solution is great when your write it but becomes unreadable when you (or worse, someone else) tries to maintain it. And then you have to understand both the hard problem and the way it was solved in the first time.
The main way to make code genuinely shorter is to actually make it simpler; replacing logic with a higher-order function call (e.g. map rather than a loop) makes it more readable and maintainable, not less. Or if we're talking about meaningless syntactic clutter like the extra lines of begin/end, they don't make the code any clearer.
> What is a hard thing that requires better syntax?

Any thing where, for the implementation you can come up with, those extra lines are the difference between fitting a function on a single screen or not. There's a huge difference in readability between a function or class that can fit on a single screen and one that can't.

To be fair Pascal is more "wider" than longer compared to C, but still it takes more time to read.
By that reasoning APL should rule, so there may be some kind of optimum.
t may just be that the learning curve for APL is so steep and so long to become truly proficient that most don't get there. I've long held the opinion that much of the criticism of Perl as "line noise" is more to do with people that aren't really proficient in it thinking they are because a subset of the language is very C-like and familiar, and it can be used for quite a while before encountering anything too foreign to someone that knows C. Once that happens though, it leaves those people scratching their heads wondering what they are seeing.

Compare and contrast to APL and Lisp, which are obviously different, and Python, which avoids the problem by having a fairly different syntax and a guide for exactly how to do things.

I've seen some pretty amazing things in APL, but I can't really understand them. I don't count that against the language, I just haven't spent the time to actually learn APL.

As for there being an optimum, I think there is, but I think it has a lot to do with how long and for how complex of things you plan to use the language. Front-loading learning time for a more expressive language may pay dividends later.

With regards to complexity theory, I'm inclined to assume that syntax is a constant factor in the equation. You only have to extend the language by writing a macroprocessor once, if you count that to the power of the language. That's why C is still very powerful, although other langs have half an STD-Lib toolbox hidden in syntactic sugar.
Erlang wasn't exactly created in the past few decades (1986), neither was OCaml (a successor to 'Caml', dating back to 1985 or so).
I agree. I don't understand the programmers who debate syntax all the time. Good syntax is important, but appropriate semantics are more important. Only after you've selected the typing, execution environment, memory model, paradigm support, available platforms, and libraries you need, should you worry about syntax. At that point there are usually 0 or 1 satisfactory languages.
The other day I was surprised to learn that the equals sign was invented in 1557. I wondered what the hell everyone did in algebra before then, and it turned out that a lot of the earliest examples of algebra are essentially word problems.

By the time the equals sign was invented, it was commonplace to use the abbreviation "aeq." for equality, for "all equivalent (or equal) to".

But the equals sign turned out to be a really important development in mathematics, because it helped to visually distill mathematics down into just their number and equation components, without the visual noise of written words.

So I wouldn't be too quick to discount the value of good syntax. I've never personally cared much about it in the past, but looking at it from the point of view of the equals sign, it's probably fair to guess that syntax does a lot more for code clarity and readability than we think.

Good point. Boole boosted logic the same way.

a ∧ (a → ¬b) → ¬b

is easier to reason with than

Socrates is a man, no man is immortal, therefore Socrate is not immortal.

Very few people actually have hard problems to solve.
Frankly, if verbosity is not a limiting factor for you, then you weren't trying to solve hard problems in an elegant way.