Jens wrote:
Jeez, nXIII.
(the Pope is more broad-minded).![]()
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?
![]()
Nope. xD
Offline
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.
Offline
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...
Offline
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
Offline
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
![]()
I love how much Jens and Brian's opinions differ.
Offline
Yeah, totally!
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:
-(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]; }
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!".
Offline
Hardmath123 wrote:
@nXIII I think I'll call it "PyScheme". Which begs for the motto "I scream, you scream, we all scream for PyScheme!".
![]()
Yes.
My language is more "efficient," if only because it has library functions that suit this particular task quite well.
File put.lines('path.txt',File get.lines('/path.txt') map(x\x factorial))
Last edited by nXIII (2013-01-26 08:43:43)
Offline
Your language?
Offline
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)
Offline
blob8108 wrote:
I love how much Jens and Brian's opinions differ.
![]()
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.
Offline
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."
Offline
bharvey wrote:
blob8108 wrote:
I love how much Jens and Brian's opinions differ.
![]()
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.
![]()
Which I suppose is how I learned any programming I know.
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?
Offline
Hardmath123 wrote:
@nXIII how do you implement a language in itself? Is it turtles all the way down?
![]()
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.
Offline
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."
Offline
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)
Offline
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."
Offline
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.
Offline
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.
Offline
Hardmath123 wrote:
Yeah, totally!
![]()
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!".![]()
If you want a succint program, this is Haskell:
factorial n = product [1..n]
Offline
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)
Offline
OldCodger wrote:
Hardmath123 wrote:
Yeah, totally!
![]()
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!".![]()
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
OldCodger wrote:
OldCodger wrote:
Hardmath123 wrote:
Yeah, totally!
![]()
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!".![]()
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
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)
Offline
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...
Offline