English 中文(简体)
Measuring code complexity of functional language and imperative language
原标题:

What is the best way of comparing code complexity of functional language and imperative language?

In my case I have to compare complexity of certain programs written in F# and C++. As for now as a code quality measure I am using lines of source code.

最佳回答

There is no "best" way. There is not even a remotely acceptable way.

  • SLoC (and related measurements, like character count) are utterly meaningless; refer to Wikipedia for a summary of the most common criticisms
  • if you want a more abstract thing to count, like "atomic elements" of the program, you got to decide what you consider such - and many will disagree, rightfully so, because this matter is mostly undecidable
  • Also, such comparisions are rarley fair because most of them use example problems that tend to be solved more naturally in one language or the other. Every tried implementing an Accumulator Factory in C++? Now remember that the problem was proposed by a Lisp advocate (Paul Graham)...
  • Moreover, many would argue that really clever solution which uses very few lines/characters/"atomic elements" isn t the best solution in any otherway - look at code golf

All things considered, the best solution might be taking many different real-world problems, solving them idiomatically in different languages, and just informally looking at the source and deciding which looks more elegant.

问题回答

暂无回答




相关问题
What are the differences between NP, NP-Complete and NP-Hard?

What are the differences between NP, NP-Complete and NP-Hard? I am aware of many resources all over the web. I d like to read your explanations, and the reason is they might be different from what s ...

upper bound, lower bound

What does it mean to prove an upper bound or lower bound to an algorithm?

Worst case time complexity

i have an algorithm that searches into a directory and search for all the text files in that directory and any sub-directory. Assuming i do not know how many sub-directories and sub-sub directories ...

Best-case Running-time to solve an NP-Complete problem?

What is the fastest algorithm that exists up with to solve a particular NP-Complete problem? For example, a naive implementation of travelling salesman is O(n!), but with dynamic programming it can be ...

Complexity in Prolog programs?

In Prolog, problems are solved using backtracking. It s a declarative paradigm rather than an imperative one (like in C, PHP or Python). In this kind of languages is it worth to think in terms of ...

Why is the complexity of A* exponential in memory?

Wikipedia says on A* complexity the following (link here): More problematic than its time complexity is A*’s memory usage. In the worst case, it must also remember an exponential number of ...

热门标签