views:

383

answers:

17

So... You've sat down and got a blank sheet in front of you, and a browser open in the background with access to the manual. What in your opinion makes you scratch your head and think Now how...

See also:

  1. Easiest language to start with
  2. Best ways to teach a beginner to program?
+3  A: 

Concatenate a string...

ian_scho
Amen Brother!Usually with a bit of sample code I can get going, but string concatenation is always a RTFM moment.
chris
I remember the first time I tried to concatenate a string in Perl...My only prior experience was with Java and beginner-level C -- "Why won't the plus sign work? *tears out hair*"
Athena
A: 
  1. write binary search

  2. write quick-sort

  3. how to do disk i/o

Nils Pipenbrinck
+4  A: 

Connect to a database. Pull some data out of it and display it.

roosteronacid
+2  A: 

Best practices tend to trip me up. Why is something implemented that way over the alternatives. Is it just convention/programmer quirks, or is there some special language-specific reason for it?

I find that stuff can take a long time to pick up.

Dan
+3  A: 

hello, world.

Seriously.

It varies from trivial (in which case I'll move on to the next thing having not "tripped up"), up to 15 or so text files (Symbian app doing everything the way you're supposed to, and it's extremely easy to get it wrong). It might even be impossible, in which case settle for flashing an LED.

Don't assume anything about a language / environment you know literally nothing about. Anything might trip me up, so I try to watch where I'm walking...

Steve Jessop
Impossible? What's stopping you from flashing the LED in Morse Code?
dan04
@dan04: I didn't realise until now there's a comma in Morse code, is what was stopping me ;-)
Steve Jessop
+2  A: 

It depends on the language. When I learn a new language, I always feel the need to sell it to myself. So the first thing I do is write something that the language is supposed to be good at. I'm looking for that WOW moment that gets me hooked and drives me forward. There is nothing worse than doing something you think is useless.

brian
A: 

The variable syntax messes me up for a while if it's different from what I'm used to.

VirtuosiMedia
A: 

Literal formats, especially in languages like F# which have many varieties for different sizes of int, signed/unsigned, floating point, etc.

Chris Ballard
A: 

Learning a new platform is worse than learning a new language. Yet another language which gives you something based on the POSIX C API is pretty trivial to pick up; learning say Win32 if you already know C++ is definitely not.

Mark Baker
+2  A: 
  • write Hello World app (skills: basic app skeleton; displaying text)
  • write a number guessing game where the computer chooses a random number between 1 and 100, and you have to guess it, and the computer says "lower" or "higher" (skills: user input; using standard library functions (for random numbers); conditionals and loops; displaying numbers as formatted text)
  • write a graphical application which displays a circle of (like) eight points and draws lines from each point to each other point (skills: graphical output; loops inside loops; mathematical functions (sin/cos); arrays (for storing the positions of the points) )

However, I usually learn a programming language with a specific goal in mind, so after the number guessing game I usually start writing the actual program I wanted to write in the first place.

oliver
+1  A: 

Terminology. For example, an "object" in one language might have a slightly different semantics than an object in another.

And this might just be part of a larger issue -- when I learn a new language, I'm starting from the assumptions of every language I've dealt with in the past. Carrying those assumptions into the new language has tripped me up several times, the most notable example being the transition from Java to C# with respect to virtual methods (i.e., all are virtual in Java, only those you specify as such are virtual in C#).

Lewis Baumstark
A: 

It's always something to do with syntax.

I'll mix up whitespace if that matters for the language, add in curly brackets or semi-colons where they aren't needed, make variables global when I mean for them to be local or vice-versa, mix up lists, sets, arrays, prototypes, and tables, use the wrong if-then formatting, use the wrong operator to concatenate strings...

The same thing also tends to happen if I stop using a language for a while and then start using it again.

Illandril
+2  A: 

Now how do I write assert (1+2*3 == 7) in this language? :)

An assert statement is the most primitive form of debugging construct that is present in every language that I have ever tried. Once I know how to assert something, I can start recording the things that I am finding out about that language. I start off with 1+2*3 == 7 because it covers equality (is it a single = or double?) and arithmetic precedence (* is evaluated first).

Next tests would be:

assert("helloworld" == "hello"+"world") // can + concat strings?
assert("1two" == 1 + "two") // convert numbers to string or just die

and so on...

jop
A: 

If I'm working on GUIs, it's always "How do I get to the toolbox/controls/widgets?"

catfood
A: 

New funky characters... Think Perl or something like that which adds @, -> <-. <=>. $, #

Brian G
A: 

Depends on the language. The place where I usually run into problems is in dealing with containers. Most languages have a set of container classes that do about the same thing, but are just different enough to throw you off. For example:

  1. How do I make an array in Python?
  2. How do I make a dictionary in C++?
  3. How do I make a list in VBScript?

These questions (for a variety of reasons) are what trip me up. Not because the answers are hard to find, but because they're the wrong questions.

And for the record:

  1. You should use a list in most cases, which isn't quite the same as an array as you would think of it in most other programming languages (although there is an array module for interfacing with C code).
  2. There's a map class, but it's probably not what you would expect it to be coming from a scripting language background. A hash table is proposed, but won't be finalized until C++0x (I believe).
  3. You can't make a list. You have to make a dynamic array and resize it before you add elements on.
Jason Baker
A: 

The first step (and often the most difficult) is setting up the environment. Depending on this language and your experience level this can be a real pain in the butt.

'Wait, how do I install Apache?!' 'Crap, gcc doesn't have a pretty IDE with a button that looks like a green play button - how do I compile/link/execute my code?!?!'

My first step is finding a very tiny 'Hello World' program in that particular language and getting it to build/run on my machine.

If that turns out to be an ugly/painful experience, I go out of my way to find one of the most popular IDEs available for that language. I wouldn't write C# code in notepad and use the command-line compiler; I don't see why anyone would do that with another language. I have painful memories of making websites (mostly just HTML and Javascript) in notepad. Why? Because 'real programmers (ha!) use notepad'.

What a joke.

None of that has anything to do with learning the language exactly, but it's pretty hard to read a book in the dark.

Rob P.