Idea No. 19: A Programming Language That Is Thread-Safe By Default

At their most basic, and by default, programming languages are not thread-safe. Programs written using these program languages are also not thread-safe by default. Thus, in order to create thread-safe programs, programmers must apply extra steps to ensure thread safety -- and these features must be specially provided and supported by the language. Now, what if a programming language is thread-safe by default?

In order for a programming language to be thread-safe, all of its variables should be volatile. Thus, all access to type instances should assume that the state/value is the most current. It can also mean that every change should be handled accordingly, appropriately and immediately. This is perhaps the most dangerous feature. It is also the most important. For example, all of the other features of the programming language should be able to detect and recognize changes that may, or may not, affect a current flow.

All collections (lists, dictionaries, enumerables, etc.) should be inherently thread-safe. Thus, even if thread safety is not a concern, the collections would still be thread-safe anyway. As the program matures and become more complex or demanding, the program is just ready to multi-thread.

Async/await, parallelism, and multi-threading are natural to the programming language's loops, control flow and data flow (pipeline) constructs. Producer-consumer and pipeline patterns are therefore common practices. Thus, programmers using this programming language are always in the discipline of thinking in parallel or multi-threaded scenarios. Even if the developer is not trained so, the programming language will naturally guide him/her to consider thread-safety first.

Fluent interface patterns may also be a feature of this programming language, which allows for constructs to be expressed in left-to-right, top-to-bottom readable narrative when programming chains or sequences of events and/or operations.

Built-in behaviors to handle cancellations, exceptions and other aspects/events that can affect threads ensure the integrity of all processes. Developers have access to customize or extend these features.

Synchronous and single-thread patterns are supported via special commands provided by the programming language.

If such a programming language can be created, what features do you think it should have? What problems can it create or solve? How should it support debugging, logging and testing? Share your thoughts...

Comments