Today’s article is slightly different from our usual ones. If you’re a developer there is no doubt that you might've gone through the process of searching for code. It can be through the code repository of your organization and you’re trying to implement something new, or it might just be another hobby project and you’re clearing your doubts from StackOverflow. Today, we will take a look at the 5 best dev tools for code search.
This article was originally posted at: https://www.quod.ai/post/5-best-dev-tools-for-code-search
Developers and code search
Increasing code base sizes and sophisticated logic are prompting developers to search through code more often. According to a study, it is found that developers search through code at least 5 sessions a day. Most of the searches are surrounding the use of particular APIs, where a particular code is located, how a piece of code is failing, or what a piece of code does. Code search is becoming a crucial part of software development and developers must be equipped with the right tools.
According to the results of the study, we will narrow down our comparison to certain aspects of the tools. Here are two tables to ease the process of understanding what the criteria will be.
With these statistics in mind, we will lay down the basic criteria that we will use to compare the tools. We will assess the tools based on their ability to do the following:
- Get code examples
- Advanced search options
- Code impact analysis
GitHub
- Ideal for: public code examples
- Pros: easy to use
- Cons: hard to find exact code and to filter to what you want
GitHub has over 190 million repositories and is the largest host of source code in the world. GitHub has tons of features for searching through code and the code review is extremely useful. The default code search in GitHub is not very powerful and the options are very limited. But with the advanced search, you can fine-tune your search by specifying the repository owners, the number of stars that it has, the size of the file, the extension, the number of issues on it, and more.
GitHub is the place you want to be if you want to get code examples. Due to the enormous amount of code hosted on it, there is always something or the other that fits your criteria when looking for examples.
In terms of searching, there are a lot of advanced options available, but to make the most of it, you will need to know what exactly you’re searching for. GitHub doesn’t let you search for exact pieces of code but rather only by project and file names. Searching for example repositories is pretty straightforward, and you can use the search bar to search for it from your current repository, your current organization or from all of GitHub.
The advanced options might not ring any bells if you haven’t seen them before. Since GitHub also powers the Git version control system, it can be used to review pull requests, view the impact of merges if there are any conflicts, and take necessary corrective action.
Quod AI
- Ideal for: in-depth code search, impact analysis
- Pros: easy to use interface, integrates with Git/Github, JIRA, versatile code search
- Cons: programming languages is limited to Javascript, Typescript, Java, Python and Ruby
Quod AI is an AI-powered tool that does a lot of the work for you. It allows you to search for code, find experts and impacts from GitHub repositories as well as from Jira issues. QuodAI can be a great tool if used in addition to GitHub because both of them complement each other very well. If you have found a particular code example that you’re looking for on GitHub, you can connect the repository to Quod AI.
Once the connection is made, Quod AI uses artificial intelligence to scan through the entire repository and generate questions and tags. These questions redirect you to code snippets where the particular operation is performed and the tags will redirect you to all the snippets where that tag might be relevant. For example, if there is a tag called API, it will take you to all the controllers in your source code where an API may be implemented. The advanced search allows you to filter down to technical tags, business tags, the path (right down to a specific file), modified date, and file extensions. The UI is very simple to get accustomed to and there is also a quick demo to walk you through everything when you first start.
VSCode
- Ideal for: searching local code
- Pros: de-facto text editor for software development, plethora of extensions available
- Cons: code search is not very feature-rich
VSCode is Microsoft’s very own code editor that has become the de-facto standard in the industry. It is being used by a huge majority of developers thanks to the rich ecosystem of extensions that it supports. Once you have a working repository on your machine, you can open it in VSCode to search through it. Searching is not very feature-rich but is pretty good for a code editor. VSCode has extensions with Git that can show a preliminary impact analysis but again, this is restricted, considering it is a code editor.
SourceGraph
- Ideal for: searching through large codebases
- Pros: supports multiple repository types, code search is fast
- Cons: complex-UI, need to understand querying
SourceGraph is a web-based code search and navigation engine. In our opinion, it has a complex UI and will need some getting used to. You can link your GitHub or GitLab accounts and select the repositories you want to search for or you can add public repositories as well. Their searching is fast and there are quite a few advanced search options that you can try. The searches are made through certain queries which you can find here, so it is a little difficult for someone trying it for the first time to try and understand these. It doesn’t have any functionality to view the impacts as well.
Opengrok
- Ideal for: searching through code quickly, better suited to more advanced users
- Pros: supports multiple version control systems, fast code search
- Cons: difficult to set up, initial configuration is a little difficult
Opengrok is a source code browser and code navigation tool. It is extremely fast to search for code and can make complex search queries but the initial configuration required is a little difficult for the faint-hearted. But they do have a Docker image which simplifies the process. Opengrok is an extremely feature-rich code browser and it supports full-text search, definition and identifier search, path and history search, API searches, using logical operators to chain queries, etc. It supports a lot of version control systems like Git, RCS, CVS, Monotone, and more. Opengrok too doesn’t support any kind of impact analysis.
Conclusion
That’s it for our 5 best dev tools for code search. In our opinion, the tool that you use depends a lot on what you’re trying to achieve. We think that to get the best results, you shouldn’t stick to one tool, but use them in conjunction to maximize efficiency.
Top comments (0)