Live data from Hacker News

Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

github.com

51–60 of 73 posts

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#51

Earlier quoted context omitted.

Would it make sense to make the code Literate Haskell?

I'm not familiar with Literate Haskell, what would that involve?

"Programs should be written for people to read, and only incidentally for machines to execute." (Structure and Interpretation of Computer Programs" by Abelson and Sussman)

The idea is that you write a "Book" and the program is extracted, from the book.

Literate Programming Wikipedia: https://en.wikipedia.org/wiki/Literate_programming

A nice talk about it: https://youtu.be/Av0PQDVTP4A

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#52

I'm tempted to just make a youtube video going over this code line by line. It's a really great introduction to a non-trivial bit of Haskell.

I want to chime in that this would be amazing also. However, an actual line-by-line video might be less helpful for those without any Haskell or blockchain experience.

I (and thousands of others at HN) really enjoyed Jeremy Ruten's tutorial of building antirez's 1000-line text editor, Kilo, from scratch (antirez is the author of Redis which is renowned for its code quality and approachability) - http://viewsourcecode.org/snaptoken/kilo/ . Additionally, the author of that walkthrough has published the project used to create that tutorial here - https://github.com/yjerem/leg

I realize this might be less trivial than creating a Youtube video, but if you have the bandwidth I'm certain creating a similar walkthrough for Legion would not go unappreciated here :)

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#53

I'm tempted to just make a youtube video going over this code line by line. It's a really great introduction to a non-trivial bit of Haskell.

I want to chime in that this would be amazing also. However, an actual line-by-line video might be less helpful for those without any Haskell or blockchain experience. I (and thousands of others at HN) really enjoyed Jeremy Ruten's tutorial of building antirez's 1000-line text editor, Kilo, from scratch (antirez is the author of Redis which is renowned for its code quality and approachability) - http://viewsourcecode…

This is a cool idea. I would love to do this, but realistically won't have time for a little while. I can certainly look into it more when I get some spare time!

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#54

I'm tempted to just make a youtube video going over this code line by line. It's a really great introduction to a non-trivial bit of Haskell.

Would it make sense to make the code Literate Haskell?

A Literate Haskell blockchain might just be Peak HN.

(Definitely peak HN if it runs in the browser).

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#55
Neat. Just browsing through the source, is there a reason that:

   calculateBlockHash (Block i p t b _)  = concatMap hashString [show i, p, show t, b]
is not

   calculateBlockHash (Block i p t b _)  =  hashString $ concat [show i, p, show t, b]
i.e. why is a block hash a concatenation of 4 SHA-256 hashes instead of just 1? Is there some security benefit of doing it one way vs. the other?

edit: thinking about it a little more, option 2 seems better because in option 1 you can calculate 3/4 of a block hash without knowing the previous block's hash. Maybe that's not a problem in this context though?

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#56
post #55

Neat. Just browsing through the source, is there a reason that: calculateBlockHash (Block i p t b _) = concatMap hashString [show i, p, show t, b] is not calculateBlockHash (Block i p t b _) = hashString $ concat [show i, p, show t, b] i.e. why is a block hash a concatenation of 4 SHA-256 hashes instead of just 1? Is there some security benefit of doing it one way vs. the other? edit: thinking about it a little more,…

You're correct, it really should be the 2nd way. The current form isn't really a problem per se, mostly just that the generated hashes are really long and make the output harder to read. I'll get that updated, great catch.

EDIT: code updated.

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#57

I'm tempted to just make a youtube video going over this code line by line. It's a really great introduction to a non-trivial bit of Haskell.

I want to chime in that this would be amazing also. However, an actual line-by-line video might be less helpful for those without any Haskell or blockchain experience. I (and thousands of others at HN) really enjoyed Jeremy Ruten's tutorial of building antirez's 1000-line text editor, Kilo, from scratch (antirez is the author of Redis which is renowned for its code quality and approachability) - http://viewsourcecode…

I actually think that if I did it line by line in the traditional haskell style that'd be more approachable for this project.

Kilo is quite a bit bigger.

With respect and praise offered to the author, Legion is a simple project. I think an approach of building it interactively and showing how a developer actually makes the types line up and uses the tooling probably answers more questions about what it's like to use Haskell than you may give it credit for.

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#58

Earlier quoted context omitted.

Would it make sense to make the code Literate Haskell?

A Literate Haskell blockchain might just be Peak HN. ( Definitely peak HN if it runs in the browser).

Is GHCJS using WASM yet, because if so...

Re: Show HN: Legion, an as-simple-as-possible blockchain server written in Haskell

#60
post #59

Can someone explain to me in short summary why blockchain without crypto currency suddenly is a thing and why anybody would want it?

ELI5: A blockchain is an »I told you so« store. Future statements/promises are linked to past ones so you can’t mess one without having to mess with all the others. It’s like a black board you can’t wipe clean again, adding more text (and space to write to) is the only thing possible.

For example, you could promise to paint your house red in a blockchain. You later regret that promise and tell your friends you never said that, but since they all have access to all promises made, they have good evidence that what you say is not true.

Post reply on HN