595 karma · joined November 18, 2014
Find me at http://shonfeder.net/
By your (imo, extremist) line of reasoning, wouldn't the existence of `unsafePerformIO` mean Haskell itself "looses its ability to reason reliably about operations over time"? I think a more reasonable position allows for gradations of reliability, and appreciates the benefits of encouraging pure computations while allowing room for judicious use of benevolent side effects.
> they are already evolutionary dead-ends
That is patently false, imo. OCaml has a number of interesting features which most statically typed FP languages are yet to explore (e.g., polymorphic variants, (typed) named and optional arguments, first-class modules, binding operators). More to the point, ongoing development on a novel approach to multi-core, native support for algebraic effects, and modular implicits, testify to it being a live evolutionary branch. OCaml aside, innovative languages and approaches like like F, 1Ml, Frank, BER MetaOcaml, and Rust seem to give clear evidence that we still have much to learn from impure* dialects of ML.
The edition could still use some more love (e.g., I had to set up auto-mounting and HiDPI compatible configs myself), but it is remarkably cohesive and (relatively) easy to get going.
There is definitely room for improvement, but this is probably a good place to look or inspiration, and contributing to advance this work might be a good use of energy for those interested.
I love Prolog syntax. I do think there is room for improvement, but the language is also extremely flexible, and it is very easy to roll your own syntax. Funny enough, so far my many experiments with alternative syntax have mainly had the effect of convincing me of the elegance and power of standard Prolog syntax.
While there is no particular reason the '.' should be used to terminate statements (except the resonance with many natural languages in this regard), I think some sort of terminator is necessary to keep the syntax as flexible as possible. Like Lisp, Prolog syntax is isomorphic to its AST. Currently my main gripe with Prolog syntax is that it represents conjunction and delimitation of predicate arguments and list items with the same operator, `(,)/2`. However, that can be fixed in two lines:
:- op(1000, xfy, user:(&)).
A & B :- A, B.
But I'm not sure it really needs "fixing"...Regarding, "batching up a bunch of attributes into one conceptual 'thing'": SWI-Prolog has implemented a special data structure it calls "dicts"[dicts] for this purpose, but I am not very fond of it (and there's a fair amount of concern over the way this implementation breaks compatibility with ISO standards). More traditional solutions are to use lists of "pairs"[pairs], option lists[option], or, for larger data structures and when performance and lookup time is an issue, association lists[assoc] or records[records]. Using the first of these techniques looks like this:
my_foo(a, [bar-Bar, baz-Baz]) :-
Bar = something,
Baz = something_else.
get_attr(Pairs, Key-Value) :-
member(Key-Value, Pairs).
set_attr(Pairs, Key-Value, NewPairs) :-
( select(Key-_, Pairs, Key-Value, NewPairs), !
; NewPairs = [Key-Value|Pairs]
).
?- my_foo(a, As), get_attr(As, baz-X), writeln(X), set_attr(As, boz-another_thing, Bs), writeln(Bs).
something_else
[boz-another_thing,bar-something,baz-something_else]
As = [bar-something, baz-something_else],
X = something_else,
Bs = [boz-another_thing, bar-something, baz-something_else].
It might be the case that Prolog's flexible syntax leaves it spoiled for choices here... That being said, it would be straightforward to implement syntax similar to your description, which evaluates and replace attribute accessors in place, using `term_expansion/2` and `goal_expansion/2`. Then you could use `As.baz` in place of the value itself (I've done so before, and this is what the SWI-Prolog's dict expansion does). Even easier, you could use Michael Hendricks' func package[func] to make a function for this purpose. But I've increasingly come to think of Prolog's explicit evaluation as a unique strength rather than a problem to be solved.[dicts]: http://www.swi-prolog.org/pldoc/man?section=dicts
[pairs]: http://www.swi-prolog.org/pldoc/man?section=pairs
[option]: http://www.swi-prolog.org/pldoc/man?section=option
[records]: http://www.swi-prolog.org/pldoc/man?section=record
Michael Hendricks' talk at last year's Strange Loop on "Production Prolog" gives an excellent high-level survey of the uses, advantages, and drawbacks of Prolog: https://www.youtube.com/watch?v=G_eYTctGZw8
BTW, I have played a tiny bit with Flora2 myself. It seemed really neat. If you're interested in the intersection of OO and Prolog, you may also want to look at Logtalk[0]. FWIW, if I understand your meaning correctly, it is very easy to "pass rules as parameters to other rules" in vanilla Prolog. It facilitates all sorts of higher-order approaches and is very good for meta-programming.
[1]: e.g., SWI Prolog's http://www.swi-prolog.org/pldoc/man?section=clpfd, or http://www.swi-prolog.org/pldoc/man?section=clpqr
>Several terms used in category theory, including the term "morphism", differ from their uses within mathematics itself
There may be other aspects of the appropriation of sexy math terms which you find problematic, but the mere act of borrowing established terms doesn't seem problematic in its own right.
fwiw, I don't like JavaScript and I am interested in and partial to mathematically and logically grounded languages. otoh, I don't care what names JS developers give to their constructs either.
I suggested in a sibling reply that the use of type-theoretic notions in FP is a natural out growth of the initial motives of the FP paradigm. While I wouldn't think that FP languages must incorporate type-theoretic notions, it does seem to me fitting that many would, since type systems have been involved with the functional understanding of computation since quite early on. Do think that line of reasoning make sense?
I think your feeling that the "goalposts have moved" is a result of mistaking 'Functional Programing' as the name for a set of language features. Instead, I understand FP to designate a far reaching paradigm encompassing language design, computer science research, and the design and development of particular programs.
As I understand it, the initial motive for FP was the development of an elegant, mathematically grounded programming style in which the human readable forms of expression neatly reflect the underlying computational model. This is evident in John McCarthy's 1962 "A basis for a mathematical theory of computation"[0], where he presents
> a formalism based on conditionals forms and recursive functions whereby the functions computable in terms of certain base functions can be simply expressed.
The same principles seem to persist right through to the current wikipedia article on FP:
> In computer science, functional programming is a programming paradigm, a style of building the structure and elements of computer programs, that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.
Of course, over the course of 50+ years of ongoing research into FP, and roughly 80 years of research into the functional expression of mathematical foundations, there have been lots of developments and plenty of emergent insights that have altered the reigning implementations of FP languages. The fact that OO languages can keep incorporating features that emerge in FP languages is simply a testament to the fertility of the paradigm.
The advent of type-theoretic constructs (like higher-kinded-types) in FP is directly related to the central motives and inspirations of FP. It continues to draw inspiration from developments in maths. Contemporary FP incorporating ideas from type-theory is just like LISP incorporating ideas form the lambda calculus. Since both FP is an ongoing research and design paradigm, the features and approaches associated with it continue to develop. And unless the implementation of FP languages ever overtakes the ongoing research into functional foundations of mathematics, FP will continue to incorporate findings that emerge in the latter.
I may be mistaken, but I don't believe homoiconicity was ever a central feature of the FP paradigm. And, as you note, is is only associated with FP because LISPs were the paradigmatic FP language for so long. But homoiconicity is always a feature of the primordial OO and LP languages, SmallTalk and Prolog.
[0] - http://dspace.mit.edu/bitstream/handle/1721.1/6099/AIM-031.p...
Michael Hendrick: https://www.youtube.com/watch?v=G_eYTctGZw8
Stylistic quibbles aside, I have some reservations about the choices you've made in diverging from Prolog.
Your use of 'functor' seems to be different from Prolog's. You are therefore adding a forth or fifth meaning to the term, will have to compete with those already given by of Carnap, Quine, category theory, and OCaml. You are, thus, further muddying the sense of an already over-loaded term (http://pinealservo.com/posts/2014-10-22-ManyFunctionsOfFunct...). You seem to use 'functor' to refer to labeled tuples, or positional records. Prolog 'functors' are rather the atoms used to label such structures, e.g., `p(a)` and `p(a,b)` are different compounds with the same functor, 'p'. As a matter of fact, Prolog's compound structures do also serve as labeled tuples, but that is only a symptom of Prolog's explicit evaluation and homoiconicity. In fact, Prolog functors are "function like" in that we can call a functor on arguments, thereby instantiating a predicate. Your "functors" seem to be inert, and I think it would keep things much clearer if you just called them "records" or something. 'Functor' makes sense in the context of Prolog, where labeled compounds can be both data structures and propositions/propositional functions; for in that case, the atom used for labeling also serves a role akin to the string 'sin' in the function `sin(x)`.
This brings me to my other reservation: one of Prolog's real strengths, in my estimation, is the combination of explicit evaluation, unification, and homoiconicity. That combination gives us many higher order behaviors for free and facilitates meta programming. Thus, explicit evaluation and data-as-code means the compound `p(a)` can be mapped over a list, giving us partial application of `p(a,X)`. We also get the equivalence of first-class functions, allowing predicates to be passed as arguments to other predicates. We are also permitted remarkably deep reflection, including unification-matching on predicates and arbitrary data structures: e.g., I can do `p(X,q(r,S)) = p(2+2, Y)` to get the assignments `X = 2+2, Y = q(r,S)` and then `Sum is X * 2`, to get `Sum = 8`, and `S` will still be free until bound to something later.
This is why we differentiate the unification operator `=/2` from the arithmetic evaluation operator `is/2` and various equality operators. Contrary to your assertion, `X = 1+2` works very well, allowing me to do `X =.. [F|Args]` to get the assignments `F = +, Args = [1,2]`, so I can choose to multiply the arguments instead (e.g., `Y =.. [*|Args], Product is Y` getting `Product = 2`), inspect he functor (in this case, `+`), or simply pattern match to get the values in X (`2+Y = X` yielding the assignment `Y = 2`).
As a Prolog user, I have to say, I wouldn't dream of giving up this flexibility just to save the trouble of writing commas for explicit conjunctions and gain the (dubious) convenience of an operator that conflates assignment and equality.
Lastly, as an SWI-Prolog user, it is disingenuous to ask "where is list.map or string.concat?", as I'm sure you are well aware that both of those predicates (and many more besides) are supplied in the standard library. SWI, great as it is, still wants for features, but basic operations like those are well provided for.
So, there's some criticism from an inexpert enthusiast. Truly, I am inspired by your effort and look forward to trying out your language!