Melbourne Meeting November 2022

What is the relationship between Functional Programming and Arpy? Is there one?

Find out at the next Melbourne meeting when Glen Kleidon (@Glen_Kleidon2) give an update on his Arpy project and a talk on Functional Programming.

Arpy is a framework that provides a new approach to web server development in Delphi. Glen first introduced us to his concept and initial development at our 2019 Symposium.

Functional programming in Delphi gives us ways to reduce lines of code and make the code more readable. Many newer languages are built with functional programming in mind. See how we can restructure code to use the new paradigm.

Come along and hear what Glen has to say, and chat with other members.

When: 6:00pm for a 6:15pm start
Where: At the Melbourne Men’s Shed, and on Zoom.

Zoom link will be up here shortly before the meeting starts.

1 Like

Looking forward to it. It would be great if it was / could be also recorded, and released on our ADUG YouTube channel or other location, sometime down the track.

1 Like

Topic: ADUG November 2022 Melbourne Meeting
Time: Nov 21, 2022 06:00 PM Canberra, Melbourne, Sydney

Join Zoom Meeting

Meeting ID: 815 2737 0125
Passcode: 219581
One tap mobile
+61280156011,81527370125#,*219581# Australia
+61370182005,81527370125#,*219581# Australia

Dial by your location
+61 2 8015 6011 Australia
+61 3 7018 2005 Australia
+61 7 3185 3730 Australia
+61 8 6119 3900 Australia
+61 8 7150 1149 Australia
+1 564 217 2000 US
+1 646 558 8656 US (New York)
+1 646 931 3860 US
+1 669 444 9171 US
+1 669 900 9128 US (San Jose)
+1 689 278 1000 US
+1 719 359 4580 US
+1 253 205 0468 US
+1 253 215 8782 US (Tacoma)
+1 301 715 8592 US (Washington DC)
+1 305 224 1968 US
+1 309 205 3325 US
+1 312 626 6799 US (Chicago)
+1 346 248 7799 US (Houston)
+1 360 209 5623 US
+1 386 347 5053 US
+1 507 473 4847 US
Meeting ID: 815 2737 0125
Passcode: 219581
Find your local number: Zoom International Dial-in Numbers - Zoom

Monday’s Meeting.

Glen Kleidon gave quite an interesting presentation, there was a bit
on Arpy, and a bit related to functional programming.

Arpy has stalled somewhat.

  • Arpy is an implementation of web server-side architecture.
  • The architecture is similar to Node/Express. It seems likely good.
  • Embarcadero showed some initial interest in the product, but has
    since not.
  • It has an architecture that allows the low-level http(s) drivers and
    lots of the other handlers to be swapped in and out. They just need
    the required interface(s) to be implemented.
  • The current builds are broken as the licensing has expired.
  • There was a suggestion that it may become open source :slight_smile:

Functional Programming

  • This part of the presentation showed some of the difficulties
    you run into when programming multi-threaded code using the OOP
    paradigm. Where multiple threads can potentially alter state,
    unless appropriate mechanisms are used to prevent this.
  • I found the demo using “the parallel for task” a bit interesting as the
    task was broken up into the required number of tasks, but only ran
    to the number of CPUs at a time.
    Ten tasks, but running 2 at a time from start to completion, as
    there were 2 CPUs.

Apparently functional programming helps with this.
(No Mutable state)

Thanks

2 Likes

@Glen_Kleidon2 Thanks for the presentation.
Was there a link to some example code in the talk, please?

Arpy documentation is at

http://www.galkam.com.au/arpy

The source code for the Tasks examples is at

https://github.com/glenkleidon/Delphi_Tasks_And_Functions

2 Likes

Thank you. :+1:

Here is the recording of the meeting. Unfortunately the last few minutes of the meeting didn’t get recorded.

1 Like

@Glen_Kleidon2

Dalija Prasnikar in her blog discussing some of the same “baked in parameter” questions …

and here :

The effect you are observing is due to anonymous method variable capture mechanism. It does not capture variable values at specific point during code execution, but location of the variables.

Since all tasks run after the loop where you create them, you will see only the last value stored.

To solve your problem you have to add additional function ensuring that you don’t capture common variables in your task.

function CreateTask(vfirst, vlast, vsize, indtask: integer; var varray: Vet): ITask;
var
  va: Vet;
begin
  // var parameter cannot be captured so we have to store it into
  // local variable - dynamic arrays act like pointers and any changes
  // to local variable will actually change the original too        
  va := varray;
  Result := TTask.Create(
        procedure
        begin
          ProcA(vfirst, vlast, vsize, indtask, va);
        end);
end;

And then you call it like

  Ptasks[indtask] := CreateTask(vfirst, vlast, vsize, indtask, varray);