Click here to Skip to main content
14,549,626 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Member 798912218-May-20 20:59
MemberMember 798912218-May-20 20:59 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Richard Deeming18-May-20 23:40
mveRichard Deeming18-May-20 23:40 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Member 798912219-May-20 6:55
MemberMember 798912219-May-20 6:55 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Richard Deeming19-May-20 7:31
mveRichard Deeming19-May-20 7:31 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Stuart Dootson18-May-20 0:59
professionalStuart Dootson18-May-20 0:59 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
BryanFazekas18-May-20 2:21
MemberBryanFazekas18-May-20 2:21 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
W Balboos, GHB18-May-20 2:35
mveW Balboos, GHB18-May-20 2:35 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Member 1181677618-May-20 3:47
MemberMember 1181677618-May-20 3:47 
Well, just in terms of the JavaScript, here is how I would write it.
var home =
   {
   cit : "Boston"
   };

home.city = function(aCity)
   {
   if (arguments.length)
         this.cit = aCity;
      else
         return this.cit;
   };

Yes, the function is a bit longer but there is only one function instead of two and writing pointless "get" and "set" is no longer necessary. That is a holdover from languages which do not have true getter / setter type attributes. I would note that the function would normally be part of a class (or prototype) and not the object itself.

In C++, it takes more work, but you can write code so that you can literally write

aCity = home.city;
home.city = aCity;

I usually don't do that, but I do do the same thing in C++ as in JavaScript. Note that brace placement may make it look longer, but that is matter of style. Braces are part of a statement block, so I indent the same as the statement block. And don't use unnecessary braces. The make code less readable.

I agree with you about APL not being readable. Perl has a lot of the same characteristics.

I disagree about COBOL, it is both far less concise and far less readable.

If something is too concise, it becomes unreadable. But, conversely, when it is too expansive (non-concise?) then it is also less readable. A straight mathematical expression whether in a conditional or an assignment is generally maximally readable. Assuming that the length and complexity of the expression is not too large. And that weird and strange operators (APL) are not in use.

So languages whose basic structure is similar to C tend to be most readable without becoming too concise.
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
sasadler18-May-20 8:51
Membersasadler18-May-20 8:51 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
nedzadarek18-May-20 10:25
Membernedzadarek18-May-20 10:25 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Member 1085545518-May-20 13:45
MemberMember 1085545518-May-20 13:45 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Kirk 1038982118-May-20 14:56
MemberKirk 1038982118-May-20 14:56 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
nedzadarek19-May-20 3:55
Membernedzadarek19-May-20 3:55 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Member 798912219-May-20 6:15
MemberMember 798912219-May-20 6:15 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
GuyThiebaut19-May-20 0:36
professionalGuyThiebaut19-May-20 0:36 
Generalhtml button not firing on mobile, oh Pin
raddevus11-May-20 9:16
mvaraddevus11-May-20 9:16 
GeneralRe: html button not firing on mobile, oh Pin
Richard Deeming11-May-20 9:31
mveRichard Deeming11-May-20 9:31 
GeneralRe: html button not firing on mobile, oh Pin
raddevus11-May-20 9:39
mvaraddevus11-May-20 9:39 
GeneralRe: html button not firing on mobile, oh Pin
raddevus11-May-20 10:54
mvaraddevus11-May-20 10:54 
GeneralRe: html button not firing on mobile, oh Pin
Marc Clifton11-May-20 9:32
mvaMarc Clifton11-May-20 9:32 
GeneralRe: html button not firing on mobile, oh Pin
raddevus11-May-20 9:41
mvaraddevus11-May-20 9:41 
GeneralGenerated over 5.5 Billion random numbers, but no 0. Pin
raddevus19-Apr-20 7:15
mvaraddevus19-Apr-20 7:15 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. *UPDATED* Pin
Peter_in_278019-Apr-20 12:13
professionalPeter_in_278019-Apr-20 12:13 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
Rick York19-Apr-20 12:14
mveRick York19-Apr-20 12:14 
GeneralRe: Generated over 5.5 Billion random numbers, but no 0. Pin
raddevus19-Apr-20 15:47
mvaraddevus19-Apr-20 15:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.