0
$\begingroup$

Can someone explain the difference between first-order programs and higher-order programs in the context of programming languages?

My understanding so far is that Functional Languages (most) use higher order programs. Plus, higher functions either a) take other functions as arguments, or b) return functions as results.

Any correction, or further elaboration would on the difference between the two would be very appreciated.

$\endgroup$
2
$\begingroup$

Your assessment is correct.

  • A higher-order program takes programs as input or produces a program as output.
  • A first-order program takes values of base types as inputs and produces a value of base type as output.

In functional programming, functions are identified with programs, so we talk more about higher-order functions than higher-order programs.

This use of the word "higher-order" is common. For example, higher-order logics allow predicates to the arguments of other predicates.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ It would be nice if you can add a few concrete examples. $\endgroup$ – John L. Nov 27 '18 at 2:31
  • $\begingroup$ @Apass.Jack a map would be a higher-order, and a loop for instance would be a first-order. I think this is right, but I'm not 100% certain. $\endgroup$ – wa7d Nov 27 '18 at 5:26
  • $\begingroup$ @wa7d, I was asking Jacob to improve his answer. Without concrete examples, it might not be easy for future readers to understand and apply. For example, is map/dictionary/association function or just data? Also, it would be nice if this answer can mention meta-programming as well. $\endgroup$ – John L. Nov 27 '18 at 5:46
  • $\begingroup$ @Apass.Jack As the person who asked the question, I am satisfied with the answer and I believe it sufficiently answers what was asked. Therefore, I have accepted it. Feel free to add another answer if you'd like. $\endgroup$ – wa7d Nov 27 '18 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.