Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Why I don't use Ruby.

Reply
Thread Tools

Why I don't use Ruby.

 
 
Sean O'Dell
Guest
Posts: n/a
 
      07-13-2004
On Tuesday 13 July 2004 14:31, Jim Weirich wrote:
> Sean O'Dell said:
> >> If you can rebind a symbol then you have states and side-effects...

> >
> > If the symbol is local to a function, what side-effect could there be?

>
> One of the benefits of functional languages is the ability to do
> algebraic-like manipulations of the source code ... kinda like provably
> correct refactorings. For example, given X=12, within the scope of X I
> can replace all occurances of X with the value 12 (or the reverse, replace
> all occurances of 12 with X). If X is sometimes 12 and sometimes 13, then
> the substitution is no longer valid anywhere in the scope of X. That is
> why even local variables are immutable in a "pure" functional language.


But this is more of an implementation feature. Tail recursion optimization
and currying are features, not really part of the true definition of a
functional language. You could make C's variables totally immutable and
pre-process C code in the same way. It's a feature that's easy to do with
functional languages, but I don't think truly at the heart of them. Having
mutable, local variables in a functional language disables such features, but
the language is still a functional one.

> > No, functional languages are not supposed to have
> > operators. That's why they're called "functional languages"; they work
> > like functions.

>
> Function being defined as an operation that returns the same result given
> the same input, right? Operators in functional languages are functions in
> this sense. The difference is a matter of syntax, not semantics. E.g.
> 1+2 is allowed in a functional language. The binary operator + is treated
> as a two argument function.


Yes, precisely what I meant.

Sean O'Dell


 
Reply With Quote
 
 
 
 
Sean O'Dell
Guest
Posts: n/a
 
      07-13-2004
On Tuesday 13 July 2004 14:37, Florian Gross wrote:
> Sean O'Dell wrote:
> >>> You're not supposed to have operators in a functional language,
> >>> like =, *, + and so on,
> >>
> >> BTW, an operator is usually nothing more than syntactic sugar for a
> >> function call.

> >
> > No, functional languages are not supposed to have operators. That's
> > why they're called "functional languages"; they work like functions.

>
> Most of those operators are exactly like functions. = isn't if its an
> assignment operator, but if it is an comparison operator it indeed is
> compatible to the definition of the function.
>
> (Just because there's a different syntax for applying it doesn't mean
> that it's really different -- in fact in LISP + is just a function with
> a special name without any additional syntactic sugar.)


I know, but I was trying to illustrate how some people seem to get the rule
against assignment operators confused with simple assignment. You can assign
values to variables in a functional language, you just have to do it through
a function call; the assignment is permitted, however. We're in agreement.

> >>> so you can't assign values "a=10" style, but you should be able
> >>> to say set(a, 10).
> >>
> >> Where is exactly the difference from a semantic POV ?

> >
> > Functional languages set the variable in a functional way.

>
> Functional languages don't enforce a specific syntax like function(arg1,
> arg2) etc., but they indeed specify that a function should have no side
> effects which means that the only way it should be able to interact with
> the outside world is by returning values. (Lambda calculus is the origin
> of functional languages and compared to computer languages its syntax is
> indeed very exotic.)


Unless something has changed, functional languages DO have to enforce a
specific syntax; it must be functional (call, parameter). The precise syntax
is up to each language; lisp does it something like (set a 10) I believe, but
another language could do it set(a, 10). It really doesn't matter.

> I hope I was able to add something valuable.


You did, because I didn't realize that what I had said came out to sound as
though I were asserting a specific syntax was needed. The only real rule
about assignment, I believe (been a long time), is that it must be in a
functional form, and operators are not allowed (can't do a=10).

Sean O'Dell


 
Reply With Quote
 
 
 
 
Florian Gross
Guest
Posts: n/a
 
      07-13-2004
Sean O'Dell wrote:

>>>Here's a question: are "pure" functional programming languages
>>>implemented according to their own rules? Internally, do they also never
>>>use variables? My guess is: no, or almost never. They break the rules
>>>internally to provide an interface that adheres to the rules.

>>It depends. Functional languages implemented in functional languages
>>will be written in a functional style of course. C is no functional
>>language, but most function language interpreters are written in C where
>>you have so many side effects that you *have* to capture different
>>states into variables.

> But how are they usually implemented? In ASM, C, ... ?


What are ASM interpreters implemented in? What are lambda calculus
interpreters (mathematicians) implemented in?

And also note that there *are* machines out there that use LISP as their
native language. (Which means that everything on them, even C compilers,
are implemented in LISP.)

>>The idea of functional languages is that the only thing a function is
>>able to give to the outside is its return value.

> Precisely. What is returned is most important; functions must return
> consistent results for a given set of parameters, regardless of when they are
> called or how often.


This is one important aspect, yes, but this definition still allows side
effects which are disallowed in purely functional languages.

>>In such a pure functional world variables are no longer needed, because
>>you can just use the function call itself where you would otherwise need
>>to use the value that was captured to the variable.

> But within a function, local variables don't affect the return value. True,
> every new function a developer writes could be simply nested calls to other
> functions, but for readability, local variables are very helpful, and as long
> as they're not global or stateful, they don't affect the return value, so to
> the outside world it's still just a function.


Yes, I didn't say that aliases for values were forbidden -- they're just
not necessary in purely functional languages, because you can replace
every refer with the alias to the computation. It's even reasonable to
assume that the languages interpreter will automatically factor out
multiple calls to the same function with the same arguments automatically.

And also note that your program won't be functional anymore when it
depends on a non-functional function, because calling it is usually seen
as replacing its call with its body with arguments inserted into the
right places. (This is inherited from lambda calculus.)

>>The implementation really has nothing to do with this IMHO. It's not
>>really part of the interface after all. (And there can be multiple
>>interpreters for the same language all written in different languages of
>>course. The really interesting parts of this are language interpreters
>>that are written in the very same language that they interpret.)

> Think of new functions that developers write in the language as part of the
> implementation itself. You can give them tools to write new functions in the
> language which don't allow them to break the functional language paradigms,
> such as local variables, just like you can implement a functional language
> such a C, which is definitely NOT a functional language.


If you give them something then it's part of your interface. If
non-functionality is part of your interface then you can't be purely
functional anymore in my opinion.

Regards,
Florian Gross
 
Reply With Quote
 
Florian Gross
Guest
Posts: n/a
 
      07-13-2004
Sean O'Dell wrote:

>>>>> You're not supposed to have operators in a functional
>>>>> language, like =, *, + and so on,
>>>> BTW, an operator is usually nothing more than syntactic sugar
>>>> for a function call.
>>> No, functional languages are not supposed to have operators.
>>> That's why they're called "functional languages"; they work like
>>> functions.

>> Most of those operators are exactly like functions. = isn't if its
>> an assignment operator, but if it is an comparison operator it
>> indeed is compatible to the definition of the function. (Just
>> because there's a different syntax for applying it doesn't mean
>> that it's really different -- in fact in LISP + is just a function
>> with a special name without any additional syntactic sugar.)

> I know, but I was trying to illustrate how some people seem to get
> the rule against assignment operators confused with simple
> assignment. You can assign values to variables in a functional
> language, you just have to do it through a function call; the
> assignment is permitted, however. We're in agreement.


I'm not sure we're that rule is coming from -- do you remember any
sources for this or could you try to explain why it exists for yourself?

I've not seen it before -- I think the only restriction about all this
is that assignment is only a way of aliasing functions or results of
function calls, but nothing more than a notation. (Which means that it
doesn't really give any more power to you than you already had without it.)

>>>>> so you can't assign values "a=10" style, but you should be
>>>>> able to say set(a, 10).
>>>> Where is exactly the difference from a semantic POV ?
>>> Functional languages set the variable in a functional way.

>> Functional languages don't enforce a specific syntax like
>> function(arg1, arg2) etc., but they indeed specify that a function
>> should have no side effects which means that the only way it should
>> be able to interact with the outside world is by returning values.
>> (Lambda calculus is the origin of functional languages and compared
>> to computer languages its syntax is indeed very exotic.)

> Unless something has changed, functional languages DO have to enforce
> a specific syntax; it must be functional (call, parameter). The
> precise syntax is up to each language; lisp does it something like
> (set a 10) I believe, but another language could do it set(a, 10).
> It really doesn't matter.


Well, all you need to do is providing a way to define and apply
functions and some basic built-in functions to make the language
turing-complete. (Unlambda states that only the K- and S-combinators are
needed for defining a turing-complete language, but I still don't
understand this completely.)

I'm not sure if we're saying the same or something different regarding
this point.

>> I hope I was able to add something valuable.

> The only real rule about assignment, I believe (been a long time), is
> that it must be in a functional form, and operators are not allowed
> (can't do a=10).


Why? Where's the difference?

Regards,
Florian Gross
 
Reply With Quote
 
Sean O'Dell
Guest
Posts: n/a
 
      07-13-2004
On Tuesday 13 July 2004 15:22, Florian Gross wrote:
> Sean O'Dell wrote:
> >
> > I know, but I was trying to illustrate how some people seem to get
> > the rule against assignment operators confused with simple
> > assignment. You can assign values to variables in a functional
> > language, you just have to do it through a function call; the
> > assignment is permitted, however. We're in agreement.

>
> I'm not sure we're that rule is coming from -- do you remember any
> sources for this or could you try to explain why it exists for yourself?


I just found a great primer on FP, and I think I have either forgotten a lot
of it from my LISP days, or LISP never had these FP features I'm reading
about. This is really a very authoritative, clear and concise explanation:

http://www.cs.nyu.edu/goldberg/pubs/gold96.pdf

Sean O'Dell


 
Reply With Quote
 
Mikael Brockman
Guest
Posts: n/a
 
      07-13-2004
"Sean O'Dell" <(E-Mail Removed)> writes:

> On Tuesday 13 July 2004 15:22, Florian Gross wrote:
>> Sean O'Dell wrote:
>> >
>> > I know, but I was trying to illustrate how some people seem to get
>> > the rule against assignment operators confused with simple
>> > assignment. You can assign values to variables in a functional
>> > language, you just have to do it through a function call; the
>> > assignment is permitted, however. We're in agreement.

>>
>> I'm not sure we're that rule is coming from -- do you remember any
>> sources for this or could you try to explain why it exists for yourself?

>
> I just found a great primer on FP, and I think I have either forgotten a lot
> of it from my LISP days, or LISP never had these FP features I'm reading
> about. This is really a very authoritative, clear and concise explanation:
>
> http://www.cs.nyu.edu/goldberg/pubs/gold96.pdf


Do you realize that paper disproves both of your claims? It uses
operators and explicitly disallows all assignment and side-effects.

mikael



 
Reply With Quote
 
Florian Gross
Guest
Posts: n/a
 
      07-13-2004
Sean O'Dell wrote:

> On Tuesday 13 July 2004 15:22, Florian Gross wrote:
>
>>Sean O'Dell wrote:
>>
>>>I know, but I was trying to illustrate how some people seem to get
>>>the rule against assignment operators confused with simple
>>>You can assign values to variables in a functional
>>>language, you just have to do it through a function call; the
>>>assignment is permitted, however. We're in agreement.

>>I'm not sure we're that rule is coming from -- do you remember any
>>sources for this or could you try to explain why it exists for yourself?

> I just found a great primer on FP, and I think I have either forgotten a lot
> of it from my LISP days, or LISP never had these FP features I'm reading
> about. This is really a very authoritative, clear and concise explanation:
>
> http://www.cs.nyu.edu/goldberg/pubs/gold96.pdf


Heh, I actually meant to say what's written there on the first page with
all that "variables are just aliases" speech.

If you intended to say this, too, then we're already agreeing here.

(Which means that this special aliasing assignment can be done via an
operator-style syntax or a function-call-style syntax. This also means
that operators and functions are actually the same things with different
syntaxes. )

Oh, and I think that let x = y is actually an operator-style syntax.

Regards,
Florian Gross
 
Reply With Quote
 
Mikael Brockman
Guest
Posts: n/a
 
      07-13-2004
"Sean O'Dell" <(E-Mail Removed)> writes:

> On Tuesday 13 July 2004 14:27, Florian Gross wrote:
>> Sean O'Dell wrote:
>> > Here's a question: are "pure" functional programming languages
>> > implemented according to their own rules? Internally, do they also never
>> > use variables? My guess is: no, or almost never. They break the rules
>> > internally to provide an interface that adheres to the rules.

>>
>> It depends. Functional languages implemented in functional languages
>> will be written in a functional style of course. C is no functional
>> language, but most function language interpreters are written in C where
>> you have so many side effects that you *have* to capture different
>> states into variables.

>
> But how are they usually implemented? In ASM, C, ... ?


GHC, the most popular compiler for Haskell, is written in Haskell.

mikael



 
Reply With Quote
 
Sean O'Dell
Guest
Posts: n/a
 
      07-13-2004
On Tuesday 13 July 2004 16:12, Florian Gross wrote:
> Sean O'Dell wrote:
> >
> > I just found a great primer on FP, and I think I have either forgotten a
> > lot of it from my LISP days, or LISP never had these FP features I'm
> > reading about. This is really a very authoritative, clear and concise
> > explanation:
> >
> > http://www.cs.nyu.edu/goldberg/pubs/gold96.pdf

>
> Heh, I actually meant to say what's written there on the first page with
> all that "variables are just aliases" speech.
>
> If you intended to say this, too, then we're already agreeing here.


Well, I was talking about variables, but I realized after looking at that
primer that I think most people were talking about "macros" or, at least,
that's what I remember calling them. It's been a long time, and LISP was my
only exposure to FP, really. I think I was mis-understanding some of the
terms people were using.

> (Which means that this special aliasing assignment can be done via an
> operator-style syntax or a function-call-style syntax. This also means
> that operators and functions are actually the same things with different
> syntaxes. )
>
> Oh, and I think that let x = y is actually an operator-style syntax.


It sure is; I think I just got a really skewed version of FP in my head.

Sean O'Dell


 
Reply With Quote
 
gabriele renzi
Guest
Posts: n/a
 
      07-13-2004
il Wed, 14 Jul 2004 06:52:18 +0900, "Sean O'Dell" <(E-Mail Removed)>
ha scritto::


>> Functional languages don't enforce a specific syntax like function(arg1,
>> arg2) etc., but they indeed specify that a function should have no side
>> effects which means that the only way it should be able to interact with
>> the outside world is by returning values. (Lambda calculus is the origin
>> of functional languages and compared to computer languages its syntax is
>> indeed very exotic.)

>
>Unless something has changed, functional languages DO have to enforce a
>specific syntax; it must be functional (call, parameter). The precise syntax
>is up to each language; lisp does it something like (set a 10) I believe, but
>another language could do it set(a, 10). It really doesn't matter.
>


not necessarily.
IIRC Haskell, wich is known as one of the purest functrional language
allows
arg1 `function` arg2

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Cisco 2611 and Cisco 1721 : Why , why , why ????? sam@nospam.org Cisco 10 05-01-2005 08:49 AM
Why, why, why??? =?Utf-8?B?VGltOjouLg==?= ASP .Net 6 01-27-2005 03:35 PM
Why Why Why You HAVE NO IDEA MCSE 31 04-24-2004 06:40 PM



Advertisments