This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#6651 2013-01-25 21:06:06

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Jens wrote:

Jeez, nXIII.
(the Pope is more broad-minded).  smile

If you're referring to this:

nXIII wrote:

Everything should be a TextMorph, and StringMorphs shouldn't exist at all.

Let me explain: TextMorphs entirely encompass the features of StringMorphs (shadows, automatic width resizing, editing, etc.), and add a few additional features as well. Aside from implementation or interface details, all StringMorphs could be replaced by TextMorphs without causing any bugs, so I see no reason for the StringMorph class to exist.

If you're referring to this:

That will kill performance instantly.

It's true—try it.

bharvey wrote:

nXIII wrote:

P.S. What does B.A.A. stand for?

Have you figured this out yet?   smile

Nope. xD


nXIII

Offline

 

#6652 2013-01-25 23:45:34

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

nXIII wrote:

Nope. xD

Hint:6642

I'm going to stay out of your fight with Jens, except to note that Snap! uses morphic.js, and its performance, while I'm sure it could be improved upon, is already quite amazing, especially compared with BYOB3.  And, efficiency is not the only consideration.  There's an old saying: You can't argue with success.  Jens pretty much singlehandedly ("pretty much" because of a few contributions by you and others) got Snap! written in a year, including the initial investment in morphic.js.  I confess that during those first few months when he was dragging rectangles around, I felt frustrated that nothing BYOB-like seemed to be happening.  But then it was like a construction site where for months they just seem to be moving piles of dirt from one place to another and, all of a sudden, one day a steel framework appears as if by magic.

Maybe someone else could have done a better job using some other framework.  But the person who actually did it chose Morphic, and that counts for a lot.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6653 2013-01-26 01:47:48

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

I'm not a big Python fan partly because it seems to have three different implementations of the Sequence abstraction

Which three are you referring to? Presumably one of them is list...

(although of course also because it has a broken lambda).

*sigh* maybe someday...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6654 2013-01-26 04:06:00

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hi Hardmath123,

I like your idea about creating your own programming language! Don't let yourself be discouraged by "experts", rolling your own is exciting and fun and perfectly legitimate. If you break some "rules" along the way, let me know, so I can applaud  smile


Jens Mönig

Offline

 

#6655 2013-01-26 04:23:54

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Jens wrote:

Don't let yourself be discouraged by "experts", rolling your own is exciting and fun and perfectly legitimate. If you break some "rules" along the way, let me know, so I can applaud  smile

I love how much Jens and Brian's opinions differ.  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6656 2013-01-26 08:21:51

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Yeah, totally!  tongue

bharvey, when I said efficient, I didn't mean execution time (which I really don't care about too much). I meant the amount of time and code it takes to do something. For example, just to take a list and replace each item with its factorial, here's what I'd do in Obj-C, JS and Python:

Code:

-(NSInteger) factorialOf:(NSInteger)n {
    if (n==0) {
        return 1;
    } else {
        return [self factorialOf:(n-1)]*n;
    }
}
-(void) main {
    NSString * contents = [NSArray arrayWithContentsOfFile:@"/path.txt" encoding:NSUTF8Encoding error:NSError];
    NSMutableArray *items = [NSMutableArray arrayWithArray:[contents componentsSeparatedByString:@"\n"]];
    for (int i=0; i<[items length]; i++) {
        [items replaceObjectAtIndex:i withObject:[self factorialOf:[items objectAtIndex:i]]];
    }
    [[items componentsJoinedByString:@"\n"] writeToFile:@"/path.txt" atomically:YES];
}

Code:

def factorialOf(n):
    return 1 if n==0 else factorialOf(n-1)*n

f = open("/path.txt","w+")
contents = f.readLines()
contents = map(factorialOf,contents)
f.write("\n".join(contents))

See the difference? I had to refer to like 3 class references for Obj-C, while the Python is off the top of my head. My language would ideally simplify this even more.

@nXIII I think I'll call it "PyScheme".  Which begs for the motto "I scream, you scream, we all scream for PyScheme!".  tongue


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6657 2013-01-26 08:38:52

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

@nXIII I think I'll call it "PyScheme".  Which begs for the motto "I scream, you scream, we all scream for PyScheme!".  tongue

Yes.  big_smile

My language is more "efficient," if only because it has library functions that suit this particular task quite well.

Code:

File put.lines('path.txt',File get.lines('/path.txt') map(x\x factorial))

Last edited by nXIII (2013-01-26 08:43:43)


nXIII

Offline

 

#6658 2013-01-26 09:54:45

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Your language?


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6659 2013-01-26 13:16:11

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

Your language?

Yep. It's designed to be minimal, fast, and object-oriented, and is (will be) implemented in itself.

And yes, bharvey, it has lambdas and continuations (though not macros, for a number of reasons). I guess I get a 2 out of 3.

We're sort of off-topic again…

Last edited by nXIII (2013-01-26 13:16:29)


nXIII

Offline

 

#6660 2013-01-26 13:49:36

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

I love how much Jens and Brian's opinions differ.  tongue

We do have differences of opinion, sometimes, but in this case we don't.  Hardmath, was I being discouraging?  That wasn't my intent.  What maybe I didn't say is that people learn by biting off more than they can chew, and sort of half-chewing it -- and then taking a compilers course to learn the state of the art.  smile


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6661 2013-01-26 13:52:13

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

I think I'll call it "PyScheme".

That'll be confusing.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6662 2013-01-26 13:56:31

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

Which three are you referring to? Presumably one of them is list...

http://python.about.com/b/2007/07/26/py … uences.htm:  "Python supports several of these: strings, lists, tuples, buffers, and xrange objects."


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6663 2013-01-26 21:17:06

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

blob8108 wrote:

I love how much Jens and Brian's opinions differ.  tongue

We do have differences of opinion, sometimes, but in this case we don't.  Hardmath, was I being discouraging?  That wasn't my intent.  What maybe I didn't say is that people learn by biting off more than they can chew, and sort of half-chewing it -- and then taking a compilers course to learn the state of the art.  smile

Which I suppose is how I learned any programming I know.  smile

Maybe I'll take the Udacity course on programming languages (build a web browser).

@nXIII how do you implement a language in itself? Is it turtles all the way down?  tongue


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6664 2013-01-27 00:29:30

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

@nXIII how do you implement a language in itself? Is it turtles all the way down?  tongue

I have no idea what that means, but the basic idea is that you implement it in something else just enough so that you can run the real implementation, and then use that from then on.


nXIII

Offline

 

#6665 2013-01-27 08:47:24

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Well, I was referencing a joke: a physicist was giving a lecture about the universe when a lady in the audience suddenly stood up and yelled, "Nonsense! The Earth rests on an elephant's back". The physicist asked what the elephant rested on, and the lady replied a turtle.
"What does the turtle rest on?"
"Another turtle."
"But what does the whole stack of turtles rest on?"
"Nothing. It's turtles all the way down."


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6666 2013-01-27 08:59:53

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Well it isn't turtles all the way down with computers: no matter how many interpreters and compilers are being used, eventually something is running directly on the
system's machine language.                                                                                         

Edit: OMG look at the post count it's #6666

Last edited by joefarebrother (2013-01-28 11:19:23)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6667 2013-01-27 13:23:05

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

I was referencing a joke

See https://en.wikipedia.org/wiki/Turtles_all_the_way_down.  The issue of infinite regress remains a vexing one in metaphysics, cosmology, and proof theory.

@joefarebrother:  Of course machine language isn't the bottom of the abstraction hierarchy.  Machine language runs on logic gates, which run on transistors, which run on quantum phenomena that are, according to some recent theories, ultimately made out of bits!

@nXIII:  The right answer to Hardmath's question is, "You get one of your graduate students to implement the language in Scheme."  smile


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6668 2013-01-28 11:20:17

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I'm going to re post this because no-one appeared to comment on it

I wrote:

When we get file I/O, we should have a reporter, OPEN FILE () FOR [ v], that reports a stream (the dropdown having input, output, and both), then READ [ v] FROM () where the dropdown would have character, number, line, and all (and possibly s-expression). Also PEEK CHAR FROM (), and STREAM () AT EOF then for output, just WRITE () TO ()  that would accept a number or a string and write it. There could also be a block for writing lists as s-expressions. There would also be two constants, STANDARD INPUT and STANDARD OUTPUT (ore possibly a single constant that can be read to and written from. There could also possibly be socket streams too, for connection to/implementation of servers.

Finally, there could also be MAKE CUSTOM STREAM INPUT () OUTPUT () EOF PREDICATE () which takes 3 inputs: an procedure that takes no inputs and reports a character for input, a procedure that takes one input and writes it for output reporting nothing, and a predicate that takes no inputs and returns true or false depending on whether the stream as at the eof or not. All of these inputs can also be the empty ring to indicate "this feature is not supported." This could be used for implementing string-streams, pipes, and stream plumbing.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6669 2013-01-28 11:56:15

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

I'm going to re post this because no-one appeared to comment on it

Sorry!  I think I had just said to some other post "we'll think about stuff like this after 4.0 is out."

It's a reasonable spec for a Unix-level-of-abstraction I/O system.  When the time comes, we'll have to talk about whether we want that or (say) files as lazy lists.  I suppose it depends on whether people are going to process non-text files; one might argue that disallowing low-level I/O might make it less of a security leak, aside from the elegance of a higher-level approach.

But, honest, I don't want to think about this yet.  Lots of things come before I/O: OOP, debugger, text on stage, vector costumes, first class costumes and sounds...  And when we do think about I/O, the first consideration has to be some kind of sandboxing; I don't want to be Panther, because we'll never get schools to use it.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6670 2013-01-28 19:41:19

OldCodger
New Scratcher
Registered: 2012-05-16
Posts: 54

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

Yeah, totally!  tongue

bharvey, when I said efficient, I didn't mean execution time (which I really don't care about too much). I meant the amount of time and code it takes to do something. For example, just to take a list and replace each item with its factorial, here's what I'd do in Obj-C, JS and Python:

Code:

-(NSInteger) factorialOf:(NSInteger)n {
    if (n==0) {
        return 1;
    } else {
        return [self factorialOf:(n-1)]*n;
    }
}
-(void) main {
    NSString * contents = [NSArray arrayWithContentsOfFile:@"/path.txt" encoding:NSUTF8Encoding error:NSError];
    NSMutableArray *items = [NSMutableArray arrayWithArray:[contents componentsSeparatedByString:@"\n"]];
    for (int i=0; i<[items length]; i++) {
        [items replaceObjectAtIndex:i withObject:[self factorialOf:[items objectAtIndex:i]]];
    }
    [[items componentsJoinedByString:@"\n"] writeToFile:@"/path.txt" atomically:YES];
}

Code:

def factorialOf(n):
    return 1 if n==0 else factorialOf(n-1)*n

f = open("/path.txt","w+")
contents = f.readLines()
contents = map(factorialOf,contents)
f.write("\n".join(contents))

See the difference? I had to refer to like 3 class references for Obj-C, while the Python is off the top of my head. My language would ideally simplify this even more.

@nXIII I think I'll call it "PyScheme".  Which begs for the motto "I scream, you scream, we all scream for PyScheme!".  tongue

If you want a succint program, this is Haskell:

factorial n = product [1..n]

Offline

 

#6671 2013-01-28 21:17:49

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

OldCodger wrote:

If you want a succint program, this is Haskell:

factorial n = product [1..n]

Yeah—in the language I mentioned above, it's `n factorial' (or `factorial := n\(1..n) product', if you think that's cheating and/or want a random global function). Including file I/O makes it longer.

Last edited by nXIII (2013-01-28 21:19:36)


nXIII

Offline

 

#6672 2013-01-28 21:19:17

OldCodger
New Scratcher
Registered: 2012-05-16
Posts: 54

Re: BYOB 3 - Discussion Thread

OldCodger wrote:

Hardmath123 wrote:

Yeah, totally!  tongue

bharvey, when I said efficient, I didn't mean execution time (which I really don't care about too much). I meant the amount of time and code it takes to do something. For example, just to take a list and replace each item with its factorial, here's what I'd do in Obj-C, JS and Python:

Code:

-(NSInteger) factorialOf:(NSInteger)n {
    if (n==0) {
        return 1;
    } else {
        return [self factorialOf:(n-1)]*n;
    }
}
-(void) main {
    NSString * contents = [NSArray arrayWithContentsOfFile:@"/path.txt" encoding:NSUTF8Encoding error:NSError];
    NSMutableArray *items = [NSMutableArray arrayWithArray:[contents componentsSeparatedByString:@"\n"]];
    for (int i=0; i<[items length]; i++) {
        [items replaceObjectAtIndex:i withObject:[self factorialOf:[items objectAtIndex:i]]];
    }
    [[items componentsJoinedByString:@"\n"] writeToFile:@"/path.txt" atomically:YES];
}

Code:

def factorialOf(n):
    return 1 if n==0 else factorialOf(n-1)*n

f = open("/path.txt","w+")
contents = f.readLines()
contents = map(factorialOf,contents)
f.write("\n".join(contents))

See the difference? I had to refer to like 3 class references for Obj-C, while the Python is off the top of my head. My language would ideally simplify this even more.

@nXIII I think I'll call it "PyScheme".  Which begs for the motto "I scream, you scream, we all scream for PyScheme!".  tongue

If you want a succinct program, this is Haskell:

factorial n = product [1..n]

to generate a list of factorials:

factorial n = scanl (*) 1 [1..n]

Offline

 

#6673 2013-01-28 21:23:31

OldCodger
New Scratcher
Registered: 2012-05-16
Posts: 54

Re: BYOB 3 - Discussion Thread

OldCodger wrote:

OldCodger wrote:

Hardmath123 wrote:

Yeah, totally!  tongue

bharvey, when I said efficient, I didn't mean execution time (which I really don't care about too much). I meant the amount of time and code it takes to do something. For example, just to take a list and replace each item with its factorial, here's what I'd do in Obj-C, JS and Python:

Code:

-(NSInteger) factorialOf:(NSInteger)n {
    if (n==0) {
        return 1;
    } else {
        return [self factorialOf:(n-1)]*n;
    }
}
-(void) main {
    NSString * contents = [NSArray arrayWithContentsOfFile:@"/path.txt" encoding:NSUTF8Encoding error:NSError];
    NSMutableArray *items = [NSMutableArray arrayWithArray:[contents componentsSeparatedByString:@"\n"]];
    for (int i=0; i<[items length]; i++) {
        [items replaceObjectAtIndex:i withObject:[self factorialOf:[items objectAtIndex:i]]];
    }
    [[items componentsJoinedByString:@"\n"] writeToFile:@"/path.txt" atomically:YES];
}

Code:

def factorialOf(n):
    return 1 if n==0 else factorialOf(n-1)*n

f = open("/path.txt","w+")
contents = f.readLines()
contents = map(factorialOf,contents)
f.write("\n".join(contents))

See the difference? I had to refer to like 3 class references for Obj-C, while the Python is off the top of my head. My language would ideally simplify this even more.

@nXIII I think I'll call it "PyScheme".  Which begs for the motto "I scream, you scream, we all scream for PyScheme!".  tongue

If you want a succinct program, this is Haskell:

factorial n = product [1..n]

to generate a list of factorials:

factorial n = scanl (*) 1 [1..n]

Here is a version in Factor:

: factorial ( n -- n ) [1,b] product ;

Offline

 

#6674 2013-01-28 23:18:15

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

factorial n = product [1..n]

factorial := n\(1..n) product

: factorial ( n -- n ) [1,b] product ;

Hmpf.  If we're having a competition for fewest keystrokes, there's no competition for APL:

×/ιN

PS: It's been a long time, but iirc this works unmodified if N is a list of numbers.

PPS: At one point, Jens and I were discussing APLifying the BYOB operators (i.e., extending their domain to arbitrary-dimension arrays of numbers).  We never exactly rejected the idea, but we never followed through on it either.

P^3S: According to http://tryapl.org my first PS is wrong.  For a list, I had to say

×/″ι″N

There's probably an easier way that I've forgotten.

P^4S:  There's also a built-in ! operator, but I thought that would be cheating.  But it does work on lists without help.

Last edited by bharvey (2013-01-29 00:16:22)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6675 2013-01-29 01:50:44

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

At one point, Jens and I were discussing APLifying the BYOB operators (i.e., extending their domain to arbitrary-dimension arrays of numbers).  We never exactly rejected the idea, but we never followed through on it either.

Oh, I absolutely want to do it, just haven't gotten around to it yet...


Jens Mönig

Offline

 

Board footer