
Picat – a logic-based multi-paradigm programming language - sriku
http://www.picat-lang.org
======
auto
Is it just me, or is there an uptick in boutique programming language posts on
HN lately? Not complaining, just curious if anyone else has noticed.

~~~
TuringTest
I'd say it's a general trend in industry, similar to that in the 80's with
their fourth generation languages.

It happens when the current programming languages fail short of solving the
most difficult problems the industry faces and programmers explore some
paradigms that solve them nicely, but those paradigms haven't been integrated
into a single coherent platform.

This shift is pretty much happening with reactive functional programming -
which solves asynchronous calls in the web -, and to some extent with large-
scale module composition, which still lacks a good widely known solution.

------
pmontra
Congratulations for the code examples on the home page. Not every language
designer does that. Plenty of examples on HN.

My only criticism is about dots and commas, and I know where they come from.
Especially as

> Picat, as a scripting language, is as powerful as Python and Ruby.

But I'm not adding commas and dots to the end of each line, it's a little
nightmare. I'm staying with Python and Ruby for scripting.

Is there really no way for logic programming languages to skip commas and dots
or is it only a tradition?

~~~
Skinney
The commas and dots are operators, not syntax.

one, two, three.

Is essentially compiled down to:

if (one && two && three) { return three; }

Whereas

one, two, three;

one, four.

compiles down to:

if (one && two && three) { return three; } else if (one && four) { return
four; }

So yeah, it's not syntax.

, === &&

; === ||

. marks end of a condition, so } in C.

~~~
pmontra
The script is

    
    
      import util.
    
      input_data(Tri) => 
        Lines = read_file_lines("triangle.txt"),
        Tri = new_array(Lines.length),
        I = 1,
        foreach(Line in Lines)
            Tri[I] = Line.split().map(to_integer).to_array(),
            I := I+1
        end.
    

In the mind of an imperative scripting developer those commas are (useless)
semicolons.

I wrote a little Prolog some 30 years ago. Probably those commas and dots have
the same function, logic and, as you write.

I understand that it's a core feature of the language, but its really awkward
when using Picat imperatively. I've seen this dynamic of obeyibg to tradition
in many languages. The vast majority of developers are used to imperative
languages. If designers of functional, logic, etc languages want to hijack
those developers to their own language they could try to be creative and bold
and give those developers a syntax their are familiar with.

Elixir has a Ruby like syntax to Erlang and had some success at onboarding
Ruby developers. But it wasn't bold. Example: they didn't have courage to turn
GenServer into a Class with a CPU. It's still a bag of functions, partly
called by clients, partly called by the server, with method names (if it was a
class) hidden in arguments and explicit state management.

The Reia language was a bolder attempt but unfortunately its designer liked
Elixir and killed his project. My guess: there would be many more Reia
developers than Elixir ones by now.

[http://reia-lang.org/](http://reia-lang.org/)

~~~
YeGoblynQueenne
I changed all the commas to "and"'s" and the dots to ";"'s (except in a.b
statements):

    
    
      import util;
    
      input_data(Tri) => 
        Lines = read_file_lines("triangle.txt") and 
        Tri = new_array(Lines.length) and 
        I = 1 and 
        foreach(Line in Lines)
            Tri[I] = Line.split().map(to_integer).to_array() and 
            I := I+1
        end;
    
    

Is that better?

~~~
pmontra
No. My point is that language designers should try to implement different
paradigms with mainstream syntax. This if they are interested in making their
languages mainstream, which might not be their goal.

The script should do without the ands, the commas and the colons. The end of
line should be the and, or what the language understands to be the end of a
statement.

By the way, the dot or the semicolon after the end look really redundant.

~~~
YeGoblynQueenne
>> The end of line should be the and, or what the language understands to be
the end of a statement.

The problem with that is that the "," is there not to separate statements
("literals") but to declare a relation between them, specifically,
conjunction.

Conjunction is one relation that you may way to declare between literals.
There is also disjunction and implication. So you do need something to
separate "A and B" from "A or B" and "A if B".

You say- "use whitespace for the and". OK. But then, what about the "or" and
the "if"? And if we use special symbols for the "or" and the "if" then what's
the point of not using one for the "and" also?

As to "block" delimiters, like "." or ";" etc. As far as I can tell the only
languages that do not have "block" delimiters are the kind you can find on
[https://esolangs.org/wiki/](https://esolangs.org/wiki/), and that is for
reasons of a) readability, actually and b) convenience in compiler writing.

------
sriku
A previous submission on Picat:
[https://news.ycombinator.com/item?id=16563349](https://news.ycombinator.com/item?id=16563349)

Not sure why the older posting wasn't picked up when I submitted the link.

~~~
detaro
because it was "a long time ago"

------
its_the_future
I won't know who Hakan Kjellerstrand is, but if you quote him you should
either put [sic] following "suites" or put [suits] instead of it. Gives a bad
impression straight off the bat. You could argue language is different from
programming but to my subconscious mind it speaks of a lack of attention to
detail and excellence.

~~~
nurettin
If you search for constraint programming examples on the internet, you will
eventually end up on his web page.

------
philip142au
There are functional languages which have logic programming libraries.

------
philip142au
Really bad idea... please no imperative

~~~
GoToRO
Actually I see all the non-imperative ways as lost time in software
development. At some point we will realize that people think imperatively.

~~~
cultus
Software developers who are taught imperative programming are used to
translating their high-level, human thoughts into imperative instructions
telling the computer exactly what to do to make the answer they want.

With functional programming, one is able to translate thoughts more directly.
Non-programmers actually have an easier time with functional concepts like
mapping than for loops, non-local mutation, etc.

At any rate, imperative languages have a legacy of frankly buggy, shitty
software. As programs get larger and more concurrent, this problem is getting
much, much worse. That's why functional(ish) libraries like Redux are so
popular. They can help tame this complexity.

Imperative programming absolutely has its place in certain situations like
systems or numerical programming, but it is a poor tool for most things people
program. Rust, I think, is imperative programming done right. While it's a bit
confusing with all the pointer types, it has the tools needed to safely
mutate, etc.

