Size Is The Enemy

@Steve:

Don’t dis SQL. It’s not QUEL or data sublanguage ALPHA; but if we end up with Xcrap instead, you’ll be singing out of the other side of your mouth. Have you looked at what Xcrap would have us do?

Not that data languages are the crux of this discussion, but they could be.

@Nik Radford
Yes, I know mono can run .Net 2.0 stuff, but it has proven useless for Gui, because even the simplest forms are arranged incorrectly with half of the stuff being placed outside the window (IOW not even remotely useable).
A way to avoid that problem is to use GTK#, but that exists only for Mono and .Net 1.1.

funny b/c I was just thinking about writing an essay on why aerospace manufacturers always seem to equate completeness of their avionics software with x millions of line of code completed. As if when they reach the magic preordained number they’re done! Or the metric of how any millions of lines of code have already been written is meaningful in any way. Moreover, how do they compute that number? Should kinda make one think the next time they get on an airplane, eh?

Vladekk:

a) Closures are simpler than Java anonymous classes, Java generics, or Java classloading.

b) Python code is more readable for non-programmers than Java.

c) C# LINQ isn’t a simple or dynamic language, it’s more extra legs nailed to the Java octopus. Simple dynamic languages suitable for learning: Smalltalk (more OO) and Scheme (more functional).

Go on, handle each line of a file as a Url, do it, show me the code, go on. Show me the damn code.

from urllib import urlopen

for line in urlopen(“http://www.codinghorror.com”):
do_whatever(line)

Hate to be harsh, but to those people who think that extra typing is a problem, that is ridiculous. If the extra typing makes it hard to read that is a problem, but more characters does not mean it is bad. For any non-trivial case, thinking, not typing, is the limiting factor in software development.

@Mark Hibberd
Your are mostly right, but there are extreme (and stupid) variants of type-safety like VHDL where in the average code about 10% are simply typecasts, sometimes 5 of them in one line.
This is an example of a language that is horribly bad due to badly designed type-safety.

nice summary jeff!!

my 2c:

java’s verbosity is not due to it being statically typed.

for example:

features that make C# less verbose than java:
generics, lambdas, closures, extension methods, anonymous types, linq. (others i can’t think of)

features that make F# less verbose than C#:
type inference, pattern matching, (many others i don’t understand yet)

F# is far ‘stricter’ in its typing than java, yet far more concise!

lesson: ‘verbose’ and ‘strict’ are orthogonal concepts.

lb

Don’t blame the language. Blame the humans.

As developers, we chronically overestimate our own intelligence and ability. We think we’ll remember next year, next week, tomorrow. The fact is, we don’t.

Good coding in any language means accommodating human limitations. Simple methods like:

  1. Design it before you code
  2. Keep it as simple as possible
  3. Document it clearly

matter more than the language.

My other rule of thumb is, “write for maintainability, not cleverness,” the opposite of programming language golf. You have no idea how much my agony levels have decreased since I got that principle.

Jeff,

Do you not mean size is complexity ?

Umm…well, I’ll wish you a happy holidays then Jeff!

One of my favourite parts of this blog is the fact that it points me to other great blogs too :slight_smile:

I’m not sure I agree with the less is more philosophy here. If I had to write a particularly complex algorithm, I’d definitely try to make it as simple as possible for maintainers to read. It links to what ThatGuyInTheBack was saying really.

Mind you, unless it’s entirely necessary, I’d take a performance hit and make code simpler to read, so maybe it’s me thats wrong.

Sure, size is the enemy, but I don’t think that the savings that dynamic languages give you cut to the crux of the problem. The crux of the problem is featuritis.

Requirements are design. Having too many is a problem. Killer products don’t try to be everything, they focus and nail the critical core that provides value.

@BuggyFunBunny

Thanks for the comment, but SQL does suck big time compared to the LIST command in NOMAD2 (I would say that SQL has perhaps 6% of the LIST command’s capabilities).

Unfortunately, if someone never worked on a mainframe at a large company back in the late 70s or 80s, they did not get the exposure, and therefore have no proper frame of reference with which to judge. Sadly, NOMAD2 never made the jump to client/server successfully.

Imagine the morons whose codes get posted on the Daily WTF working with a dynamically typed language. Depending on the path the code took, you might be given different objects. In one case, the object gets a member ‘parent’, in the other it’s called ‘PARENT’. No thanks.

Also, it took 500K LOC for a crappy 2D RPG? Here’s the stats for Quake3:

Files: 912
Lines: 498019
Lines Blank: 58540
Lines Code: 296398
Lines Comment: 110583
Lines Inactive: 30567

So… the 2D RPG should probably be a lot less.

Should kinda make one think the next time they get on an airplane, eh?

Why? Do many planes crash due to software issues? Seems like, supposing they say what you say they say, it might be a good idea after all.

“c) C# LINQ isn’t a simple or dynamic language, it’s more extra legs nailed to the Java octopus.”
–Vladekk

LINQ has allowed me to take 50 lines of code and one-line-it. C# with LINQ is powerful. Download the Visual C# Express and review the sample code.

I believe that there is a balance with everything. Having written some websites in classic ASP with VBScript where you CANT declare the type of your variable vs. ASP.NET with insert your favorite .net language here, I’d choose the latter, because I got into trouble SO many times in classic ASP. However, I like the tetris analogy that I feel Java, and now the .NET framework have sort of fallen into. When starting out with Java, I always felt like I was solving a puzzle to get what I wanted. Consider the following:
BufferedReader cin = new BufferedReader(
new InputStreamReader( System.in ) );
This is how to initialize an object to read information in from a console input. How is a new programmer supposed to make head or tails of this? “Well, simply create a BufferedReader…” Now, if I want to read input from a console, every application has to have this “just copy it to make it work” line of code, or create a utility class that contains all common functionality that should be there in the first place.
Now, alot of people blast on VB.NET, but the VB.NET team has realized the “less code is better” approach, and has worked toward that goal.
Consider:
dim s as String = My.Computer.FileSystem.ReadAllText(“filename.txt”)
I LOVE being able to read a text file in one line of code (even if I HATE the word My).
But File IO is a very common task, so why make us jump through hoops to do it?
Anyway, the good side of all of this debate is now I’m on a mission to learn a dynamic language (I downloaded ruby the other day) to see what the hullabaloo is about, and hopefully I’ll learn something good.

half a million lines of code is a lot? Since when?

True, some dynamic functionality would be nice, and would easily reduce 20 or 30 thousand lines of code in my project, but I would hardly call it essential if you have object inheritance and typecasting AND a good scripting engine to create the type customized classes you require.

I typically find that when I create a type customized structure like a list that each type instance also has unique helper functions for the particular task at hand. Dynamic would get you half way there, but the unique functionality would still need to be written and maintained.

C# has a few nice features coming along those lines in Linq that should eventually reduce it even more, but never remove it completely.

And no, half a million lines of code isn’t that much, as long as you have some semblance of organization and firm grasp on the concept of code reuse. Making libraries can dramatically simplify your life.

Of course, changing the libraries can be a little more complicated and tedious to ensure it doesn’t break something using it, but again, a little practice and you start to learn when and how…

So Steve believes the majority of developers, when encountering a code base approximately the size of the Death Star, would think: I could totally build that.

I think the point was that if you have a team that has built a system that size, they will be impressed with themselves. “Look at how much we got done!” and “Wow, we must be really good to build this towering edifice of code!”

Personally, in my more foolish days (which, unfortunately, weren’t all that long ago) I led a team that built a darn large system, and that’s exactly what I thought. Sure it does a ton of cool stuff to have gotten to that size, but the size itself is indicative of things I failed to do better to keep it small, not indicative of our prowess as a team.

So now our job is to balance adding new functionality with trying to keep the size of the codebase either constant or shrinking, and I’m actively exploring alternative languages (as well as better code structure in general) as tools to help us do that.

] for line in file(“FileName.txt”):
] # Process line

That’s wonderfully simple, I agree. But there are ways in C++ to write the code that does the bulk of the stuff that the programmer doesn’t want to have to deal with repeatedly. Create a class that can open a text file, loop through the lines until EOF, and call a virtual method with the line. Now subclass and provide your own custom method for processing the line. Now for simple text file processing, nobody ever has to think about how that file is being opened and they don’t have to write that boilerplate code, or copy/paste it.

Personally, I find that when I’m in a rush (which is most of the time), I tend to write code inline, and cut and paste, and I don’t stop to think, “This is something I’m using or will use in multiple places. How should I write it to be reusable, and which library should I put it in.”

My current project uses three difference classes for reading and writing registry values, and there are parts of the code that actually don’t even make use of the registry classes, they just call in the Windows API registry calls. Ugh! Time to refactor that into one class… Sure, I’ll do that when I get free moment (in Jan 2012).

In a microISV, when your time has to go to development, qa, marketing, sales, it, accounting, and customer support, you tend to mostly be moving forward rather than looking back and cleaning up the messes, even when you know that eventually they will catch up with you and cause you problems. And you sometimes fall into the trap of not stopping and thinking about design as much. But it is important to do those things and will no doubt save time in the long term if you do go back to refactor the messes and take a little more time to “think” about what you’re doing before you do it, rather than to just jump in and do do do.

that opens and loops through the file until it hits the end of file once in C++