0

Context

To level set, I've been working with OOP and FP for my whole career, so my experience with the imperative paradigm is limited. The team I joined is made up of very senior (20+ years xp) imperative programmers using a domain specific language - think Pascal. The team is challenged to try new things (not the focus of this question). I've been tasked to architect a system for an asynchronous problem.

Question

Currently, the team uses something to the equivalent of Thread.Sleep to handle the asynchronous bits, but that leads to all sorts of bugs.

From what I gather, since imperative programming works using step-by-step instructions, it appears that polling is probably the main way of solving asynchronous problems. In general, what are the other techniques used to solve asynchronous problems using an imperative paradigm?

Attempts

I introduced the team other tools like callbacks, promises and events in the hopes that I can change the language, but unfortunately, they found it overwhelming. I'd like to build a system that plays to the team's strengths, but slowly nudges them in the direction to change how they approach asynchronous problems.

1 Answer 1

1

Assuming that your DSL has the required low-level primitives (mutexes, semaphores, an efficient select-like API etc), you can in theory implement almost anything you like; some incredibly efficient asynchronous programs have been written in C since time immemorial with nothing more than those constructs.

However, the reason that people moved away from these low-level constructs towards higher-level constructs (callback, promises, the actor model or whatever else) is not because you can't write this kind of program with those low-level constructs, but because it is notoriously hard to write correct programs with those low-level constructs.

I would strongly recommend that you get your team to use those higher level constructs, even if they find it overwhelming today. If your team don't want to/can't learn new skills, that's a different issue and one you probably have to discuss with your management.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.