views:

2007

answers:

27

Hi,

I understand that this question could be answered with a simple sentence and that it may be viewed as subjective, however, I am a young student who is interested in pursuing a career in programming and wondered how long it took some of you to get to the level of experience you are now?.

I ask this because I am currently working on building an application in Java on the Android platform and it bothers me that I am constantly having to look up how to write a certain section of code in my application such as writing to a database, or how the if statement should be structured.

My question really is, how long did it take for you to become experienced enough to actually know exactly how your next line of code was going to look, before you even wrote it?

+46  A: 

The speed at which you can quickly recall language syntax, common library functions, and best practice patterns is directly proportional to the amount of time you spend using them.

In other words you will find yourself getting faster the more you do it.

Andrew Hare
Strongly agree with this. Throw in how recently you used that syntax/library/pattern. I started writing C/C++ in notepad and could write complete and correct solutions to my intro classes. After doing Java for 5 years, I definitely couldn't write a C++ Template from memory. But show me a reference or sample and I know it instantly!
Tim Bender
Following along to Tim's comment, even when I haven't used a language in years, I find I can read it still and understand what's going on. The everyday knowledge that would allow me to type it in and create something is rusty because it isn't fresh, but recognizing and reading seems to always be there.
Greg
I find I can read and understand what's going on in *any* reasonably-designed language, even if I've never seen it before. Experience generalizes, and most modern languages are built very similarly. (There's a reason nobody but Apple uses ObjC--the syntax is needlessly unconventional. I can't begin to guess why Apple uses it.)
Glenn Maynard
+6  A: 

It took me 12 years to get where I am at today, which is my experience in professional programming. You will always improve when working with some programming language, even if you have been working with it for the past 5 years.

About your question, it depends. I think that you should be comfortable with the syntax after a week, comfortable with the main libraries after a month, and comfortable with the platform after 6 months.

But when you get there, don't stop!

Ravi Wallau
That time line seems reasonable to me now that I've been developing for 5 years. I couldn't imagine doing it that fast my first couple of years though.
robault
+27  A: 

I have been a C++ programmer for the last 20 years. It has taken me that long to get to this expertise level. I'm mostly a Windows programmer, and I keep the msdn website up on one of my monitors all the time.

Doesn't matter how long you've been doing it. You will never know everything from memory. Don't sweat it.

John Dibling
Sweat it when you get to an interview and the prospective employer expects you to have some things in memory though. :P
robault
Yeah, but any employer that holds it against me when I don't remember the function parameters for some WINAPI function is an employer I don't want to work with.
John Dibling
Although I used to feel the same way about having the Javadocs site up, Eclipse sort of eliminated that. I occasionally have to reference the docs, but 99% of the time what I need to know is a ctrl-space away. I'd assumed MS tools would have copied this by now.
Bill K
John Dibling
There's a big difference between parsing C++ code and Java code though. An intellisense that has to deal with the fact that you can have the word `const` in 5 different places on the same line of code can't work as well as one that has a "tight" syntax.
Patrick
I have yet to meet anyone that can write a call to CreateWindow and remember which parameters are which. That applies to pretty much the entire Win32 API. When the hell is MS going to give us a new native API to work with?
Mike Weller
@Mike: If you mean a new API that replaces the current one, unlikely to ever happen.
John Dibling
uh, downvoter thinks they can memorize the entire WINAPI? yeah, ok...
John Dibling
+20  A: 

I've been programing for almost half of my life and I sill can't always recall simple syntax, let alone entire tracks of code for more complex tasks. If you ask me that's what reference books and Google are for.

A far more important skill to have is the general knowledge of programming in any language, i.e. recursion, looping, object oriented design, working with APIs, error handling etc... Once you have all that down, you can apply it to any language and platform.

Donal Boyle
And Intellisense!
Charles
Yep, the basics of design and logic will get you anywhere. It can take a long time to learn all of that, a whole career for some.
robault
@robault: unfortunately there are some for whom an entire career is even close to enough...
Jerry Coffin
Being able to recall simple syntax is a pretty fundamental skill. References are for the uncommon stuff.
Glenn Maynard
+2  A: 

You should use code snippet if you are using certain piece of code repeatedly. I doesn't bother me if I cannot remember some piece of code from memory.

fastcodejava
Right, it is not necessary at all.
javaguy
+3  A: 

There's a false assumption going on here I think...

At my job I end up working all over the stack in different languages and platforms. If I'm away from a project for 6 months I end up having to look at code to get even basic things done. The advantage of experience is reducing the re-ramp up time on productivity though.

So, instead of it taking weeks or months to get back to a point where I can write 80% of the code from memory it takes a few or several days (if that sometimes). I've been programming for about 5 years now. I'm just now getting to the point of being able to visualize small applications in their entirety.

As long as you're working on solving a problem that you haven't already solved (numerous times) you'll probably always have to look up code.

If it can be done I'm guessing it takes longer than 5 years for most people, unless they work in one language with one editor and in one area. (ex: C#, Visual Studio, file system operations) My company isn't big enough to employee someone that specific.

robault
+6  A: 

If you code every day with the same language, you'll probably have the common language elements and patterns memorized in a month or two. But there are plenty of things that you'll probably never memorize, simply because you don't use them often enough, and also because modern IDE's can help you so much that you don't really need to remember everything if you utilize all their features (like code snippets, shortcuts, intellisense).

I've been coding for 15 years, and doing C# for the last three, and I still use the MSDN reference material every day. However, as far as the basic building blocks of the language are concerned, I had them memorized in the first month or two.

Also, the more often you code, the better you'll commit it to memory.

Charles
Basic building blocks like operators, syntax and types?
robault
@robault: Yes, and also the most frequently used elements of the libraries that come with the language (e.g. collections in C#).
Charles
+6  A: 

Don't sweat it too much. As others have mentioned it eventually gets easier to write code without looking things up so much as you work with a particular language over time.

HOWEVER There are a few reasons that even veteran programmers find themselves constantly using reference material:

(1) Unlike days of yore, most projects now require you to use a number of languages to get the job done. For example single web site-project a web-site may require C#, XML, JavaScript, SQL, HTML, XHTML, RegEx and CSS all in the same project. Switching between some of these languages can really throw you for a loop sometimes because many of them are just similar enough to be familiar, but just different enough to make you forget the subtle differences in syntax.

(2) Just when you start getting comfortable that you know a language inside and out, the vendor will release a new update that changes everything you knew about it. For example ASP->ASP.NET.

I still look up simple things fairly frequently and I've been at this almost 20 years. The important thing is that you understand the underlying concepts and principles.

JohnFx
Yeah, recently I was working on VBA and kept putting semicolons at the end of everything. So used to C#...
robault
VB/C# transitions are the worst. I go back and forth all day and I am always getting the variable declarations wrong (Dim X as string vs string x)
JohnFx
After about 30 years of programming I think remembering we've seen something on a subject and then finding it quickly and implementing it is a real strength. I can't remember everything, though I have a photographic memory, but I can remember reading it and what the page looked like and a quick search or two will bring it up, and I'm off coding again.
Greg
Good point. One of the major differences I've seen between beginner programmers and experts is that when the experts need to look something up they know the right term to type into Google. Photographic memory helps too. Unfortunately I only have fax memory, it's all there but it is a little fuzzy.
JohnFx
@JohnFX, loved the fax memory. That was new :)
Thorbjørn Ravn Andersen
Oh definitely, especially if you're writing javascript in php (or web scripting lang of your choice) because you don't know what values you need for the javascript *or* the php (owsloyc) until runtime. Talk about confusion!
Elizabeth Buckwalter
It's quite maddening to be writing in Python and Lua at the same time and end up writing -- comments in Python and # comments in Lua. I'm embarrassed for the software industry as a whole that we havn't decided on a reasonably universal syntax for *comments*. Lua's a great language, but its `--[[ block comment ]]` syntax is absurd (and also a pain to type).
Glenn Maynard
+2  A: 

Don't be downhearted by having to consult documentation all the time man, that's what it's there for. Over time you get used to syntax and things like that but don't sweat it if you can't remember library methods or ways to connect to a DB.

Over time (with experience) you might remember these off the top of your head but in reality there's nothing wrong with taking a quick consultation of the documentation to refresh the memory.

Also remember that technology is ever changing so it's good to keep the mind fresh with new ways of thinking/ways to do things.

djhworld
+1  A: 

For me, it depends heavily on what I'm writing. For example, I doubt that most people ever quite memorize all the parameters to some Windows functions. I may know that I need to call CreateFile on the next line, but don't know all the parameters in order until they're typed in (with help from Intellisense, and sometimes MSDN).

With something that's doing simple computation, I'm a lot more likely to be limited by my typing speed (but I'm a fairly poor typist, so thinking faster than I can type doesn't take much).

That means it's really a question of how much of the time you need to refer to something to type the next line of code -- at first, it's a pretty small percentage, and over time it grows. I doubt it ever gets to 100% for anybody though. I, for one, don't think I'd want it to -- that would indicate I wasn't working on new and different things...

Jerry Coffin
Yep, if you're not looking it up, you're probably not growing.
robault
+2  A: 

Question is not 100% clear. One of the best programmers I know doesn't remember anything and needs to look up printf formatting strings almost daily. On the other hand if you are having hard time figuring out how to write that for (int i = 0; i < len; i++) loop after doing this for 6 months -- that doesn't sound right.

MK
+1  A: 

If you use eclipse and java, you may find yourself already there.

Other combinations may be a little slower to a lot slower.

Java has the advantage that it's pretty easy for the environment to build an entire parse tree while you are typing. At any place in your code, typing ctrl-space can give you an entire list of valid options.

Also syntax errors are always underlined.

If you want to go hard core though, I started in C before the day of decent editors and it took me about a year before I typed in more than a few lines and didn't get a compile error.

Bill K
Eclipse will do the job for other things than just Java. I use it for C and Python (PyDev package) in exactly the same way and it works fine for me. The PyDev package could use some debugging though...
inspectorG4dget
It's impossible to resolve either C or Python 100% at runtime, but they kind of work. Python can't resolve everything because it's dynamic and dynamic languages cannot be resolved statically (Although I understand I may be wrong about this with regard to Scala). C because is essentially pointless since everything is untyped. (In java, when a method takes a Frame, it can tell you exactly which frame objects are available to you at that point in time. In C it would just give you every pointer which would be--umm--pointless, or only pointers to struct frame which might not be complete)
Bill K
+14  A: 

I can tell you that after 25 years there are lines of code that I don't know how they're exactly going to look like.

Want an example? I'm programming in Java since last century and I can honestly still make a mistake if I were to type hashcode() or hashCode().

Why? Because actually typing such a method name yourself is so last century. Your intention is to override Object's hashCode() method, so you use programming by intention.

You hit Ctrl-O then h and you get a list of the methods starting with an 'h' that you can override. Then you hit enter. As a bonus, the "@Override" gets inserted for you too.

4 keys. 4, to get this:

@Override
    public int hashCode() {

    }

And honestly, whether hashCode takes an uppercase 'c' or not... I couldn't care less. This is not what an hashcode is about and my intention is not to know all the inconsistencies languages and API designers came up with. My intention is to override the method that gives back an object's hashcode and my (modern) IDE allows me to get that skeleton in four keypresses, including hitting enter.

Another example: there are people who do really type this countless times a day:

for (int i = 0; i < ; i++) {

}

or the more tricky:

for (int i = ; i >= 0; i--) {

}

Note in that latter case I can still mess up and type "i++" instead of "i--" (a 'thinko' as its called).

But I don't care at all, because I type "fi<tab>" (three keys) and I get the first one or "fir<tab>" (four keys, "for i (in) reverse") and I get the second one. You ain't beating that (especially seen that I'm a touch typist so I type these three or four keys fast). In addition to speed, as an added bonus the autocompletion won't mess you "i--".

In many case I don't know exactly the line I'll get: sure, I know it "more or less" and that's exactly the way it should be.

Webinator
Totally agree. Let the IDE do the majority of the work. Spend time on learning general concepts (OOP, recursion etc) and specific technologies (libraries, frameworks, systems, tools etc) instead.
Rickard von Essen
+1  A: 

I don't know about memorization. Repetition is mother of all learning and that applies to all aspects of life. Look at the experienced accountant vs. the novice when filing taxes, who looks up stuff more. But what I did discover recently is that I navigate documentations much quicker and have a sense for going directly to where my question is answered. I got 6h sense - I can see the code! Seriously, it all comes with experience. Still, when learning something completely new, there's no shame in looking up how to do certain things. That's what separates humans right, learning from others. The more you work on something, the better you become.

Daniil
Good point about the 6th sense; I have that too. "Knowing" what the code does, without thinking about it consciously; but also the other way; thinking about a concept, and "knowing" the code.
Pindatjuh
+1  A: 

I'm programming Java now for about 5 years, and I never have had any trouble remembering syntax. I can <brag>write almost all java.util.*, java.io.*, java.lang.* and javax.swing.* stuff out of my memory</brag>, but does it help me? Not very much. It doesn't make me a better programmer than someone who can't!

I'm using Netbeans, which greatly helps working with libraries. Also, the documentation, just in the place where you need it. Sometimes, it's quite unnecessary, but sometimes you'd wish the "auto complete" screen would popup faster!

The best thing as a student is to concentrate on what you are doing, not how fast you are doing it. Looking up things isn't bad; as it'll help your so-called "unconsciousness mind" process what you are really trying to accomplish. Having such breaks, e.g. by looking up a certain documentation or syntax reference, may even let you be better at programming (no proof for this, though).

Question is quite subjective.

Pindatjuh
+1  A: 

There is absolutely nothing wrong with having to lookup the documentation every time you want to write some code. I got lucky in that once I use a certain function, I don't forget it very easily. However, most of the time, especially when I'm coding in a language that I haven't used in a while,

  1. I start out by writing a flowchart of the algorithm that I want to code - just the pure logic. The most important reason for doing this is so that I don't lose my train of thought and forget the algorithm that solves my problem in the midst of technical problems like syntax and < what library functions exist? >
  2. Then I look at the documentation and check to see if there are simple function calls that will help me accomplish each task in my algorithm
  3. If such functions do not exist, then I either modify my algorithm to accommodate for what functions the language does provide or write helper functions do fill in the gaps.
  4. I only start coding NOW, which is not too difficult to do anymore, because I already have all the relevant functions written down. So now it's just a question of translating pure logic into syntactically accurate code.

Proper syntax usually does not elude me, but if that does happen (VERY rare), Google provides very nice code snippets if you ask nicely.

Hope this helps

May the Force be with you

inspectorG4dget
A: 

Why should you be able to remember all of this stuff? Personally I embrace the fact that I can't remember all of this stuff and simply try and remember where to find the information that I need. I find that much more useful. This takes the form of blogging, taking notes, keeping large amounts of 'sample' code and reusable libraries and writing about code that I find useful and interesting; oh and lots of books, some of which I hardly ever 'need' and some of which I hardly ever really read but they've been skimmed and I know where they live.

Technologies come and go and there's just no way I could have kept all of the things that I may one day find useful in my head; so I page them out and just keep the index in memory... For example; 9 years ago I was doing some stuff with Java and Corba and whatever. There's no way that I could drop back into that now without the notes that I wrote up for my website back when I was doing it: http://www.lenholgate.com/archives/000469.html. Likewise I have code that I use on a daily basis that has been kicking around since 1997 or earlier. I don't remember how to type it in, I have it in a file with tests (if I'm lucky) and docs (if I'm even luckier).

Whilst I realise that most of what I'm talking about is 'big stuff' I also often have to go and look at some of my old code to simply work out how to structure a typedef...

Of course the day to day stuff will come with time and practice; but you need to work out that you have to page some of it out in a form that you can reload later very quickly. Embrace the fact that your memory is never going to be able to hold it all and outsource it :)

Len Holgate
You should remember this stuff because **every time you pause to look something up, it interrupts your _thinking about the problem you are trying to solve_**. You want to avoid interruptions and spend as much time as possible thinking about problems. This means you want to know the language and API stuff you use every day, for much the same reason that a really good programmers puts in the time and effort to learn how to type fast.
Norman Ramsey
Of course you need to know the stuff you use every day but you ALSO need to know the stuff you used 10 years ago and the ONLY way to do that when technology changes as often as it does in our industry is to accept that you can't know everything and embrace the fact that you MUST make notes, write stuff up, keep stuff as working examples and whatever. Also, IMHO typing fast is overrated; programmers need to know how to think deeply about the problems they're solving. Typing fast just means you rush in and make mistakes quicker - and yes, I can type plenty fast enough... ;)
Len Holgate
+2  A: 

the idea that one could every bit of code from even a single language and then type plainly from memory is pretty far out. the amount of pre-defined functions for, say PHP or Java alone is immense.

but that being said, its important to learn the programming structures, and know them the best you can. structures like foreach, if then else, switch, etc. are really the things that need to be integrated thoroughly. also, conceptual things like Object Orientation (not just "using" objects like mysqli, but understanding things like controlling code, client code, bottom-up and top-down architecture) are the real things that make good programmers great. for myself, i know that i have not the capacity to learn every defined function thats provided by language writers so i instead learn whether or not it can be done(and of course still try on occasion to do things that cant be done, lol). if you know that, then its a matter of google and books to find the "specific" mechanisms on how.

cheers my friend.

mechhfly
A: 

Sociologist Malcolm Gladwell believes that ten thousand hours is a good benchmark for the amount of practice required to become world class at many fields of endeavour. I think that sort of number applies to programming as well. This isn't quite what you asked, though; being able to code competently certainly requires familiarity with your environment (language constructs, system libraries, third party libraries and perhaps something of the concepts underpinning them), but there are many soft skills involved which are harder to describe and can only really be acquired through practice.

As others have said, being good at programming is not about typing code from memory; it's about recognising patterns, understanding systems, solving problems. It's about choosing the right tools for the job (languages, libraries, algorithms, whatever) and being able to make proper use of them. In all the jobs I've had, it's about adaptibility and flexibility; you might have to learn a new language or pick up somebody else's poorly documented code tomorrow, and a good programmer will be able to take this in their stride.

crazyscot
+1  A: 

With the great many IDE's available and the "newbie" tutorials on getting started, it won't take you long before you're off writing your own apps.

That said, unless you have a "thirst" for how stuff works kinda attitude all the time towards everything, you won't go far. In this field, you really have to have a passion for what you do to be great.

Kevin Friedheim
A: 

I've been coding professionally for nearly 10 years now; there's all sorts of code I use semi-regularly which I look up the options for at least some of the time. There are too many commands with too many options in too many languages for me to remember each and every last one in detail and Google is quite good enough at getting the information I want.

That said - there are some bits of routine code which I use all the time but can count on one hand the number of times I've written - the exact syntax for populating a dataset in .Net for example. One of the skills I've most come to value over this time and which saves me the most time is spotting when some code can be quickly and easily moved into utility libraries. If it's fiddly but routine, consider this approach to save yourself hassle and improve your overall code quality.

eftpotrm
+1  A: 

... It bothers me that I am continually having to look things up... How long did it take you to get to the level where you are now?

For me, and for most of the students I teach, the answer depends on two variables:

  • How many lines of code have I written?
  • Do I use the language or library every day?

(Reading other people's code is very helpful for learning a language and learning how to think in a language, but for me at least, it hasn't helped me become a fluent writer of programs in a language. Only writing code does that.) So my first comment is that time should be measured in lines of code written, not hours or years. (Ray Bradbury once advised aspiring writers of fiction to write a thousand words a day six days a week, and after they've written a million words they might start to know something about their craft. This is good advice for programmers too.)

As for my own experience, across a half dozen languages that I currently know well or once knew well, it's been pretty consistent for me that

  • After writing 100 lines I am continually looking things up in the manual and don't really know what I am doing.
  • After writing 1,000 lines I use the manual occasionally and am starting to learn how to think in the language.
  • After writing 10,000 lines I am about as good as I'm going to get without making special efforts.
  • After writing 25,000 lines I probably will not need the manual again.

It's also true that

  • To learn to write 100 lines I had to read 100 to 1,000 lines that someone else wrote.
  • For the first 1,000 lines I write it is good for me to read 2,000 lines someone else wrote. For the next 1,000 lines it is good for me to read 1,000 lines someone else wrote.
  • After I've written 5,000 lines I learn the most by reading code written by world experts or by people who designed the language and understand what is there. I no longer have much to learn by reading just any program.

On the other hand, my experience about when I stop having to refer continually to the documentation is much less consistent. I find it especially hard when two languages are very similar; I will never stop needing the ksh manual to tell me what is different from sh or bash, and I will never stop needing the Haskell manual to tell me what is different from Standard ML (though the need grows less with each additional 1,000 lines of Haskell that I write). I also find it interesting that while I have written over 35,000 lines of Lua code, and I will never need the manual again for a language question, I have to look up libraries and API functions almost every time I write something longer than 500 lines. (I've written a lot of short Lua programs and a couple of long ones, and I don't use the language every day, although I definitely use it at least several days each month.)

As for the unspoken question, when are you personally going to get better?, take some advice from Watts Humphrey: measure your own performance and track it over time. I think if each day you count the number of times you had to stop and look things up, and graph that against number of lines of code written or edited (which you can get from source-code control), you will be pleasantly surprised by objective evidence of improvement. And I think once you have such evidence, you will be able to focus more on continuing to improve, and not so much on where you are now or where you hope to be in a year.

Norman Ramsey
You may have learned the language syntax, but I do not think you can learn the whole JRE by writing 5000 lines of code.
Thorbjørn Ravn Andersen
**Nobody** can learn the whole JRE, no matter how much code they write. Just like the bloody Haskell library.
Norman Ramsey
+1  A: 

It's true that after some years of programming you'll be able to remember a lot of thing without having to check the "manual". For me this is not an important milestone in your programming life though, the really important moment is when you reach the point where you don't know how to do something... but you're sure that can be done and you know where and how to research about it :-)

You made a very important step participating on this site. Exchanging ideas and helping each other it's a excellent way of learning.

Claudio Redi
A: 

In the context of this question ; java, c++, javascript the languages are still evolving. I can't say about other languages.

  • The language standard/specification changes over time
  • Libraries are added to supplement the language constructs e.g Boost, Google Collections, Apache Commons, jQuery
  • Applications will rarely be bound to a single aspect of a language
  • Across organizations/projects, coding standards change
    • A project I worked upon recommended against using primitives
  • When unfamiliar with the constructs used, I put in pseudo-code flagged with //TODO first .. then go in and find the actual API to use.

IMO, the answer to your question is - there is no definite answer.

Everyone
A: 

As a Java programmer the sheer size of the runtime library makes it impossible to remember everything. Swing is big, there is an XSLT engine (which contains TWO languages), the Concurrent support evolves and grows.

The direct access to the Javadoc API from within Eclipse combined with code completion makes it possible to find the information you cannot remember but you know is there, quickly and efficiently.

I have found the javaalmanac.com (which has been reworked into the more convoluted http://www.exampledepot.com/egs/index.html) invaluable in presenting short, concise and above all correct programs doing just one small thing. Strongly recommended.

Thorbjørn Ravn Andersen
+1  A: 

Not an answer per se, but I just wanted to say that as a novice myself, this q&a is one of the most useful things I've read on SO. It seems that yes, experts can probably code the basic stuff from memory, but even they revert to book for complex problems, and for beginners, that's what the book is for.

I feel like I'm just beginning

Toby
A: 

Most weeks I program in Java, C#, Python, PHP, JavaScript, SQL, Smarty, Django Templating and occasionally C++ and Objective C. I'm a student so this is partially school work and partially my part-time job. Instead of learning syntax I've learned what concepts to look for.

Seeing patterns and concepts is key, once you know the concepts and what to look for the syntax is secondary.

I find that even when I am just being exposed to a language I can accomplish a lot just by looking for 'what ought to be there'

Michael