Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

04-21-2018 , 10:18 AM
Quote:
Originally Posted by goofyballer

Oh man, I love C++11. Strongly disagree here.


out of curiosity, what other languages do you like?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 01:39 PM
i should start doing the rest of my freq counter assignments this quarter in C++ to prepare for my new job, i just really don't like visual studio and i don't want to go pure text editor with it.

IDE's are the way to go for me, I don't think I can change. A 450 line C program took me about 12 hours last week, most of it debugging stupid run time errors I couldn't find.

I wrote ~1000 lines of java code last night in 4 hours. Eclipse sucks but it tells you exactly where you're ****ing up and auto complete is soooo powerful and having the documentation right there in front of you rather than having to go look up something every time you run into a problem.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 03:20 PM
I don't know how it is for C++ but I like JetBrains products for Python and Java. They have a C++ specific one too. Both pycharms (python) and intellij (java) have some support for other languages, so I know for example that pycharms recognizes C and C++ system and does some basic highlighting, but I don't think it does much correctness checking, or symbol lookup, or stuff like that.

Until a few years ago I never used IDEs which was partly that IDEs sucked for most of my career and partly stubbornness. But yeah your cycle time gets cut way down because now I never make stupid spelling mistakes or errant commas and stuff like that. Those are especially annoying when it takes a few minutes to get a program running to the point where your bug occurs. The refactoring tools are nice too, especially since I am terrible at naming everything.


Regarding C++ and it's undefined behaviors, they are many. I am not sure I want to get into it here, but they are so numerous that the standard actually defines multiple classes of them.
http://en.cppreference.com/w/cpp/language/ub

C++ compilers are allowed to have behaviors that differ between them as long as they're documented. Holy ****, good luck with your cross-platform project.

Then there's "unspecified behavior" where what you're doing isn't explicitly covered by the spec, but you will get *one* of the possible valid results. You may get a different one if you turn optimization on! A good example of these are order-of-operations, which have somewhat complex and subtle problems, especially in multi-threaded programs. I think most C++ programmers probably know that a single line of C++ is not necessarily going to be atomic in a multi-threaded environment, but because a single line might be 3 or 4 atomic operations, the order those operations happen in might have weird results in a multi threaded environment. There's a good example here (the double-checked locking example):
https://stackoverflow.com/a/367690

Another favorite of mine is that
foo(a(), b())
it is not necessarily the case that a() will be called before b()

And finally there's undefined behavior where the compiler is literally allowed to produce whatever nonsense it wants. Most of these are mistakes by the programmer but a lot of them will look like pretty valid code, or actually will be valid except for some edge cases in input parameters.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 03:25 PM
I should note that a lot of C++ problems can be caught by using -Wall on most compilers, and a lot more can be caught with static analysis tools, and if you're working on a big important project you should probably be using both. A good code coverage tool can be useful too (and some static analysis tools do both, including branch coverage, which is super useful but still not perfect)

I have to admit I have spent a lot of god damn time on differences between compilers. I finally started using llvm for everything, and when possible, using the same version. I haven't (yet) come across cross-platform problems this way. But also holy **** it's a pain in the ass to do this on windows. (and man, the MSVC compiler is Very Very Far from interoperability with llvm or even gcc. Hope you like lots of #defines)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 03:44 PM
Yea, I hate the fact using a text editor that an errant comma, slightly mispelled word or misplaced symbol like an i == 3 (stuff the compiler doesn't mind) can cause a bug that takes way too long to find sometimes.

most IDE's will tell you "hey, that's stupid" and can even catch the == error.

i know there's probably a way to do stuff like this in VIM but even so just pressing "ctrl - space" and getting a list of things i can refer to with that object is so great. then press space one more time and it auto fills it for you (in eclipse). It usually does a pretty good job of guessing what you're trying to do before you do it.

then clicking the error symbol on the side and having it fix your error for you, and most of the time it can. i'm prone to stupid errors so that kind of stuff really helps me. maybe as i become a stronger programmer i wont need those kinds of tools.

For instance the bad java program I wrote last night would’ve taken me 30 years in a text editor because of all the bad typecasting everywhere and complicated method calls
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 03:51 PM
I’ve been wanting to check out IntelliJ for a while but it’s So ingrained and comfortable to me I haven’t yet. Sometimes I write C++ in eclipse, Lol.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 06:49 PM
Quote:
Originally Posted by gaming_mouse


out of curiosity, what other languages do you like?
JS/TS and Go (though it's still young) are probably my other favorites that I've used.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 08:27 PM
Writing html by hand has to be the purest form of hell. Wysiwyg tools not allowed for this site i have to build by monday
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 09:56 PM
Lots of tools for that. Emmet and auto bracket closer on VSC for one.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-21-2018 , 11:44 PM
Quote:
Originally Posted by RustyBrooks
Another favorite of mine is that
foo(a(), b())
it is not necessarily the case that a() will be called before b()
What you're calling undefined behavior here, I call poor programming. If it's necessary for a() to be called first, then it should be explicit:

x = a();
y = b();
foo(x, y);

If a() and b() can't be renamed to convey this, then this code also requires a comment so that future programmers don't repeat the same mistake.


Quote:
Originally Posted by RustyBrooks
And finally there's undefined behavior where the compiler is literally allowed to produce whatever nonsense it wants. Most of these are mistakes by the programmer but a lot of them will look like pretty valid code, or actually will be valid except for some edge cases in input parameters.
Compilers, programmers and language designers are separate entities. The language can't be blamed for poor compilers or programmers.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-22-2018 , 01:16 AM
It isn't so much about what is "necessary" as it is about mental load. If you have to examine every line of your code to root out potential order of operations problems, you're going to be less productive. The language holds you hostage. Did you look at that link? I mean, that is some bull****. I specifically mean the
Code:
A* a = new A("plop");
This is not a thread-safe line of code! That is ridiculous.

Don't get me wrong - I like C++, it's my language of choice. And it is ****ing *ridden* with pitfalls like this.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-22-2018 , 01:30 AM
The language standard literally allows for these situations. The fact that MSVC, gcc, clang, etc have undefined behavior is not because they're ****ty compilers, it's because the language standard allows for compilable code that produces undefined results

ETA: maybe I should be more clear. The language is designed to value speed over correctness. This is a fine tradeoff if you're willing to make it. In the context of languages to teach to beginners, it makes it an extremely poor choice.

It would be better to teach new programmers a completely unsafe language, like RISC assembly, than one that looks sane but actually is waiting to **** you at the first opportunity.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-22-2018 , 05:09 AM
Pardon me for being a moron but why isnt that thread safe?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-22-2018 , 08:26 AM
Quote:
Originally Posted by RustyBrooks
It isn't so much about what is "necessary" as it is about mental load. If you have to examine every line of your code to root out potential order of operations problems, you're going to be less productive. The language holds you hostage. Did you look at that link? I mean, that is some bull****. I specifically mean the
Code:
A* a = new A("plop");
This is not a thread-safe line of code! That is ridiculous.

Don't get me wrong - I like C++, it's my language of choice. And it is ****ing *ridden* with pitfalls like this.
Quote:
Originally Posted by jmakin
Pardon me for being a moron but why isnt that thread safe?
Yes it is only one line of code in one thread where we have an automatic var declaration i.e. the point needs more explanation.

C++ 11 introduced a concurrency model into the language. This article discusses issues with using it.

C++ 11 Memory Model

Last edited by adios; 04-22-2018 at 08:39 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-22-2018 , 08:33 AM
Quote:
Originally Posted by RustyBrooks
The language standard literally allows for these situations. The fact that MSVC, gcc, clang, etc have undefined behavior is not because they're ****ty compilers, it's because the language standard allows for compilable code that produces undefined results

ETA: maybe I should be more clear. The language is designed to value speed over correctness. This is a fine tradeoff if you're willing to make it. In the context of languages to teach to beginners, it makes it an extremely poor choice.

It would be better to teach new programmers a completely unsafe language, like RISC assembly, than one that looks sane but actually is waiting to **** you at the first opportunity.
If one really was targeting doing a lot of "close to the machine" type development, I agree that doing some ARM assembly language programming would be a good place to start. FWIW I agree with Rusty, on his critique of C++ vs. higher level programming languages.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-22-2018 , 10:42 AM
Quote:
Originally Posted by jmakin
Pardon me for being a moron but why isnt that thread safe?
So, this is exactly my point.

Read this for more info, the double-checked locking example
https://stackoverflow.com/questions/.../367690#367690

The first problem is, as he mentions, that 3 things happen here:
memory is allocated
constructor is called
assignment is made

but the last 2 operations do not have a fixed guaranteed order, so the assignment can be made *before* the object is constructed. If another thread is checking (a == null) in preparation to *use* it, it could use an uninitialized object. You have to break the line into 2 pieces using a temporary variable to guarantee ordering.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-22-2018 , 01:13 PM
Yikes, thanks for that
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-23-2018 , 01:26 PM
Quote:
Originally Posted by RustyBrooks
but the last 2 operations do not have a fixed guaranteed order, so the assignment can be made *before* the object is constructed. If another thread is checking (a == null) in preparation to *use* it, it could use an uninitialized object. You have to break the line into 2 pieces using a temporary variable to guarantee ordering.
I'm kinda confused about why that code isn't safe too, main reason is the bolded - of the 3 things that happen, would any of them not be done by the time you pass the 'a' variable (which was just declared) to another thread for it to use?

(for the example you're talking about, is it more like if 'A* a = ...' was instead a member variable that was already declared getting assigned, while another thread was checking it?)

(but yeah I don't **** with multithreading without liberal use of std::atomic and/or std::lock_guard)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-23-2018 , 10:01 PM
so i started my job today and i'm definitely going to be programming. I need to learn Spark/Scala and read a book on Hadoop.

I looked at the org chart and my position is definitely management, before I kind of was suspicious it was just a title.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-23-2018 , 10:18 PM
Quote:
Originally Posted by goofyballer
I'm kinda confused about why that code isn't safe too, main reason is the bolded - of the 3 things that happen, would any of them not be done by the time you pass the 'a' variable (which was just declared) to another thread for it to use?

(for the example you're talking about, is it more like if 'A* a = ...' was instead a member variable that was already declared getting assigned, while another thread was checking it?)

(but yeah I don't **** with multithreading without liberal use of std::atomic and/or std::lock_guard)
The example was not quite right, probably, it's more like you have some shared variable that you already declared, i.e.
A* a;
and later you want to say
a = new A("plop")

Variables aren't "passed" between threads in C++, scoping rules apply across threads so for example a global will be shared across threads. So if one thread is supposed to initialize "a" at some point and the other is going to do something with it, then you get the problem in the link, where the creator has to jump through extra hoops so that the user doesn't accidentally try to use an uninitialized variable.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-24-2018 , 01:29 AM
Quote:
Originally Posted by jmakin
I need to learn Spark/Scala
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-24-2018 , 10:25 AM
Quote:
Originally Posted by jmakin
so i started my job today and i'm definitely going to be programming. I need to learn Spark/Scala and read a book on Hadoop.
Nice. Good times!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-24-2018 , 08:16 PM
That feel when you leave work without pushing changes to your side project, and you want to work on it from home but now you can't.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-24-2018 , 09:08 PM
Sounds like a good time to start a new branch.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-24-2018 , 09:08 PM
Lol i think I've been given a suicide mission.

I have 8 weeks to catch up on all three of the company's projects and develop a sprint system with my boss. their current system is to just post issues on github and the devs work on things at their choosing. for like the last 5 years.

it's kind of amazing they've gotten this far, they're really talented
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m