Preheat oven to 350°F (175°C) and set a rack in the middle position. Grease a 9x13 inch (23x33 cm) baking pan well, then line with a parchment strip overhanging the two long sides.
Peel, core, and dice the apples into roughly ½ inch (1.25 cm) pieces, about the size of a large grape. You want 3½ to 4 cups (430 to 490 g) of diced apple.
In a medium bowl, whisk together the flour, baking soda, cinnamon, nutmeg, and salt for 20 to 30 seconds so everything is evenly distributed.
In a large bowl, beat the eggs, granulated sugar, and brown sugar until well blended and slightly lightened, about 1 minute. Stir in the oil and vanilla until smooth and glossy.
Add the dry ingredients to the wet and stir just until no dry streaks remain. The mixture will be very thick and stiff, closer to cookie dough than pourable batter — this is exactly right.
Add all the diced apples and the walnuts, if using, and fold gently until evenly coated and distributed. The batter will loosen slightly as the apples release moisture.
Scrape the batter into the prepared pan and spread into an even layer, pushing into the corners. If using the topping, stir the sugar and cinnamon together and sprinkle evenly over the surface.
Bake at 350°F (175°C) for 45 to 50 minutes, until golden brown and a toothpick in the center comes out with only moist crumbs. Tent with foil for the last 10 minutes if the edges brown too fast.
Set the pan on a cooling rack and let the cake rest for at least 20 minutes before slicing. Serve slightly warm or at room temperature, cut into 15 squares.