5 ms·
I see no difference in learning symbols in order to read source code and learning alphabet in order to read words/sentences.
by mirpa 3y ago
I see no difference in learning symbols in order to read source code and learning alphabet in order to read words/sentences.
- tmcdos 3y agoThis is like comparing Latin alphabet with Egyptian pictograms or Chinese hieroglyphs. The time has proven multiple times that using words is easier for humans than using symbols.
- spookie 3y agoPicking up a game engine without prior knowledge and making something on your free time, I assume that would be the aim.
- darkwater 3y agoMost probably you already learnt the alphabet in the past, and there is 0 cognitive load for your brain to parse it. Unless you come from a language using another alphabet, but then unfortunately you need to bow to Latin alphabet rule over programming languages in any case.
- mirpa 3y agoOh, really? if ((input = 'y') or (input = 'Y')) then begin writeln ('blah blah'); end else if ((input = 'n') or (input = 'N')) then begin writeln ('blah'); end else begin writeln ('Input invalid!'); end; if input == 'y' || input = 'Y' { writeln ('blah blah'); } else if input = 'n' || input = 'N' { writeln ('blah'); } else { writeln ('Input invalid!'); } If you find Pascal easier to read, I would guess you have very special set of eyes.
- andsoitis 3y agoYour example isn't idiomatic. You would not write begin/end for single-line cases. Instead it would be: if ((input = 'y') or (input = 'Y')) then writeln ('blah blah') else if ((input = 'n') or (input = 'N')) then writeln ('blah') else writeln ('Input invalid!'); OR even better case uppercase(input) of 'Y': writeln('blah blah'); 'N': writeln('blah'); else writeln('Input invalid!');
- logicprog 3y agoWell if we're doing that, then you wouldn't use the curly brackets in the C style syntax example either. If you just make one ideomatic without making the other ideomatic, the comparison ceases to be fair. Anyway, doing that to both of them would make the comparison pointless, because the point wasn't to compare ideomatic code examples, but to compare the syntax in a general case, so writing them slightly unideomatically to show off the general-case syntax is fine, as long as both are written the same way to control for unrelated variables (like special-case syntactic sugar), which is precisely what the original comparison did: write both code samples in the most general way, and crucially in the same way, so we could directly compare the scanability of syntax. And imo C won by a mile.
- FpUser 3y agoyou are also allowed: case input of 'A'..'C': writeln('blah blah blah'); 'N','n': writeln('blah blah'); 'Y','y': writeln('blah'); else writeln('Input invalid!'); end;
- darkwater 3y agoTBH? I see them basically the same. My brain probably scans equally faster "b...n" and "e..d" then the direction of the curly brace. And I haven't read or written Pascal since early high-school, ~30 years ago.
- FpUser 3y agoYour example is not Pascal problem. It is inability of an author to come up with clean looking version. One can do bad style in any language.
- dennis2354 3y agoGreat example. Your C-Code translated to Pascal would be if (input = 'y') or (input = 'Y') then begin writeln ('blah blah'); end else if (input = 'n') or (input = 'N') then begin writeln ('blah'); end else begin writeln ('Input invalid!'); end; Now this does not look any different then your code. Except your code does compile but has several errors. And why should be the double pipe be any better to read than an "or" statement? Btw: as you won't need the begin and ends it would look like if (input = 'y') or (input = 'Y') then writeln ('blah blah') else if (input = 'n') or (input = 'N') then writeln ('blah') else writeln ('Input invalid!');
- vrruiz 3y agoWell, other simpler options are: if (input in ['Y', 'y']) then WriteLn('blah blah') else if (input in ['N', 'n']) then WriteLn('blah') else WriteLn('Input invalid'); And: if (LowerCase(input) = 'y') then WriteLn('blah blah') else if (LowerCase(input) = 'n') then WriteLn('blah') else WriteLn('Input invalid');