Computer Languages aren't Human Languages

Mark Freedman: My preferred version of that statement is as follows:

if (filesAreProcessed) {}

A variable name like filesprocessed doesn’t tell me anything about whether or not its value must be true or false. Throwing “Are” in the name does. That obviates it for me.

A variable like filesprocessed could be a number–the total number of files processed, for instance–in which case it might break that nifty if statement above.

Camel case alone isn’t sufficient to make the code clear. The names of the variables themselves have to be clear.

In any case, VB.NET or C# is suitable for language choice. I use both. But in whatever lanugage you choose, that’s only the start of the battle. The coder is responsible for making sure that the portion he or she writes is as clear as can be. An effective strategy for naming variables, classes, methods, properties, and fields, goes a long way towards accomplishing this.

And then of course, there’s the golden rule: Refactor, refactor, refactor.

You know, I wouldn’t mind VB so much if it weren’t for all the “End KEYWORD” constructs. Really now.

How readable would this paragraph be if instead of using punctuation COMMA I ended everything with “END SENTENCE” END SENTENCE It isnAPOSTROPHEt an issue with typing since the IDE handles that for you COMMA but readability END SENTENCE

“A variable name like filesprocessed doesn’t tell me anything about whether or not its value must be true or false. Throwing “Are” in the name does. That obviates it for me.”

Good point, Mike. You caught me not putting enough forethought into it myself :wink:

How readable would this paragraph be if instead of using punctuation COMMA I ended everything with “END SENTENCE”

The whole point of this post is that rules that work for English don’t work at all for programming languages. The further you go down that particular rabbit hole, the worse things get… eg, AppleScript.

the most frightening thing about COBOL is that it was created so that MANAGERS COULD WRITE THEIR OWN PROGRAMS! scary…

MOVE 10 TO MYNUMBER
ADD 4 TO MYNUMBER

I personally prefer C like languages. I learned how to program before i knew any english, so for many of us that english isnt our first language, vb or applescript or whatever dont really offer that much advantage.

I know many of you Americans will say: Everyone in the world speaks english, at least they should.

I think is all about how the syntax is structured, how easy is to achieve something with it and more importantly what company is behind it.

I once heard of a programming language in that the sentences were based in the spanish lang. But it didnt succeed. No one would want to use it.

Nowadays programming is far from human language, and thank god coz my job for that matters would be at risk.

PS Excuse any orthographic mistakes, its my firts post in english.

Your English is quite good!

Everyone in the world speaks english, at least they should.

I wouldn’t say that, but it’s clear that if you are a programmer, you’ll be writing programs using English keywords…

Foobar, your linguistic claims about English and Korean are silly, and spelling is irrelevant unless you want advocate using Korean keywords.

I prefer VB.NET. I especially like the “End *” syntax. In the C style syntax, the same character means end of class, end of method, end of if, end of while, end of for, or if I want to have a block of code I want to segment out, I can just put in { } anywhere I please. If I am writing a While loop with alot of conditional logic in it, and the top of my loop is off the top of my page, I want to be able to scroll down and immediately find the end of the loop I’m working in. When I’ve written programs in Java and C++, I found myself doing the following:

} //end if
}//end while

Foobar, your linguistic claims about English and Korean are silly, and spelling is irrelevant unless you want advocate using Korean keywords.

They’re silly? What, because they’re true? God, you guys bitch about case sensitivity, when there are so many human languages don’t even have a notion of case. That would just make the whole retarted argument about case just irrelevant.

And of course I was writing using Korean keywords. What the hell did you think I was writing about?

Well, most people get AppleScript wrong ;-), it’s major flaw is that its Java-like syntax (optimized for coding) was not released.
AS (the english representation) is designed to be easily readable,
but its that easy to write. The fundamental concept is nice, and its absolutely not english-dependent there are japanese and french representations of applescript (and the Java like one that did not appear) an applescript is the (semantic) parse tree of one of this representations, thats why the scripteditor will somtimes do wired things to the sourcecode when the semantics are not so well defined (as with the POSIX file “:example”, but actualy you would see what’s wrong when the compile retranslates to “the englisch version” (or whatever language you want, english is just the defacto standard)

The only big flaw in applescript is that one never knows which variable names are free for use because there are many “reserverd words”

Edsger W.Dijkstra
On the foolishness of “natural language programming”.

http://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD667.html

WHOA what are the odds we both comment within 12 hours of eachother on the same post from a post over 2 years and 11 months ago! NUTS!

also, are you having difficulty pronouncing Dijkstra? is it… dih-juh-kuh-stra? that is hard.

It’s interesting that the line between terse elegance and explicit verbocity is so subjective. I’m most comforatable at the level of abstraction of C# right now. I personally find the “elegance” of Python and Ruby to be a poor trade - you save a few lines of code, but the code requires more mental parsing. I can understand how some folks who spend most of their time in VB feel the same way about C# - why do I need to parse this end brace to an “End If”? Why not just write “End If” if that’s what you mean?

I guess there are tradeoffs to be made. Investing time in training your mind to precompile the code entails a learning curve (for all developers who will work on the code, not just the author). Some of these may offer gains that are only apparent after several years.

The case sensitive part of C# is a little annoying which I never cared for. But once you get used to it, its not that bad, although it makes things a little harder.

I think you can make a program a little easier to read with a liitle forethought on variable names, but functionally it would be the same.

Example:

if (pf) {}

if (processedfiles) {}

if (processedfiles == true) {}

Which one is better? From a machine standpoint, they are all equal, from a human standpoint the last one if the most verbose and probably the clearest for the intentions of the program.

VB.NET has the upper hand with its “Dim … New” syntax. And possibly XLinq, at least in its present stage. Other than that, C# tends to be less verbose, and any other differences are essentially cosmetic in nature.

The syntax in C# is an adaptation from Delphi, and carries over the coding convention that interfaces should always start with an “I” (but drops the “T” in front of classes). So when you see “public class SomeClass : ParentClass, ISomeInterface”, the meaning really is quite obvious to any OOP programmer. And if someone isn’t familiar with OOP, how are the words “Inherits” and “Implements” going to help them anyway?

It’s a Coke vs. Pepsi debate indeed. Mr. Appleman is using some pretty flimsy logic suggesting that VB.NET’s syntax is “easier to understand” in any significant way. It may be easier for rank amateurs, but contrary to popular belief, VB.NET is not a language designed to be used by neophyte programmers, so using this hypothetical dumb-dumb as a benchmark is disingenuous at best. It’s almost as if he’s suggesting that source code should be readable by an end user, which is baloney.

Personally, I prefer the term “abstract”, which is a description of the class itself, than “MustInherit”, which sounds more like an instruction to me. But would I really care if I had to write in VB.NET instead of C#? No, not at all, and it’s almost funny that someone wrote an entire book about it.

I prefer if (processedfiles) {} as well as this tells me that processedfiles is a bool(ean). It can be of no other type. The compiler will not take a non-boolean value for this type of statement.

For Example:

int testthis = 1;
if (testthis)
MessageBox.Show(“Must be true.”);

Try to compile:

Performing main compilation…
c:\documents and settings\jraynor\my documents\visual studio projects\threadingexample\form1.cs(250,8): error CS0029: Cannot implicitly convert type ‘int’ to ‘bool’

If it were a number, one could use Convert.ToBoolean(fileProcessed), but this statement would be better:

if (filesProcessed 0) {}

I think that would meet everyone’s needs.