Discuss Scratch

PkmnQ
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

Greg8128 wrote:

PkmnQ wrote:

Greg8128 wrote:

In C++, the vector implementation is provided for you, but gives you a lot of opportunities to shoot yourself in the foot. For example:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector<int> vec {10, 15, 18};
    int* ip = &vec[2];
    cout << *ip << endl;
    for(int i = 0; i < 1000; i++) // This invalidates the pointer 'ip'
        vec.push_back(i);
    cout << *ip << endl;
    return 0;
}
What? I'm assuming it's because they both start with the letter I, but how?
When we create the vector “vec”, we request a block of memory from the heap (a pool of shared memory) that can store 3 ints.

“ip” is an int pointer. An int pointer represents the memory location of an int. "int* ip = &vec“ means that ”ip“ represents the location of the third item in the vector (currently 18)

We then add a bunch of numbers to the vector. When ever a number is added to the vector, the vector might need to grab a larger block of heap memory, copy all the numbers over, and throw the old block out. Then, anything can happen to the data there.

When we read ”ip" the second time, we're reading a location that was in the old block of memory used by the vector. However, that block may have been thrown out as soon as we added the first additional number to the vector. We might read the original number, we might read some random made-up data, we might even get a segmentation fault.
Ah, that makes sense.
Maximouse
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

Vaibhs11 wrote:

you have to know more about those extra functions. In C++, a graphical bitwise graph (again, different meanings) would take something like ??? lines (somebody help me)
In C, there is no graphics, and you have to depend it all on ascii. Including the 2D bits array, would just take 7-20 lines.
Graphics can be made in both C and C++.
Vaibhs11
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

Maximouse wrote:

Vaibhs11 wrote:

you have to know more about those extra functions. In C++, a graphical bitwise graph (again, different meanings) would take something like ??? lines (somebody help me)
In C, there is no graphics, and you have to depend it all on ascii. Including the 2D bits array, would just take 7-20 lines.
Graphics can be made in both C and C++.
I know graphics.h exists but

Vaibhs11 wrote:

There are many more headers but only few are compatible with the compiler you're using.

AmazingMech2418
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

Raihan142857 wrote:

Amazingmech2418 wrote:

Therefore, it is easier, and any C program can run in a C++ compiler.
If you're writing C using a C++ compiler, you're still writing C.
All C++ is, is C with more features. XD

Vaibhs11 wrote:

AmazingMech2418 wrote:

Try floating point arithmetic in Batch. XD
never heard of it, even cmd doesn't tell about it.

AmazingMech2418 wrote:

And C++ has more features, so you don't have to create them yourself. Therefore, it is easier, and any C program can run in a C++ compiler.
you have to know more about those extra functions. In C++, a graphical bitwise graph (again, different meanings) would take something like ??? lines (somebody help me)
In C, there is no graphics, and you have to depend it all on ascii. Including the 2D bits array, would just take 7-20 lines.
Floating point arithmetic is decimal numbers, and it's terribly difficult to do in a basic shell script. XD

Also, you don't need graphics for either, and can do graphics in either. IDK what you're talking about. You can't compare an apple in one language and an orange in another and expect it to give you an accurate comparison. XD A GUI is much more complex than a command line app, so it makes perfect sense that the GUI one would be more code than the command-line one in any language, other than GUI-specific languages, such as Scratch.
Vaibhs11
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

AmazingMech2418 wrote:

Raihan142857 wrote:

Amazingmech2418 wrote:

Therefore, it is easier, and any C program can run in a C++ compiler.
If you're writing C using a C++ compiler, you're still writing C.
All C++ is, is C with more features. XD
So how is it easier? The syntax took a huge punch and less easier to understand than C.
PkmnQ
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

Vaibhs11 wrote:

AmazingMech2418 wrote:

Raihan142857 wrote:

Amazingmech2418 wrote:

Therefore, it is easier, and any C program can run in a C++ compiler.
If you're writing C using a C++ compiler, you're still writing C.
All C++ is, is C with more features. XD
So how is it easier? The syntax took a huge punch and less easier to understand than C.
I think it's harder, because you have to first deal wih the difficulty of C, and then there's still the extra features.
AmazingMech2418
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

PkmnQ wrote:

Vaibhs11 wrote:

AmazingMech2418 wrote:

Raihan142857 wrote:

Amazingmech2418 wrote:

Therefore, it is easier, and any C program can run in a C++ compiler.
If you're writing C using a C++ compiler, you're still writing C.
All C++ is, is C with more features. XD
So how is it easier? The syntax took a huge punch and less easier to understand than C.
I think it's harder, because you have to first deal wih the difficulty of C, and then there's still the extra features.
You don't need to allocate the memory yourself. XD You can just use a vector or a map or something. LOL!
Socialix
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

bump is cool oh
GoboSnack
Scratcher
100+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

Socialix wrote:

bump is cool oh
Vaibhs11
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

whadyall think about vbs?
AmazingMech2418
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

Vaibhs11 wrote:

whadyall think about vbs?
Personally prefer C-family languages, but not bad. XD It was my first language though. LOL!
Vaibhs11
Scratcher
1000+ posts

lua vs python vs js vs c vs malbolge vs cow vs c++ vs c# vs go vs dart vs scratch vs byob vs everything

AmazingMech2418 wrote:

Vaibhs11 wrote:

whadyall think about vbs?
Personally prefer C-family languages, but not bad. XD It was my first language though. LOL!
*fake error messages intensify*

Powered by DjangoBB