• by zmonx on 5/1/2017, 10:17:24 PM

    I have two comments about the Prolog code:

    First, the article claims: "the sudoku solver above does a brute force search", but that is specifically not the case. In fact, quite the opposite holds: The Prolog Sudoku formulation shown in the article uses a powerful technique known as Constraint Logic Programming over Finite Domains, which automatically performs pruning before and also during the search for solutions. This effectively eliminates large portions of the search space in practice, and degenerates to brute force only in those cases where almost nothing can be deduced from initial constraints. In the particular case of Sudoku, the pruning is especially effective and can in many cases eliminate the search entirely, since the initial constraints (hints) basically determine the whole solution.

    Second, yes, it is easy to write an O(n!) search algorithm in Prolog. However, it is almost as easy to implement much more efficient search algorithms in Prolog. For example, here is Quicksort in Prolog:

        quicksort([])     --> [].
        quicksort([L|Ls]) -->
                { partition(Ls, L, Smalls, Bigs) },
                quicksort(Smalls), [L], quicksort(Bigs).
    
    Note how natural the declarative description of "first the smaller elements, then the pivot element, then the bigger elements" is in Prolog. This only requires a suitable implementation of partition/4, which is very easy to implement in at most 7 lines of Prolog code.

  • by sixo on 5/1/2017, 4:35:49 PM

    'Concurrency-by-default' is similar to a notation I've been using to map out async service calls. It's just this: lines are terminated with "," or ";". A comma doesn't block and all comma-separated lines are executed in any order, while a semicolon blocks. Names are only usable when a semicolon is reached, and a semicolon unblocks flow when all preceding names are bound. Probably code is scoped into { } blocks. So a lambda is like "pyth_distance = {x, y; sqrt(x^2 + y^2)}". A series of async callbacks would be given by an inner block {x = call1(), y = call2(); pyth_distance(x,y)}, allowing you to do any manipulations you can do with normal code.

    Might try making a toy language out of it eventually.

  • by tannhaeuser on 5/1/2017, 5:43:46 PM

    I don't know if Prolog should be called esoteric. Prolog is an ISO-standardized language after all, and its syntax has been used for 4+ decades now in most papers on conceptual database system and query language design I've read. Which isn't surprising since Prolog syntax, being based on operator-precedence grammar concepts, is arguably as minimalistic as it gets. There's definitely also a lot of interest lately in Datalog, not just as a decidable logic fragment (which has been used for decades as well), but also as a practical non-SQL database query language and proper Prolog syntax subset.

  • by pron on 5/1/2017, 3:29:48 PM

    To this I would add synchronous programming[1], which is particularly suited for interactive or concurrent programs and formal reasoning, and has had success in industry in safety-critical realtime systems. Examples include Esterel[2] and SCADE, and outside realtime, Céu[3] and Eve[4] (the latter is based on Dedalus[5], which combines SP with logic programming).

    As someone who loves formal methods and believes most mainstream software systems today are mostly interactive and/or synchronous, I think this paradigm has a lot of untapped potential, and I'm glad to see it slowly move out of safety-critical systems into the mainstream, in languages like Eve.

    [1]: https://en.wikipedia.org/wiki/Synchronous_programming_langua...

    [2]: https://en.wikipedia.org/wiki/Esterel

    [3]: http://www.ceu-lang.org/

    [4]: http://witheve.com/

    [5]: https://www2.eecs.berkeley.edu/Pubs/TechRpts/2009/EECS-2009-...

  • by robmccoll on 5/1/2017, 3:33:11 PM

    ANI reminds me of HDLs [1] - I'm assuming that's the inspiration with terminology like "latch"?

    Hardware is also concurrent by default. Coding some hardware logic will also change the way you approach coding. Anyone who's interested get an FPGA demo board and write some verilog or VHDL - I highly recommend it.

    1. https://en.wikipedia.org/wiki/Hardware_description_language

  • by richard_shelton on 5/1/2017, 5:05:31 PM

    Honestly, I don't think that "concatenative" is a good term here. I prefer to call it a special case of combinator-oriented programming. You may see examples of this approach in vector languages like APL, FP and in functional world too (see Henderson's book, SICP and so on). The author of Joy (the language which spawned the whole "concatenative" activity) clearly was inspired by Backus's FP. Here we have stack combinators and we can emulate them even in Python, thanks to closures.

    square = code(dup, op("*"))

    Add a bit of syntactic sugar and you'll get "concatenative", or, better stack combinator-oriented language.

    As for Prolog, I really appreciate that the author is calling it "declarative" not a "logic" language. It's more important to learn about backtracking and unification (powerful variant of pattern matching) than about something like Horn clauses. For anyone who wants to learn Prolog better (and it's worth it, Prolog is one of most beautiful PLs around!) I recommend this article: http://www.amzi.com/articles/prolog_under_the_hood.htm

  • by asavinov on 5/1/2017, 3:54:43 PM

    Would like to mention concept-oriented programming [1] which is work in progress but has highly ambitious goals of changing the way we think of programming. The initial idea is to make references active and customized elements of the program which can intercept all accesses to the represented objects. A new programming construct, called concept (hence the name of the approach), describes both behavior of references and behavior of objects. Objects exist in a hierarchy modeled by the concept hierarchy. IS-IN relation is used instead of the traditional IS-A. Also, concept-oriented programming distinguishes between incoming and outgoing methods, that is, every method has two versions: for external access and for internal access. More papers in [2].

    [1] https://arxiv.org/abs/1501.00720 [2] https://www.researchgate.net/profile/Alexandr_Savinov

    Disclaimer: I am the author of concept-oriented programming and data model

  • by anotheryou on 5/1/2017, 3:23:28 PM

    Will Eve ever take off? I like the thoughts behind it.

    https://youtu.be/VZQoAKJPbh8 very good talk about the background of eve. When he finally talks about eve you might want to switch to a more recent talk about it.

  • by nialv7 on 5/1/2017, 8:41:35 PM

  • by dkersten on 5/2/2017, 1:37:23 PM

    A few random comments:

    Forth is a great concatenative language, since its the pioneer in that area (I think), but Factor is definitely worth mentioning too as a "modern" take on the paradigm. It essentially tries to be a concatenative Lisp.

    ANI was dead even in 2014 when this article was written (which the author acknowledges: "the language seems dead, but the concepts are pretty interesting"). It has some really interesting ideas, but since it never got implemented, I'm not sure how much use there is in discussing it here amongst real languages. It would be useful as a discussion for possible future languages for sure, but its currently still just a concept, so I'm not sure what practical thing you can learn from it right now.

  • by oolongtea on 5/1/2017, 7:35:39 PM

    ANI/Plaid reminded me of the LabVIEW visual dataflow language, which is quite widely used in the branch of physics I used to work in, for data acquisition and instrument control. While I've often longed for a text-based alternative that plays better with modern version control and my favorite text editors, I have to say that having everything laid out for you in a visual way does make it easier to reason about the execution flow. That is, after a few years of working with it --- initially, this paradigm shift was rather a painful stretch of the nerves.

    If every language has its own specific dark patterns and bottlenecks, LabVIEW's is definitely the "brightly-colored spaghetti" structural breakdown of an advanced beginner's code :-)

    Incidentally, why do we, as programmers, tend to focus on a language's bottlenecks so much, in such an emotionally charged way? Any psychology-of-programming people out here? You might consider LabVIEW an excellent case study in getting on people's nerves...

  • by mcguire on 5/2/2017, 12:08:59 AM

    For some extra dependently typed fun, check out ATS and Dafny.

    ATS is aimed at system programming, and if you think Idris has a steep learning curve, you'll need belaying for ATS. And, the language is horrible. But it's really mind expanding to see it in action.

    Dafny is a really basic language with support for Hoare/Dijkstra verification. It's completely unlike the type system model.

  • by _pmf_ on 5/1/2017, 3:20:34 PM

    I'd recommend to everybody (but especially those involved in either embedded systems or a lot of concurrent state) to try out HSM / state chart programming (note: this has basically nothing to do with "flat" FSMs). It's as close to a silver bullet as you'll ever get for these kinds of systems.

    Stateflow or QP/QM, all other systems suck.

  • by lioeters on 5/1/2017, 3:56:44 PM

    Thought-provoking. The examples are all programming languages, but the paradigms themselves can apply on a smaller scale, i.e., for application features, as design patterns or inspiration.

    The section on "symbolic programming" has me pondering still about potential implications. It makes me imagine something like a "visual" WYSIWYG editor, but a "conceptual" editor.. Looking forward to digging deeper via provided references.

  • by ramchip on 5/1/2017, 5:12:11 PM

    It's strange to see ANI mentioned as if it were a real, working language. AFAIK it was never able to compile even the samples: https://code.google.com/archive/p/anic/issues/7

  • by dkarapetyan on 5/1/2017, 3:59:13 PM

    Wait. What exactly is esoteric about these paradigms? All the books I've read simply call them regular paradigms.

  • by minxomat on 5/1/2017, 3:42:04 PM

    Curious. ANI seems to me like an abstract form of graph-parallel programming, where the language itself is the scheduler.

    There are some production-ready schedulers for GPP, like Intel's TBB[1] (C++), but learning to be effective with this requires a major shift in thinking about code - essentially thinking in graphs.

    [1] - https://www.threadingbuildingblocks.org/tutorial-intel-tbb-f...

  • by protomyth on 5/1/2017, 5:06:39 PM

  • by combatentropy on 5/1/2017, 5:33:41 PM

      > Dependent types
      > 
      > Example languages: Idris, Agda, Coq
      > 
      > You’re probably used to type systems in languages like C and Java,
      > where the compiler can check that a variable is an integer, list, or string.
      > But what if your compiler could check that a variable is “a positive integer”,
      > “a list of length 2”, or “a string that is a palindrome”?
    
    This is what I love about SQL. You can even define your own types, like "email", at least in PostgreSQL:

      create table contacts (
        name text not null,
        age int check (age >= 0),
        email email
      );
    
    It already has a few of these special types built in, like for IP and MAC addresses (https://www.postgresql.org/docs/current/static/datatype.html).

  • by afdsadf on 5/1/2017, 3:18:35 PM

    Shame not to see factor in the concatenative list, it addresses some of the pain points there with locals

  • by toolslive on 5/2/2017, 5:56:04 AM

    I have also seen _persistent by default_ where every variable is by default store in a database and automatically initialized when you come back to that piece of code. Useful for web development. (Sorry, forgot the name of the programming language)

  • by leovonl on 5/1/2017, 8:52:37 PM

    This classification of "paradigms" is a bit off.

    First, declarative programming is a generic name which includes a broad range of paradigms - from functional to logic programming. Logic programming is something that deserves a special mention and discussion, because there are a number of interesting and unique concepts that deserve a more in-depth explanation.

    Second, "dependent types" is better understood as a feature of a language (or better yet, of a type system) than a paradigm by itself.

    Some of the other "paradigms" also seem more like characteristics of languages, and not really something that structures the way solutions are expressed/understood.

  • by devrandomguy on 5/2/2017, 12:01:07 AM

    There should be a category for analogy based languages. Rail or the Billiard Ball Machine, which looks like Feynman diagrams on a pool table, are examples of this.

    https://esolangs.org/wiki/Rail https://esolangs.org/wiki/Billiard_ball_machine

  • by dragonwriter on 5/2/2017, 2:23:29 AM

    I'm kind of uncomfortable calling "declarative" a paradigm; it's a broad (and not binary) feature. Prolog and SQL are, respectively, the leading examplars of the logic and relational paradigms. They are both fairly declarative (but then, in the age of optimizing compilers, even C is somewhat declarative: your code constrains the result but it doesn't dictate the how as much as it seems to.)

  • by rmidthun on 5/2/2017, 4:30:37 PM

    I would add pictorial programming languages, such as ProGraph if you want a really unusual way to program. Object oriented, but inherently dataflow. Loops were very weird though.

    https://en.wikipedia.org/wiki/Prograph

  • by tjalfi on 5/2/2017, 12:08:49 AM

    ParaSail[0] is another implicitly parallel language. It has similar goals to Rust and Spark Ada.

    [0] https://forge.open-do.org/plugins/moinmoin/parasail/

  • by a_c on 5/1/2017, 4:09:02 PM

    On concatenative languages, I would like to add Piet[1] as a contender. Plus Piet program could look like 8-bit art (to me).

    [1] http://www.dangermouse.net/esoteric/piet.html

  • by westurner on 5/2/2017, 1:20:50 PM

    Re: "Dependent Types"

    In Python, PyContracts supports runtime type-checking and value constraints/assertions (as @contract decorators, annotations, and docstrings).

    https://andreacensi.github.io/contracts/

    Unfortunately, there's yet no unifying syntax between PyContracts and the newer python type annotations which MyPy checks at compile-type.

    https://github.com/python/typeshed

    What does it mean for types to be "a first class member of" a programming language?

  • by Blackthorn on 5/1/2017, 4:49:14 PM

    Concurrency by default feels a bit like the underlying processor of the machine, what with superscalar architectures and all.

  • by garyclarke27 on 5/2/2017, 7:05:07 AM

    Great thought provoking article. Good explanation of Dependent Types, Title is misleading though, should be called - Particular or Specfic Types. Postgres has the same capability - Domains - always surprised that other db's such as sql server have never adopted this useful feature.

  • by oddmunds on 5/1/2017, 3:26:43 PM

    There seems to be and old discussion over here https://news.ycombinator.com/item?id=7565153

  • by Chris2048 on 5/1/2017, 4:10:47 PM

    Aurora looks interesting, but it seems to be .Net/windows only?

  • by DonHopkins on 5/2/2017, 11:24:51 AM

    I recently submitted a link about "Robust First Computing". It didn't get any response, but I'll repeat the link and description here, since it's certainly esoteric, but has some extremely important properties.

    Robust-First Computing: Distributed City Generation https://www.youtube.com/watch?v=XkSXERxucPc

    A Movable Feast Machine [1] is a "Robust First" asynchronous distributed fault tolerant cellular-automata-like computer architecture.

    The video "Distributed City Generation" [2] demonstrates how you can program a set of Movable Feast Machine rules that build a self-healing city that fills all available space with urban sprawl, and even repairs itself after disasters!

    The paper "Local Routing in a new Indefinitely Scalable Architecture" [2] by Trent Small explains how those rules work, how the city streets adaptively learn how to route the cars to nearby buildings they desire to find, and illustrated the advantages of "Robust First" computing:

    Abstract: Local routing is a problem which most of us face on a daily basis as we move around the cities we live in. This study proposes several routing methods based on road signs in a procedurally generated city which does not assume knowledge of global city structure and shows its overall efficiency in a variety of dense city environments. We show that techniques such as Intersection-Canalization allow for this method to be feasible for routing information arbitrarily on an architecture with limited resources.

    This talk "Robust-first computing: Demon Horde Sort" [4] by Dave Ackley describes an inherently robust sorting machine, like "sorting gas", implemented with the open source Movable Feast Machine simulator, available on github [5].

    A Movable Feast Machine is similar in many ways to traditional cellular automata, except for a few important differences that are necessary for infinitely scalable, robust first computing.

    First, the rules are applied to cells in random order, instead of all at once sequentially (which requires double buffering). Many rule application events may execute in parallel, as long as their "light cones" or cells visible to the executing rules do not overlap.

    Second, the "light cone" of a rules, aka the "neighborhood" in cellular automata terms, is larger than typical cellular automata, so the rule can see other cells several steps away.

    Third, the rules have write access to all of the cells in the light cone, not just the one in the center like cellular automata rules. So they can swap cells around to enable mobile machines, which is quite difficult in cellular automata rules like John von Neumann's classic 29 state CA. [6] [7]

    Forth, diffusion is built in. A rule may move the particle to another empty cell, or swap it with another particle in a different cell. And most rules automatically move the particle into a randomly chosen adjacent cell, by default. So the particles behave like gas moving with brownian motion, unless biased by "smart" rules like Maxwell's Demon, like the "sorting gas" described in the Demon Hoard Sort video.

    In this video "Robust-first computing: Announcing ULAM at ECAL 2015" [8], David Ackley explains why "Robust First" computing and computing architectures like Movable Feast Machines are so incredibly important for scaling up incredibly parallel hardware.

    I think this is incredibly important stuff in the long term, because we've hit the wall with determinism, and the demos are so mind blowing and visually breathtaking, that I want to try programming some of my own Movable Feast Machine systems!

    [1] http://movablefeastmachine.org/

    [2] https://www.youtube.com/watch?v=XkSXERxucPc

    [3] http://www.cs.unm.edu/~ackley/papers/paper_tsmall1_11_24.pdf

    [4] https://www.youtube.com/watch?v=helScS3coAE

    [5] https://github.com/DaveAckley/MFM

    [6] https://en.wikipedia.org/wiki/Von_Neumann_cellular_automaton

    [7] https://en.wikipedia.org/wiki/Von_Neumann_universal_construc...

    [8] https://www.youtube.com/watch?v=aR7o8GPgSLk

  • by bryanrasmussen on 5/1/2017, 3:32:22 PM

    Isn't Lua supposed to be an example of a concatenative language?

  • by pitaj on 5/1/2017, 3:43:30 PM

    I believe HN title convention is to remove the number of list items ex. this title should be just "Programming paradigms that will change how you think about coding".