IDE and available functions

When writing an application on a typical IDE using an OOP language one does not have to remember all functions that can be used on specific objects. The IDE provides support for that and so when the developer types a dot (usually) next to a variable a popup window appears which displays all the available functions and (on a well documented code) one can then see more details about what each function does and what arguments it requires. Of course, one can use some kind of online HTML documentation for that purpose e.g. when using Qt the online documentation for each class and the available API is excellent and easy to locate.

In Julia there can be a hundred different functions which can operate on a particular object and a hundred different versions of each one of these functions coming from anywhere e.g. the system, several versions from external packages, local versions etc.

So, my question is this: given a regular person with limited capacity to remember and limited time to read the complete documentation of everything, how can one find out the function he needs to use in order to perform some operation? Is there support for this in some Julia IDE?

For example, I may have some kind of variable of some type and I want to do an operation that computes a gradient in space and I know that there is some function available to do that but I don’t know its name and arguments I have to use. Suppose also that there are different gradient computation algorithms available from different packages/modules I am using and therefore I want to know what is available and how to use it. Other than reading the documentation of everything or looking at a long list of functions that use this type (or super types) as an argument to do all sorts of things, is there a simple and efficient way to find what I need?

Unfortunately, I don’t think so. I would suggest 1) Google. 2) Ask here. (not necessarily in that order)

This part, if the package is properly documented can be solved with julia> ? function_name, that should show you the help entry of the function with how it works.

2 Likes

There is a PR open that does something like this https://github.com/JuliaLang/julia/pull/38791 so its been worked on. But it is an issue currently.

6 Likes

Also names(module) will get you all the exported names of that module. But it’s not 100% what you are looking for.

1 Like

There is also the apropos function which can help if you know some keyword(s).

Even if an IDE implements a facility to display all available functions that can use a particular object as an argument the problem remains: one has to examine potentially hundreds of functions to find the one he wants to use. With classes or interfaces the list of functions is much smaller because these are actually operating as filters to examine a limited number of methods relative to the type of the object.

This issue and the poor implementation of the modules system in Julia, I think, are the result of designing a language mainly for scripts and notebooks with the use of many little packages rather than large scale applications so that one could replace the C++ and Fortran dinosaurs.

Defining a new type, a few “base” methods, then having entire libraries work seamlessly with your type, is maybe the core feature of Julia as a language. And I don’t think the ability to extend others’ work makes it harder to make large projects.

Overloading might make it harder to write the ideal tooling for method discovery. But I wouldn’t say this cost outweighs the benefits.

3 Likes

It is a tradeoff that the power of generic programming and multiple dispatch brings to the table. If functions are written generically and can work on any of many types of variables all code becomes more useful. But you loose that possibility of searching a few methods that apply to one specific type.

The Fortran dinosaurs don’t have either facilities, so that is hardly a requirement for large libraries.

1 Like

That depends on the object you want to use, if it is an floating point number of course there will be lots of functions but if its an user defined type, there won’t be that many functions that work on it so the IDE/REPL won’t show so many options.