While the i5-8400 is great, I don't see any point pairing it with a Z370 board, because those are the only motherboards that are out right now and the cheapest one will set you back a bit more. Strange how the other chipset boards are delayed.
A B350 board will do overclocking and will be kinda cheap depending on where you get it. The on-board sound is probably going to be strapped with older Realtek codec, which in my experience isn't good in 2017, it's OK but don't expect the on-board sound to be good unless you opt for motherboards that have ALC1220 codec which are probably nearing the $100 mark.
The AM4 socket will live on at least until 2020. Intel is probably going to switch pin count or their placement the next time they release the other generation. It's not so bad if you have an overclockable CPU, but good luck trying to get even turbo frequencies to be good on Coffee Lake. And then again the K parts are already pushed pretty far in terms of clocks already, without delidding them, you can't overclock more than 100-300MHz on the stock TIM they used between the die and the heatspreader.
Current Ryzen gen is limited to 3.8-4.1GHz on clocks. In my experience I keep my R5 1600 at 3.8GHz because I can set a really low voltage and keep a good overclock while having thermals in check, I do run a closed loop cooler though. 3200MHz memory is probably pretty expensive, you can sometimes find lower clocked memory modules that can overclock, but the memory controller on the CPU is picky sometimes and might not run the desired clock speed unless it is guaranteed to run it.
For Intel you have to have both the CPU and motherboard that can support overclocking in order to get anything higher than 2666MHz on the memory. If you are planning to upgrade to the i7 later, you might have to invest in a Z370 board regardless.
For gaming you can get extra 5-10FPS on games on lower resolutions with Kaby/Coffee Lake CPU, it's worth it to hit near 144FPS if you have the monitor to refresh that fast. If you don't plan on high-FPS, I think the R5 1600 extra SMT cores trump the i5-8400 from a longevity standpoint.
I've been on the i5-2400 before, but I could overclock that to some degree. It lasted quite a while and going to R5 1600 was a big jump in performance, but some games still prefer faster clock speeds over core count. A lot of older titles still love Intel's better single-thread, but now that Ryzen is pretty close in terms of that (it's pretty equal to Haswell chips and people are still happy with their 4790K's). It's not much of a big deal, especially if you're gaming over 1080p.
So be aware of those factors. In the end, you probably want a good price-performance ratio and right now Ryzen 5 1600 delivers, until Intel decides to release lower-end motherboards, Ryzen is the better choice.
It's a great shame Intel locked down most SKU overclocking. I always like to entertain the idea of the i5-8400 being OC'd, it would be a complete beast. But it will never happen, because that would cut into sales of their other CPU's and they don't want that.