By is used to indicate proximity, the person that performs an action in a passive sentence, an action with a particular purpose, a means or method, a deadline, the person or thing that performs an action, how something is done, measurements or amounts, increasing or changing amounts over time, and describing someone's character or job. By can also be used to express being near or at the side of something. With is used to indicate using something, and beside means either next to or compared to, with next to being more common.