I would like to say "The source code can be extended by/with line(s) of code"

Which word (by or with) is more appropriated and what is the difference in the meaning?


2 Answers 2


Great question! I believe the correct form would be "by". However, it really depends on what the additional lines are doing to the source code, and what's happening to the source code by the adding of more lines. I am a native user of English (but NOT a programmer) and could not answer this without doing research myself, so here's what I found:


VERB. [with object = transitive] Cause to cover a larger area; make longer or wider. (oxforddictionaries.com). There are several uses of this verb in instransitive form as well.

  • Here's the deal with transitive verbs (from "grammar girl")

Transitive verbs require an object. For example, filled is a transitive verb and the cup is the object in the sentence She filled the cup. It doesn't make much sense to have filled without an object. She filled is incomplete.

The tip for remembering the name is to think of transitive verbs as transferring their action to the object. Transitive and transfer both start with the prefix trans-.

(The question of how source code behaves, without the addition of more lines, is important here. If it is static, and cannot extend like an arm or a antenna, then the transitive form of "extend" is applied by the additional line to the source code.)


  • Here's the deal with "by" or "with":

Many similar questions regarding "by" or "with" have been asked on ELU: https://english.stackexchange.com/questions/277669/challenged-by-or-challenged-with-how-to-decide-whether-to-use-by-or-with. You can go to that page and do your own search and find lots of discussion about "by" or "with".

I also found this instructional piece on an English language learner site:


BY: We only use “by + agent” when it is important to say who or what is responsible for something.

Example: - The radio was invented by Marconi. - A number of trees were blown down by the strong winds.

NOTE: We sometimes use the subject of an active sentence (Marconi, the strong winds) as ‘the agent’ in a passive sentence. When this happens, we use “by” to introduce the agent in the passive.

WITH: We use “with” to talk about an instrument which is used by the agent to do something.

Example: - I was hit with an umbrella. - The World Trade Center was crashed with two aircraft.

NOTE: We also use “with” to talk about materials or ingredients. Example: - The room was filled with smoke. - Irish coffee is made with whiskey." (http://advancegrammar.blogspot.com/2009/08/passive-with-by-and-with.html)

  • Here's some examples of "by" from published sources:

    I searched "can be extended by" on Google in the 'books' category, and several resources came up in the results. Here are two that I think are similar to your topic (technology) and show the use of "by" similarly to your statement.

1) "Genome Stability" - Page 101

https://books.google.com/books?isbn=1317682319 James E. Haber - 2013

"The length of the hDNA can be extended by additional strand exchange mediated by RecA/Rad51 (Figure 6.18 panel ii) or by the initiation of new synthesis from the first 3ʹ end (Figure 6.18 panel iii). Finally hDNA can be extended by branch ..."

2) "Term Rewriting Systems" - Page 681

https://books.google.com/books?isbn=0521391156 Marc Bezem, ‎J. W. Klop, ‎Roel de Vrijer - 2003

"Then the path can be extended by an unlabelled edge and a node labelled with ( t', ()). (iii) Otherwise, s is a right-hand side t', and £' u is a variable x. Let the last occurrence of t in a node label of s be with position v. Then v will be the position ..."


There are lots of examples for the use of "with":

1) Distributed and Parallel Systems: From Cluster to Grid Computing

https://books.google.com/books?isbn=0387698582 Peter Kacsuk, ‎Thomas Fahringer, ‎Zsolt Nemeth - 2007

"... allows users to select only tested and working resources when mapping the execution of a newly created workflow, or when rescuing a failed workflow component. This paper presents how GEMLCA can be extended with the above features ..."

2) Term Rewriting Systems - Page 681

https://books.google.com/books?isbn=0521391156 Marc Bezem, ‎J. W. Klop, ‎Roel de Vrijer - 2003

"If u • i is a position of t or t' respectively, then the path can be extended with an edge labelled i and a node labelled (t, u • i) or (t', u • i) respectively. (ii) Alternatively, s is t, and u is the position of a redex in S, the right-hand side of whose rule is t'."

The reason I determined that it should be "by" is because I think that in your statement, the source code is made longer by the additional lines of code that are doing the action of extending. The source code is changed in length by the addition of more lines of code. Another example of this meaning of extend would be in its usage referring to time; to change the length of the school year by adding more days at the end of the year: Administrators determined that due to too many snow days, the school year will have to be extended by three more weeks.

However, if the source code is only made capable of reaching farther beyond itself by additional lines, as one would add an extension cord to an electrical appliance so it can reach the wall outlet, then I think "with" would be more appropriate. Here, the combination of the cord with a second cord, provides more length. If the source code remains essentially the same, and acts in tandem with the additional lines, then "with" should be your choice.

  • Thanks for your details explanation! I didn't know that context is so importent :). I think, with is more appropriated in my case because the additional line does not change (or extend) the logic of "the source code" - it just adds new logic of another aspect.
    – JanDotNet
    May 15, 2016 at 9:55
  • 1
    You're welcome - it's a usage quirk that is still up for debate on ELU, so the research is well worth it for me. I saw your comment about other verb choices like "appended" or "supplemented". Others could include "amended" or "expanded". All of these would work with "with", if you find that you need to avoid "extend" due to its specific meaning in programming jargon.
    – Bea Bonmot
    May 15, 2016 at 17:24

Here's how it works. You extend something BY some action you take to extend it. With what do you extend it?

So if you extend a piece of paper using staples and another piece of paper, then you extend it by using a stapler, and you then have extended it with another sheet of paper.

So you extend source code with added lines. Or, you extend source code by adding lines. Is it the extending action or the object added you wish to emphasize?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .