enobrev 7 years ago

This looks like an exceptionally useful tool! Thanks for making and sharing it. The video is excellent.

It reminds me of a feature I've always wanted, which would be a code unravel-er. Basically I'd like to be able to select a line anywhere in a codebase, and have said codebase expand to show me the entire execution path as if it were in one single scope, with the ability to re-collapse sections back into loops and functions while reading.

I think it would help to better understand the codepaths that can start to get fuzzy when jumping between abstractions. It would be great - not only for understanding unfamiliar code - but also for double-checking logic across longer code paths.

At any rate - great idea, great implementation, and beautiful website.

  • CPAhem 7 years ago

    If you're looking for a similar tool which does have a code unravel-er look at SciTools Understand[1] for C/C++/Java

    My previous company used Understand on a large unfamiliar codebase, it helped greatly, but was pricey.

    [1] https://scitools.com/

    • popeko 7 years ago

      There's also Source Insight [1] which supports C/C++/Java/Obj-C - quite a fantastic tool, but unfortunately it's Windows only (Wine works with a few hiccups)

      [1] https://www.sourceinsight.com/

      • Operyl 7 years ago

        Wait a second, a tool that supports going through Obj-C is Windows only? That’s .. a shame.

  • fazzone 7 years ago

    I am playing around with an idea like this for editing Clojure in Emacs with cider-mode. You have to manually build the 'thread' that such a code unravel-er would return, but then you can read and edit functions from many files in one buffer. You start with the highest-level function you are interested in, and then pull the definitions of functions it calls into view as needed.

    https://github.com/fazzone/multifiles.el/tree/cider-hacks

danielvf 7 years ago

I used Sourcetrail a few months ago to figure out a ugly ball of embedded C code that I needed to reimpliment. Sourcetrail was super helpful for this. It paid for itself in an afternoon.

  • nebucnaut 7 years ago

    Thank you for the kind words! We are always happy to hear from a satisfied customer :)

chubot 7 years ago

Hm does anyone know of a web-based tool like this that uses Clang as a back end? I want to put open source code like the bash and Python interpreters in it and be able to navigate symbolically. And I want nice permalinks.

EDIT: It looks like https://woboq.com/codebrowser.html is what I want. The code available but not under and open source license. https://github.com/woboq/woboq_codebrowser/

I will probably try this, but I'm interested in alternatives!

  • sqs 7 years ago

    We built Sourcegraph, which is a web-based code search and navigation tool. Our Python support is in beta, and you can try it out at https://sourcegraph.com/github.com/plotly/dash/-/blob/dash/d.... (And hit Alt+D/Opt+D to search by symbol.) Sourcegraph also supports a bunch of other languages: https://sourcegraph.com/help/languages.

    It gives you nice URLs (hit Alt+Y/Opt+Y to get the full commit ID in the URL to make it permanent).

    Would love to hear your feedback.

    • chubot 7 years ago

      I just spent a few minutes clicking around but had a bit of trouble.

      EDIT: nevermind, most of this is due to the fact that you have to keep "repo" in the search box, which I found confusing.

      I quickly found the repo I wanted, but discovered that C/C++ isn't supported, so Woboq is more useful to me at the moment.

      I tried to build something like this once myself, and made the mistake of going "wide" rather than "deep". That is, trying to support all languages. I think it does make sense to try to get the absolute best experience for one language. But yeah for now since C/C++ aren't supported, it's not useful for me.

      ------

      I typed "cpython" in the search box on https://sourcegraph.com/ and got no results. (I also typed "python" and got no results, which seems pretty odd.)

      I would have liked to browse this repo:

      https://github.com/python/cpython

      I guess you have to import repositories yourself? There seem to be sample repositories, but they are in Go, and I'm interested in C/C++ (the Python interpreter, not Python source code).

      I'm looking for something that uses Clang as a back end for intelligent navigation of C/C++ projects.

      Also, I would like to browse the bash source code, but as far as I know it isn't available on Github. Can SourceGraph import from an arbitrary git repo?

      https://savannah.gnu.org/git/?group=bash

      That said I'm glad somebody is working on this problem! I like your mission statement.

      • sqs 7 years ago

        Thanks for posting this. We'll think about how we can make that search UX clearer. And when we have C/C++ support, I hope you'll find it super useful.

alkonaut 7 years ago

Website feedback: Supported languages is the #1 most important piece of info about this software. It should be front and center and probably repeated a few times already on the landing page.

  • ska 7 years ago

    This may be a result of your feedback, but for me looking just now it it front and center: "Sourcetrail - A cross platform source explorer for C/C++ and Java"

    • 0xffff2 7 years ago

      Although physically front and center, the fact that that line is nearly the smallest thing on the page caused me to gloss over it entirely my first time through.

      • haffla 7 years ago

        I didn't see it either. Was about to ask if it'll work for Rails projects haha

    • fspear 7 years ago

      it should be in a bigger font, and it seems like it's the only place where language compatibility is clearly visible without going into the documentation.

  • bigtunacan 7 years ago

    If I could upvote you more than once; I would.

    I left the site not really knowing what language/s are supported.

    After digging through the entire page it looks like maybe C/C++/Java?

    There should be a huge button, or something, front, and center. <<SUPPORTED LANGUAGES>>

    Looks like a cool idea, but I don't know if I can even utilize this tool.

  • orclev 7 years ago

    I'd suggest second most important piece of info is probably supported editors.

peternicky 7 years ago

Can you please share the roadmap for adding new language support?

  • nebucnaut 7 years ago

    To be honest: We have not decided what language we will pick up next. Our first priority is to improve on our Java coverage. In a few months we should be ready to choose our next language. We are thinking about either tackling Python or implement support for a more recent language like Kotlin, Swift or Go.

    • fusiongyro 7 years ago

      I doubt there's very much legacy-ish Kotlin or Swift code out there to be a significant selling point for your product.

    • xyclos 7 years ago

      I spend a lot of time in clients' ios apps which were developed by other contractors long ago and then I'm asked to fix bugs and add new features. I think this would help me save a lot of time. Since it already supports C/C++ would objective-c support be relatively straightforward to add? Not sure if there are many others who would like to see it, but I know I would definitely appreciate it.

    • dbcurtis 7 years ago

      Seems to me there is probably a huge amount of legacy Python code around that people need to explore. In fact, I've spent the entire day so far creating some so that we have enough legacy Python code around in a couple more years. Wouldn't want to run short.

    • notheguyouthink 7 years ago

      I might buy this for Go if it was available, this looks interesting!

      Note that I'm mainly interested because my current editor of choice does not have the full suite of tools I'm used to for Go. I used to use Vim, and vim-go has such an excellent suite of tools I don't think I'd buy this. However, I've since switched to Kakoune, and the tool support is quite young and I've not had time to improve it myself. So this tool (at the $100 self employment pricing) is a nice fit for a tool I'm on the fence about. At $200 I don't think I would, but at $100 I think I would.

      Anyway, just providing a bit of feedback. Looks really nice!

      • nebucnaut 7 years ago

        Thank you for sharing your opinion! This will be exactly what we will be interested in when deciding what language to tackle next :)

    • 3wolf 7 years ago

      I know it's easier said than done, but a pluggable interface for community created language support would go a long way towards gaining traction.

    • devrandomguy 7 years ago

      A Lisp might be an easy language to target, because of its consistent syntax and "code is data" philosophy. With Clojure, you could both reuse some of your work on Java, and support Clojure's Java interop. Attempting to support Clojure would drive improvements in the Java support.

    • Shank 7 years ago

      Seems to me like the obvious choices would be languages that have large, long standing legacy codebases. Swift code is going to be relatively tight just because it's so recent, whereas something like C# isn't.

    • tylerc230 7 years ago

      Swift would be great. Perhaps you could leverage SourceKit.

    • fspear 7 years ago

      Python, Scala and Go would be great additions (in that order).

  • tluyben2 7 years ago

    C# please!

    • ianceicys 7 years ago

      Um..you already have this if you have visual studio 2015. https://youtu.be/01MzfE8s6G8?t=54

      • CMay 7 years ago

        Code Maps requires Enterprise, I think. You can view generated Code Maps from other editions, but you need Enterprise in order to generate them. Kind of unfortunate.

agentgt 7 years ago

Just a feature request if it isn't already in the works:

Runtime analysis of code that actually matters ie live code.

Often its hard to figure out what in the code base actually matters.

Debugging is still sort of difficult and dead code is really hard to find and get rid of. Particularly if reflection is used heavily which it almost always is these days.

Otherwise (IMO) as a Java developer IntelliJ and Eclipse are actually not that far off in their static analysis and already pretty good to discover the code. Especially IntelliJ as I can easily see them enhancing their code view/discovery as well as they already have static dead code analysis.

I guess I don't think discovering code bases is that much of a problem compared to understand what is actually running.

That is I think debugging particularly multithreaded applications is vastly more difficult problem. Thus runtime analysis would be very useful.

  • egraether 7 years ago

    Thank you for your input! I wouldn't call it a feature request though, I'd say it's another tool. But, you are right, exploration of dynamicly analyzed code would also greatly benefit understanding.

dkarapetyan 7 years ago

I really want something like this for heterogenous codebases. Maybe along the lines of ollydbg and ida but for "reverse" engineering Ruby, python, and go.

m712 7 years ago

Not saying this is bad, but...

Instead of giving money to a tool like this, you could just use ctags/etags, both of which are Free Software. It doesn't show detailed graphs like Sourcetrail does, but it allows source code traversal by function definitions, and supports a crapton of languages.

kuangye 7 years ago

Has anyone run a large codebase like chromium with this tool? Is the indexing looking at what's compiled like libclang or is it static like gtags?

  • davidshepherd7 7 years ago

    Pretty sure it's compiled,I tried it out and it took a while to process on code that ggtags parses in seconds.

  • ensiferum 7 years ago

    I'd imagine it's going to violently shit itself. Chromium has pretty good online code search btw.

    • kuangye 7 years ago

      Yes, but not the kind of visualization and calling stack shown by SourceTrial. Some of the code is 10 layers deep where the stuff actually happens with many complicated usage of inheritance, which I figure is where this kind of tool can shine.

mden 7 years ago

On a first look, it looks amazing. This is actually what I've always imagined "graphical" programming to look like.

aeling 7 years ago

This looks super interesting - great video! Everything is processed offline, I assume? No code leaves the machine?

  • nebucnaut 7 years ago

    Indeed, everything's offline! You don't even need an internet connection to run Sourcetrail :)

nikki93 7 years ago

Interesting can you edit code in the text view too? Wonder if this could be the one place to write your code too.

  • egraether 7 years ago

    We decided to leave out editing early in the process. Most developers already have their favorite editor and it's a lot of work to implement all features that users would expect from it.

    We decided to focus on source exploration instead. Sourcetrail is made for the second screen. We implemented plugins for the most used source editors to enable easy switching. Please have a look at our documentation: https://www.sourcetrail.com/documentation/#CODEEDITORPLUGINS

    • nikki93 7 years ago

      Cool! Wonder what the graph exploration view would be like if you used a hyperbolic plane to embed it in haha: https://en.m.wikipedia.org/wiki/Hyperbolic_tree

      Nice work; seems like you hit a nice medium between trying out something new and keeping it connected to the real world and practical. :)

girishso 7 years ago

Slightly tangential.. a code editor was showcased on HN few years back, with context sensitive "panes".. for example currently selected function/variable declarations in another pane. Very impressive stuff, but can't seem to find it anywhere now.

  • nkerkin 7 years ago

    Visual Studio 2013 and lower had the Code Definition window, which sounds very similar to what you are describing. It was replaced by the (possibly inferior) inline Code Peek feature in VS15.

    • girishso 7 years ago

      It was most definitely not Visual Studio, it was from some startup. But thanks anyway!

coffeeski 7 years ago

Watched the demo video, can you add support to Javascript and Ruby? This is an amazing tool

fomojola 7 years ago

Looks really good: one possible suggestion would be to allow sharing/reuse of indexes. Let me commit the built index to git and then have someone else checkout and use the index that was prebuilt.

One (potentially paying) alternative would be to provide a precompilation service. Not sure if your index generation can be parallelized, but potentially you could take an archive of the code (or pull directly from Github or Bitbucket or any other repo endpoint) then spin up a large EC2 instance (or the equivalent for your cloud of choice) and accelerate the generation of the index. For large codebases it may provide a good boost.

davidshepherd7 7 years ago

I had a quick play with this today and it seems like something that could be really useful.

A couple of relatively minor comments for you:

* In C++ it might be useful to filter include guards out of the symbol lists.

* I had some problems with using the menus (couldn't click on them, when I did select them couldn't get the menu to drop down). It's probably just because I'm using a weird window manager (xmonad, no window decorations, Ubuntu 16.04).

boltzmannbrain 7 years ago

Looks cool! This hits a pain point of mine working in a legacy Python and C/C++ codebase. Any plans for Python support?

  • nebucnaut 7 years ago

    Happy to hear that you like it! Full support of Python won't be easy but maybe we could tackle this one in stages. Implement highly demanded features in a first Python release and improve on that later on.

justboxing 7 years ago

How different is this from CodeLens ? Seems like most of these features are in CodeLens anyways, maybe the licensing for CodeLens??

CodeLens => https://msdn.microsoft.com/en-us/library/dn269218.aspx

  • egraether 7 years ago

    CodeLens is great for finding references within the IDE. It also provides information about the history, which Sourcetrail doesn't do yet.

    I would say we go a step further, by also providing a visual representation of the references to symbol, which quickly conveys how a symbol is embedded into the rest of the code base, without even reading a line of code. That makes exploring a lot faster.

bastijn 7 years ago

Do you also have arrows to methods in your own class? In addition, how does this relate to code maps in VS?

https://msdn.microsoft.com/en-us/library/jj739835.aspx

Seems they cover a similar thing.

  • nebucnaut 7 years ago

    Yes, Sourcetrail also shows class internal calls and accessed fields. Code Maps in VS has a different approach because they try to keep the graph small by making the user add symbols. So if you are trying to see every access of a symbol it is easy to miss something. Sourcetrail on the other hand keeps the graph small and comprehensible by showing only one level of dependencies. You don't need to add anything yourself. So you cannot miss any relation ;)

    • bastijn 7 years ago

      Thanks. Sounds more promising than I took from you landing page. I will give it a go on my c/c++ code bases. See if it can help me.

      I now notice the free trial cannot be run on your own project. I have to say I won't buy anything that I didn't try on a real sample before. What made you decide to go for this option instead of regular limited functionality or time bound (my preference).

nautilus12 7 years ago

I doubt you could ever get something like this working for Ruby, which is where it is actually badly needed.

  • nebucnaut 7 years ago

    Yes, dynamically typed languages are much harder to tackle :/

    • dkarapetyan 7 years ago

      You don't need it to be fully automated. For dynamic languages you would have people in the loop to annotate the parts the tool couldn't figure out.

      • nautilus12 7 years ago

        This seems like no better off. Documentation is historically always out of date the second its written. The same would be true for annotation.

        • dkarapetyan 7 years ago

          As noted by others the annotations would be active checks. More like proofs in coq than static text. That way you'd be building up a logical understanding of the code base that was machine verifiable sidestepping the issue of stale comments.

          If done properly this could even feed into code dynamics to capture information on the runtime information. So that at every point in the program you could start asking questions like how many times did this line execute, what was the type of this variable at this point, how much memory was allocated, and so on and so forth.

          • nautilus12 7 years ago

            Seems like youve just abstracted things like static typing into a extension of the language thats checked at a less optimal time. At this point arent you better off just using a language that incorporates this functionality and compiles it? Sounds like youve just implemented static typing but in a really akward and unecessary way

        • diggan 7 years ago

          Guess you could have some assertions together with the annotations to make sure things are up-to-date. Then integrate those tests with your CI of choice and it should be a bit easier to keep up-to-date.

      • lallysingh 7 years ago

        You're best off getting traces from a modified runtime to annotate what's going on.

problems 7 years ago

What's the C++ support like?

  • egraether 7 years ago

    Sourcetrail developer here: Pretty solid. We use clang libTooling.

    • malnourish 7 years ago

      How's the performance on a large codebase?

      North of 500k lines, few thousand cpp/h files, 40+mb

      • nebucnaut 7 years ago

        We have been working on that for the past few month. Right now the performance is pretty good for C++ projects up to around 2 million lines of code. For C projects the performance is even better! If you want to test it, just download the pre-indexed clang project (900k loc) from our website (https://www.sourcetrail.com/downloads#extra). Indexing the project took 12 minutes on a 5 year old laptop.

        • malnourish 7 years ago

          Really great news! I think I'll give this a demo when I have some capacity.

          Thanks

      • davidshepherd7 7 years ago

        I tried it on a fairly big repo today (~500k loc) and once it was done with the initial processing performance was fine.

    • rasjani 7 years ago

      Compile commands ? Please Yes?

      • jschwartzi 7 years ago

        There is also a tool called Bear which will generate compile commands from Make-based builds, in case you were wondering. I've used it with some success.

        https://github.com/rizsotto/Bear

        • rasjani 7 years ago

          Im well aware of bear. Works fine in some cases, not so well in others. Author is also doing scan-build replacement in python which imho is far superior to bear.

      • nebucnaut 7 years ago

        Yes, we support Compile Commands :)

      • voltagex_ 7 years ago

        What are compile commands?

        • nebucnaut 7 years ago

          A Compile Command is a JSON file entry that specifies what the C/C++ compiler should do when compiling a file. So it defines a file to compile and all the required flags (like include paths or preprocessor defines). These Compile Commands are used for all kind of Clang based tools. You can read more here: https://clang.llvm.org/docs/JSONCompilationDatabase.html

nickpresta 7 years ago

What languages are supported? At least on mobile, there is zero mention of language support outside of testimonials and screenshots. Is it just Java and C++?

  • RussianCow 7 years ago

    The intro video mentions Java, C, and C++.

    • nebucnaut 7 years ago

      Right, it's "just" Java, C and C++ for now but we are planning to extend our available languages as soon as possible!

      • gaelian 7 years ago

        Any rough idea when you might have C# support?

      • critium 7 years ago

        would that happen to include scala?

        • nebucnaut 7 years ago

          Unfortunately it doesn't. Even though Scala and Java output the same kind of bytecode, these languages have different language specifications. We currently only support what's in the JLS.

joshdotsmith 7 years ago

Looks fantastic. Do you have plans to support additional languages?

This would be particularly useful in open source.

redm 7 years ago

I love the implementation for C++, I'm just waiting for more language support.

jsk2600 7 years ago

Any plans to support Kotlin ?

  • nebucnaut 7 years ago

    Kotlin is definitely on the shortlist for the next language to be supported! Which language we'll pick up exactly depends on the landscape of available tools for that language. Kotlin is pretty new so I guess that there could be a need for Sourcetrail :)

    • ftomassetti 7 years ago

      If you ever go that route and you plan or using/creating some open-source components I would be very interested on hearing more (I am a JavaParser/JavaSymbolSolver contributor)

Zalos 7 years ago

Any plans to add support for PHP to this? it looks really cool :)

ifree 7 years ago

Got lots of compiling error when trying it on a large code base

  • nebucnaut 7 years ago

    Those are probably caused by an issue in your project setup, but I don't think that this is the right place to go into details. If you like to investigate, please send us an e-mail!

    • ifree 7 years ago

      thanks for your quick reply, I'll send you a mail later after my investigation

coffeeski 7 years ago

A CDN hosted site would be good

  • coffeeski 7 years ago

    Or hosted on an S3 bucket... took forever to load