HNHacker News
TopNewBestAskShowJobs

asrp

426 karma · joined January 21, 2017

github.com/asrp

blog.asrpo.com

Contact: asrp email com

submissionscomments
asrp··on Show HN: A minimal Python interpreter in Python with edit-and-continue
This old post explains some of the library it interpret at start up was designed http://blog.asrpo.com/bootstrap_chicken_or_egg

I'd also be interested if anyone knows a relatively easy way to get edit-and-continue in CPython or maybe PyPy.

asrp··on Bounter: A Python counter that uses limited memory regardless of data size
The introduction is misleading about what tradeoffs it makes

  >>> from bounter import bounter
  >>> bounts = bounter(size_mb=1)
  >>> bounts.update(str(i) for i in xrange(1000000))
  >>> bounts['100']
  0L
should give 1. The description should be more upfront that you are getting inaccurate answers.

> Bounter implements approximative algorithms using optimized low-level C structures, to avoid the overhead of Python objects.

"approximative algorithms" isn't a commonly used phrase (at least according to Google) and this sentence doesn't say anything about what the actual trade-off is (loss of accuracy in the counts). A possible alternative would be writing to hard disk so what trade-off is made isn't obvious.

I also don't know what the precision and recall percentages in the example table mean.

asrp··on Another tutorial for writing a Forth interpreter in assembly (Part 1)
[Note: This post assumes you already know why you want to write a Forth (or at least something higher level) interpreter and doesn't try to convince you that its worthwhile. There's already plenty of resources that do that that you can lookup.]

I wrote this tutorial mainly because I wanted to try and implement my own Forth interpreter so that I could have better control over how my programs are run (up to the assembly level anyways). Jonesforth is very good but doesn't let me easily see consquences of changes in implementation.

I tried to start with the parts that I thought were the main ideas needed to get a working language that's a bit higher level and easier to reason about (to me) than assembly.

As usual, I tried to make all sources short and/or not too complicated. That's probably going to be hard in Part 2.

I wrote the other goals of this tutorial in the post itself.

Tell me if this method works for you or not.

asrp··on Counterintuitive problem: People in a room keep giving dollars to random others
True, but I think Grue3's remark is more about the fact that this Markov chain is not irreducible than the number of states being wrong. Because you can go from the state where one person has all the money to the other states but not the other way around.
asrp··on Startup School 12: Alan Kay, Part II [video]
I found that ball animation to paint demo very interesting. But what if instead of an array of frames, the animation was a function from time to images such as

circle(x=time, y=-time*time, r=10)

so a render can get the information it needs but there aren't individual frames to edit.

In general, what happens to interoperability if different programs/projects represent the same things, like images and animations, very differently?

And how security could be handled in such a system? Either against a malicious or haywire programs/project?

asrp··on How to Generate Self-Referential Programs
I agree. Using quote is basically using the Lisp parser to do the work and is almost like reading the source program as input. It would have been interesting if their program contained a parser (which I think wouldn't be too distracting because of homoiconicity).

I found this an interesting read anyways especially when they start parametrizing the quine by a function F near the end. Although my interest shouldn't be that much of a surprise given my username:

asrp: a self-referential person/program/place

asrp··on How to Generate Self-Referential Programs
I have a number of projects that make use of self-reference. Although not using the particular method in this article and instead of passing code through an interpreter, it passes some first-thing into a second-thing which gives another first-thing that can again be given to second-thing. They're also all very self-referential.

https://github.com/asrp/pymetaterp The boot portion of this parser can its own AST from its own grammar and its own AST

https://github.com/asrp/tkui This GUI editor can modify and (re)generate itself. Its the "generate UI code" button.

https://asrp.github.io/blog/gui_toolkit This toolkit maker can (and is required to) make itself.

asrp··on Tree Oriented Programming [pdf]
I just read a good chunk of your article.

Could you give an idea of what the graph and interface would look like if the language we want to write in is Lisp?

It is indeed very string that we've settled on character based editors for making programs.

asrp··on Making a GUI toolkit
Maybe I should have used a different title. This is half about making a GUI toolkit and half about a GUI toolkit maker.
asrp··on The fish shell is awesome
I switched to fish a bit more than a year ago. I used to have a script with shorthands of frequently used long commands because I just couldn't get to them easily enough with bash's ctrl+r.

Now with fish, I don't need that anymore. Pressing up a few times always gets what I need and I don't need to come up with names for shorthands. (If I really want to name it, I can always add a # "tag" at the end. A trick I picked up from one of the post here (I can't remember which one).)

Although sometimes I do wish there was a keyword search feature treating space as a separator for what I've already typed. One frequent case is when I'm looking for `rsync --bunch --of --options user@server:path other_path`. I remember `rsync` and I remember `user@server` (or one of the two paths) but not the rest (and I also ssh, sftp, scp, etc to the same place a lot).

asrp··on Resources on creating programming languages
Yeah, I was also thinking along those lines when writing my comment. That there trade-offs are like those in a Huffman tree. So one easily accessible/expresible feature means many more distant ones.

Has someone thought and wrote about this?

And there are other aspects that don't quite fit the information theory model (like using infix notation for operators or not, from Paul Graham's post).

asrp··on Resources on creating programming languages
Same here about finding resources for language design.

I wish there was some course that could teach me language design so that I can (better) predict how my decisions will affect the final result.

Plus how much can reasonably I "pack" into the language [1] in terms of notation and cognitive load when used.

Maybe some resource about choosing notation would be nice too (as opposed to parsing notation once chosen). When I try to pick many ideas from different places, I'm sometimes surprised by collisions in notation.

In general, I have to idea in what model I have to run my estimates.

What are some examples of consequences taught through the course you linked to?

[1] I'm talking about textual languages only for now.

asrp··on If Google achieves superintelligence, time zones will be its Achilles heel
How would Google Calendar know the event is at 4pm in California? Is the location field filled with enough information? If not, that seems like almost as much work as entering the timezone.

This did happen to me with daylight saving a while back so I do sympathize.

asrp··on Rope Science – Computer science concepts behind the Xi editor
Well, you can already have half of a split unicode character at the beginning and end of a substring in the rope.

If that doesn't happen (like in the "parens" or "other" description), to use CYK, I think you could maybe have piece of the table for each substring (so for all entries with both indices inside the substring) in each node but then I don't think the operation at the parent is commutative. And you have to decide to copy the info from the children or not (if not, you'll spend an extra log n time looking down the tree).

asrp··on Rope Science – Computer science concepts behind the Xi editor
This write up is really good! Are there similar write-ups for things other than text editors?

I wonder if only wanted a printable character ASCII editor would simplify things a lot or only a little. And I guess no tabs.

> Part 2 Line breaking

I don't really understand the problem here. Can't we count the line breaks like anything else? Is it because that's not the values we want in the end?

> Part 4: Again, making this into a monoid is pretty easy. You store two copies of the (t, m) pair - one for the simple case, and one for the case where the beginning of the string is in a comment. You also keep two bits to keep track of whether the string ends or begins a comment. In principle, you have to do the computation twice for both cases, whether the first line is a comment or not, but in practice it doesn’t make the computation any more expensive: you compute (t, m) for the first line and for the rest of the string, and just store both the first value and the monoid sum.

What if a node of the rope contains an "end comment" and (later) a "("? What should the two pairs of (t, m) be? Now that substring might be entirely inside, outside or partially outside and inside a comment.

Although I do understand the general idea of computing the result for all possible initial/input state to achieve paralellism.

asrp··on Neural Complete – A neural network that autocompletes neural network code
This reminds me a bit of auto-sklearn[1] for automatically select the machine learning algorithm to use and its parameters (and so isn't quite doing it at code level like this one).

[1] https://github.com/automl/auto-sklearn

asrp··on What made Xerox PARC special? Who else today is like them?
I think the biggest difference is the funding went from unrestricted to being very specific. A lot of questions are asked before money is given. But the answers for an interesting project may involve concepts and vocabulary that do not yet exist, ideas that are not currently trendy. While I can understand the desire to avoid misallocation, this model assumes the funder has a better idea of what needs resources that the funded. From the second point in the answer:

> 2. Fund people not projects — the scientists find the problems not the funders. So, for many reasons, you have to have the best researchers.

So yes, the total amount may be there but is now diverted.

asrp··on Visual explanation of the last Google Codejam 2017 question
I think Inkscape uses Cairo for rendering. So eventually Cairo.

P.S., thanks for answering some of the questions in here! Guess I should reformulate that last part.

asrp··on Visual explanation of the last Google Codejam 2017 question
I, um, recorded my screen while a loop was running to change values. Its a bit of a hack.
asrp··on Show HN: Txtpen – web highlights and in-text comments
How come there are so many posts of this within a short period?

https://news.ycombinator.com/item?id=14058502 (2 days ago)

https://news.ycombinator.com/item?id=14074622 (2 days ago)

asrp··on Visual explanation of the last Google Codejam 2017 question
Which greedy algorithm do you mean?

I meant that bipartite matching was enough for getting the answer, not that the two are equivalent.

asrp··on Visual explanation of the last Google Codejam 2017 question
This wasn't my intention. I hope the feeling subsides!

I did try to keep it short although some parts still (fortunately) shows how to come to those conclusion. That might give it the impression of being smart but the presentation is definitely selected among many idea and rearranged.

asrp··on Flex
Hi!

So right now, I can write the grammar G1 for a language L1 in Ohm and parse strings written in L1 by putting them in examples.

If L1 is a language for describing grammars (such as a Ohm with a slightly different syntax), one of the "example" could be the grammar G2 for a language L2. But then I can't give the editor examples of L2 to be parsed!

(Of course if L1 has extra semantics instead of just syntax, it wouldn't be easy to change anyway, except by editing the Ohm Editor's source.)

A sample use case:

G2 is something like this:

https://github.com/asrp/pymetaterp/blob/master/pymetaterp/bo...

The example/input written in L2 that I want to give it is something like this

https://github.com/asrp/pymetaterp/blob/master/pymetaterp/py...

I could of course, rewrite this input in Ohm's grammar just so I can visualize the parse in the Ohm editor but it would be faster if I only needed to write G1 (that is, G2 translated to Ohm but matching the same language as L2=L1) and make minor adjustments to the input.

A full translation of this "input" to Ohm would also make it harder for me to port bugs fixed in the Ohm version back to the original version.

The next step would be to make this input the grammar G3 and give it inputs which can be visualized in the editor.

I'm not sure if you intend to have the Ohm editor used like this or not though.

Very nice project, by the way. I really like how you show the parts of the inputs that matches, with the option of expanding rules.

asrp··on Flex
I wish the Ohm editor allowed custom grammars for describing the grammar.

In fact, I wish more projects based on Ometa and Ohm allowed this so there's a better chance they can bootstrap each other. Of course, some semantics might still be missing but at least parsing would work.

asrp··on Flex
Is there no audio for any of the videos or is that just my browser?
asrp··on How much your computer can do in a second
This reminds me of "Latency Numbers Every Programmer Should Know"

https://gist.github.com/jboner/2841832

Edit: Just realized halfway through that there's already a link to this from their page!

asrp··on Show HN: How to write a recursive descent parser
There's the Ohm editor now.

https://ohmlang.github.io/editor/

Ohm is the successor of Ometa. The editor shows which portion of the string are matched by each rule.

asrp··on Show HN: How to write a recursive descent parser
By going to the other extreme, you can use only precedence climbing (with just a grammar) by using Floyd's algorithm, which will treat all tokens as operators. It uses two precedences functions instead of one, a left and right precedence.

https://en.wikipedia.org/wiki/Operator-precedence_grammar

asrp··on Show HN: How to write a recursive descent parser
I've found parser expression grammars (PEG) to be a good solution to avoiding the ambiguity stated at the very beginning. This is done by making all choices (|) into ordered choices.

I've recently used PEGs to write a Python parser (parsing all of Python, except for possible bugs) in ~500 lines of Python [2]. Its entirely interpreted. No parser is generated, only trees.

I'll also add that Floyd's operator precedence grammar [3] includes an algorithm which can deduce precedences from a grammar.

[1] https://en.wikipedia.org/wiki/Parsing_expression_grammar

[2] https://github.com/asrp/pymetaterp

[3] https://en.wikipedia.org/wiki/Operator-precedence_grammar

asrp··on Show HN: Build python ASTs in 502 lines of python without using modules
This release is a bit early but it does run just fine, at least for the tests I did. I thought I'd make it available today because of recent interest in similar topics [1, 2].

I didn't think it was possible to get the whole thing into 500 lines (well, 502 lines but `Node.__repr__`, commented code and a number of other knick knack aren't needed except for debugging). At least top search engine results all point to using large tools and/or needing multiple passes of different kind which makes the subject sound complicated and hard to get anything even working.

Prompted by arcfide's project [1], I rewrote this one and the main part (boot.py) went down from ~600 to 100 lines. Of course, the features available are not the same but I'm starting to see why shorter code is easier to change globally. I'm much more willing to refactor (by hand) anything that only happens at most 6 times in the code! (And also maybe those other features aren't as useful as I thought.)

I wasn't sure how to count lines for this one. The generated tree contains no extra information (it can be regenerated from itself and the bootstrap grammar).

[1] https://news.ycombinator.com/item?id=13797797

[2] https://news.ycombinator.com/item?id=13825225

(both are not quite the same, just similar)

← PreviousPage 2 of 3Next →