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

0 Members and 1 Guest are viewing this topic.

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: event-oriented programming language
« Reply #50 on: January 06, 2023, 03:27:03 pm »
I do prefer free toolchains and relatively affordable development boards –– seeing as I can nowadays get very powerful Linux SBCs for ~ 40-60 € (Amlogic, Samsung, Rockchip SoC chips and chipsets having very good vanilla Linux kernel support, so one is not dependent on vendor forks) –– as a hobbyist myself.

Opensource is limited, and for example, you cannot have the same Ada experience with Gnat that you can have with GreenHills AdaMulti.

Here you need a serious job, AdaMULTI is a complete integrated development environment with serious ICE support for embedded applications using Ada and C with serious support. Just the ICE's header costs 3000 euro, the full package costs 50000 euro.

What do you have with Opensource? Poor man debugger? gdb-stub? umm?
Our my-c-ICE technology is not as great as GreenHills's but it's several light years ahead gdb!

And note: once again, it's not OpenSource!
 
So, my opinion here is clear: you need to find a job in avionics to enjoy the full C+Ada experience.

The same applies with Linux SBC ... they are all the same, over and over, all the same story. Linux bugs, Userland bugs ... nothing of nothing different from the same boring daily experience, just new toys.

The M683xx and MPC840 are great piece of hardware like never seen, and - once again - opensource has ZERO support for their hardware design, whereas the industry has some great stuff.

MPC840 is used in AFDX switches, used from from avionics to naval to high speed railways
M683xx is used by Ford Racing for internal combustion engine

Now, I'd love to find a job which exposes me to the Dyson Digital Motor technology.
I know, their electric car is an epic business failure, but their technology, even at the software side, is great!

I agree, I'd love to see Dyson reenter electric cars, they'd crush Tesla, literally drive them out of business.
“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 DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5098
  • Country: gb
Re: event-oriented programming language
« Reply #51 on: January 06, 2023, 03:55:14 pm »
I admit I've been extremely interested in XMOS xCore ever since I first heard of it from tggzzz, but the single-vendor approach with non-open toolchain feels, well, "too risky" or something

umm, it's not expensive, so... if I were you, I'd give it a try.
let's define x-experience as x: { worst ... best }
  • the worst that can happen... less than a lost bag of coffee capsules
  • the best that can happen .... new skills and ideas acquired
to me, it seems it's worth the attempt  :D
« Last Edit: January 06, 2023, 03:59:00 pm by DiTBho »
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5098
  • Country: gb
Re: event-oriented programming language
« Reply #52 on: January 06, 2023, 04:48:10 pm »
(
More about my personal experience and thinking

To see the industrial technology behind a "black-box voter and its redundant system" can be much worse, like seeing for yourself what's down the rabbit hole you have to spend four months retrofitting a steam train (2) to modern rail to then finally see what's behind an high speed train!

I did it in 8 years ago, and after two months of training (1) I finally saw the one truth behind GreenHills (lucky coincidence) and its developing ecosystem Ensuring Code Quality, being similar to DO-178B/C Compliant(1), and got a Level 4 personal card which it allowed me to read all the technical documentation on both their software and hardware, including their "voter box", which is a true secret black box ....

WOW, the secret box has no more secrets for you, sure, but ... considering the psychological cost of that training, it was a rather insanely bizarre experience of which I'm not even allowed to talk about because of what I had to sign (worst negative).

So even before I got home, I felt quite emotionally and logically understand Cypher, when in the first Matrix movie, he betrayed his friends to re-enter the Matrix.

Red Pill always has a price to pay.

Sure, with Xmos you have to seat your belt but it's a soft drop into the border of the comfort zone.
It costs, but it's not a steep price  :D

(1) railway ~ avionics, I had to study and adapt my little knowledge and skills, and exercise with new tools.
(2) "crazy snob, no argument just because I was paid for the job" I thought at the time... years later... well that stuff made a lot of money with up to seven serving platters served aboard a steam train!!!

)
« Last Edit: January 06, 2023, 04:50:15 pm by DiTBho »
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: event-oriented programming language
« Reply #53 on: January 06, 2023, 05:00:26 pm »
I do prefer free toolchains and relatively affordable development boards –– seeing as I can nowadays get very powerful Linux SBCs for ~ 40-60 € (Amlogic, Samsung, Rockchip SoC chips and chipsets having very good vanilla Linux kernel support, so one is not dependent on vendor forks) –– as a hobbyist myself.
Opensource is limited, and for example, you cannot have the same Ada experience with Gnat that you can have with GreenHills AdaMulti.

Here you need a serious job, AdaMULTI is a complete integrated development environment with serious ICE support for embedded applications using Ada and C with serious support. Just the ICE's header costs 3000 euro, the full package costs 50000 euro.

What do you have with Opensource? Poor man debugger? gdb-stub? umm?
As a hobbyist.

When you start doing product development, things become very different.  (You know that I myself use very different licenses – from CC0-1.0 in my examples to fully proprietary, and I've no problem developing stuff under a (properly written) NDA.)

I've also mentioned how low quality Linux vendor systems integration work is; I do my own.  For a hobbyist interested in such things, a few hours now and then to reconfigure or tinker with the appliance is OK.  But, to do proper systems integration and maintenance, you actually need experience.  To provide those to customers, you need servers (to hold pre-vetted and tested repositories of packages) and a lot more infrastructure, including actual paid maintainers. Current vendors aren't even interested in paying for people who can do the integration, they just use whoever is cheap enough to do that.  And it shows: most appliances are put together with spit and bubblegum.

Also, you do realize even XMOS uses GDB for debugging?
Open source isn't better or worse, it is just developed using a completely different 'payment'/'cost'/'benefit' model.

I admit I've been extremely interested in XMOS xCore ever since I first heard of it from tggzzz, but the single-vendor approach with non-open toolchain feels, well, "too risky" or something
umm, it's not expensive, so... if I were you, I'd give it a try.
The processors are not too expensive, sure, but I'd like to start with a development kit.  The cheapest active (non-obsoleted) one I can get from Digikey here, XK-EVK-XU316, costs 266€ including VAT.  That is quite a lot for me: remember, I'm a poor burned out husk of a man without steady income.

But anyway, it's more that I've sworn to myself to no longer give money to vendors who just use that to fuck me over later on.  Burned before too many times, shame on me, you can't fool me again, like Dubya said.

tggzzz said that the ecosystem works, so perhaps I should just give it a try, if I can find a cheap/used kit.. and I do like the background of the company.

But, I cannot download the XTC Tools without registering, and the 15.1.4 release notes say "Inclusion of the lib_xcore system library and headers marks a shift in emphasis towards programming the xcore in C, rather than XC", which combined with the shift towards audio processing, makes me suspect the longevity of the platform.

Also, what exactly is the xcc compiler based on?  Its documentation says "The XCore compiler (xcc) supports targeting the XCore using GNU C or C++." but all I can find is an out of date clang mirror.

I sure hope it is not a GCC fork in violation of the license.  I've had enough of vendors like Microchip and their shady shenanigans and marketing-speak, exploiting others' (gcc devs') work and trying to lie about end users' rights by planting misinformation in the discussions.  (Yes, end users are allowed to both modify the Microchip GCC-derived compiler, and publish the changes and even binaries, so that one does not need to pay Microchip to use an unencumbered open source compiler.  There has been several threads with mostly misconceptions (especially how EULA somehow overrides the copyright license that allowed Microchip to create a derivative in the first place ::) here at EEVblog forums about this.)

If one wants to do proprietary software, it's absolutely fine; I do so all the time myself.  But doing so in violation of the copyright license, forking an open source project to do so, is evil.  The licenses aren't hard to abide by, and nobody is forcing anyone to use the open source projects either.
If your business plan revolves around breaking copyright licenses and banking on nobody suing, you are no better than any other mass pirates online.

So yeah, I'm interested, but suspicious, too.
« Last Edit: January 06, 2023, 05:03:34 pm by Nominal Animal »
 
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 #54 on: January 06, 2023, 05:12:41 pm »
Classic imperative patterns are not good, this is probably why no hobbyist wants anything to do with those chips (which are also hard to find, and expensive).
I do prefer free toolchains and relatively affordable development boards –– seeing as I can nowadays get very powerful Linux SBCs for ~ 40-60 € (Amlogic, Samsung, Rockchip SoC chips and chipsets having very good vanilla Linux kernel support, so one is not dependent on vendor forks) –– as a hobbyist myself.

I admit I've been extremely interested in XMOS xCore ever since I first heard of it from tggzzz, but the single-vendor approach with non-open toolchain feels, well, "too risky" or something.  (I've been burned enough times by vendors already, you see, so maybe I'm paranoid.)  And vendor toolchain support for Linux or BSDs tends to be second-tier, which further reduces the value of investment, even if for purely learning and experimentation.

It is definitely a risk, both that a vendor might disappear (they've been shipping product for 15 years) and in terms of spending effort on a niche that isn't interesting to the next employer (not a problem for me).

Quote
Which nicely leads me to:
Why 'language' as opposed to 'runtime' or 'library' ?
To do better.

Like I mentioned earlier in a reply to Kalvin, none of what I have suggested here leads to "new" machine code; everything stems from already existing patterns.  The problem I'd like to solve, is to express those patterns in a clearer, more efficient manner, and at the same time avoid the known pitfalls in existing low-level languages –– memory safety, and ease of static analysis.

No new abstractions, just easier ways for us humans to describe the patterns in a way compilers can statically check and generate efficient machine code for.

Yes. The harmonious integration of existing knowledge/experience should be sufficient; it was for Java.

Quote
To me, the number of times I've had to argue for MPI_Isend()/MPI_Irecv() –– event-based I/O in MPI; the call initiates the transfer and provides an MPI_Request handle one can examine or wait for completion or error –– against highly-paid "MPI Experts", indicates that whenever imperative approach is possible, it will be used over event-oriented one, because humans.

I myself do not have "libraries" for my event-oriented stuff, I just have patterns (with related unit test cases and examples) I adapt for each use case separately.  I seriously dislike the idea of having one large library that provides such things, because it leads to framework ideation where you do things a certain way because it is already provided for you, instead of doing things the most efficient or sensible way.  Many small libraries, on the other hand, easily lead to (inter-)dependency hell.

Design patterns are a key concept, which appear to be becoming less fashionable.

Quote
Do note I've consistently raised the idea of experimenting with how to express the various patterns, using an imagined language (but at the same time thinking hard about what kind of machine code the source should compile to).  So, there is no specific single pattern I'm trying to recommend anyone to use, I'm pushing/recommending/discussing/musing about how to experimentally discover better-than-what-we-have-now ways of describing the patterns we already use, and build a new language based on that.

If you've ever taken a single course on programming language development, or any computer science courses related to programming languages really, this will absolutely look like climbing a tree ass first.  Yet, I have practical reasons to believe it will work, and can/may/should lead to a programming language that is better suited to our current event-oriented needs on resource-constrained systems than what we have now.

(As to those practical reasons: I've mentioned that I've occasionally dabbled in optimizing work flows by spending significant time and effort beforehand to observe and analyse how humans perform the related tasks.  This itself is a very well documented (including scientific papers, as well as practical approaches done in high-production development/factory environments) problem solving approach.  My practical reasons are thus based on treating programming as a problem solving workflow.  This has worked extremely well for myself (in software development in about a dozen programming languages), so I have practical reasons to expect that this approach, even if considered "weird" or "inappropriate" by true CS folks, will yield very useful results.)

As I point out to inexperienced softies, when building systems neither top-down nor bottom up is sufficient. Both are necessary - and they should meet each other in the middle :)
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 #55 on: January 06, 2023, 05:21:21 pm »
The processors are not too expensive, sure, but I'd like to start with a development kit.  The cheapest active (non-obsoleted) one I can get from Digikey here, XK-EVK-XU316, costs 266€ including VAT.  That is quite a lot for me: remember, I'm a poor burned out husk of a man without steady income.

Yes, that's a bummer.

I have 5 SBCs that cost £15 each :) USB on one side and pins on the other, conceptually similar to an Arduino.

Quote
But anyway, it's more that I've sworn to myself to no longer give money to vendors who just use that to fuck me over later on.  Burned before too many times, shame on me, you can't fool me
tggzzz said that the ecosystem works, so perhaps I should just give it a try, if I can find a cheap/used kit.. and I do like the background of the company.

But, I cannot download the XTC Tools without registering, and the 15.1.4 release notes say "Inclusion of the lib_xcore system library and headers marks a shift in emphasis towards programming the xcore in C, rather than XC", which combined with the shift towards audio processing, makes me suspect the longevity of the platform.

Oh; that's concerning.

They do appear to be drifting towards ML, but I hadn't spotted a potential drift away from xC. They've always had tight C/C++ interoperability.

If the underlying hardware architecture is the same, then it ought to be possible to achieve the same benefits in C. A sugary syntax is less important than the patterns.
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 DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5098
  • Country: gb
Re: event-oriented programming language
« Reply #56 on: January 06, 2023, 06:25:09 pm »
you do realize even XMOS uses gdb

Yup, because it must be cheap! gdb is not bad, just it doesn't give you the experience you have with high-end ICEs.
Different costs, different purposes, different experiences.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: event-oriented programming language
« Reply #57 on: January 06, 2023, 07:01:27 pm »
As I point out to inexperienced softies, when building systems neither top-down nor bottom up is sufficient. Both are necessary - and they should meet each other in the middle :)
Quite!  To me, it is analogous to the modular approach, where one constructs the solution from modular pieces, instead of trying to define the solution beforehand (top-down) or just throw stuff together and see what comes out (bottom-up).

For me, the typical application design process starts with a lot of thought, and some unit tests to see what kind of modules I have for the lowest-level key parts.  Often it is an iteration, with my overall design changing and evolving, until I have a full plan.  Even then, I typically end up needing a full rewrite later on, when I have some experience using the application, and can find ways to optimize the workflows.

With such an approach, things like combining proprietary computation (in a dynamically linked library) and an open-source, user-modifiable user interface (written in e.g. Python), is no longer "strange": you look at the licenses and their intent (and possibly existing case law) to define the generally accepted division, also defining the API between the two sides.  You then start developing each side modularly/piecewise, hopefully refining (or even redefining) the API as needed by both sides.  For web-based services, you have a very similar situation, with server-side logic never revealed to end users, but client-side logic (run within the browser) always is (although Javascript/WebAssembly code obfuscation and minimization tries to do just that).

(To see the industrial technology behind a "black-box voter and its redundant system" can be much worse, [...])
I'm not actually disagreeing with you, just explaining the reasons for my current opinion/stance.

I'm taking the hobbyist approach here, because a thing like a new programming language will take something like a decade before it is ready to be widely used in industrial applications.  Much less, if you create a variant like you did with my-c, of course; but here, we're talking about an event-oriented language, designed basically from scratch.  Indeed, I've been talking more about how I'd like that design process to go, instead of what the resulting design should be!  ;D

The problem with vendor-created programming languages or programming toolchains is a three-edged sword.  On one hand, the development is limited to the resources the company can afford to put into its development.  On the other hand, for any for-profit company, such spending must be explained to the shareholders, and essentially have to generate income.  If we consider language development, things like ease of use and portability, the company interests and the client developer interests, do not align too well.  On the gripping hand (it's a reference to Moties), the vendor is in full control of the language, and if you are big enough, you can get the vendor to extend/modify the language so that solving a particularly intractable detail becomes easier; rather than having to convince basically unpaid volunteers that such change is better for everybody (or at minimum, harms nobody), and do the hard work needed to implement the change as well.

Open source development is not cheap, it is just ... different.  The rules are different, I mean.

considering the psychological cost of that training, it was a rather insanely bizarre experience of which I'm not even allowed to talk about because of what I had to sign (worst negative).

So even before I got home, I felt quite emotionally and logically understand Cypher, when in the first Matrix movie, he betrayed his friends to re-enter the Matrix.
I do know how weird NDAs can get; that's why I included "(properly written)" when mentioning those.

As to Cypher, I always perceived him as overly naïve; like the people who are ardent proponents of one political system and another, believing that it would make life all roses and butterflies, with everyone happy (and those who disagree silenced without messing up the clean world).
Yes, he was put into a hard position without asking him whether he wanted it or not.  Thing is, easy answers don't make people happy.  You might think you'd be happier if you didn't know or did not have a specific impactful experience –– they do say "with knowledge comes pain" –– but fact is, it is experience and knowledge that shapes us.  That unknowing person would be a different one than you are now, so it is making a decision for someone else.  There is no guarantee that other you wouldn't be even more miserable, for example because they never got to make the choice in the first place.

This relates very closely to programming languages and software development.  It seems that one truly has to work with difficult and painful projects before they understand the importance of maintainability and readability –– and even then, some just never grasp it.

In this analog, one might wish they never had to encounter a specific project –– like me with certain Perl project by authors I like, but who definitely were not suited for creating that project back then at least; causing me to avoid Perl to this day! ––, but it is exactly those painful experiences that teach us the cost of doing things that way.

Red Pill always has a price to pay.
Yup.  Put more generally: There ain't no such thing as a free lunch.

(Definitely also applies to open source, as well.  The costs and payments are just measured using a completely different yard stick.)
 
The following users thanked this post: DiTBho

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5098
  • Country: gb
Re: event-oriented programming language
« Reply #58 on: January 06, 2023, 07:20:38 pm »
I just discovered an eBay feature that I didn't know about: you can save a search and ask eBay to notify - by email - you when it finds something. This way you can find a second hand board for cheap without daily actively having to search.

Great stuff  :D

The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 
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 #59 on: January 06, 2023, 07:58:19 pm »
you do realize even XMOS uses gdb

Yup, because it must be cheap! gdb is not bad, just it doesn't give you the experience you have with high-end ICEs.
Different costs, different purposes, different experiences.

I always found the debugging experience was excellent with the XMOS IDE, which is based on Eclipse. I expect is the same as debugging C/C++ in Eclipse. Certainly breakpoints, single stepping at the xC and machine code level (as fast as possible with highly optimised C). Plus it shows the exact number of cycles between here and there via all paths - without executing the code.

What am I missing?
« Last Edit: January 06, 2023, 08:08:05 pm by tggzzz »
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 DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5098
  • Country: gb
Re: event-oriented programming language
« Reply #60 on: January 06, 2023, 10:33:22 pm »
What am I missing?

Dynamic coverage, performance analysis, code and data injection, continuous built-in test stimulus for normal and abnormal behavior, which is very useful for verifying cbit and for simulating hw failure ... etc

Also uploading is massively faster (fiber optic link, up to 400Mbyte/sec), and then you also have automatic test-report though the ICE itself, which requires large built-in buffers and AI local intelligence for pattern matching.

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

Offline Zipdox

  • Regular Contributor
  • *
  • Posts: 228
  • Country: nl
Re: event-oriented programming language
« Reply #61 on: January 11, 2023, 02:56:51 pm »
JavaScript is a largely event driven programming language. The JavaScript runtime runs an event loop. Other languages can have event loops too, like C with GLib, but JavaScript has by far the nicest syntax for event-driven programming (at least that I have used).
 
The following users thanked this post: DiTBho

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17788
  • Country: fr
Re: event-oriented programming language
« Reply #62 on: January 11, 2023, 07:43:56 pm »
We can mention Erlang too, although this one is a particular beast in itself. I like the concepts, but not so much how they have been translated. Certainly intersting to learn though.
 

Offline DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5098
  • Country: gb
Re: event-oriented programming language
« Reply #63 on: January 11, 2023, 08:29:17 pm »
We can mention Erlang too, although this one is a particular beast in itself. I like the concepts, but not so much how they have been translated. Certainly interesting to learn though.

Yup, I do program in ErLang, but for me it's dedicated stuff (mnesia-only), rather than general purpose.

At the moment I am trying to support a frame for my-c to transform a function with multiple arguments into a sequence of single-argument functions; that means converting a function like this f(a, b, c, ...) into a function like this f(a)(b)(c)...

I desperately need it to use the map method with a curried function, this even if my-c is not functional programming like ErLang or Haskell.

Oh, from doc (I am a complete nuuuub with JS), it seems that JavaScript can easily do it via "function wrapper".

That's good!!!  :o :o :o

So, I'll probably try to add a "function wrapper" mechanism to my-c(1), hopefully it fixes my problem.


Meanwhile, let's {read, study, play} more about JS!



edit:
(1) functions in my-c always have a fixed number of arguments
"..." removed, so printf(...) can no more be implemented, and I'am SO HAPPY about this, because nobody will ever try to resurrect it, nobody, never, no way!!!  ;D
« Last Edit: January 11, 2023, 08:33:34 pm by DiTBho »
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline gf

  • Super Contributor
  • ***
  • Posts: 1830
  • Country: de
Re: event-oriented programming language
« Reply #64 on: January 12, 2023, 09:45:32 pm »
At the moment I am trying to support a frame for my-c to transform a function with multiple arguments into a sequence of single-argument functions; that means converting a function like this f(a, b, c, ...) into a function like this f(a)(b)(c)...

I desperately need it to use the map method with a curried function, this even if my-c is not functional programming like ErLang or Haskell.

Oh, from doc (I am a complete nuuuub with JS), it seems that JavaScript can easily do it via "function wrapper".

That's good!!!  :o :o :o

So, I'll probably try to add a "function wrapper" mechanism to my-c(1), hopefully it fixes my problem.

The key primitives which make such things possible are
  • first class functions
  • closures
and JavaScript functions are both.
 
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 #65 on: January 14, 2023, 05:49:49 pm »
SiliconWizard linked a Youtube video in another thread, GOTO 2018: Old is the New New, by Kevlin Henney, talking about how many of the things that are touted as New have been known for quite a long time.  I loved it, because I have had similar vague opinions for a long time, but without clear basis I could explain other than my own observations; and have someone show the basis and refer to the historical publications involved is extemely useful.
(But now I have to go hunt down those papers and books, dammit.)

Anyway, that talk made me realize one possible model for 'event handlers' is to model each handler as a process, with events and associated data passed in messages/events between them.  Instead of global memory accessible to all event handlers, each event handler would have their own state/context object(s), plus possibly access to explicitly named read-only or 'slow-atomic' objects.  (Do note that 'process' here is the concept, I'm not referring to OS processes.)

For example, consider an event handler that receives a chunk of samples, calculates a windowed DFT with 50% overlap (so it technically always has "previous chunk", "current chunk", and generates two DFTs per chunk received, with chunk and DFT window size the same).
If there is some kind of memory arena concept, then the samples and their DFTs could use a shared memory arena, with room for say four sample chunks and four DFTs.  Whenever the handler receives a new chunk, it would allocate calculate the windowed DFT that crosses both chunks (to a newly allocated DFT message), then drop the old sample chunk and send the DFT message, then calculate the windowed DFT for the new chunk (to a newly allocated DFT message), remember the new sample chunk as the old chunk in its own context, and send the DFT message, and be done.

This approach allows static analysis tools to verify all memory accesses within the handler are valid, whether incoming data objects as message payloads are correctly handled (remembered, passed forward, or completely freed/dropped), and so on.  Obviously, some kind of "auto-drop unaccessed data objects" mechanism is required, for the code to be maintainable.  Reference counting data objects in messages would provide a very easy mechanism for that; essentially, something akin to systematic garbage collection with collection done whenever the handler completes.

(The 'process' model also implies that such each event handler is not re-entrant wrt. the same state/context object –– or rather, that each state/context object is single-threaded ––; this has significant implications to how e.g. stack can be managed across many event handlers, using just one stack per concurrent thread.)

This is still quite vague in my mind, still forming, but I believe there might be something useful in here.  The Discrete Fourier Transform (DFT) example above also illustrates how its memory management requirements would differ quite a bit from the traditional C and C++ models, what with the concept of "owner" (tracked by the compiler or interpreter at compile time, not at run time).
A key facet I'm adamant on is that instead of pointers, objects are treated as memory ranges (or sets of memory ranges), so that we can finally get rid of silent buffer overrun bugs.
 
The following users thanked this post: DiTBho

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17788
  • Country: fr
Re: event-oriented programming language
« Reply #66 on: January 14, 2023, 07:17:26 pm »
I remember having created a thread about message passing as a way of circumventing synchronization problems entirely. Of course, that was absolutely nothing new.
It has been shown to scale much better and be more robust, but it's still used in niche applications only.

If you are processing a large amount of data, it may look less efficient. All this message passing looks pretty expensive at first sight. But it does require rethinking your data flows almost entirely.

Synchronization and concurrent access in parallel computing are the bottleneck, and are notoriously difficult to get right, and even harder to prove correct.

I have written a small library with message queues and did some experiments with it. It turned out to make it very easy to get near 100% CPU use across all cores for multithreaded computation, compared to a more typical approach. I plan on using that more often.
« Last Edit: January 14, 2023, 07:23:22 pm by SiliconWizard »
 
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 #67 on: January 14, 2023, 07:47:48 pm »
I remember having created a thread about message passing as a way of circumventing synchronization problems entirely. Of course, that was absolutely nothing new.
It has been shown to scale much better and be more robust, but it's still used in niche applications only.

If you are processing a large amount of data, it may look less efficient. All this message passing looks pretty expensive at first sight. But it does require rethinking your data flows almost entirely.
I do believe such change in thinking suits the event-driven paradigm quite well, too.

And, as you said, the 'looks expensive' is just at first sight.

At the hardware level, passing data from one event handler to another is just a pointer, size, and object type (unless included in the passed data object itself).  Avoiding unnecessary copying of data ("zero-copy" approaches) tends to be quite important whenever you have lots of data flowing about.

The key is to consider these event handlers as if they were separate processes inside a superprocess, so that while there is no MMU to stop one event handler from accessing whatever memory it wants within the superprocess, the language itself tracks the accesses at build time: the language itself acts like the MMU.
The idea is to have all memory accesses statically verifiable at compile time, by encouraging (or requiring) developers only use patterns that allow that.

(This in turn implies that concepts like "allocate" and "free" are not sufficient; we need concepts something like "accept" or "take ownership for", and "send" or "release ownership for", so that attempts to access the data afterwards is detected as a violation.)

I mentioned in another thread that if C did not allow or automatically convert between arrays and pointers, and in function declarations variably-modified types were allowed to refer to later parameters in the same argument list (so that one could use (char buf[len], size_t len) and not just (size_t len, char buf[len])), the compiler could track basically all buffer accesses at compile time within each compilation unit, and detect most buffer over/underrun bugs.  (If you write such code today, and carefully avoid using pointers, GCC and Clang do that for you already.)
« Last Edit: January 14, 2023, 07:51:01 pm by Nominal Animal »
 
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 #68 on: January 14, 2023, 10:32:49 pm »
Anyway, that talk made me realize one possible model for 'event handlers' is to model each handler as a process, with events and associated data passed in messages/events between them.  Instead of global memory accessible to all event handlers, each event handler would have their own state/context object(s), plus possibly access to explicitly named read-only or 'slow-atomic' objects.  (Do note that 'process' here is the concept, I'm not referring to OS processes.)
...
This is still quite vague in my mind, still forming, but I believe there might be something useful in here. 
...

There is indeed.

I'll generalise your points to include hardware, which also responds to event such as input changes and which also doesn't have global memory.

If you aren't already familiar with them, do have a look at CSP (Communicating Sequential Processes) and Erlang. CSP makes no theoretical distinction between hardware and software, and has been practically embodied in xC and Occam. The design patterns in those correspond closely to  your thoughts above :)
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 tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: event-oriented programming language
« Reply #69 on: January 14, 2023, 10:44:03 pm »
I remember having created a thread about message passing as a way of circumventing synchronization problems entirely. Of course, that was absolutely nothing new.
It has been shown to scale much better and be more robust, but it's still used in niche applications only.

Important niches, and moving towards being mainstream with modern hardware capabilities/limitations and modern languages.

Quote
If you are processing a large amount of data, it may look less efficient. All this message passing looks pretty expensive at first sight. But it does require rethinking your data flows almost entirely.

There is a tendency that larger blobs imply less frequent messages, thus balancing out to some extent.

Message passing needn't be more expensive that the alternatives. If two processes are sharing memory, then messsages only need to pass pointers in a disciplined way. If they don't share memory then you have to copy anyway.

xC supports both types :)

Quote
Synchronization and concurrent access in parallel computing are the bottleneck, and are notoriously difficult to get right, and even harder to prove correct.

There are two levels to consider:
  • low level: correct use of primitive operations to ensure messages are passed correctly
  • application level: passing the right messages and ensuring the absence of deadlock/livelock

By design, CSP has solid theoretical properties at the application level. In the general case, proving absence of deadlock/livelock will never be easy :)

Quote
I have written a small library with message queues and did some experiments with it. It turned out to make it very easy to get near 100% CPU use across all cores for multithreaded computation, compared to a more typical approach. I plan on using that more often.

I've used Doug Lea's concurrency classes and the half-sync half-async pattern to similar effect in telecom server applications. Another company was so surprised that, unexpectely, they bought access to the application so they could see how it was done :)
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

 

-->