What does it mean to do/determine something "programmatically"?

Viewed 28738

Programmatically. (alt. programmically)

I've never used it, but I see it in questions a lot, i.e. "How to programmatically determine [insert task here]". Firefox immediately tells me that neither of these two words are real (at least, it doesn't recognize them). I've also never seen them used anywhere but here.

1) What does it mean to do/determine something "programmatically"?

2) Why do so many people ask how to do/determine something "programmatically"? Isn't it assumed that, if you're asking how to do something on a programming help board, you're asking how to do it "programmatically"?

3) Why is it that I've never seen the word "programmatically" anywhere else?

17 Answers

Doing something programatically generally means that you can do it using source code, rather than via direct user interaction or a macro.

For example, consider the problem of resizing columns to fit in Excel.

You could do it manually by double clicking between the columns, but that requires user interaction.

You could use the excel macro recorder, but that is fairly complicated.

Or, you could use VBA to write code that would do it.

I doubt it's actually in the dictionary.

In .NET, "programmatically" generally means doing something in code rather than in a template, markup, configuration, or xml.

For instance, in an ASP.NET page you can add a textbox in the ASPX markup:

<asp:TextBox runat="server" />

Or you can add the control programmatically in the ASPX.cs codebehind:

this.Controls.Add(new TextBox());

Similarly, you can change configuration manually by editing the xml in the App.config file, or you can write code that will modify the configuration programmatically.

  1. To execute code that does it. Previously having written the code is implied.
  2. Probably in most cases it's something that's relatively easy for a human to do, with the challenge being automating it. The assumption you describe may or may not apply.
  3. I have no idea. I've seen it many times and in many circumstances. Incidentally, I categorically deny the idea that a word has to be on somebody's list somewhere to be a 'real word', especially when it's a clear construction from well-known roots, as in the case of 'programmatically'.

1) What does it mean to do/determine something "programmatically"?

I assume from your second question that the answer to this is already known to you ;) .*

2) Why do so many people ask how to do/determine something "programmatically"? Isn't it assumed that, if you're asking how to do something on a programming help board, you're asking how to do it "programmatically"?

Yes, but no harm comes from using the word!

3) Why is it that I've never seen the word "programmatically" anywhere else?

You're not looking hard enough! http://www.google.com/search?q=programmatically

  1. To accomplish it with a program / in code. Example: eating a sandwich programmaticly would mean you write a program that eats a sandwich.
  2. I agree.

I think people (myself included) use the term 'programmatically' to refer to a function performed in source code (eg C#), as distinct from something done declaratively(eg XAML).

  1. doing something programmatically is doing something by executing program code
  2. do not ASSUME. It makes an A** of U and ME :) the thing is, many people can ask questions that are not programming-related (e.g. "how do i overwrite a read-only file in linux?")
  3. Usually it is clear by the context if things are done programmatically or not. Therefore the word is often redundant and not used. In here, people want to make sure they are understood, and their question is not answered in a wrong way ("how do i programmatically overwrite a read-only file in linux?" will provoke a different kind of answer than the one in 2.)

The way I use "programatically" or sometimes "proceedurally" is best described using the following code:

int[] arr = new int[] { 1, 2, 3, 4, 5 };

to do the same thing programatically would be:

int[] arr = new int[5];
for (int i = 1; i < 6; i++)
  arr[i] = i + 1;

Now while a very limited example, what would you rather type if the array was hundreds or thousands of elements. In real-world situations, there are usually pros and cons as to which is best to use at a time, but for complicated operations, generally things are more efficient if they're done "programatically".

Perhaps a better example of this is the value of alt Pi. You could simply input the number 3.141592653589793238, but it would be very difficult to type it in if you needed alt Pi it accurate to 100 decimal places. You would instead use a function, perhaps something like alt function.

** Reference wikipedia http://en.wikipedia.org/wiki/Pi*

As others have said, it means asking for a solution for a particular problem in the form of code. This is particularly relevant in the modern era where GUIs are everywhere and operating systems are big, sprawling things with innumerable functions. It may be incredibly easy to find out a particular piece of information or perform a certain action manually as a human but how to do so as code is less obvious and requires research.

For example, consider how to delete a file and move it to the recycle bin in windows. Manually, this is trivial, select the file in explorer and hit delete. Or drag the file to the recycle bin. In code it's not remotely intuitive how you perform this action.

Developers usually try to state the question as precisely as possible. They try to state the environment, the language, whatever else they already know. The more precise is the question the more precise hopefully is the answer. But when they can't state anything (like they just want to know if there is an API call to do something) they just ask how to do it programmatically.

I mostly use the word in the context davogenes and ash explain it.

However I'd like to add that in this case, a synonym would be "dynamically" because you can add control elements at run-time and not already at design-time.

For me its the difference between working in the designer or in code (runtime).

You can do a lots of things in designmode, set a datasource to a datagrid and layout the columns and set colors and a lot of other things without do a single line of code. If I want to know how to do it in code instead of setting it in the design mode I would ask how to do it "programatically".

My 5 cents.

Related