Live data from Hacker News

Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

gitlet.maryrosecook.com

51–60 of 78 posts

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#51

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

What is the tool that builds this literate source view from source code?

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#52
post #36

So, 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.

I think that this is something else, it's a simple difference but having the code on the size changes everything for me.

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#53

In 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?

The ref would be HEAD (the last commit) here.

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#54
post #37

Earlier 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.

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...

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#55
post #22

Earlier 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.

I don't see why it couldn't be removed from a future release after a period of deprecation.

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#56

Earlier 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...

> This book has deservedly won an Academy Award. I believe it should also be nominated for a Pulitzer Prize — Donald Knuth

It's hard to beat that book review.

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#57
post #20

Earlier 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 :)

If you ever want to see "deleted" (flagged/dead) comments like that one, turn on "showdead" in your profile.

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#58
post #51

Earlier 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?

My guess is it's Docco: http://ashkenas.com/docco/

Re: Gitlet.js – Git implemented in 1k lines of JavaScript (2015)

#59
post #52

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.

I think that this is something else, it's a simple difference but having the code on the size changes everything for me.

> 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)

#60
post #20

Earlier 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.

Ah I see it now, thanks for the heads up!
Post reply on HN