Earlier quoted context omitted.
As @chungy says in a sibling comment, this is what's known as a literate program. It never really took off, and I suspect it's partially because doing it well means you'll be writing a lot more text than you'd typically see in a program's comments. See http://www.literateprogramming.com/ for more information and examples.
The particular method of turning javascript comments into a "literate" source view, used in the link under discussion here, comes from Jeremy Ashkenas circa 2009, e.g.: https://underscorejs.org/docs/underscore-esm.html https://coffeescript.org/annotated-source/lexer.html https://backbonejs.org/docs/backbone.html
Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
51–60 of 78 posts
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#52So, I'm going to put that out there, but I really wish I could read security-sensitive code like this. TLS implementations, cryptographic implementations, etc. It would be really amazing if there was a way for Github to automatically display code like this by extracting comments out. In general I think it's an amazing way of learning, I remember reading the gobyexample.com website and writing the same thing for go as…
As @chungy says in a sibling comment, this is what's known as a literate program. It never really took off, and I suspect it's partially because doing it well means you'll be writing a lot more text than you'd typically see in a program's comments. See http://www.literateprogramming.com/ for more information and examples.
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#53In the 'real' Git, one of the functions I use frequently is `git checkout -- .`, which discards any unstaged changes. Looking at Gitlet's implementation, it wouldn't handle that well as `checkout` can only take a ref. So I guess I'm wondering what the real `git checkout -- .` actually does behind the scenes?
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#54Earlier quoted context omitted.
It's a very old idea. Donald Knuth implemented it with both Pascal and C to promote an idea of "literate programming" -- you'd literally just write prose sprinkled with little bits of programming. On compilation, you can choose to compile either the documentation or program.
For an example, the PBRT book is great.
https://www.amazon.com/Physically-Based-Rendering-Theory-Imp...
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#55Earlier quoted context omitted.
This is correct, ‘git restore’ is the way to do this in the current version of git. ‘checkout —-‘ still works, but the ‘help’ text in ‘git status’ now recommends using ‘restore’. Not only is it more semantic, it reduces the complexity of ‘git checkout’ which is a common complaint. Really, It doesn’t make much sense to tack on some random ’--‘ flag on ‘checkout’ for that functionality. ‘restore’ is clear and describes…
> Not only is it more semantic, it reduces the complexity of ‘git checkout’ which is a common complaint. It doesn’t since the feature can’t be removed from git checkout for BC reasons.
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#56Earlier quoted context omitted.
For an example, the PBRT book is great.
PBRT is Physically Based Rendering: From Theory To Implementation by Matt Pharr, Wenzel Jakob, Greg Humphreys. https://www.pbrt.org https://www.pbr-book.org https://www.amazon.com/Physically-Based-Rendering-Theory-Imp...
It's hard to beat that book review.
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#57Earlier quoted context omitted.
it's not that simple. git is a snapshot, i.e. it saves an entire file. How to recover changed lines from it efficiently? And How to do it for the entire history? Basically, I want to understand this code https://github.com/git/git/blob/master/blame.c
I was replying to another comment that has since been deleted. It said something roughly along the lines of git blame being a contentious and passive aggressive command. I totally agree the technical implementation would be cool to study :)
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#58Earlier quoted context omitted.
The particular method of turning javascript comments into a "literate" source view, used in the link under discussion here, comes from Jeremy Ashkenas circa 2009, e.g.: https://underscorejs.org/docs/underscore-esm.html https://coffeescript.org/annotated-source/lexer.html https://backbonejs.org/docs/backbone.html
What is the tool that builds this literate source view from source code?
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#59Earlier quoted context omitted.
As @chungy says in a sibling comment, this is what's known as a literate program. It never really took off, and I suspect it's partially because doing it well means you'll be writing a lot more text than you'd typically see in a program's comments. See http://www.literateprogramming.com/ for more information and examples.
I think that this is something else, it's a simple difference but having the code on the size changes everything for me.
I assume you mean "on the side" and I agree, it's a game-changer. Normally I find literate programs to be tedious to read but simply changing the layout makes a huge difference.
Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)
#60Earlier quoted context omitted.
I was replying to another comment that has since been deleted. It said something roughly along the lines of git blame being a contentious and passive aggressive command. I totally agree the technical implementation would be cool to study :)
If you ever want to see "deleted" (flagged/dead) comments like that one, turn on "showdead" in your profile.