Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » 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
-
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
Ah, that makes sense.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.What? I'm assuming it's because they both start with the letter I, but how? 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; }
“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.
- Maximouse
-
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
Graphics can be made in both C and C++. 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.
- Vaibhs11
-
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
I know graphics.h exists butGraphics can be made in both C and C++. 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.
There are many more headers but only few are compatible with the compiler you're using.
- AmazingMech2418
-
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
All C++ is, is C with more features. XDIf you're writing C using a C++ compiler, you're still writing C. Therefore, it is easier, and any C program can run in a C++ compiler.
Floating point arithmetic is decimal numbers, and it's terribly difficult to do in a basic shell script. XDnever heard of it, even cmd doesn't tell about it. Try floating point arithmetic in Batch. XDyou 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) 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.
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.
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
-
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
So how is it easier? The syntax took a huge punch and less easier to understand than C.All C++ is, is C with more features. XDIf you're writing C using a C++ compiler, you're still writing C. Therefore, it is easier, and any C program can run in a C++ compiler.
- PkmnQ
-
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
I think it's harder, because you have to first deal wih the difficulty of C, and then there's still the extra features.So how is it easier? The syntax took a huge punch and less easier to understand than C.All C++ is, is C with more features. XDIf you're writing C using a C++ compiler, you're still writing C. Therefore, it is easier, and any C program can run in a C++ compiler.
- AmazingMech2418
-
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
You don't need to allocate the memory yourself. XD You can just use a vector or a map or something. LOL!I think it's harder, because you have to first deal wih the difficulty of C, and then there's still the extra features.So how is it easier? The syntax took a huge punch and less easier to understand than C.All C++ is, is C with more features. XDIf you're writing C using a C++ compiler, you're still writing C. Therefore, it is easier, and any C program can run in a C++ compiler.
- Socialix
-
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
-
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
bump is cool oh
- Vaibhs11
-
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
-
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
Personally prefer C-family languages, but not bad. XD It was my first language though. LOL! whadyall think about vbs?
- Vaibhs11
-
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
*fake error messages intensify*Personally prefer C-family languages, but not bad. XD It was my first language though. LOL! whadyall think about vbs?
- Discussion Forums
- » Advanced Topics
-
» 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