News for hackers. Stuff that matters.
Re:Ask HN: How do you familiarize yourself with a new codebase? by fokz on Friday June 26, 2015 @11:11AM (#9785001)
Thanks for sharing. I often get lost in large projects. Blindly jumping around is quite inefficient and frustrating.

How hard do you think it is to write a tool to draw dependencies map for a specific language?

May be there're built-in code analyzing tools in compilers for popular languages that I'm not aware of?

Re:Ask HN: How do you familiarize yourself with a new codebase? by h8liu on Friday June 26, 2015 @01:36PM (#9786394)
For golang std lib, since packages have no circular deps, it can be automatically drawn out like this:

http://lonnie.io/gostd/dagvis/

If you write your project that even has no circular deps among files and all files are small (like me in https://github.com/h8liu/e8vm), you can draw the similar graph but at a much finer granularity, like this:

http://8k.lonnie.io/

Re:Ask HN: How do you familiarize yourself with a new codebase? by baby on Friday June 26, 2015 @10:14PM (#9788822)
wow! What did you use to make these? It looks awesome!
Re:Ask HN: How do you familiarize yourself with a new codebase? by h8liu on Friday June 26, 2015 @11:59PM (#9789045)
Thanks.

Here are my hand-made tools to generate those stuff: https://github.com/h8liu/e8tools

Javascript version (I actually wrote this first for go std lib): https://github.com/h8liu/dagvis

Re:Ask HN: How do you familiarize yourself with a new codebase? by tessierashpool on Friday June 26, 2015 @01:14PM (#9786201)
dependency graphs and code analysis are huge topics. this is probably the hard part with libraries like npm or Bundler.

the graphs can have cycles, multiple references to the same dependency, multiple distinct versions of the same dependency, et cetera. it's also all very, very language-specific. in many languages, the order of the require or import statements matter; in others, they don't. you can also have something like Clojure, with several different ways of bringing in a dependency, which makes the whole issue much more fine-grained.

prior to writing these scripts, I tried to do something more ambitious with auto-refactoring tools. these exist in Eclipse and can even be graceful in Smalltalk but my own results were not so amazing. I got somewhere with regular expressions, code generation, and shell scripting. but I also built a thing in Ruby which could auto-refactor a tiny, TINY subset of the most obvious refactorings in JavaScript. it took me months, maybe harmed my sanity, and was definitely not the best code I ever wrote.

TLDR: compilers, zomg.

edit: forgot to say you're welcome. :-)

Re:Ask HN: How do you familiarize yourself with a new codebase? by roflc0ptic on Friday June 26, 2015 @11:24AM (#9785119)