Page 1 of 1

Functional programming ?

Posted: Thu Nov 18, 2021 8:48 am
by Simon Knight
Hi,

While I understand that Livecode does not provide "Functional Programming" commands I am hoping that one of the forum experts might be able to explain what it is and why it is seen by some programmers as an advantage.

My own googling suggests that it is a way of processing items contained in lists where the call to the routine includes the list and the "operation" that is to be performed on each item in the list with the result being passed back as a second list.

I found this paper on the Livecode site https://livecode.com/functional-feature ... t-a-dream/ but I am uncertain if and why the techniques are significant.

It is probably best if any explanations are kept to about the same level of complexity as you would use why speaking to your pet dog.

best wishes
Simon

Re: Functional programming ?

Posted: Thu Nov 18, 2021 10:21 am
by stam
Very good question Skids - after googling this i came away more confused...

I suspect the reality is probably that LC has some features of 'functional programming' or that it may be possible to emulate structures from other languages that are classed as such.

But at the end of the day this differentiation may be completely abstract and academic. Each language has a natural flow and trying to bend one language into the flow of another may not make for a happy future. Maybe.
Or i might be completely wrong ;)

Out of curiosity, was there a specific issue you were trying to solve, or is this a thought experiment?

Re: Functional programming ?

Posted: Thu Nov 18, 2021 10:53 am
by richmond62
If one were really bloody-minded one could write a routine in LiveCode that would read its
way through a truckload of code in a different programming language (say, in a field in a stack)
and convert it into LiveCode.

This would take a very long time and a large amount of effort which would probably involve learning the other
language as well; so hardly justifiable.

Re: Functional programming ?

Posted: Thu Nov 18, 2021 3:19 pm
by dunbarx
I just read a little about Functional Programming as well, and I think that LC is flexible enough to emulate that style. It seems that the main strength of functional programs is the ability to embed functions and parameters into other "parent" functions in compact ways. It would be interesting to take a simple problem (an example I read about was to take a list of names and return only the first names) and see how these compare.

I note that the above task in LC would take about six lines.

Craig

Re: Functional programming ?

Posted: Thu Nov 18, 2021 5:27 pm
by Simon Knight
#Stam. Just a thought experiment. Last night I watched a Youtube video about designing the worlds worst programming language (Its named BS by the way) https://www.youtube.com/watch?v=hCvHTrUh4os , its worth a watch. Anyway when it finished the next video was about what makes programming languages successful and the speaker describes himself as a Functional Programmer, https://www.youtube.com/watch?v=QyJZzq0v7Z4 .

I googled Functional Programming and came up with Lambda functions, Map and Filter commands and finally the paper I linked to above. It seemed to me that the use of Functional Programming is used to overcome some limitations of the language, Python I think, overall I was left thinking so what? I also suspect that the popularity may have something to do with brevity. So taking Dunbarx's example I guess the advantage is that the whole definition and call was in one single line, whereas in LC we have to define a function which is called from elsewhere.

I'm hoping that someone who has used a Functional Programming language may chime in and explain what the advantages are.

Simon

Re: Functional programming ?

Posted: Thu Nov 18, 2021 5:59 pm
by richmond62
https://en.wikipedia.org/wiki/Functional_programming
Functional programming languages are typically less efficient in their use of CPU and memory than imperative languages such as C and Pascal/quote]

Re: Functional programming ?

Posted: Thu Nov 18, 2021 6:16 pm
by Klaus
I read the german Wikipedia entry for this and now:
monty.jpg

Re: Functional programming ?

Posted: Thu Nov 18, 2021 7:35 pm
by FourthWorld
Which is best?:
a) Model-View-Controller
b) Model-View-Presenter
c) Shipping an app

#ThingsTheoristsDebateOnTheInternet

Re: Functional programming ?

Posted: Thu Nov 18, 2021 7:39 pm
by richmond62
I believe what is best is what a programmer is comfortable with
and which delivers what the programmer wants to deliver.

So whether Functional programming or non-Functional programming is best is
a bit like whether you prefer blue cheese or stinky tofu for breakfast.

Re: Functional programming ?

Posted: Thu Nov 18, 2021 7:53 pm
by Klaus
FourthWorld wrote:
Thu Nov 18, 2021 7:35 pm
Which is best?:
a) Model-View-Controller
b) Model-View-Presenter
c) Shipping an app
Yes! Definitively! :D

Re: Functional programming ?

Posted: Mon Nov 22, 2021 11:19 pm
by jiml
Which is best?:
a) Model-View-Controller
b) Model-View-Presenter
c) Shipping an app
😂😂😂😂😂

Re: Functional programming ?

Posted: Tue Nov 23, 2021 8:49 am
by Simon Knight
a) Model-View-Controller
b) Model-View-Presenter
:?: :?: :shock: :?: :?:

Two people who work for a TV show about Airfix perhaps