Remix.run Logo
▲ amelius an hour ago

Javascript is actually a great language. Its garbage-collected closures made it easy to do GUI programming.

The C/C++ world where browsers came from didn't have this (closures). So it is actually a miracle we got a language as (relatively) great as Javascript.

▲torginus 40 minutes ago | parent | next [-]

Each to their own I guess, by personally I really don't like closures (at least ones that as per their namesake, close over objects with nontrivial lifetimes).

I think it was the right call by the C++ people to explicitly list what objects are captured and how, even if the syntax's not the best.

RAII is a fact of life unfortunately, not just in C++ or Rust, but if you talk over some high level protocol over the internet you go TCP socket->HTTP connection->your stream protocol; and have to do the exact reverse.

Closures break RAII hard.

Incidentally, you don't even need closures for nice looking UI code. Immediate mode GUIs like Dear Imgui or Clay allow for super-simple looking code in basic C

▲baq an hour ago | parent | prev | next [-]

It was a missed opportunity for a mature language like Scheme which had at the time all the good parts, none of the bad parts and the only issue was slightly unfamiliar syntax.

▲egeozcan 8 minutes ago | parent [-]

I like Scheme syntax but someone coming from a C-syntax background can easily understand this in the first look:

const add = (a, b) => a + b;

And may need to read this a couple of times because of the lone "+" and the parentheses:

(define (add a b) (+ a b))

... and this is the simplest of examples. It's not slightly unfamiliar syntax. Perhaps Rust is slightly unfamiliar syntax, if we mean really just the syntax - as in, you can tell where the functions start and end.

You could also say that Scheme has very little syntax, for example, no distinction between statements and expressions, no operator precedence, and nearly zero reserved punctuation. So I'd argue that it needs more adaptation because it is less.

▲raincole an hour ago | parent | prev [-]

> garbage-collected closures

A feature existed since 1960s...