They are grubs but without something in scale to show their size it is impossible to say which kind. A common grub found in compost piles is the larvae of the Rhinoceros beetle. They are very large, about 2 inches long and 3/4inch thick. I think the pictures show little brown dots on the larvae's side and if so it is the larvae of the Rhinoceros beetle. They are harmless and they are actually beneficial in the compost pile. They also make excellent fish bait.
They do appear to be the grub (larvae) of some type of Scarab Beetle.(Scarabidae, Coleoptera). The Rhinoceros Beetles (Subfamily Dynastinae) are one group of Scarabs, but there are many, many, species in the Family Scarabidae.