• Java is utter shit
    97 replies, posted
Time for this de-rail for a good reason. All hands in favour of saying Java is utter shit say I All hands in against say Java.
[QUOTE=~Kiwi~;18448115]Time for this de-rail for a good reason.[/QUOTE] Isn't it more like a re-rail in this case? [QUOTE=~Kiwi~;18448115]All hands in favour of saying Java is utter shit say I All hands in against say Java.[/QUOTE] Java.
[QUOTE=gparent;18443882]Which is fine. The only thing you shouldn't be able to do is modify the elements inside the vector that was passed (which is what std::vector<const T> implies). What happens outside the function is irrelevant.[/QUOTE] [cpp]#include <vector> static const int var(42); void some_func(std::vector<int *const> &vec) { vec.push_back(&var); } int main() { std::vector<int*> v(1); some_func(v); *v[0] = 21; //we just modified the global constant var };[/cpp] This would not be good if it compiled. But it also fails if I pass by value, which doesn't make sense in a non-C++ way of thinking. You could write a wrapper though: [cpp]#include <cassert> #include <vector> //force to copy template<typename T2, typename T> std::vector<T2> copy_convert(const std::vector<T> &a) { std::vector<T2> ret; ret.reserve(a.capacity()); for(size_t i = 0; i < a.size(); ++i) ret[i] = a[i]; return ret; } static const int var(42); void some_func(std::vector<const int*const> &vec) { vec.push_back(&var); } int main() { std::vector<int*> v(1); some_func(copy_convert<const int*const>(v)); //useless call though, since the copied vector will be destructed after this *v[0] = 21; assert(var == 42); //doing fine, we just copied it :) };[/cpp]
Check out C# / .Net; its based on Java/C++ syntax and similar concepts, but.. better :) .Net generics for example aren't just syntax sugar to hide autoboxing etc, they really don't autobox, just as one example. There are reference types on integers etc if you want, and you can even use pointers if really necessary. I'm pretty fond of it.
[QUOTE=streeter;18479689]Check out C# / .Net; its based on Java/C++ syntax and similar concepts, but.. better :) .Net generics for example aren't just syntax sugar to hide autoboxing etc, they really don't autobox, just as one example. There are reference types on integers etc if you want, and you can even use pointers if really necessary. I'm pretty fond of it.[/QUOTE] You must've completely missed the thread because I said C# is much better than Java, hands down.
java can run on microwaves and c# cant u fukin dumasses
-Shnip- Wrong thread.
Sorry, you need to Log In to post a reply to this thread.