Monday, September 30, 2019

Sentient: a high-level, declarative programming language

Hello,

Computer, here’s my problem. Go figure.

Sentient is a high-level, declarative programming language that lets you describe what your problem is and not how to solve it. Sentient tries to figure that out for itself. It provides a rich toolkit to allow programmers to express their problems in a familiar way.

The following Sentient program solves the subset sum problem. The challenge is to find a subset of numbers that add up to the given sum. This program iterates through an array of ‘numbers’ and adds them to the ‘sum’ if they are a ‘member’ of the subset. We don’t tell Sentient how to solve the subset sum problem, we just describe what it is.

array20<int> numbers; array20<bool> members; sum = 0; numbers.each(function^ (number, index) { sum += members[index] ? number : 0; }); expose numbers, members, sum; 

The example above is running in real-time in your browser. Sentient is written in JavaScript and is extremely portable. You can compile and run programs on a command-line or in a browser. Sentient can integrate with web applications or node modules alike.

Sentient is an experimental programming language that was created by Chris Patuzzo as an exploration of declarative programming. It’s still in development and has a few rough edges. You can listen to the story of its inception on the Why Are Computers podcast.



from Hacker News https://ift.tt/2mwTxBZ

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.