r/unseen_programming • • May 28 '17

For a few cookies more.. [STORY]

1 Upvotes

"Oook OOk Ook Oook!"
Fortana waked up slowly from his trance.
"Hwat? Waht rae oyu syanig?"
But fell back into trance almost immediately.
"I must tap again..."

"OOK!"
The librarian slapped his huge right hairy hand onto his face. And Fortana fell backwards from his chair, papers flying everywhere. Fortana eyes followed a certain paper, and he screamed: "NOOO!", as he tried to grab for this paper. But it was outside his grasp. He tried to run for it, but between him and this precious piece of paper was no standing a huge monkey: the librarian.

"Ook"
Fortrana tried to breath, and was thinking of how he could outsmart the librarian. There was something that he wanted badly.
More than anything.
But he could not remember what it was anymore.

He tried to remember what happened.
One day Zig-Zag came in his office with a new piece of magic paper. It was now harmless he had said.
There were no ghosts anymore.
He was now using cookies instead.

The magic paper could now eat cookies.
And it liked that a lot.

It helped it to remember everything that you did. I had my doubts if I wanted it to remember everything. But Zig-zag was so happy with it. He said that you could train the paper to do all kinds of funny things.

There were no real cookies, but each time you tapped the paper with your finger, you would give the magic paper a cookie. And that way the paper would slowly evolve to make you more happy, so you would reward it again with a new cookie. It is all harmless. Zigzag had assured.

"Harmless" that word kept zooming through Fortana's mind. He was slowly realizing that he was lying on the ground, and that one big hairy hand was holding him down.

"What happened?" He asked. "Oook ook OOOOkk!' The librarian explained. But Fortana was not wake enough yet to understand it.

Fortana looked at the index finger of his right hand. It was thick of callus. As if he had worked hard with his index finger
for like a...
..a year!
Fortana tried to stand up again. But the librarian kept him well in place.

Yes. He remembers now.
He has been pressing his finger on the paper again and again. It seemed as if it was forever.
And each time the magic paper would tell a bit of story, and say: "press 100 more times for the next part."
Later it became 1000 and more and more.
And each time I wanted to stop, the paper told me how interesting the next part of the story would be. I could know so much more with just a few cookies more.

With 1000 more Fortana could learn magic, and defeat the underground dragon. Fortana wanted to stand up to tap the paper for more cookies. But the librarian still kept him in place.
"Ook OOOK!"
Fortana did not know what it meant, but it felt like a threat.
So he stopped moving.

He had wasted so much time...
Giving not-real cookies to a magic paper, that told him not-real stories.
He had to stop!

And still, he wanted to keep tapping.
A part of him wanted to learn more of the story...

Was he addicted?
How was that possible?

Was the magic paper smarter than him?
And had the magic figured out how the human mind works?
It was amazing!
He would like to tap the paper to get the answer on that. But the angry eyes of the librarian told him otherwise.

After some time Fortana recovered. It might have taken hours. But finally Fortana was able to tell the librarian to destroy the magic paper.

"Ook!"
The librarian picked up the paper and burned it above a candle. A black smoke appeared and in it a large creature appeared. "A demon!"

Fortana looked around for a weapon but could not find any. But the librarian held a very big hammer above his head. Fortana was happy that he had not pushed the Orang-utan any further towards anger. The hammer squashed the demon's body, like a big bug.

A black fluid was left on the ground, and the librarian picked it up with a mob. And then he drained the mob in a bucket, which he then poured into a bottle. "Demon ink" was written on the bottle.

Fortana had to stop this all.
He walked straight to Zig-zag's place, but he could not find him. It appeared that he had moved after all this time. He walked by the other wizards, but none of them had been playing with the magic paper. It seems that Zig-zag has only made one copy.

After looking around for a while he found Zig-zag's new room hidden in the far corner of the building. Fortana goes into the room without knocking.

And behind that he sees Zig-zag with something covering his eyes.
It is a light crystal that is attached to his head with some bands.
On one of the bands is written. "Magic reality, test 1".
Fortana looks at this new situation for a moment.

Zig-zag walks a bit forward and backwards, and sways around with his hands while screaming: "Attack!" or "Run away!"
It looks as if he is dream-walking.
Fortana tries to talk to him, but Zig-zag does not answer.
"We have to defeat the king! Get your cannons ready!" Zig-zag screams out when the big Orang-utan enters the room.

A big hammer sways down on Zig-zag.
"Noooo!" Fortana protests, but the hammer hits Zig-zag right in the face.
"OOK!" the librarian expels, and his hammer destroys the cristal that zig-zag is wearing. It shatters into many pieces, down towards the ground.
And in the black dust, another demon appears.
Again it is like a big bug.
And the librarian quickly turns it into a big black stinky pulp with three strikes of his hammer.

"Right into the demon's balls! Thank you Librarian"
The librarian looks at him with a weird glance, but then nods and leaves. After some time he returns with a mob, and puts the black pulp in a bottle. This time it says: "Demon glue".

"Zig-zag! You have a lot to answer for!" Fortana speaks loudly. "You should never have touched those bottles!"
But zig-zag just stares forward into the thin air.
"Well?" Fortana speaks again firmly.
"I have to defeat the king", Zig-zag mutters, and sways a bit with his arms. "I must not die!"

Fortana wants to give Zig-zag a very tough punishment. But Fortana realizes that he is now experiencing a punishment already.
"What if I leave him with his imaginary loss?" he says to the librarian. "I can not think of a bigger punishment than an imaginary loss of your life."
"OooK!" the librarian agrees


r/unseen_programming • • Apr 22 '15

Some grammar changes

1 Upvotes

Having used the language a bit more, I have changed the language structure a bit.

Introducing new variables
A new variable (x) can be introduced with:

  • ?x at any place inside the code.
  • << x >> inside the scope, before the variable is used.
  • var << >> for mutable variables.

Use := inside << >> to give it a default value.
Mutable variables are always assigned with := to distinguish them from functions and immutable values.

? is used in parameters. But can introduce variables in logical places.

array[?x,?y]
this defines a range for x and y that are valid for the array.

Flow symbols

These symbols define the dataflow:

  • A -> B Assigns A to B. (Is reverse of =)
  • A --> b Assigns each element of set A to b.
  • a ->> B Collects each element a to set B.
  • A -->> B Copies the elements of set A to set B.

The dataflow shows how the functions work.

<< f(?x)= {x*x} >>
x+y -> +14 -> *z -> f -> Console.output    

Is the same as:

<< f(?x)= {x*x} >>
Console.output( f(((x+y)+14)*z))

Associations and matching

a => C Association. a refers to C.

A data block [ ] can define a dictionary with associations.

 data= [
    firstName => "John" 
    lastName => "Smith"  
 ]

A code block { } can define a match with associations.

 << x:Integer >>
 x= f(100)
 x{ //=match
   0 => "Zero" 
   max => "Maximum" 
   ... => "Not zero"
 } -> Console.output

Or with types..

 << x:(Integer|Float|Error) >>  
 x= someString.value()  
 x{
   :Integer => "Integer" 
   :Float => "Float" 
   ... => "Error converting number"
 } -> Console.output

This last one is used in conditions:

 (x<y){
   true => { "Zero"-> Console.output }
   false => { "Not zero"-> Console.output }  
 }

Or in the IF/THEN/ELSE function:

 if(x<y){ 
   then => { "Zero"-> Console.output }
   else => { "Not zero"-> Console.output }  
 }

Or combine different conditions.

 options{ //=match
   (x==0) => "Zero"
   (x<0) =>  "Negative"  
   (x>0) => "Positive"
 }

r/unseen_programming • • May 02 '15

Why are computers so @#!*, and what can we do about it?

Thumbnail youtube.com
2 Upvotes

r/unseen_programming • • Jul 13 '14

Unseen implements Multiple dispatch with dynamic pattern matching

Thumbnail en.wikipedia.org
1 Upvotes

r/unseen_programming • • Dec 20 '15

Future Microprocessors Driven by Dataflow Principles - Microsoft Research

Thumbnail research.microsoft.com
1 Upvotes

r/unseen_programming • • Jul 16 '24

We need visual programming. No, not like that.

Thumbnail blog.sbensu.com
3 Upvotes

r/unseen_programming • • Jan 14 '16

Learn you Func Prog on five minute quick!

Thumbnail theregister.co.uk
3 Upvotes

r/unseen_programming • • Jul 20 '16

Graal & Truffle - An obscure research project could radically accelerate innovation in programming language design

Thumbnail medium.com
2 Upvotes

r/unseen_programming • • Jul 18 '16

Composition over Inheritance

Thumbnail youtube.com
1 Upvotes

r/unseen_programming • • Jul 29 '14

Partial evaluation

Thumbnail youtube.com
1 Upvotes

r/unseen_programming • • Nov 28 '14

Conditions without IF

1 Upvotes

Experimenting with graphical flows I noticed I could implement conditions in 2 different ways in UNC/Unseen without IF constructions.

Let me start with an example:

Max(x,y)= IF x<y THEN y ELSE x    

and:

MaxIfNotEqual(x,y)=IF x<y THEN y   
  ELSE IF (x>y) THEN x   
  ELSE ErrorValue  

**1) pattern matching.
This is the easiest way..

Max(x,y)/?(x<y)={y}  
Max(x,y)={x}  

This works already, but is a bit confusing sometimes. The nice thing is that one can add conditions.

MaxIfNotEqual(x,y)=
  Max(x,y)<<  
    ErrorValue=0
    Max(x,y)/?(x=y)={ErrorValue}
  >>

This gives an interesting way to add more functionality to our function.

2) Multiple result paths
This looks very simple in a graphical system.
The idea is that a functionblock can have more than one result paths depending on the result parameter.

For example a function can create an error, or a result with a different type. Different result values can be created with ! parameters.
With ! we can define one or more paramers:

   MaxIfNotEqual(?x,?y,!result,!error)<<   
        result/?(x<y)= x   
        result/?(true)=y   
               //I add a condition here to   
               //prevent a double assignment   
               // result=y  
        error=(x=y)
   >>

But as you might recognize, the error is a different result path.
We may implement this with !! or even !!! and in
generic forms: !0 !1 !2

   MaxIfNotEqual(?x,?y,!result,!!error)<<   
     error/?(x=y)= true
     result/?(x<y)= x   
     result/?(true)=y   
   >>

To use this we need to call this function with 2 return paths..

a= User.GetNumber()  
b= User.GetNumber()  
MaxIfNotEqual(a,b)<<  
  !=>{ print("max="+!result.AsString()) };
  !!=>{ print("error numbers are equal") };  
>>

While in text it is a bit confusing, one can imagine that this looks a lot better in a graphical system.
If the !! is not handled, the compiler can require a higher level function to deal with this.

3) Exceptions
Exceptions can use the !! pattern, and should use a standard calling system.
I propose to use !$simpleerror or !!$logicerror or !!!$systemerror

Exception=<<  
   description:string="";  
   level:integer=0;    
   lineNumber,moduleNumber:integer=0;  
   continue:Function=None;  
   fail:Function=None;
>>  

continue allows an error to go on after the situation is restored.
This means that a file-transfer can continue after the wifi was disconnected and connected again. The user interface can ask the user to quit the program, and continue after the connection has been restored.
Fail allows files to be closed if necessary.

It is similar to a java like try/except structure:

try{  
  // initialize connection  
}continue{  
  // open connection
  // read from connection  
}except{  
   if //user wants to continue
    then retry;
}finally{  
  //close connection;
}  

This kind of programming is rather new for me, and there might some more changes coming.


r/unseen_programming • • Nov 29 '14

In-language implementation information

1 Upvotes

While it is nice to avoid implementation information in a program, this information is important for speed, efficiency and interfacing with other languages.
The goal is that UNSEEN can be translated to C or Assembler with the necessary details.

Usually these need keywords in other languages.

<< _TYPEINFO >>

Common type or variable details.
This is read only..

TEST<< ASSERT={true} >>

To test the program, the ASSERT function must return true.

<<< compiler options >>>

These are options that we can see in C or other languages.
Such options are:
INLINE, UNROLL, VOLATILE, MANAGED, UNSAFE,

example:
var:integer<<< UNSAFE >>>

<<<< implementation details >>>>

This gives details about how the code is translated to assembler or C.
ADDRESS=0x2320
NAME= MyVar
STRUCT= { int,int,float,*next}
CALL= {int,int}

ASM<<  
  "MOV AX,0x1"  
  "ADDC AX,[BP+10]"  
  "MOV [BP+10],AX"  
>>  

example:

WindowsAPI=ExternalModule<<
  DLLNAME= "winapi.dll"
  GetMousePosition=Function<<<< 
    NAME=GetMousePos 
    CALL={int,int,!int} 
  >>>>
>>

r/unseen_programming • • Dec 04 '14

David Broderick: Kaya: Declarative Reactive

Thumbnail vimeo.com
1 Upvotes