When printed, they're different enough that as you get more used to Arabic, you'll be able to tell them apart easily. In sloppy handwriting, context will help you determine which it's supposed to be: for one, you can try reading it both ways and see which one ends up making sense. Once you read enough in the hand of a particular individual, you'll also begin to recognize the idiosyncratic ways they might write these letters. Otherwise, there are no special secrets, anymore than I could tell you how to tell the difference between a lowercase L and an uppercase I in handwritten English.
Please correct my mistakes in any language.