Results 1 to 9 of 9

Thread: Ease of use - Pascal vs CPP

  1. #1
    Join Date
    Oct 2015
    Location
    Nowhere
    Posts
    134
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default Ease of use - Pascal vs CPP

    Is CPP difficult to learn/code in, compared to Pascal?

    I needed to do some stuff in CPP, and to say the least it's a complete nightmare. Of course I don't know the language whatsoever, but in getting what I needed to get done, the language to me seemed extremely unintuitive compared to Pascal (the only thing I have coded in before CPP).

    I did get everything done at least. I hope once I learn the syntax it'll come as easily to me as Pascal does. Anyone have any good resources they've used to learn CPP?

  2. #2
    Join Date
    May 2014
    Posts
    633
    Mentioned
    8 Post(s)
    Quoted
    322 Post(s)

    Default

    Do you mean C++? If so, I'd say yes. C and C++ are nightmarish ro learn compared to many languages, but they both have immense power if you wield them right. Probably "The C Programming Language" by Kerninghan and Ritchie would be a good start if you really want to understand C (and it definitely will help with C++ too).

  3. #3
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    One of the other lads posted this link

    http://programming-motherfucker.com/become.html

    A great resource. That needs to be passed around more =D

    <------------------>



  4. #4
    Join Date
    Oct 2015
    Location
    Nowhere
    Posts
    134
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default

    I never got an email saying there was replies here...

    Thanks guys! I've been slowing learning from the ground up. And yes, it is indeed a complete nightmare. However I'll put in the time and see where it goes. I found it helped a lot comparing pascal to c++, e.g.. Once I knew "&var" was the same as "var var", it made perfect sense in my mind. Also, it's pretty crazy how many things I was missing out on with pascal/lape now that I've learned about it while reading, like overloading. No more FindObj, FindObjP, FindObjB....

    And thanks for that link AFools. Massive resource..

  5. #5
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Quote Originally Posted by skollstagg View Post
    Once I knew "&var" was the same as "var var", it made perfect sense in my mind.
    I mean..that's just not true. & is the reference operator, so the result of &var = the memory location it is stored in.

    C and C++ are incredibly intuitive and just as easy to learn as any other language. From a pascal background, you'll have an easier time learning C than C++. C++ is named as such because it is an incremental of C, and was originally simply refereed to as "C With Objects". OOP is (imo) the most powerful programming tool there is. Its also the reason no major program will ever be written in Pascal. Pascal might solve the use of what we need here, but it is a god awful and ancient language.

    You'll want to get into the mindset and ideology of Object Oriented Programming. That will make your experience much more pleasant.

    My only real gripe with C++ is header files. I mean, its super cool to be able to distribute function headers to clients without them actually having your source, but still, not really my thing.

    Best of luck!

    Here's another great resource: http://www.cplusplus.com/doc/tutorial/

  6. #6
    Join Date
    Jun 2013
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    9 Post(s)

    Default

    Have to second the recommendation of K&R, that book is fantastic. I've enjoyed it more than any other programming book I've read.

  7. #7
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    I mean..that's just not true.
    It is actually "true". Whether or not he's talking about a reference or a pointer/address, makes all the difference. You can tell he's talking about references because he says: var.

    C++ Code:
    void meh(int &X)
    {
       X = 10;
    }

    vs.

    Pascal Code:
    procedure meh(var X:Integer);
    begin
      X := 10;
    end;


    ---------------


    You are interpreting what OP said as:

    C++ Code:
    int X = 10;
    int* Y = &X;

    vs.

    Pascal Code:
    var
      X: Integer;
      Y: ^Integer;
    begin
      X := 10;
      Y := @X;
    end;
    Last edited by Brandon; 01-20-2016 at 02:58 AM.
    I am Ggzz..
    Hackintosher

  8. #8
    Join Date
    Oct 2015
    Location
    Nowhere
    Posts
    134
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default

    I did mean reference, and specifically what you show in your first example Brandon. Am I right in saying those two are functionally the same? What I'm reading hasn't gotten to pointers yet, although I know there's a pretty massive section dedicated to it.

    Quote Originally Posted by the bank View Post
    You'll want to get into the mindset and ideology of Object Oriented Programming.
    I haven't read specifically about OOP, but I believe I've been making use of it, unless my understanding is wrong.

    For example, my object search function uses a type that I pass several 'attributes' to. e.g, Door := [color, size, etc..]; Is that what you mean?

    My main reason for learning is because I hit a road block in my hobby game project in UE4. I am able to change things in the engine fine, but I don't fundamentally understand what I'm doing which bothers me.

  9. #9
    Join Date
    Jun 2013
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    9 Post(s)

    Default

    So I'm actually in the opposite of your situation, I know only a little Pascal but am pretty familiar with C++. Hopefully this explanation is valuable. The core difference between passing an argument by value and passing it by reference is this:

    C++ Code:
    void foo() {
       int a = 0;

       passByVal(a);
       cout << a << endl; // Value of a here is still 0.

       passByRef(a);
       cout << a << endl; // Value of a here is now 10!
    }

    void passByVal(int x) {
       x = 10;
    }

    void passByRef(int& x) {
       x = 10;
    }
    * Function prototypes and namespace stuff left out for succinctness.

    Passing by value actually gives the new function a copy (which, notably, forces the copy constructor to run!) with which to work, while passing by reference gives the function a "reference" to the original object, allowing you to make changes to it directly (and not requiring a call to the copy constructor!). This constructor behavior is why you will often see large objects passed into functions by const reference.
    Last edited by enchilada; 01-20-2016 at 04:10 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •