CoffeeJanitor
Member
Is today's developer absolutely screwed for the future if they don't know Javascript?
thanks bros
thanks bros
They only told us about smart pointers in the last lecture or the one before last, it would have saved us so much headache (even if we can't use the libraries, it's easy to implement yourself). But I guess memory management is part of the syllabus.
I don't know Rust, but I'm skeptical about this claim. Are you saying every memory access is guarded by a lock? Even if that's true (which is very unlikely) It's still possible to have a race. Detecting race conditions is equivalent to the halting problem, so how can it provably prevent them?
Indeed.Sure, but getting high performance out of C++ isn't really the problem most people have with it
Yes... But memory corruption can come back in force because of classes copies if you're not really, really careful.so I assume that's not what the poster was referring to. More likely it was about memory leaks, memory corruption, managing memory so it's deleted at the right time, that kind of thing.
Assuming modern = strict X14, I'd say you're right, but that's assuming you know how to code correctly in X14 (I've yet to find a good book, especially for newcomers, and I don't even talk about a book in my native language) and you don't interact with non-X14 code...Those kinds of issues are almost non-existant in modern C++.
You'll also learn a lot about:everywhere in your code, and fixing compiler errors that result to make it work. In the process you'll learn about move semantics as well.
From there you can audit your codebase for uses of new, and think "how can I eliminate this new?" You will almost always find a way, and probably learn a bunch of stuff along the way
That kind of logic doesn't apply to homework limitations, there's a list of things you can use and the rest you can't.It's not really a library. Did you use cin and cout for i/o? Because that's the same "library", it's part of the c++ language
There are caveats, so your skepticism is not misplaced. The first is that there isn't allowed to be more than one mutable pointer toward the same memory at a time. So this makes sure that you can't invalidate an iterator by accident, and it also means you can never cause a data race because only one mutable pointer is ever lying around.I don't know Rust, but I'm skeptical about this claim. Are you saying every memory access is guarded by a lock? Even if that's true (which is very unlikely) It's still possible to have a race. Detecting race conditions is equivalent to the halting problem, so how can it provably prevent them?
Indeed.
But even outside of performance, understanding how C++ handle pass-by-value can avoid a lot of trouble. Granted, with C++14, we're closer to sanity, but you can still easily stumble into big problems since the language allows you to do pretty much what you want with constructors and destructors.
Half a dozen years ago, I was trying to get used to Rule of Three. It changes each time they improve the norm, and code you'll find online (and also courses/tutorials/books) will gives you a patchwork of strategies, resulting in really strange code at the end, I fear.
Yes... But memory corruption can come back in force because of classes copies if you're not really, really careful.
Assuming modern = strict X14, I'd say you're right, but that's assuming you know how to code correctly in X14 (I've yet to find a good book, especially for newcomers, and I don't even talk about a book in my native language) and you don't interact with non-X14 code...
You'll also learn a lot about:
- finding the very last version of your compiler
- discovering the small hidden option (and include) that'll make make_unique work
- how to (not) decipher totally unreadable errors (the more sane C++ become, the most unreadable the errors messages become, it seems)
I really think that wondering whether you can use of unique_ptr make as much sense as wondering whether you can use "while". It's at the core of the language now, and a good habit to take.That kind of logic doesn't apply to homework limitations, there's a list of things you can use and the rest you can't.
IIRC, shared_ptr, unique_ptr and make_shared are C++X11, make_unique is X14.We were using some old version of C++ anyway, not sure if it had those pointers
Well, the more you use modern functions, the more they're linked to templates, and verbosity increase...I think error messages have come a long way.
/tmp/ccq8d3Hg.o: In function `std::_MakeUniq<int>::__single_object std::make_unique<int, int>(int&&)':
unique.cxx:(.text._ZSt11make_uniqueIiIiEENSt9_MakeUniqIT_E15__single_objectEDpOT0_[_ZSt11make_uniqueIiIiEENSt9_MakeUniqIT_E15__single_objectEDpOT0_]+0x25): undefined reference to `operator new(unsigned long)'
/tmp/ccq8d3Hg.o: In function `std::default_delete<int>::operator()(int*) const':
unique.cxx:(.text._ZNKSt14default_deleteIiEclEPi[_ZNKSt14default_deleteIiEclEPi]+0x18): undefined reference to `operator delete(void*)'
/tmp/ccq8d3Hg.o:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
I really think that wondering whether you can use of unique_ptr make as much sense as wondering whether you can use "while". It's at the core of the language now, and a good habit to take.
I'd be curious to see the "list"...
IIRC, shared_ptr, unique_ptr and make_shared are C++X11, make_unique is X14.
auto_ptr (now deprecated) can be a replacement if unique_ptr is unavailable. It's C++98, so even with a VERY old compiler, it should be available.
Well, the more you use modern functions, the more they're linked to templates, and verbosity increase...
This is what I get if I miss the liaison with C++ standard library:
I think it can scare newcomers...Code:/tmp/ccq8d3Hg.o: In function `std::_MakeUniq<int>::__single_object std::make_unique<int, int>(int&&)': unique.cxx:(.text._ZSt11make_uniqueIiIiEENSt9_MakeUniqIT_E15__single_objectEDpOT0_[_ZSt11make_uniqueIiIiEENSt9_MakeUniqIT_E15__single_objectEDpOT0_]+0x25): undefined reference to `operator new(unsigned long)' /tmp/ccq8d3Hg.o: In function `std::default_delete<int>::operator()(int*) const': unique.cxx:(.text._ZNKSt14default_deleteIiEclEPi[_ZNKSt14default_deleteIiEclEPi]+0x18): undefined reference to `operator delete(void*)' /tmp/ccq8d3Hg.o:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0' collect2: error: ld returned 1 exit status
Sure, but getting high performance out of C++ isn't really the problem most people have with it, so I assume that's not what the poster was referring to. More likely it was about memory leaks, memory corruption, managing memory so it's deleted at the right time, that kind of thing.
Those kinds of issues are almost non-existant in modern C++.
You can start by just making the following trivial change
Code:// old way Foo *f = new Foo(1, 2, 3); // new way auto f = std::make_unique<Foo>(1, 2, 3);
everywhere in your code, and fixing compiler errors that result to make it work. In the process you'll learn about move semantics as well.
From there you can audit your codebase for uses of new, and think "how can I eliminate this new?" You will almost always find a way, and probably learn a bunch of stuff along the way
Isn't this basically garbage collection in C++? Seems blasphemous.
Anyway, this appears to be similar to the factory pattern which helps you decouple instantiation of objects from the code that uses them. It's quite handy.
https://en.m.wikipedia.org/wiki/Factory_method_pattern
Nope. And it won't take long to learn anyway.Is today's developer absolutely screwed for the future if they don't know Javascript?
thanks bros
I suggest avoiding QA. You may not even be doing any scripting at all, and even if you are doing it it will likely be secondary to your standard role.
As someone who is very new to software dev, I want to get all of y'alls wisdom on technology and languages and tools and outlook.
How about for an internship? I definitely plan to work in dev as soon as possible, but I want to build some experience before I apply in earnest.
No reason to avoid a dev role to be honest. I knew absolutely nothing about SQL for instance when I got my co-op and I learned a fuck load on the job. Definitely more than I ever learned in college.
No, it's a linkage problem, not a compilation one. gcc compile C++ programs, but link them with libC not libC++. It's the result of not passing -lstdc++ (or using g++ instead of gcc).I don't use gcc, is this the result of not passing -std=c++11, or something else?
No more than the fact that an int or an int[] get deleted when you exit the scope...Isn't this basically garbage collection in C++?
Learn Java/C# if you want stable jobs that might be seen as boring and unsexy but bring a steady paycheck. Good if you want to settle down and thinking about starting a family. Both languages are here to stay for god knows how long, so no worries your skills will soon be obsolete.As someone who is very new to software dev, I want to get all of y'alls wisdom on technology and languages and tools and outlook.
I'm afraid to get into mobile development as the Android and iOS app scene hardly seems stable. That being said, if the tools used to code said apps are easily transferable to more traditional applications, then that isn't so bad.
I've heard mixed reactions about web development. But it seems that that is here to stay. Since I hardly know anything about front vs. back end, I'll probably go full-stack.
Oh boy. Gonna have my first job interview next Wednesday. I hope I can keep my nerves under control, otherwise it's gonna be an embarrassing disaster.
It was alright. I was nervous and said a few stupid things, but it wasn't as bad as it could have been. They think I'd be a good fit for the company, they said, and I have a "high chance" to be hired. They're gonna tell me their decision next Wednesday.
The company sounded pretty cool. Personal atmosphere, flat hierarchy, training opportunities, a lot of freedom, nice perks, and the best view in town. It's mainly Java Enterprise stuff, but they also use other languages and technologies from time to time. I'm fine with that.
It's not so much that I'm avoiding dev, but I already have an offer for a QA role (which I haven't accepted yet). So I'm debating whether I should accept it, and learn on my own time. Or reject it, and try to find a dev internship that I'm likely underqualified for (I've interviewed for a few coding internships, but haven't landed a single offer).
Learn Java/C# if you want stable jobs that might be seen as boring and unsexy but bring a steady paycheck. Good if you want to settle down and thinking about starting a family. Both languages are here to stay for god knows how long, so no worries your skills will soon be obsolete.
Learn Python and Javascript for the sexy startup jobs at companies that promise you they will become the next facebook and will pay you in stock that might be worth nothing. Also be prepared to work insane hours. Good if you are in your twenties with no obligations.
Whatever you do, learn the basics of SQL and databases. Postgres is probably the best bet, unless you decide to learn C#, then go for SQL Server.
Well, now it's Monday afternoon the week after. No call. I'm getting antsy.
No more C/C++ love? T_T
I do wonder how the industry will adapt to the large number of experienced C/C++ developers retiring in the near future. Don't C/C++ developers tend to be older on average?No more C/C++ love? T_T
I do wonder how the industry will adapt to the large number of experienced C/C++ developers retiring in the near future. Don't C/C++ developers tend to be older on average?
Move on to better languages that can interop with C++.I do wonder how the industry will adapt to the large number of experienced C/C++ developers retiring in the near future. Don't C/C++ developers tend to be older on average?
Question
char stuff[2][3] = { data };
&stuff = address of where array starts, right?
&stuff[0] = first array's start address?
&stuff[3] = second array's start address?
Funilly enough, I can't find a reference (pun not intended) that confirms it works...Question
char stuff[2][3] = { data };
&stuff = address of where array starts, right?
Same problem... stuff (and stuff[0] ) already are the "first" array start address.&stuff[0] = first array's start address?
[1], definitively not [3]&stuff[3] = second array's start address?
White theme. Of course.
Tools > OptionsMostly because I'm too lazy to change to a dark theme. My NeoGAF theme is dark because it only requires 1 click
It's easy to check that something doesn't work, but when it seems to work, I still want to understand why.This is easy to check with a debugger.
2D arrays in C are just 1D arrays in memory...Wouldn't the address for a multi dim array be &&stuff?
int t[2][3];
t, t[0] or &t[0][0] -> 0x76534 : 00 <- t[0][0]
-> 0x76538 : 01 <- t[0][1]
-> 0x7653C : 02 <- t[0][2]
t[1] or &t[1][0] -> 0x76540 : 10 <- t[1][0]
-> 0x76544 : 11 <- t[1][1]
-> 0x76548 : 12 <- t[1][2]
int t[2][3];
int t[][3];
int* t[2];
It's easy to check that something doesn't work, but when it seems to work, I still want to understand why.
I can't find what happen in the simple case of using &a when a is declared as int a[10]... I expect the & to do nothing, but I'd like to see written somewhere. Already checked several books (unfortunately, I don't have many on hand), such as K&R, and I can't find anything on this.
Can you help me getting some sleep this night?
1.8.6 Unless an object is a bit-field or a base class subobject of zero size, the address of that object is the address of the first byte it occupies. Two objects that are not bit-fields may have the same address if one is a subobject of the other, or if at least one is a base class subobject of zero size and they are of different types; otherwise, they shall have distinct addresses.
4.2 Array-to-pointer conversion [conv.array]
1 An expression of type “array of N T”, “array of runtime bound of T”, or “array of unknown bound of T” can be converted to a prvalue of type “pointer to T”. The result is a pointer to the first element of the array
It's easy to check that something doesn't work, but when it seems to work, I still want to understand why.
I can't find what happen in the simple case of using &a when a is declared as int a[10]... I expect the & to do nothing, but I'd like to see written somewhere. Already checked several books (unfortunately, I don't have many on hand), such as K&R, and I can't find anything on this.
Can you help me getting some sleep this night?
Thanks...http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf
In the case of "int a[10]", these two show directly that a == &a. For the first element, obviously the first byte is part of the representation of the first element, so again by 1.8.6, &a[0] is a pointer to the first byte of a[0], and thus is equal to &a and a.
Nice...a is the same as a[0]. a[0] is the same as *(a+0). Thus, &a = &a[0] = &(*(a+0)) = a+0 = a.
Thanks...
I couldn't see how &a could be different from a, but it's interesting to see how it works.
I still think it's a bit strange to use & on a...
(and if you're picky, they're not totally "equals", since they're of different type, even if they're both pointers and hold the same adress... the compiler will refuse a == &a)
Nice...
That could be convincing, but with the same proof, you could expect that either &(&a) or &&a would work.
&(&a) = &(&a[0]) = &(&(*(a+0))) = &(&(*(a+0))) = &(a+0) = &a = &a[0] = &(*(a+0)) = a+0 = a
They're not, though...
I know, that's just a reason to be careful with this kind of "proof" (although if it's allowed, it should at least prove that it can't have a different result)That's because you can't take the address of an rvalue.
Thanks for all the help and interesting discussion
Where is a good source on how to learn the Visual Studio debugger on issues like this?
I'll take an advance reference if there's one you'd recommand.There are some really good books about debugging, but most of them are a bit more advanced.
Head First JavaHey guys, looking for advice on a good book to learn Java.
I used to program in Java in college years ago so I do understand the basic gist but it's been a long time and now I think I need to get back into it. I can program in Python and a little Javascript too.
I have purchased paperback "The Pragmatic Programmer" and "Growing Object-Oriented Software Guided by Tests" from Amazon so I'll have them I think by the middle of next month.
I have "Clean Code" by Robert C Martin in PDF format and also Gang of Four Design Patterns in PDF.
So far I haven't read any of these yet so I'll spend the next year or so going through them.
Can anyone recommend a good general book for Java or I suppose what is generally considered the "best" Java book? I suppose I'm sort of a beginner because I haven't used it in a long time and only used it to a basic level.
I'll take an advance reference if there's one you'd recommand.
I'm used to debuggers, but I've never thought about buying a book on this topic.