Recent

Author Topic: Why I got F in C  (Read 4043 times)

lainz

  • Hero Member
  • *****
  • Posts: 4741
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: Why I got F in C
« Reply #15 on: April 14, 2019, 09:47:18 pm »
Repeat
Until a > b

Keep executing if a is less than b

Should it be: Keep executing if a is less or equal than b?

Yes. Good catch :)

THanks. That's my point, is even hard to compare with C.  :D

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: Why I got F in C
« Reply #16 on: April 14, 2019, 10:59:31 pm »
THanks. That's my point, is even hard to compare with C.  :D

I didn't want to say it ... but WTH! It's even more basic: a question of "English", i.e. the meaning of "while" vs. the meaning of "until" ;D
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

lainz

  • Hero Member
  • *****
  • Posts: 4741
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: Why I got F in C
« Reply #17 on: April 15, 2019, 12:26:45 am »
I did the exam in Spanish.

Hacer mientras
Repetir hasta

But I just assisted to the previous class to exam due to problems when registering myself on the course.

So I went all Pascal, didn't know that we was seeing pseudocode in c style. Then the rest of the course was all c related.

So I used Pascal when I was required to use c style. My code was right in Pascal.

Tz

  • Jr. Member
  • **
  • Posts: 54
  • Tz with FPC Pen Cil
Re: Why I got F in C
« Reply #18 on: July 03, 2019, 09:52:02 pm »
I was intrigued by this

https://wiki.lazarus.freepascal.org/Why_Pascal_is_Not_My_Favorite_Programming_Language

but most of it are prove obsolete, great!


and yea, well kido Child(Java) GrandChild(C#)

about ha file and haha file, you prove your father(C) and uncle(C++) ....
you hate it right? hahaha

we use only one, right, wonder have you lost the ha haha file ?

but why you two have so much detail in front,
dont you know detail can be the devil?
we dont need to scroll, we just look at interface. 

yea, but, but, there is tool call code folding
dont you know, we can still do programming with a pencil and paper?

but you have to scroll in line full of comment,
just to find a method? ouch!

we do less comment, and try to self-documenting code

and kido(Java), your child(C#) learn from us,
you say dont need unsigned?
see your cousin(Java Script) and your friend Kotlin and Lua, what happen?

and this from your uncle
http://cshandley.co.uk/CppConsideredHarmful.html
https://whydoesitsuck.com/cpp-sucks-for-a-reason/

we learn from him also.



Now for

https://www.kernel.org/doc/html/v4.10/process/coding-style.html

Quote
1) Indentation

Tabs are 8 characters, and thus indentations are also 8 characters.
There are heretic movements that try to make indentations 4 (or even 2!) characters deep,
and that is akin to trying to define the value of PI to be 3.

Rationale:
The whole idea behind indentation is
to clearly define where a block of control starts and ends.
Especially when you’ve been looking at your screen for 20 straight hours,
you’ll find it a lot easier to see how the indentation works
if you have large indentations.

Now, some people will claim that having 8-character indentations
makes the code move too far to the right,
and makes it hard to read on a 80-character terminal screen.
The answer to that is that if you need more than 3 levels of indentation,
you’re screwed anyway, and should fix your program.

In short, 8-char indents make things easier to read,
and have the added benefit of warning you when you’re nesting
your functions too deep. Heed that warning.

if I am not mistaken, easier to read for 20 straight hours ...

well I m working 9 to 5, so that means 8 hours, but sometimes late 2 hours
in current average equal to 10 hours

so my tab 10/20*8 equal 4 characters,

ah I wonder when I was newbie, just read less than 5 hours,
so the tab is 2, and still newbie ...


for PI to be 3, I think He should meet aunt ADA, she strict to 3 character,
or may be she is been influence by uncle Tesla number.

the number should be 3 and 6 -> 234 6 8, make balance in between


just to prove, it may be true or false:

https://wiki.freepascal.org/Coding_style

use of hanging indent, to skim quickly, without distractions,

http://faculty.georgetown.edu/spendelh/handouts/hanging-indent.htm

Code: Pascal  [Select][+][-]
  1. program identation;
  2. {$mode objfpc}
  3. {$h+}
  4.  
  5. type
  6.    
  7.    Timestamp = record
  8.       DateTime  :Int64;
  9.       TimeTick  :UInt64;
  10.    end;
  11.    
  12. var
  13.    ts :Timestamp;
  14.    i :Integer;
  15.  
  16. // block statement  
  17. begin
  18.  
  19.    WriteLn;
  20.    WriteLn;
  21.    WriteLn;
  22.  
  23.    -- with end
  24.    with ts do
  25.       begin
  26.          WriteLn;
  27.       end;
  28.  
  29.    -- try except end
  30.    try
  31.          WriteLn;
  32.    except
  33.          WriteLn;
  34.       end;
  35.  
  36.    -- or try end finally end
  37.    try
  38.       begin
  39.          WriteLn;
  40.       end;
  41.    finally
  42.          WriteLn;
  43.       end;
  44.  
  45.    while true do
  46.       begin
  47.          WriteLn;
  48.       end;
  49.      
  50.    repeat
  51.          WriteLn;
  52.       until false;
  53.  
  54.    for i:=1 to 10 do
  55.       begin
  56.          WriteLn;
  57.       end;
  58.  
  59.    if true then
  60.       begin
  61.          WriteLn;
  62.       end
  63.    else
  64.       begin
  65.          WriteLn;
  66.       end;
  67.  
  68.    // for simple if else
  69.    if true then  
  70.          WriteLn
  71.    else  
  72.          WriteLn;
  73.  
  74.    // or
  75.    if false
  76.    then  WriteLn
  77.    else  WriteLn;
  78.  
  79.    case i of
  80.  
  81.       1:
  82.       begin
  83.          WriteLn;
  84.       end;
  85.  
  86.       2:
  87.       begin
  88.          WriteLn;
  89.       end;
  90.  
  91.       3:
  92.       begin
  93.          WriteLn;
  94.       end;
  95.  
  96.    end;
  97.  
  98. end.
  99.  


as we can see in the program,
statement WriteLn is consistently align by 6 characters
and keyword are align by 3 characters

When I read more than 10 hours, is when to find bug,
thats it! we are in hurry, its time for speed reading.

https://en.wikipedia.org/wiki/Speed_reading

by skimming, scanning, jumping, skipping

today debugger so generous that we can directly spot the line number which error
so we can directly open our file.

when we do debugging, our intent is more toward identifier,
rather than keyword, keyword can be skip,
or for our Hero member it could be by sixth sense.

so by dimming keyword color, we can make more intent of Identifier.

by making 3 tab characters with a appropiate style,
make look indentation balance and not too far 6 vs 8.

Is it true aunt(ADA) ?


Quote
4) Naming

C is a Spartan language, and so should your naming be.
Unlike Modula-2 and Pascal programmers,
C programmers do not use cute names like ThisVariableIsATemporaryCounter.
A C programmer would call that variable tmp, which is much easier to write,
and not the least more difficult to understand.

HOWEVER, while mixed-case names are frowned upon,
descriptive names for global variables are a must.
To call a global function foo is a shooting offense.

We are the real spartan, dont you like our helmet?
https://forum.lazarus.freepascal.org/index.php?topic=34693.0

aunt(ADA) use This_Variable_Is_A_Temporary_Counter so clear,

but we and she can do directly and briefly, also. meh

Quote
Encoding the type of a function into the name (so-called Hungarian notation)
is brain damaged - the compiler knows the types anyway and can check those,
and it only confuses the programmer.
No wonder MicroSoft makes buggy programs.

https://en.wikipedia.org/wiki/Hungarian_notation

somehow we agree
https://wiki.freepascal.org/DoDont

and by the way because your so case sensitive and we are not

can you spell it
   
   string MYString      // MYString is supposed to be string
   string MyString      // MyString is supposed to be string
   string myString      // myString is supposed to be string
   string mystring      // mystring is supposed to be string

we hear it all the same? which one?

   AString :String;     // A string is String
   FString :String;     // we agree that prefix F is for field name

   FString := AString;

   myString = MyString; // ? yes it same, but you say not? oh my...


anyway

   Dom Tor Etto said 'This is brazil!'

   and well ...

   uncle Ver Dom Me say 'This is Free Pascal!'


SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1315
Re: Why I got F in C
« Reply #19 on: July 03, 2019, 11:25:21 pm »
I started with BASIC, then assembler and forth. My first commercial app was in Microsoft C 5.0. There was another team that was using Turbo Pascal 3, and I was quite jealous: instead of builds that took many minutes and generated endless, incomprehensible errors, theirs took seconds, and when an error was encountered, the cursor was placed on the word where the error happened. And I had to limit myself to four asterisk around variables to keep it still somewhat comprehensible. Debugging was a real pain.

And when I started using Turbo Pascal myself, I totally loved it: this is how programming has to be. And that hasn't really changed.

The first versions of C# and .NET were .. ok. Well, designed by the same people, just with Microsoft management. The later versions went completely wild.

Java is somewhat ok-ish, but they don't have basic things like unsigned ints. And Oracle, of course.

C++ is nice if you don't know better or are a masochist.

Perl is really hardcore. It gives me a headache.

JavaScript and PHP want to be a real language when they grow up.

 

TinyPortal © 2005-2018