Evidence-Oriented Programming

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Xanthir
My HERO!!!
Posts: 5330
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Evidence-Oriented Programming

Postby Xanthir » Sun Dec 20, 2015 10:11 pm UTC

This is a cool talk about Evidence-Oriented Programming, by Andreas Stefik. He talks about how programming language design has basically *zero* user studies to guide its features and syntax, and his own language, Quorum, showcasing some of the things that have rigorously tested.

For example, static typing has a statistically significant but small negative effect on novices, but a large positive effect on skilled programmers (3+ years), so it's worthwhile to optimize toward static typing (and a study done by others has suggested a point about 9 months into a CS education where the static-typing error rate suddenly drops, supporting his data).

Other interesting points are about syntax - for example, for(), while(), and foreach() loops test *terribly*. Loops that "read" a little better, like "repeat 10 times {}" or "repeat while ... {}" do much better at all levels for only a little bit more syntax. In order to do randomized controlled trials, they invented a language with randomly-generated syntax, "Randomo", and tested it against real languages; amusingly, novices do equally bad with Randomo, Perl, and Java (and presumably better with other langs).
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: Evidence-Oriented Programming

Postby thoughtfully » Mon Dec 21, 2015 5:52 am UTC

Yeah, "for" is awful. I can still remember the moment when I suddenly grokked it, back when I was a wee protoprogrammer.

I'm a few weeks into learning Scala. It reads like Perl sometimes, but it isn't a language for a total novice, either.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

User avatar
Yakk
Poster with most posts but no title.
Posts: 11088
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Evidence-Oriented Programming

Postby Yakk » Mon Dec 21, 2015 4:45 pm UTC

Perl: slightly less readable than Randomo.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

BedderDanu
Posts: 39
Joined: Tue Jan 14, 2014 6:18 am UTC

Re: Evidence-Oriented Programming

Postby BedderDanu » Tue Dec 22, 2015 2:57 am UTC

After listening to his talk, it seems really fascinating.

Although, when he talks about things like "Returning" not having anything positive, but having no good replacements, I wonder if that isn't evidence that the word itself should be removed.

Instead of

Code: Select all

Action Concatenate(Text left, Text right) Returning Text
  Return left + right
End


Maybe something like the following would work:

Code: Select all

Text Action Concatenate(Text left, Text right)
  Concatenate = left + right
End


But I don't know how you would get a survey option of "Nothing" workable.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Evidence-Oriented Programming

Postby EvanED » Tue Dec 22, 2015 5:07 am UTC

BedderDanu wrote:Maybe something like the following would work:

Code: Select all

Text Action Concatenate(Text left, Text right)
  Concatenate = left + right
End


But I don't know how you would get a survey option of "Nothing" workable.
I didn't watch the video, but I'll point out that "classic" Visual Basic (and probably other variants of BASIC with true functions) use that for function returns.

One problem with this is either you need a separate return statement anyway, or you don't allow early exit from functions, which is freaking obnoxious on balance.

User avatar
ucim
Posts: 6566
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Evidence-Oriented Programming

Postby ucim » Tue Dec 22, 2015 5:40 am UTC

EvanED wrote:One problem with this is either you need a separate return statement anyway, or you don't allow early exit from functions, which is freaking obnoxious on balance.

Done.

Code: Select all

Text Action Concatenate(Text left, Text right)
  left is empty?
    Concatenate = right
    Done
  right is empty?
    Concatenate = left
    Done
Concatenate = left + right
End


It was an interesting talk. There are however two conflicting goals - making it easy for the programmer is a newish goal; the original goal was making it easy for the computer. In ancient times, computer time was far more valuable than human time, so it didn't matter how hard it was for people. Now that's upside down. (I am still getting used to the idea).

There's another caveat - novices don't know what they want to be able to do yet, so a language designed by and for novices may be inherently less powerful. Making it easy to do the easy stuff could make it harder to do the hard stuff.

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Please help addams if you can. She needs all of us.

User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: Evidence-Oriented Programming

Postby thoughtfully » Tue Dec 22, 2015 7:01 am UTC

ucim wrote:Making it easy to do the easy stuff could make it harder to do the hard stuff.

This is Microsoft's business model, and why we hate strongly dislike them.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

DR6
Posts: 171
Joined: Thu Nov 01, 2012 1:44 pm UTC

Re: Evidence-Oriented Programming

Postby DR6 » Wed Dec 23, 2015 3:43 pm UTC

BedderDanu wrote:After listening to his talk, it seems really fascinating.

Although, when he talks about things like "Returning" not having anything positive, but having no good replacements, I wonder if that isn't evidence that the word itself should be removed.

Instead of

Code: Select all

Action Concatenate(Text left, Text right) Returning Text
  Return left + right
End


Maybe something like the following would work:

Code: Select all

Text Action Concatenate(Text left, Text right)
  Concatenate = left + right
End


But I don't know how you would get a survey option of "Nothing" workable.


Along with VB(according to EvanED, I haven't used it) Matlab and Pascal do this too.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11088
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Evidence-Oriented Programming

Postby Yakk » Wed Dec 23, 2015 3:58 pm UTC

That does eliminate the distinction from assigning and constructing the return value (which can be different operations).

Also, `auto bob = function_name` -- did I store the current value of the return value in `bob`, or did I store a pointer to `function_name` in `bob`? (presuming some kind of auto-typing support).

The existence of one, singular return value is a bit of a straitjacket. In a sense, a generalization of a function (from the outside) is a machine with one or more entry points with inputs, outputs and input/outputs, and one or more exit points (which may or may not populate the outputs).

If a function throws an exception, it is using a different exit point. An enumerator can return the next element, or say done. A function could want to return a collection of different values, or even do internal work and decide which of the collection to return. Etc.

Different restrictions on this generalized function thing have been exposed in various languages. We should possibly make the easy things easy to understand, but not block the more complex things, and maybe even make important complex things easy as well...

But this is a tangent.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

Derek
Posts: 2179
Joined: Wed Aug 18, 2010 4:15 am UTC

Re: Evidence-Oriented Programming

Postby Derek » Sat Jan 02, 2016 9:59 pm UTC

There's the functional programming approach where the value of the last (and usually the only) statement is the return value of the function.

Code: Select all

Racket:

(define (fact n)
  (cond [(zero? n) 1]
        [else (* n (fact (- n 1)))]))

Haskell:

factorial n =
  if n == 0 then 1
  else n * factorial (n-1)


This means that either functions cannot return nothing (void), or they have to do so explicitly by having something like "void" or "()" as the final expression. This also means that the language makes no distinction between statements and expressions.


Return to “Coding”

Who is online

Users browsing this forum: Google [Bot] and 11 guests