User loginNavigation |
LtU ForumTrip Reports on Dagstuhl Live Coding seminarMark Guzdial:
More: http://cacm.acm.org/blogs/blog-cacm/168153-trip-report-on-dagstuhl-seminar-on-live-coding/fulltext Dave Griffiths:
More: http://www.pawfal.org/dave/blog/2013/09/dagstuhl-collaboration-and-learning-through-live-coding/ GADTs meet subtypingI was looking for work on GADTs in the presence of subtyping and found this 2013 paper GADTs meet subtyping of Gabriel Scherer and Didier Rémy.
The running example of the paper is (can you guess?) an expression type. One thing that I was looking for specifically that I didn't find addressed in the paper is how to interpret e.g. xkcd: FunctionalXKCD comic on functional programming. Overlay money quote:
A little insight on iterators/accumulatorsIf you've used a popular OO language chances are you've dealt with iterators. For example if I wanted to append to a list while traversing it back and fourth,
template
operator ++ ()
m.fwd = m.pos == m_cont.size() - 1 ? 0 : m_pos == 0 ? 1 : m_fwd;
return m_fwd ? *m_cont[(m.pos++)] : *m.cont[(m_pos--)];
The key to this iterator is that whenever the upper bounds or lower bounds is met the iterator simply traverses in its the opposite direction. Decent in situations where one would want to compare array values having added or removed new ones - the drawback however is knowing when to stop. In addition, one must be somewhat aware of its length throughout. Otherwise it can lead Another example would be the nthElement iterator. This basically says that after each iteration we sort its indice in the array. Consquently sample dataset: set = [n, n - 1, n + 1] *set ++; // returns n set.at(0) // returns n - 1 // [n - 1, n, n + 1] Lastly consider a usage iterater. In a nutshell this says every time a resource uses an indice it's usage count increments. This practice involves keeping a pointer to the next ideal location in the array. Consider: dataset = [1,2, .. , n] consume(dataset[1]) *dataset ++; // returns 2 given we've used its indice the most In this example the array itself needn't be rearranged the iterator could simply keep a pointer to the next location. Anyway for brevity that's it for now. ANN: Bipedal, a new, untyped, stack-based HLLIn the seven years since I first began tinkering on what would eventually become Babel, the Internet has exploded with things called Babel. It is, unfortunately, a very popular name for things related to language. So, I've renamed the syntax layer of the language to Bipedal, while the VM is still called "Babel" or "the Babel-core". I spoke on Babel at StrangeLoop 2013 in St. Louis on the 18th. The video will be available sometime in the next few months. Bipedal Bipedal is a front-end for the Babel programming langage core. Babel is essentially the VM on which Bipedal runs. Bipedal progamming language is a general-purpose, untyped, stack-based high-level language. Despite being stack-based, it is not concatenative. It is not pure, as many operators can have side-effects. The syntax-layer is as transparent as possible, so when you look at Bipedal, you're looking at a nearly 1:1 translation to Babel bytecode. Blitz Syntax Overview There is more to the syntax, but this is enough to introduce some of the key concepts of the language. You can check out more examples at RosettaCode. Bipedal as High-Level Language There are two strikes against Bipedal's use as a HLL: 1) it is stack-based and some people are of the view that stack-based languages are only suited to intermediate-languages, 2) it is untyped. I have attempted to address each of these problems in my design of Bipedal/Babel. Stack-noise reduction Babel actually maintains two stacks: up-stack (ustack) and down-stack (dstack). Let the notation represent a stack where x has been pushed first, z last, with '|' visually marking the TOS. Now, let us define star_n as a combinator that will print an asterisk n times, where n will be passed on TOS. One way to write the code for this is as follows: The order of operands for the times operator is "{ code } N times", where N is some number. Since n is being passed on TOS, this creates stack-noise where we must swap the code to be executed with the number of times it is to be executed, already on TOS. Another way to solve this in Babel is to use the up (->) and down (<-) operators: This has an equivalent effect. A view of the stack images: In this case, it is not clear that up/down are an improvement over swap - in fact, we have used an additional operation to accomplish the same task. However, the up and down operators allow the stack to be "taken apart" and processed piece-by-piece, for any number of "arguments" passed to a particular operator. To illustrate this, consider the following function in the notation of C: The arguments are pushed on the stack and then foo is called. If it is possible to perform all processing on a, then b, and then c, then we can apply the following schema using the up/down operators to process foo in a similar way in Babel: Of course, this pattern will not solve all stack-noise problems, as it can be the case that values on the stack need to be accessed in some arbitrary order with repetitions, such as: a c b c b a c b. The up/down operators are unlikely to reduce stack noise over against the more traditional stack-rotations in this case. So, Babel permits the use of a 'let' construct to allocate local variables: This construct should not be confused with the let form in Lisp because it does not perform any kind of "binding" - a, b and c in this case are just pointers and the let operator merely saves/restores the pointers (using the rstack). Another tool for tackling stack noise is the nest operator. Nest allows the construction of a stack-discipline using the following rules:
Invoking bar will cause 'b' to be printed to STDOUT and the following will be left on the stack: Nest allows a nested-section to monopolize the stack. This is useful if you want to generate a bunch of results on the stack and then collect them together into a list (you can use the collect pseudo-operator for this). Using nest in combination with let will give something roughly analogous to an ordinary function-call stack discipline: Bipedal has a pseudo-operator called args to perform this: The args pseudo-operator also assigns the elements of the list on TOS (assumed) to a, b and c. Typing Babel does not have any built-in type system, beyond some rudiments to differentiate between pointers and non-pointers. To me, "type" means one of two, completely different concepts: a) The format of data. ASCII is a type specification, XML is a type specification, JPEG image format is a type specification. When you say, "this is type string", it is difficult to say what exactly you mean without talking about the format in which the string data is kept. b) Data-flow connectors, i.e. "you can't put a square peg in a round hole", or "you can't put an int in a char" (usually). Of course, typing systems can convey much more information, but it is my contention that there is no reason why this information must be conveyed through types - for example, the "is-a" and "has-a" relationships. What Babel implements instead of types is a tag - a tag is a hash (typically, from hashing a string) that can be attached to an otherwise untyped data-structure. Of course, tagged things can be composed, so you can have "types all the way down", if you need it. That is, you could track the fact that a string is a string, a number is a number (and its size) and so on. What you don't get (automatically) in Babel is any kind of inference. However, you can implement your combinators in such a way that typing is always tracked through tags. Support for prevalent data forms, I/O Babel has built-in support for operating on UTF-8 encoded strings, numerics, arrays, lists, hash-tables, binary and n-ary trees. Bipedal files are UTF-8 formatted. File and console I/O are supported. Unique or Notable Features The Babel Virtual Machine is ultra-lightweight, making launching of nested virtual machines very cheap. In Babel, the VM is intended to be the natural unit of abstraction. There is no OO support built-in. The advantages of VM abstraction over OO include that the VM can be interrupted, hibernated, forked, and has configurable resource limits (such as memory-allocation, time, file-access privileges, etc.) Other unique or notable features of Babel include:
But We Already Have Factor My answer to this is that, while Babel is a "practical" stack-based language, it's just a completely different flavor of programming language. It's difficult to meaningfully compare very complex things like programming languages, but perhaps it could be put most succinctly this way: Babel is the Perl5 to Factor's Python. Minus Perl's labyrinthine syntax, of course. Another way of comparing the difference is that the Babel binary is right around 100K as of this writing; it may grow as large as 200K by the time Babel is at revision 1.0, but this will mostly be the result of linking in some support for encryption and compression operators. The Babel-core is essentially finished. Babel takes a more minimalist "swiss-army-knife" approach versus the more "kitchen-sink" approach of Factor, which has a 425K core plus an incredible 66M image file of Factor library code. Conclusion Your feedback is welcome. Babel isn't quite ready for prime-time, but it's getting closer every day. If you have a Windows box with Cygwin and ActivePerl, you can just clone Babel from github, run make.pl and you're ready to roll. You don't need a compiler as the repo has a copy of tcc and will compile from that. If you want to try Babel, please do not hesitate to contact me and I'll help you with any questions you may have. By claytonkb at 2013-09-26 08:08 | LtU Forum | login or register to post comments | other blogs | 13089 reads
just a funny rant re: cpu design historyAs seen many places by now, no doubt: The Slow Winter by James Mickens. By raould at 2013-09-25 20:31 | LtU Forum | login or register to post comments | other blogs | 3739 reads
Coroutines as a Basis for UI ProgrammingI've written a short piece, illustrating the use of coroutines to build up UIs compositionally, at my blog. I'd be curious if anyone here knows of prior research in this direction. I think there is some similarity between this approach, and immediate-mode GUI, discussed previously here. I believe that immediate-mode GUI could be seen as a special case of coroutine UI. questions re common lisp readtable hacksThe Common Lisp reader has a feature known as The Readtable which can be used to configure an ad hoc but interesting assignment, to individual characters, of a syntax type or reader macro. I'm interested in historic and current experience with these features. I'm especially interested in experience that does not make use of the reader macro feature but that uses the mutability of the "syntax type" of characters in interesting ways. How good or bad an approach to lexical analysis is this? How general purpose has this approach proved to be in a practical rather than theoretical sense? Has Common Lisp's list of character syntax types been compelling extended? The more general question I'm contemplating asks what good alternatives there are to regular expressions for specifying lexical syntax. Common Lisp syntax tables have some appeal to me because the character syntax types reflect how a person might describe a lexical syntax to another person: "These characters can begin an identifier. This other, overlapping set of characters can be constituents of an identifier. This is the single-escape character for identifiers."... and so forth. I'm wondering about the possibility of a system for defining lexers in those kinds of familiar terms. Scalable concurrency paper(Turon has been mentioned before on LtU, it appears.) Aaron Turon's PhD thesis lists 3 bullet points (heavily boiled down here since copy-paste from the pdf goes wrong): Visual artifacts for understanding; Declarative synchronization; Monadic reagents. By raould at 2013-09-01 20:59 | LtU Forum | login or register to post comments | other blogs | 4423 reads
New programming language Ya
I'm making this new programming language Ya. I'm not sure I'm right writing to you, yet I just don't know what to do to make people know that new programming language Ya exists. If you know what I should do - please help me. Thank you.
Pavel Senatorov, Ya-Lang.com .
|
Browse archives
Active forum topics |
Recent comments
9 weeks 1 day ago
9 weeks 1 day ago
9 weeks 1 day ago
9 weeks 2 days ago
9 weeks 5 days ago
9 weeks 5 days ago
9 weeks 6 days ago
10 weeks 1 hour ago
10 weeks 2 hours ago
10 weeks 2 hours ago