You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Shubh Karman Singh, golan...@googlegroups.com
I've been programming for more than four decades. In that time I've personally rewritten three apps in a different language. I've also read several post translation reports for other projects. The most important lesson is that it is usually a mistake to perform a literal translation. In fact, of the rewrites I've participated in or read about a literal translation was appropriate in only one case. That was the first one I ever did: translating Donald Knuth's TeX typesetting program from Pascal to C.
I haven't written any Javascript in over a decade. But translating its async API pattern to idiomatic Go is likely to involve starting a goroutine for each async op and having the goroutine communicate a result via a channel. For your second question, yes, functions are first-class objects in Go and can be passed to other functions to perform a specialized operation or act as a callback.
--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
Konstantin Khomoutov
unread,
Nov 6, 2022, 5:43:24 AM11/6/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
While my exposure to programming is twice as less than that of Kurtis,
I would like to support his view on this.
The chief idea of Go's concurrency is that it's integrated into the language's
code - as opposed to be bolted on in form of a library, as is the case with
most other popular programming languages out there. This is one of the reasons
why you don't see many callbacks in idomatic Go code: they are either not
needed or their functionality is implemented via sending values via channels
and a set of patterns involving them (see [1, 2, 3]).
For a good and fun overview of that "in core" vs "as a library" distinction
please see [4].