On Wed, 2006-08-30 at 21:33 -0400, Peter Tanski wrote:
> On Aug 30, 2006, at 4:54 PM, skaller wrote:
> Unfortunately, no functional language outside
> of Haskell (or a Haskell clone) has quite the ease of functional
> composition. Point-free style is exceptionally succinct.
What's point-free style?
> The
> downside is that everyone may freely create new operators (operators
> are simply infix-functions) so you may see all kinds of crazy stuff
> and even overlap between modules.
You can in Felix too: it's stronger than Haskell, in that
in Haskell you have to use typeclasses to overload.
In Felix .. 'everything' overloads (open overloading).
It's even better than C++: overloading is by name,
but in Felix the name of a function includes its signature
(in C++ it doesn't).
You can also define infix operators:
#infix +++ 10 myadd
however the functions have to have names first (and the operator
so defined is localised to the file which is a bit messy but
better than C macros).
> Higher order functions, currying and partial application are
> difficult operations in C++: Lambda, FC++ and FACT! go to great
> lengths to overload standard C++ operators (though in my opinion FC++
> has shown restraint and done so more elegantly) and to derive return-
> types using nested, recursive templates.
Recursive templates can't be done directly: this is a limitation
of the C++ core language. It has to be done with open recursion,
manually, by the user (or a code generator). This is why Felix
doesn't use C++ templates.
> > ML isn't a functional language: it has mutable store. So does
> > Ocaml. These days even Haskell does :)
>
> According to the definition I gave above, ML is a functional
> language.
If your definition is that it supports functions as values,
then C and C++ are also functional.
C function pointers are first class values, and support
currying.
The key difference is that C functions can't be lexically
scoped more than one level (static/extern globals),
so the closures are trivial, whereas in 'functional'
languages, the closures can bind significant environment
(lexical scoping).
BTW: closure == function value.
> > Any procedural, imperative, or other language should have
> > all these things: imperative languages still have expressions:
> > they still have a functional component.
>
> One of C's most powerful features is the variable-length parameter
> list. Printf is a function but it is practically used as an
> operator.
BTW: Felix can do this now:
var s : string = f"%d" 99;
The LHS term is a 'printf' style literal which acts as a
formatter function.
> (How many people check the return value of printf to see
> how many characters were printed?)
The Felix implementation uses vsnprintf with a NULL
buffer to do that, so it can allocate a large enough
string :)
> You might verify this yourself--functional
> languages have a different feel to them.
So is Felix functional?
> The only other languages that have attempted that kind of built-in
> microthreading seem to have been functional--maybe I'm wrong. Sisal,
> for example was one of the first languages with built-in parallelism
> and is essentially a functional language. Too bad Sisal never caught
> on: it has elegant syntax.
The reason is probably because (a) smart people invent functional
languages .. for PhD theses for example .. (b) Advanced languages
based on actual mathematics are more amenable to coherent extension.
That is, the correlation is incidental, not causal.
The root causation is the desire to have a language
one can reason about -- that is, program compactly and
expressively with good correctness assurances.
> True. The thing for making a programming language popular is how
> easy it is to work with things like parallelism.
Yes, that's why so much work was put into the Async I/O subsystem:
nonblocking socket operations are essential for the fthread (fibres)
to act 'concurrently': we needed to block an fthread, but not
the pthread it is part of.
> I agree. I have followed F# a bit. It's the general C# syntax and
> the .NET system I hate. Programs should be stand-alone, leaving the
> operating system to manage resources.
.NET is an operating system.
So too is Felix! The driver, 'flx_arun', really IS an operating
system! It has a scheduler for fthreads(fibres). It even has
system (kernel) calls .. they're termed 'service calls' after some
archaic operating systems I once used.
Part of the 'cleverness' of the design is that much of the
nasty stuff is stripped away by the optimiser: you can even
statically link with a driver 'flx_run' that refuses to
support any async I/O (and flx_pkgconfig does just that).
> I didn't mean the programming language--to interact with the outside
> world, at least sequencing is certainly a necessary feature for any
> language. I meant the difficulty people seem to have learning to
> program in a (mostly) pure functional language--especially learning
> to program well in a functional language. Too many people who learn
> OCaml use the functional aspects for things like parsing and rely
> heavily on the imperative/procedural features because that is how
> they are used to thinking.
Me included .. look at the Felix compiler.. I can even see older
and new code, with the newer code tending to be more functional
in style.
> SDL is great for games, but you would essentially have to write your
> own GUI library to work with it.
Exactly :)
All the other GUI's are screwed. Felix GUI wants a (f)thread
for each object .. not a callback.
It is certainly possible for Felix to hook GUI callbacks
and control invert .. the problem is the threads for
multiple objects would have trouble communicating.
It is EASY to do for low level windowing systems such
as Windows or X-Windows, since one only needs to dispatch
simple low level messages -- no Widgets. Both these
systems are NOT callback driven .. the user has to
write the dispatcher, and so the user's event loop
is in control.
But Widget libraries control invert: they take control
away irrevocably.
BTW: it can be done .. but it isn't trivial. The basic
idea, floating around for some time, is to
write the Felix scheduler in Felix, so that the top
level 'event loop' is itself micro threaded and
thus can be event driven. The "one more level
of indirection" thing .. :)
> If Felix had a .NET binding it might help with the Windows GUI.
A .NET binding seems quite possible .. I just don't have the
expertise.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language