read the datasheet of both you will find many differences....
such as flash memory, Ram, Timers, max Oscillator allowed...etc
But both are pin compatible..
imaging: pic18f452 is a Hi-fi system and pic16f877 is an ordinary radio cassete. both can play radio but hifi sounds better, has equalizer, surround system and others. if you just want to listen to the news both can offer you the news station. but, if you want to tune to surround system, only hifi can offer you.
conclusion:
PIC18F series has more built in module i.e. PWM, CAN, USB, and others which is not available on PIC16F series. Besides PIC18F series offer larger flash and RAM memory.
if price is no issue op for PIC18F. afterall, both pic16f877 and pic18f452 are pin compatible. meaning, you can simply swap the IC on the same circuit.
note:
1) pic18f452 is obselete and replaced with pic18f4520.
2) no changes needed in c command except the fuses settings, and configuration. go and try first. never try never know.