Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Currently, I'm following a course on embedded software development. The lecturer has chosen J as an architecture language for model-driven software development. J itself is a very terse programming language and one of his main arguments for this language is its terseness. For instance, this is a Quicksoft implementation in J:

quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)

Another argument is that through such a language and the reduced number of characters, you introduce less bugs and the time to fix bugs is reduced.

Since I have a strong software engineering background and through various books like Clean Code, Pragmatic Programmer and others, I feel that these arguments aren't valid. I find that there is a strong movement towards descriptive names and code that reads like natural language (alright, this might only be related to applications with lots of business logic and less math).

The question therefore is, can you really argue that usage of a terse programming language will result in less errors and that time to fix a bug is reduced? Also, since the language is terse, the number of lines of code is reduced and you would get a better COCOMO rating. But can this be applied in the first place or does the COCOMO model use the number of lines of code as a way to estimate a project's overall size (project size should be the same whether you implement it in a terse language or in an imperative one, but again, maybe I didn't understand the COCOMO model correctly)?

Update

Thank you all for your answers. Admittedly, I should have stated more clearly that my intention was to get more information on the COCOMO model (again, sorry S.Lott). As such, I feel that Thomas Owens's extensive answer and comments are the best fit for this question. Thanks again! :-)

share|improve this question
    
There is no ubiquitous model for estimating software cost. COCOMO is based on a lot of metrics and you can play with it to get an improved rating. But I believe that the major hitch in generating cost for any model is the dynamism involved with changing requirements and the cascading effects of an error. More than terseness and SLOC, if your model is orthogonal with an easy syntax,useful comments, a standard convention, aided by decent documentation, its good. You should be able to read and understand your code after some time and somebody with the same ability should also be able to read it. –  Ubermensch Jan 4 '12 at 14:01
3  
that quicksort implementation looks like line noise to me, I don't see how that would be maintainable by a broad set of of the software development community. It almost makes the most obfuscated Perl look reasonable. Terseness isn't a virtue if it sacrifices maintainability. Maybe you are missing another more substantial reason for your instructor picking this obscure language. Like "the traditional use of J – programs are entered into a J interpreter session". Which might be a valid reason, in an interactive teaching environment. –  Jarrod Roberson Jan 4 '12 at 18:27
    
@Jarrod Roberson, the question wasn't meant to include all the rationale behind this decision. According to the solution of a test exam question: "J descriptions are compact and have a reduced risk for side effects". Also, I picked the quicksort example from Wikipedia and I believe that this isn't the way most J programs look (at least if you wan't to keep it maintainable). –  BenR Jan 4 '12 at 18:44
1  
if you interpret "J descriptions are compact and have a reduced risk for side effects". for "reduced number of characters, you introduce less bugs" you misunderstand what he means by side effects. –  Jarrod Roberson Jan 4 '12 at 19:12
    
"reduced number of characters, you introduce less bugs" was a different statement and is not based on "J descriptions are compact and have a reduced risk for side effects". –  BenR Jan 4 '12 at 19:52

3 Answers 3

up vote 4 down vote accepted

Is the COCOMO model a good argument when defending a programming language choice?

No. COCOMO says nothing about language choice at all. It is a cost estimation tool to determine how much it will cost to build a given software system given a series of inputs. The latest iteration is COCOMO II, and there are web based tools to use when applying this model. Some of the inputs that go into COCOMO II include the estimated size in SLOC or function points, the team cohesion, maturity of the process, desired reliability, complexity, the capability of people filling different roles on the team, platform constraints, and schedule. The output is the estimate for effort, schedule, and cost for the project.

Only a handful of the inputs are related to technology and programming language. The key adjustment factors that cover these areas are the capabilities of the programmer, experience of the programmer in the application domain, experience with the platform and language, and the ability to obtain and use supporting tools.

As far as defending a language, the best that you can do with COCOMO is produce multiple estimates for different technologies and languages that the team knows to varying degrees. Perhaps there's one technology that the entire team knows and has successfully used before, so platform and language experience would be high, but that language has very few supporting tools so that would be lower. You can compare that to a language that perhaps only one person knows extremely well and a few people know a little about, calling the experience nominal, yet factoring in the rich tool set. Given two (or more) sets of effort, schedule, and cost estimates, you can compare to see which might be more effective to use.

Also, since the language is terse, the number of lines of code is reduced and you would get a better COCOMO rating.

There is no such thing as a COCOMO rating. COCOMO is an estimation tool that you can use to try to determine how much effort (person-months), schedule (months), and cost a project will require to complete. When estimating, this data is compared against the size of the project team and the business schedule to determine if it's realistic and to provide the project manager with information needed to control the project schedule.

For example, COCOMO might produce a schedule estimate of 15 months and a cost estimate of $500,000. However, the business schedule might call for 12 months and $450,000. This schedule and isn't unreasonable, and the project manager can use this information when controlling the project and negotiating with the customer.

But can this be applied in the first place or does the COCOMO model use the number of lines of code as a way to estimate a project's overall size (project size should be the same whether you implement it in a terse language or in an imperative one, but again, maybe I didn't understand the COCOMO model correctly)?

Although source lines of code (SLOC) is a valid input to COCOMO, estimating size using source lines of code is not recommended because the number of SLOC varies depending on programming language (among a number of other problems). Function points are a preferred method of size estimation. There are conversion ratios that allow you to estimate a number of function points and apply the ratio to determine the size of the system in a given programming language.


Now, comes the other parts to your question.

Currently, I'm following a course on embedded software development. The lecturer has chosen J as an architecture language for model-driven software development. J itself is a very terse programming language and one of his main arguments for this language is its terseness. Another argument is that through such a language and the reduced number of characters, you introduce less bugs and the time to fix bugs is reduced. [...] I feel that these arguments aren't valid. I find that there is a strong movement towards descriptive names and code that reads like natural language (alright, this might only be related to applications with lots of business logic and less math).

That's nice. In my experiences, the lecturer has more experience in the topic than the typical student. When they choose a given language, framework, platform, or technology to use to teach their content, they have a good reason to.

Terseness is, in my opinion, a rather poor measure to discuss a language on. There are far better criteria to use when choosing a language to implement a project in - platform support, tool support, available resources, team knowledge. With never having seen J before, it seems rather difficult to read. However, it might be very good at solving the particular problems that the project is trying to solve, and the people on the team might have experience with it. It might also be easy to learn.

In your specific case, of a class, you need to focus on the point - learning concepts and techniques. Not only will you learn about J (and learning new tools is always good), but you'll learn techniques that can probably be applied to other languages as well.

The question therefore is, can you really argue that usage of a terse programming language will result in less errors and that time to fix a bug is reduced?

My intuition says no, but that's beside the point. You need to factor in knowledge of the language, supporting tools (compilers, IDEs, static analysis), and process methodology (pair programming, code reviews, style guidelines), and more to have an adequate discussion of how to reduce errors and time-to-fix.


If you're interested in more about COCOMO and what it's all about, I'd recommend reading Software Engineering Economics and Software Cost Estimation with COCOMO II, both by Barry Boehm. Software Engineering Economics is mostly general software project management, cost estimation, and effort estimation. The portion of the book that discusses COCOMO discuses the COCOMO 89 version, which Boehm has said should no longer be used due to inaccuracies that were corrected in the COCOMO II version, however the rest of the sections of the book are still relevant.

share|improve this answer

It may result in fewer faulty characters per program, but that is all you can predict. And the COCOMO metric doesn't account for the natural verbosity of different languages, therefore it is meaningless to use it as an argument for one language over another.

No, the question of whether a language promotes better, more error-free code or not can only be solved through rigorously controlled contrastive experiments. Unfortunately there are few really unbiased research studies, and it seems there is always a reason why a non-advocate will reject the findings of an advocate in favor of one particular language.

Perhaps the most convincing argument is real-world use. Granted, there is a lot of inertia, backward-compatibility constraints, willful ignorance etc. in the world of commercial software development, but you have to ask yourself: if Wonder Language X (be it J, or Lisp, or Haskell, or whatever) really consistently produced better programs faster - wouldn't at least some of the less backward managers eventually notice that and at least try to gain an edge over the competition by using it? And note that it has to bring actual benefits, not benefits that only work for academic toy problem sizes, or only if you have extremely smart people use it.

share|improve this answer
1  
If you use function points as an input to COCOMO, I believe there is an adjustment factor for different languages to account for time. If you use SLOC, you can only compare COCOMO output against projects in the same language. Unfortunately, I only have Software Engineering Economics, which covers COCOMO 89 and not COCOMO II (the preferred COCOMO implementation these days). –  Thomas Owens Jan 4 '12 at 10:44

First. Do you want to pass the course? If so, learn J rather than argue with the lecturer. Learning J has value.

Second. COCOMO backs up the lecturer, not you.

can you really argue that usage of a terse programming language will result in less errors and that time to fix a bug is reduced?

Yes. That's what COCOMO says. Lines of code ➜ effort ➜ duration (and staffing and cost).

since the language is terse, the number of lines of code is reduced and you would get a better COCOMO rating.

Correct.

But can this be applied in the first place

What?

or does the COCOMO model use the number of lines of code as a way to estimate a project's overall size (project size should be the same whether you implement it in a terse language or in an imperative one,

No.

maybe I didn't understand the COCOMO model correctly)?

You did. CoCoMo says lines of code == effort, and J will minimize lines of code.

Third. J has value even if you initially find it unclear.

A predecessor to J, APL, was invented specifically to mirror mathematical notions of reasoning, the way operators work across various data types and the way functions can be combined in a functional programming sense.

The point of APL (and J) is to allow you to create new, higher-order, application-specific operators so that your code looks (and feels) like ordinary mathematics. It reduces the "gap" between specification, design and implementation.

share|improve this answer
    
First of all, thank you for your answer. I should point out that I'm at the end of the course and that I already studied J. So this is not one of the "I just don't want to learn this so please give me arguments against it" questions. I'm really interested in the reasoning and the way the COCOMO model takes SLOC into account. As Thomas Owens also pointed out, there is a notable difference between various programming languages which should be recognized. –  BenR Jan 4 '12 at 11:45
1  
@BenR: "So this is not one of the "I just don't want to learn this so please give me arguments against it" questions.". That's false. Reread the question. It's entirely that question. If you don't want it to be that question, the edit it so that it's not that question. If you just want to know about COCOMO, then get rid of the entire "I disagree with J as a language" part of the question. –  S.Lott Jan 4 '12 at 11:47
    
Sorry S.Lott, but I never wrote this in my question. While I wouldn't have chosen J personally, this question was not meant to find alternatives or further reasons against it but instead I'm interested in the reasoning. Specifically, I'm asking for information on COCOMO and don't even mention J after the code snippet. –  BenR Jan 4 '12 at 11:59
1  
Sorry, @BenR, but you're not reading my comments. You clearly have an idea of what you hoped your question said. However, I'm trying to explain that your hoped-for message did not actually arrive. Your question has four paragraphs complaining about J. And only one paragraph with a question. Really. You may hope that it reads like "context" or "background". I'm trying to explain that it's sounds like complaining. Perhaps you should consider rewriting it a bit rather than insisting that people are misreading it. If your audience doesn't get your message, it might be your presentation. –  S.Lott Jan 4 '12 at 12:18
    
Size is one input into COCOMO, so SLOC == effort is wrong. Effort and cost are functions of size (SLOC or function points, preferrably function points), team cohesion, process maturity, required reliability, complexity, the capability and experiences of team members, and more. If all other things are equal, using tools and platforms that the developers are familiar with in order to reduce effort and cost. However, the whole concept of using COCOMO in an academic setting to argue language choice is pointless. The purpose of a class is not to reduce cost/effort, but to learn concepts/techniques. –  Thomas Owens Jan 4 '12 at 12:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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