Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old Yesterday, 10:18 AM   #32476
gaming_mouse
Carpal \'Tunnel
 
gaming_mouse's Avatar
 
Join Date: Oct 2004
Location: taking notes on u (see profile)
Posts: 13,782
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by goofyballer View Post

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


out of curiosity, what other languages do you like?
gaming_mouse is offline   Reply With Quote
Old Yesterday, 01:39 PM   #32477
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

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.
jmakin is online now   Reply With Quote
Old Yesterday, 03:20 PM   #32478
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,451
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

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.
RustyBrooks is offline   Reply With Quote
Old Yesterday, 03:25 PM   #32479
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,451
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

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)
RustyBrooks is offline   Reply With Quote
Old Yesterday, 03:44 PM   #32480
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

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
jmakin is online now   Reply With Quote
Old Yesterday, 03:51 PM   #32481
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

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.
jmakin is online now   Reply With Quote
Old Yesterday, 06:49 PM   #32482
goofyballer
 
goofyballer's Avatar
 
Join Date: Jun 2005
Posts: 61,904
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by gaming_mouse View Post


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.
goofyballer is offline   Reply With Quote
Old Yesterday, 08:27 PM   #32483
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

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
jmakin is online now   Reply With Quote
Old Yesterday, 09:56 PM   #32484
Grue
Pooh-Bah
 
Grue's Avatar
 
Join Date: Mar 2004
Location: It is pitch black.
Posts: 5,129
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Lots of tools for that. Emmet and auto bracket closer on VSC for one.
Grue is offline   Reply With Quote
Old Yesterday, 11:44 PM   #32485
:::grimReaper:::
veteran
 
:::grimReaper:::'s Avatar
 
Join Date: Jul 2010
Posts: 2,291
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by RustyBrooks View Post
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 View Post
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.
:::grimReaper::: is offline   Reply With Quote
Old Today, 01:16 AM   #32486
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,451
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

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.
RustyBrooks is offline   Reply With Quote
Old Today, 01:30 AM   #32487
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,451
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

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.
RustyBrooks is offline   Reply With Quote
Old Today, 05:09 AM   #32488
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Pardon me for being a moron but why isnt that thread safe?
jmakin is online now   Reply With Quote
Old Today, 08:26 AM   #32489
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,148
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by RustyBrooks View Post
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 View Post
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; Today at 08:39 AM.
adios is offline   Reply With Quote
Old Today, 08:33 AM   #32490
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,148
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by RustyBrooks View Post
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.
adios is offline   Reply With Quote
Old Today, 10:42 AM   #32491
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,451
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by jmakin View Post
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.
RustyBrooks is offline   Reply With Quote
Old Today, 01:13 PM   #32492
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Yikes, thanks for that
jmakin is online now   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 03:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online