Live data from Hacker News

Programming Beyond Paradigms

micahcantor.com

61–68 of 68 posts

Re: Programming Beyond Paradigms

#61
Hmm...I still don't think that the differences between imperative, OO and functional programming are sufficient for them to be called "paradigms" and for a language that supports variations to be called "multi-paradigm"

"What kinds of music do you have here"

"Oh we got both kinds: Country and Western"

(Blues Brothers, https://www.youtube.com/watch?v=vS-zEH8YmiM)

Let's see:

    f(x)    // procedural, side effects discouraged
    x.f()   // OO, the procedures are scoped/namespaced/grouped
    f(x)    // functional, side effects disallowed
OK, that's a little facetious, but only a little. More details here:

https://2020.programming-conference.org/details/salon-2020-p...

So yeah, we need to go beyond this.

https://blog.metaobject.com/2019/02/why-architecture-oriente...

Re: Programming Beyond Paradigms

#62
post #51

Earlier quoted context omitted.

It isn't clear what you're discussing. You mentioned that functional programming has lost its meaning and then went on to describe things as if your defintion would exclude some of the most shining examples of functional programming. Functional does not mean just pure functional. And a purely pure functional language would literally be worthless as it wouldn't be able to do anything useful.

> then went on to describe things as if your defintion would exclude some of the most shining examples of functional programming Maybe those examples are "most shining" from your perspective or definition but not mine. Mind to mention the specific languages? That being said, to be precise, functional programming is a technique or style, it's not a property of a language anyhow. However, some languages make it very ha…

I guess I was confused, and still am, about what the point is here.

> You haven't understand what functional programming is.

I almost exclusively use functional languages, so I'm not sure about that.

> I was ranting a bit that the term "functional" is nowadays so unclear that there is little benefit in knowing that a language is "functional".

I'm actually not sure that is a problem. Any examples? And it's quite common to describe something as "functional-first" if it has a functional core but allows other paradigms such as imperative or OOP, such as OCaml.

And a lot of this is based upon the semantics and definitions of the words like "pure", "functional", etc. which are more like spectrums than binary.

Re: Programming Beyond Paradigms

#63
post #60

Earlier quoted context omitted.

LINQ is an interesting example because it exists in two forms, query syntax and method syntax. You might consider these "mini-paradigms". Most users know one or the other. I've rarely met people who are equally proficient at both. But almost anything you can accomplish in query form can also be done in method form, and the industry has settled on method syntax as the standard. Why do you think that is? I think it's b…

I think it is more about education, the way "we" study/teach programming than an intrinsecally problem about paradigms. I personally find the query syntax better and I am not working as a developer "anymore". I would say that is a matter of taste and education. Related [1]. Personally, I look for simple and clear syntaxes and don't have a problem switching from one programming language to another while the focus in t…

I understand what you're saying, and I agree people should be able to switch as needed. But look at one of the top comments from that link (I swear that wasn't me):

"I find query syntax nigh unreadable. It's like someone stuck some other language in the middle of my C#. The mental switch between that small snippet of code and the surrounding code is harsh and annoying." [1]

[1] https://www.reddit.com/r/csharp/comments/w7n11s/why_does_the...

Re: Programming Beyond Paradigms

#64

A better example is the Oz programming language and the Mozart programming system ( https://en.wikipedia.org/wiki/Oz_(programming_language) ) explained in the book Concepts, Techniques, and Models of Computer Programing by Peter Van Roy and Seif Haridi .

Not necessarily. Oz was created as poster child to multi-paradigm language design. The book shows this. Each paradigm gets its own chapter and Oz examples to program in each are shown. This is similar to the cirricula structure author mentions. In contrast the article makes a case for programming without paradigm distinction and mixing elements across styles. Since Oz's Wikipedia page was linked, Wikipedia apparently…

The original article did not actually make much sense to me since there can be no "Programming beyond Paradigms" by virtue of the fact that all languages allow solving problems in at least one "default" Paradigm (the computation model embodied by its abstract machine). Thus the correct term is "Multi Paradigm" and current day languages do this to varying levels of ease by providing appropriate syntactic features mapping to abstract machines. In that regard Mozart/Oz is the poster child since unlike other languages that is its stated goal.

The author states "I believe that programming paradigms are now best understood as a style of programming, rather than as an exclusive set of features." which is not correct. A "Style of Programming" is not a "Paradigm" unless that style embodies a specific computation/abstract machine model. The relevant syntactic features could be used in a mix-and-match manner to increase the design expression space. A good example is the template features in C++; originally designed as an alternative to macros to implement containers until some smart people figured out that it was much more powerful and could be used for programming in the "Functional Paradigm" (with some additional extensions).

Re: Programming Beyond Paradigms

#65
post #62

Earlier quoted context omitted.

> then went on to describe things as if your defintion would exclude some of the most shining examples of functional programming Maybe those examples are "most shining" from your perspective or definition but not mine. Mind to mention the specific languages? That being said, to be precise, functional programming is a technique or style, it's not a property of a language anyhow. However, some languages make it very ha…

I guess I was confused, and still am, about what the point is here. > You haven't understand what functional programming is. I almost exclusively use functional languages, so I'm not sure about that. > I was ranting a bit that the term "functional" is nowadays so unclear that there is little benefit in knowing that a language is "functional". I'm actually not sure that is a problem. Any examples? And it's quite commo…

Yeah, you hit the nail on the head. ;)

> definitions of the words like "pure", "functional", etc. which are more like spectrums than binary.

That's exactly it. "functional programming" originally was not a spectrum. It was well defined. Functions meant "pure functions" or (which is the same) "mathematical functions" in that context. And they still do when people use the term "functional programming" in the original meaning. Though nowadays, I rather use "pure functional programming" since "functional programming" was taken over. ;-)

So on the other hand, can you provide a precise and meaningful definition for "functional" from your own perspective?

Re: Programming Beyond Paradigms

#66
post #39

Earlier quoted context omitted.

Not necessarily. Oz was created as poster child to multi-paradigm language design. The book shows this. Each paradigm gets its own chapter and Oz examples to program in each are shown. This is similar to the cirricula structure author mentions. In contrast the article makes a case for programming without paradigm distinction and mixing elements across styles. Since Oz's Wikipedia page was linked, Wikipedia apparently…

My impression is that the Wolfram language is not particularly object-oriented and that it does not support OOP. Am I wrong? It has certain features that are enablers for libraries supporting OOP. OTOH Java has a defined language standard (independent of implementations), which describes classes/fields/methods/dynamic dispatch/inheritance/hiding/constructors, ... ( https://docs.oracle.com/javase/specs/jls/se22/html/j…

Not sure either. Could exist but don't know about it and sadly Wolfram lacks a formal specification. After bit of searching though found there're few[0] packages to enable object-oriented programming. So can probably assume there isn't native support for it. Seems the Wikipedia page needs more thorough research.

[0]: https://raw.githubusercontent.com/antononcube/MathematicaFor...

Re: Programming Beyond Paradigms

#67

Earlier quoted context omitted.

A lisp that didn’t spam parentheses would probably be more palatable.

Classic counter-answer: Javascript: f(x). Lisp: (f x). Javascript: f(g(x)) Lisp: (f (g x)) Same amount of parens.

This is called “proof by example” and is a fallacy.

Show me how to write `a + b * c` in Lisp without parentheses.

Re: Programming Beyond Paradigms

#68
post #67

Earlier quoted context omitted.

Classic counter-answer: Javascript: f(x). Lisp: (f x). Javascript: f(g(x)) Lisp: (f (g x)) Same amount of parens.

This is called “proof by example” and is a fallacy. Show me how to write `a + b * c` in Lisp without parentheses.

One version would be to actually leave the expression as is and temporarily switch the Lisp reader to Infix.

I'm loading an infix reader macro into LispWorks, the code is roughly 30 years old:

    CL-USER 1 > (ql:quickload "INFIX")
    To load "infix":
      Load 1 ASDF system:
        infix
    ; Loading "infix"

    ;;; *************************************************************************
    ;;;   Infix notation for Common Lisp.
    ;;;   Version 1.3  28-JUN-96.
    ;;;   Written by Mark Kantrowitz, CMU School of Computer Science.
    ;;;   Copyright (c) 1993-95. All rights reserved.
    ;;;   May be freely redistributed, provided this notice is left intact.
    ;;;   This software is made available AS IS, without any warranty.
    ;;; *************************************************************************

    ("INFIX")
Now we can write Infix expressions:

    CL-USER 2 > '#I( a + b * c )
    (+ A (* B C))
Let's set the variables a, b, c

    CL-USER 3 > setf a 10 b 20 c 30
    30
The Infix expression reader macro at work:

    CL-USER 4 > #I( a + b * c)
    610
Inside the Infix macro Lisp parses a sublanguage of Infix expressions into Lisp s-expressions. Generally this would be possible with a normal macro, but the reader also changes the tokenizing of elements, so we can also write:

    CL-USER 5 > #I(a+b*c)
    610
In "normal" Lisp syntax a+b*c would be a single symbol. The infix reader parses it into five symbols and a list according to operator priorities.
Post reply on HN