Re: Curious about "functional programming"

2018-01-05 Thread brianpowers via 4D_Tech
I believe that there is a place for incorporating functional programming
aspects into 4d programming.  As the size of a given function increases, we
have a tendency to grow the number of outside dependencies. (Database calls,
Non-locally scoped variables,etc...) Code that has a large number of
externalities becomes practically untestable.

Functional code is 100% unit testable.  This is a primary consideration in
larger systems where we are investing in code quality.  Being able to reduce
regressions lends itself to more flexible code as the system changes.  

In Object Oriented world the S.O.L.I.D. principles are well revered and lend
themselves to maintainable code.  The D stands for dependency injection and
is a pattern used to reduce the externality of a given chunk of code.  By
isolating external functions to their own function, the rest of the code
base can become more functional in nature.  While this may seem like extra
overhead, the benefit comes in maintainability.



--
Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re(4): Curious about "functional programming"

2017-12-22 Thread Don Lapin via 4D_Tech
Thanks John.

- Don

>
>> On Dec 22, 2017, at 1:44 AM, Don Lapin via 4D_Tech <4d_tech@lists.
>4d.com> wrote:
>> 
>> Do the difficulties of a functional approach apply to almost any
>database-type application, or is it more the issues with error handling
>in 4D? 
>
>Difficulties implementing a functional approach arise from only being
>able to do certain things with mutable data structures. Programming
>languages that support a functional approach usually support both
>mutable and immutable data structures. A database is inherently mutable,
>so I suppose that part makes it difficult to begin with.
>
>> 
>> Are there other circumstances where a functional approach works well,
>or is it simply an ideal? Do object-oriented languages (Python/Java/
>Apex?) work better in this regard, or is language unrelated to
>functional programming?
>
>It works well for highly parallel systems and some newer languages were
>designed with functional support features specifically for this purpose.
>For example see Clojure, Haskell, and Erlang.
>
>John DeSoi, Ph.D.
>
>
>
>**
>4D Internet Users Group (4D iNUG)
>FAQ:  http://lists.4d.com/faqnug.html
>Archive:  http://lists.4d.com/archives.html
>Options: http://lists.4d.com/mailman/options/4d_tech
>Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
>**

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Re(2): Curious about "functional programming"

2017-12-22 Thread John DeSoi via 4D_Tech

> On Dec 22, 2017, at 1:44 AM, Don Lapin via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Do the difficulties of a functional approach apply to almost any 
> database-type application, or is it more the issues with error handling in 
> 4D? 

Difficulties implementing a functional approach arise from only being able to 
do certain things with mutable data structures. Programming languages that 
support a functional approach usually support both mutable and immutable data 
structures. A database is inherently mutable, so I suppose that part makes it 
difficult to begin with.

> 
> Are there other circumstances where a functional approach works well, or is 
> it simply an ideal? Do object-oriented languages (Python/Java/Apex?) work 
> better in this regard, or is language unrelated to functional programming?

It works well for highly parallel systems and some newer languages were 
designed with functional support features specifically for this purpose. For 
example see Clojure, Haskell, and Erlang.

John DeSoi, Ph.D.



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re(2): Curious about "functional programming"

2017-12-21 Thread Don Lapin via 4D_Tech
Hi John,

Do the difficulties of a functional approach apply to almost any database-type 
application, or is it more the issues with error handling in 4D? 

Are there other circumstances where a functional approach works well, or is it 
simply an ideal? Do object-oriented languages (Python/Java/Apex?) work better 
in this regard, or is language unrelated to functional programming?

Thanks (also to Chuck) for replying,
Don


>
>> On Dec 21, 2017, at 3:06 PM, Don Lapin via 4D_Tech <4d_tech@lists.
>4d.com> wrote:
>> 
>> 4D does not seem to lend itself to the functional approach.
>
>Completely true. Changing the database is non-functional. You could try
>to enforce this discipline, but I think it would be difficult to get
>real work done in 4D. Even if you never passed a pointer or used a
>process/interprocess variable, a method might have side effects if it
>changes the database or modifies an object parameter. Error handling in
>4D is incredibly primitive compared to other languages and the only way
>to get error information is via side effects.
>
>
>> 
>> When designing something new, do you give any thought to using one or
>the other approach? Do you force yourself to only return values to a
>calling method? Or do these paradigms represent a distinction of no
>practical significance?
>
>
>I think making every method functional with minimal side effects is a
>good goal. But I don't think it is possible to write understandable and
>maintainable 4D code using a purely functional approach.
>
>John DeSoi, Ph.D.
>
>**
>4D Internet Users Group (4D iNUG)
>FAQ:  http://lists.4d.com/faqnug.html
>Archive:  http://lists.4d.com/archives.html
>Options: http://lists.4d.com/mailman/options/4d_tech
>Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
>**

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Curious about "functional programming"

2017-12-21 Thread John DeSoi via 4D_Tech

> On Dec 21, 2017, at 3:06 PM, Don Lapin via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> 4D does not seem to lend itself to the functional approach.

Completely true. Changing the database is non-functional. You could try to 
enforce this discipline, but I think it would be difficult to get real work 
done in 4D. Even if you never passed a pointer or used a process/interprocess 
variable, a method might have side effects if it changes the database or 
modifies an object parameter. Error handling in 4D is incredibly primitive 
compared to other languages and the only way to get error information is via 
side effects.


> 
> When designing something new, do you give any thought to using one or the 
> other approach? Do you force yourself to only return values to a calling 
> method? Or do these paradigms represent a distinction of no practical 
> significance?


I think making every method functional with minimal side effects is a good 
goal. But I don't think it is possible to write understandable and maintainable 
4D code using a purely functional approach.

John DeSoi, Ph.D.

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Curious about "functional programming"

2017-12-21 Thread Charles Miller via 4D_Tech
I view it a little differently although my CS backround is old (graduated
in 1983 with MS)., Procerdural is a style which is baed upon a language,
COBOL for example ios a procedural based language. C++ is an object based
language. Not sure if this helps

Happy holidays to all and to all a good night
Chuck


On Thu, Dec 21, 2017 at 4:06 PM, Don Lapin via 4D_Tech <4d_tech@lists.4d.com
> wrote:

> Hello,
>
> There seem to be at least two different "programming paradigms":
>
> - Procedural programming, where the subroutines make changes to the
> system; and
>
> - Functional programming, where called methods only return results to the
> calling method (ie, the called method does not perform any work which
> changes "state" of the system itself).
>
> There is some discussion of functional programming on Wikipedia.
>
> I looked back on forum messages and didn't find a discussion on this
> topic. Is it too abstract to be practical?
>
> When I'm creating something in 4D, I use both approaches. When some task
> runs to thousands of lines of code, I break it up into subroutines. Usually
> the subroutines perform the actual work - calculations which update field
> or array values.
>
> In some instances, I will write a routine which returns the work product
> without making other changes. But usually the task becomes more complicated
> when it must return its work, rather than simply doing the work.
>
> 4D does not seem to lend itself to the functional approach.
>
> When designing something new, do you give any thought to using one or the
> other approach? Do you force yourself to only return values to a calling
> method? Or do these paradigms represent a distinction of no practical
> significance?
>
> Thanks,
> Don
>
>
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **




-- 
-
 Chuck Miller Voice: (617) 739-0306 Fax: (617) 232-1064
 Informed Solutions, Inc.
 Brookline, MA 02446 USA Registered 4D Developer
   Providers of 4D, Sybase & SQL Server connectivity
  http://www.informed-solutions.com
-
This message and any attached documents contain information which may be
confidential, subject to privilege or exempt from disclosure under
applicable law.  These materials are intended only for the use of the
intended recipient. If you are not the intended recipient of this
transmission, you are hereby notified that any distribution, disclosure,
printing, copying, storage, modification or the taking of any action in
reliance upon this transmission is strictly prohibited.  Delivery of this
message to any person other than the intended recipient shall not
compromise or waive such confidentiality, privilege or exemption
from disclosure as to this communication.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Curious about "functional programming"

2017-12-21 Thread Don Lapin via 4D_Tech
Hello,

There seem to be at least two different "programming paradigms": 

- Procedural programming, where the subroutines make changes to the system; and 

- Functional programming, where called methods only return results to the 
calling method (ie, the called method does not perform any work which changes 
"state" of the system itself).

There is some discussion of functional programming on Wikipedia.

I looked back on forum messages and didn't find a discussion on this topic. Is 
it too abstract to be practical?

When I'm creating something in 4D, I use both approaches. When some task runs 
to thousands of lines of code, I break it up into subroutines. Usually the 
subroutines perform the actual work - calculations which update field or array 
values. 

In some instances, I will write a routine which returns the work product 
without making other changes. But usually the task becomes more complicated 
when it must return its work, rather than simply doing the work.

4D does not seem to lend itself to the functional approach.

When designing something new, do you give any thought to using one or the other 
approach? Do you force yourself to only return values to a calling method? Or 
do these paradigms represent a distinction of no practical significance?

Thanks,
Don


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**