When I bought my first Canon DSLR several years ago the kit EF-S 18-55mm f/3.5-5.6 II that came with my camera was horrible.¹ The succeeding IS versions that replaced it were much better, but still leave a lot to be desired.
I had already bought an EF-S 55-250mm f/4-5.6 IS lens as well (very good value for the price in my opinion). Maybe I just got a bad copy of the 18-55. Maybe I got lucky with a very good copy of the 55-250. In terms of optics the EF 55-250mm f/4-5.6 IS is pretty much the equal of the more expensive EF 70-300mm f/4-5.6, it just is limited to APS-C cameras and is one half the price of the 70-300. For a more in depth look at the 55-250, see my answer at this question. Here is a comparison of the two lenses.
At that point in time my budget was extremely limited and the solution for me was the Tamron SP AF 17-50mm F/2.8 XR Di-II. Tamron had an instant rebate going at the time and I picked mine up for about 15% less than the current market price. In terms of optics it is every bit as good as a couple of subsequently purchased lower tier "L" lenses. I got a lot of great images with that lens for several years. If it weren't more or less on permanent loan to my brother-in-law I would still use it occasionally when the need to shoot in that focal length range on a crop body arises. The biggest downside was that it got me addicted to constant aperture f/2.8 zoom lenses! For a more detailed look at the SP AF 17-50mm f/2.8 Di II see my answer at this question.
You can compare the EF 17-40mm f/4L and the Tamron SP AF 17-50mm f/2.8 Di II here. At most focal lengths the Tamron is just as sharp at f/2.8 as the 17-40 "L" is at f/4. My own experience with both these lenses has been very similar. When stopped down to f/4, the Tamron 17-50 holds its own with the 24-105 over their common focal lengths. Again, this mirrors my own experience with both these lenses on crop bodies.
DxO Mark comparison.

By f/5.6 there's very little difference between all three:

¹ My copy of the EF 18-55mm f/3.5-5.6 had a soft spot in the left center of the frame in every picture taken with it. At f/5-f/8 things both closer and further from the camera (even when closer to the edges and/or corners) were in proper focus and that one spot would still be soft. This was the non-IS older version of this lens and it was pretty well known to be a substandard lens, even for a kit lens. I apparently got one of the worst copies of it ever manufactured, and wanted to return it to Canon for exchange but they said since it was bought in a kit I would have to return the camera also.