Author Topic: event-oriented programming language  (Read 21417 times)

0 Members and 1 Guest are viewing this topic.

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5087
  • Country: gb
event-oriented programming language
« on: January 02, 2023, 10:58:14 pm »
Let's discuss here (if it's possible/reasonable) this interesting idea.

How should it be? :D
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DC1MC

  • Super Contributor
  • ***
  • Posts: 1925
  • Country: de
Re: event-oriented programming language
« Reply #1 on: January 02, 2023, 11:06:19 pm »
IMHO, first we need a clear and consistent definition of an event and some taxonomy(types, classed and property of events).
Afterwards we need to see on what programming problems is the event paradigm applicable and if is a general thing or some limited special case application.
Finally we need to see how to implement it in C with a bit of assembly (eventually) and we're done  :-DD
 
The following users thanked this post: DiTBho

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: event-oriented programming language
« Reply #2 on: January 02, 2023, 11:16:05 pm »
Things that come into my mind are state machine, declarative paradigm, QML/QtQuick, GUI programming.
« Last Edit: January 02, 2023, 11:29:54 pm by gf »
 
The following users thanked this post: DiTBho

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5087
  • Country: gb
Re: event-oriented programming language
« Reply #3 on: January 03, 2023, 12:03:21 am »
Finally we need to see how to implement it in C with a bit of assembly (eventually) and we're done  :-DD

Yup, great start, like it  :D

(if you find examples, please post here, and I will study them)
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5087
  • Country: gb
Re: event-oriented programming language
« Reply #4 on: January 03, 2023, 12:18:37 am »
Good idea for EP: a/synchronous calls between Producers and Consumers, blissfully unaware of one another and interact through the message queue only.

Producers are entities that generate events and send them to a message queue.
Consumers are entities that either subscribe to receive new events or poll periodically from the queue.

The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline Alex Eisenhut

  • Super Contributor
  • ***
  • Posts: 3727
  • Country: ca
  • Place text here.
Re: event-oriented programming language
« Reply #5 on: January 03, 2023, 12:26:05 am »
I've heard of object-oriented and event-driven, but not event-oriented.
Hoarder of 8-bit Commodore relics and 1960s Tektronix 500-series stuff. Unconventional interior decorator.
 

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5087
  • Country: gb
Re: event-oriented programming language
« Reply #6 on: January 03, 2023, 12:37:00 am »
Like this?  :D

Book: Practical UML Statecharts in C/C++: Event-DrivenProgramming
(it's already in my list)
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline YurkshireLad

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: ca
Re: event-oriented programming language
« Reply #7 on: January 03, 2023, 01:26:16 am »
Good idea for EP: a/synchronous calls between Producers and Consumers, blissfully unaware of one another and interact through the message queue only.

Producers are entities that generate events and send them to a message queue.
Consumers are entities that either subscribe to receive new events or poll periodically from the queue.

Been there, done that, enjoyed it. 😁
 
The following users thanked this post: DiTBho

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17774
  • Country: fr
Re: event-oriented programming language
« Reply #8 on: January 03, 2023, 02:02:40 am »
Ever looked at Go? (Not that I like all of it, but just worth a mention.)
 
The following users thanked this post: DiTBho

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11725
  • Country: my
  • reassessing directives...
Re: event-oriented programming language
« Reply #9 on: January 03, 2023, 05:18:29 am »
been using event oriented/driven for ages, its VB6, had experience with Delphi (now called Embarcadero), built my own simple MFC like class/structure.. currently still struggling with learning/implementing Qt.. read and exercise book like Windows++ by Paul Dilascia then you'll have better picture how it works, esp on single CPU, the trick is scheduler (if you have to build one your own) and a lot of callbacks..
 
The following users thanked this post: DiTBho

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: event-oriented programming language
« Reply #10 on: January 03, 2023, 06:59:49 am »
I work with two different kinds of events: explicitly queued, and asynchronous.

Interrupts and POSIX signal handlers are asynchronous events: their handlers can be called at any point in time.
Interrupts often do not have any payload, but POSIX signals handlers can have one (of siginfo_t type, including an user-defined arbitrary pointer or corresponding integer value per sigqueue()).

(Technically, asynchronous events can also be queued, in the sense that when e.g. a signal or interrupt is blocked, it will be postponed until not blocked anymore; and if a POSIX realtime signal arrives while the thread is already handling that signal, it won't be dropped but postponed until the signal handler returns.  I'm sure there are better terms for the two (queued vs. asynchronous), I just don't recall/realize what they are when writing this.)

Queued events are what GUI toolkits like Qt, Gtk, etc. use, and what things like X11 (X Windows) are based on.  You have one or more queues, and a call that blocks until an event object is available from one of them, returning the first one (or the one with highest priority).  The object itself is polymorphic, or a tuple (type, object), so that new events can be added without recompiling the applications.

Imperative languages like C, C++, Python, Perl, Ruby, Rust, etc. implement the former using callbacks (or closures) and special requirements (see e.g. async-signal-safe functions in POSIX C: the C library interfaces that can be used in signal handlers), and the latter using explicit queue operations and a superloop.  (Javascript is also an imperative language used with event-based interfaces, but it does not have signal or interrupt support.  It's "superloop" is inherent in its runtime.)

In my event-based sort command example in the other thread, I showed that things like records emitted from a datastore can be usefully treated as events as well ("datastore record (this) available"), but I am not actually certain if that is better considered an event source, or just a normal queue.

This is exactly the unknown region where real-world experimentation and research ought to yield useful results and information: exactly how can be express things like "let this datastore generate an event, emitting its contents one record at a time in order, until it is empty", in a way that requires minimal runtime support?  Imperative languages do this via polling, and that part is prone to bugs (especially when event priority is involved; see e.g. priority inversion).

I firmly believe that experimenting on scenarios like this –– event-based sort utility that reads records into a min/max-heap and then emits them to standard output –– with an imagined language, experimenting on the syntax while also roughly sketching out what kind of machine code that would compile to, is the only way to find the answers this kind of discussion threads are looking for.  I do not believe such work has been done yet, but I have already used event-based libraries and programming paradigm in several languages, so that I know the underlying idea is sound: the question is, how such concepts best map to human-written linear language forms (i.e. textual source code) –– and without involving abstractions that require heavy runtime or more RAM than is available on small microcontrollers.

There are even conceptual things that are very important when looking at the low-level, machine-code implementation.  One is, does a hardware/interrupt/signal event handler need to be re-entrant?  I do not ever recall writing an interrupt or signal handler that would have been hindered by not being re-entrant.  If one does not need to be re-entrant, it can run off a static context; essentially a tiny dedicated stack.  In POSIX, one can even set up an alternate stack for (selected) signal handlers; see sigaltstack().  In practice, if signals/interrupts with the same priority cannot interrupt each other, the maximum nesting in the alternate stack is defined by the number of unique priorities, and the exact maximum alternate stack size can be statically determined (sum of maximum stack sizes needed at each priority level).
 
The following users thanked this post: DiTBho

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: event-oriented programming language
« Reply #11 on: January 03, 2023, 10:23:57 am »
Good idea for EP: a/synchronous calls between Producers and Consumers, blissfully unaware of one another and interact through the message queue only.

Producers are entities that generate events and send them to a message queue.
Consumers are entities that either subscribe to receive new events or poll periodically from the queue.

Welcome to Communicating Sequential Processes (CSP), Occam, Erlang, xC, and languages incorporating elements of CSP such as Rust and Go.

There's a lot of hard-won experience out there. Choose whether to stand on other people's shoulders or toes :)

In the language's whitepaper, define which concepts have been included and omitted, why the included ones play well together. This excellent example from an author I respected convinced me that the language was worth learning. I was right :)

Always remember " You know you've achieved perfection in design, not when you have nothing more to add, ut when you have nothing more to take away." Antoine de Saint Exupery. 
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: newbrain, DiTBho

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: event-oriented programming language
« Reply #12 on: January 03, 2023, 10:43:37 am »
In my event-based sort command example in the other thread, I showed that things like records emitted from a datastore can be usefully treated as events as well ("datastore record (this) available"), but I am not actually certain if that is better considered an event source, or just a normal queue.

That is exactly the kind of area where the half-sync half-async design pattern works superbly.

An incoming event is recorded in a queue, and pulled from that queue by a worker thread, and the  relevant action is processed to completion. If such processing would take "too long" (e.g. a database update) then that can be forked off to a separate context for completion. If appropriate, a "completion event" can be placed in the queue for subsequent processing.


Quote
This is exactly the unknown region where real-world experimentation and research ought to yield useful results and information: exactly how can be express things like ...

I firmly believe that experimenting on scenarios like this ... with an imagined language, experimenting on the syntax while also roughly sketching out what kind of machine code that would compile to, is the only way to find the answers this kind of discussion threads are looking for. 

Exactly. At this stage use a pseudo-code to express concepts; ignore compilers since they are a very well understood technology.

Quote
I do not believe such work has been done yet, but I have already used event-based libraries and programming paradigm in several languages, so that I know the underlying idea is sound: the question is, how such concepts best map to human-written linear language forms (i.e. textual source code) –– and without involving abstractions that require heavy runtime or more RAM than is available on small microcontrollers.

There are quite a few event based environments, usually involving a proprietary Domain Specific Language.

There are many realtime design patterns that encapsulate different aspects of event oriented programming.

Many specifications are written in terms of events, e.g. telecoms systems.

See what primitive concepts are in embedded RTOSs, ignoring the ones that are simple transliterations of C/UNIX/POSIX.

Quote
There are even conceptual things that are very important when looking at the low-level, machine-code implementation.  One is, does a hardware/interrupt/signal event handler need to be re-entrant?  I do not ever recall writing an interrupt or signal handler that would have been hindered by not being re-entrant.  If one does not need to be re-entrant, it can run off a static context; essentially a tiny dedicated stack.  In POSIX, one can even set up an alternate stack for (selected) signal handlers; see sigaltstack().  In practice, if signals/interrupts with the same priority cannot interrupt each other, the maximum nesting in the alternate stack is defined by the number of unique priorities, and the exact maximum alternate stack size can be statically determined (sum of maximum stack sizes needed at each priority level).

There are too many similarities between hardware interrupts, messages, exceptions, and events for them not to be treated identically. That implies they are all unified in a single language concept, and the runtime support treats them identically.

It is possible that different run-time support systems could be required for different environments, e.g. server side and MCU.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: Nominal Animal, DiTBho

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: event-oriented programming language
« Reply #13 on: January 04, 2023, 11:20:47 pm »
Let's discuss here (if it's possible/reasonable) this interesting idea.

How should it be? :D

I think its high time intelligent, thinking, engineering minded people asked themselves why they are all obediently perpetuating the fashion of using "oriented" when discussing languages.

Like "language oriented language" or "computer oriented language" or "crash oriented language" or "reliability oriented languages" the term is just so over used!

« Last Edit: January 04, 2023, 11:23:49 pm by Sherlock Holmes »
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline AndyBeez

  • Frequent Contributor
  • **
  • Posts: 858
  • Country: nu
Re: event-oriented programming language
« Reply #14 on: January 04, 2023, 11:39:44 pm »
Anyone for node.js?
https://nodejs.org/en/

Node is asyncronous event driven architecture: https://en.m.wikipedia.org/wiki/Event-driven_architecture
 
The following users thanked this post: DiTBho

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17774
  • Country: fr
Re: event-oriented programming language
« Reply #15 on: January 05, 2023, 12:00:27 am »
Let's discuss here (if it's possible/reasonable) this interesting idea.

How should it be? :D

I think its high time intelligent, thinking, engineering minded people asked themselves why they are all obediently perpetuating the fashion of using "oriented" when discussing languages.

Like "language oriented language" or "computer oriented language" or "crash oriented language" or "reliability oriented languages" the term is just so over used!

Well sure, but it has the benefit of clearly stating what was the focus when designing some language.
The problem may not be so much with the term "oriented" than with the fact that general-purpose languages actually be too "oriented" one way or another, making people using them design software fitting a single paradigm religiously. Which leads for instance to the disastrous intricate piles of objects you get in most C++ designs.
But the same appears with just any paradigm which is too opinionated. So likewise, writing everything as events in an "event-oriented" programming language would potentially lead to some spectacular piles of shit. IMHO. :popcorn:
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: event-oriented programming language
« Reply #16 on: January 05, 2023, 12:03:32 am »
Let's discuss here (if it's possible/reasonable) this interesting idea.

How should it be? :D

I think its high time intelligent, thinking, engineering minded people asked themselves why they are all obediently perpetuating the fashion of using "oriented" when discussing languages.

Like "language oriented language" or "computer oriented language" or "crash oriented language" or "reliability oriented languages" the term is just so over used!

Well sure, but it has the benefit of clearly stating what was the focus when designing some language.
The problem may not be so much with the term "oriented" than with the fact that general-purpose languages actually be too "oriented" one way or another, making people using them design software fitting a single paradigm religiously. Which leads for instance to the disastrous intricate piles of objects you get in most C++ designs.
But the same appears with just any paradigm which is too opinionated. So likewise, writing everything as events in an "event-oriented" programming language would potentially lead to some spectacular piles of shit. IMHO. :popcorn:

You do have a point: "common business-oriented language" seems I missed that, it can all be traced back to COBOL!

Anyway, lets start drafting C++++ that'll get everything nice and clean again.



“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11725
  • Country: my
  • reassessing directives...
Re: event-oriented programming language
« Reply #17 on: January 05, 2023, 12:18:25 am »
The problem may not be so much with the term "oriented" than with the fact that general-purpose languages actually be too "oriented" one way or another, making people using them design software fitting a single paradigm religiously. Which leads for instance to the disastrous intricate piles of objects you get in most C++ designs.
isnt that what you get in Java? or even Python? piles of objects in its runtime/standard library? for being too "object" or "machine independent" oriented language?

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5087
  • Country: gb
Re: event-oriented programming language
« Reply #18 on: January 05, 2023, 12:54:33 am »
My t-shit knows it  ;)
"Use tools rationally"
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5087
  • Country: gb
Re: event-oriented programming language
« Reply #19 on: January 05, 2023, 12:59:54 am »
Anyone for node.js?
https://nodejs.org/en/

Node is asyncronous event driven architecture: https://en.m.wikipedia.org/wiki/Event-driven_architecture

Yup, it's in my list because it offers several real life examples.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17774
  • Country: fr
Re: event-oriented programming language
« Reply #20 on: January 05, 2023, 01:00:11 am »
My t-shit knows it  ;)
"Use tools rationally"

Good idea. ;D
 
The following users thanked this post: DiTBho

Offline MK14

  • Super Contributor
  • ***
  • Posts: 5385
  • Country: gb
Re: event-oriented programming language
« Reply #21 on: January 05, 2023, 06:35:47 am »
https://en.wikipedia.org/wiki/Event-driven_programming

Quote
Criticism
The design of those programs which rely on event-action model has been criticised, and it has been suggested that the event-action model leads programmers to create error-prone, difficult to extend and excessively complex application code.[2] Table-driven state machines have been advocated as a viable alternative.[5] On the other hand, table-driven state machines themselves suffer from significant weaknesses including the state explosion phenomenon.[6] A solution for this is to use Petri nets.
Bold added by me.
 
The following users thanked this post: DiTBho

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2175
  • Country: fi
  • Embedded SW/HW.
Re: event-oriented programming language
« Reply #22 on: January 05, 2023, 07:53:27 am »
https://en.wikipedia.org/wiki/Event-driven_programming

Quote
Criticism
The design of those programs which rely on event-action model has been criticised, and it has been suggested that the event-action model leads programmers to create error-prone, difficult to extend and excessively complex application code.[2] Table-driven state machines have been advocated as a viable alternative.[5] On the other hand, table-driven state machines themselves suffer from significant weaknesses including the state explosion phenomenon.[6] A solution for this is to use Petri nets.
Bold added by me.

State explosion can be limited using hierarchical state machines. They are somewhat more complex to implement, but way more flexible, than the traditional flat, table-driven state machines.
 
The following users thanked this post: MK14

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: event-oriented programming language
« Reply #23 on: January 05, 2023, 09:34:56 am »
https://en.wikipedia.org/wiki/Event-driven_programming

Quote
Criticism
The design of those programs which rely on event-action model has been criticised, and it has been suggested that the event-action model leads programmers to create error-prone, difficult to extend and excessively complex application code.[2] Table-driven state machines have been advocated as a viable alternative.[5] On the other hand, table-driven state machines themselves suffer from significant weaknesses including the state explosion phenomenon.[6] A solution for this is to use Petri nets.
Bold added by me.

That statement is of very limited value.

There are several good and practical ways of implementing FSMs. Sometimes table-driven FSMs are a good solution (e.g. parsing sequences of characters to create corresponding numbers) sometimes not.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: event-oriented programming language
« Reply #24 on: January 05, 2023, 10:20:36 am »
A lot of reinventing the wheel would be avoided if people would read the literature.

I recommend
  • the "Gang of Four" "Design Patterns" book, p305.
  • the more verbose "Practical UML Statecharts in C/C++, 2nd Ed Event-Driven Programming for Embedded Systems" https://www.state-machine.com/psicc2 Chapter 3 has a useful set of consequences of each way of implementing FSMs. It is not necessary to learn that book's QE/QP/QK!
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: DiTBho


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf