Traditionally pine nuts are used for pesto, but walnuts offer a similar texture, mellow flavor, and are generally a fraction of the price of pine nuts. It's not necessarily that one is better than the other for pesto, but you can experiment with both and enjoy the different flavors or see which one you prefer.