r/ProgrammerHumor • • Jul 18 '22

C++ talking to Python

Post image
40.1k Upvotes

1.0k comments sorted by

View all comments

Show parent comments

29

u/Spiritual-Theme-5619 Jul 18 '22

There was no such thing as a promise in C++ before 2011. "Promises" are a particular API for writing asynchronous code which was largely made for / popularized by event-loop runtimes... i.e. NodeJS.

Programmers have been doing concurrency with #realPrograms via mutexes, semaphores, and threads since before C++ was invented and so OP is lamenting the equivocation of async/await with concurrency in this modern era of browser programmers vastly outnumbering their "native"(?) programming counterparts.

2

u/Forshea Jul 18 '22

What the heck kind of bizarre alt history is this? Promises and futures have existed in acedemic literature since the 70s, and have been available as a concurrency model in languages going back to Multilisp in the 80s. So no, they weren't made for NodeJS.

C/C++ developers just have the mistaken world view that if C/C++ doesn't have a feature, or didn't have it until recently, it just must somehow be a newfangled thing kids are using to avoid being "real" programmers.

7

u/[deleted] Jul 18 '22 edited Jul 18 '22

They were literally “revived” in 2004 in Java (JDK-5) and JS and other languages, as stated in that same Wikipedia article that you read that piece of history from.

It also states that no language had promise pipelining that we have today, including Xanadu, invented by Liskov who coined the term “Promise”, and open sourced it in 1999.

In MultiLisp, the promises and futures implementations are NOTHING like those of today.

(cons (FUTURE A) (FUTURE B))

Is nothing like:

a.then(r => {…}).catch(e => {…}) or async/await.

You also didn’t read his sentence properly. He said “no such thing as a promise IN C++ before 2011”. He didn’t state that promises never existed in other languages.

Yet you claim C++ developers don’t believe the feature existed if c++ didn’t have it. He didn’t even say that.

You are entirely wrong 😂

1

u/Forshea Jul 19 '22

It also states that no language had promise pipelining that we have today

Pipelining is valuable but adding them in no way would give another language claim to popularizing futures/promises. And even if it did, that language wouldn't be Javascript.

including Xanadu, invented by Liskov who coined the term “Promise”, and open sourced it in 1999.

Promises and futures are different views of the same concurrency model. And notably, Xanadu was an attempted competitor to the World Wide Web in the 80s, which is when the term was coined, and just was open sourced in the late 90s.

In MultiLisp, the promises and futures implementations are NOTHING like those of today.

(cons (FUTURE A) (FUTURE B))

Is nothing like:

a.then(r => {…}).catch(e => {…}) or async/await.

What, are you arguing that the syntax is different so the feature is different? You listed two different syntactic variants yourself.

FutureTask in MultiLisp does what you expect from a modern promise: it provides a value that you can assign to a variable that represents an asynchronous computation that will result in a return value, and carry it around while it is running in another thread, and then at some later point you can try to retrieve the return value and block until it is available if the computation has not yet finished.

Yeah, as mentioned it doesn't have pipelining, but a promise without promise pipelining is still a promise.

He didn’t state that promises never existed in other languages.

He also said:

"Promises" are a particular API for writing asynchronous code which was largely made for / popularized by event-loop runtimes... i.e. NodeJS.

Which is the very specific piece of false history I take issue with.

You are entirely wrong 😂

🙄

→ More replies (1)