When I was a kid I had this adventure book where this group of teenagers end up ensnared in some mad scientist's scheme and at several points throughout it they have some problem they need to solve, and just happen to have access to a computer and BASIC and the book pauses and tells you go write a program to solve it. In the back of the book it had example programs that solve it. Like, one was the matchstick game. I forget what the others were. Anybody ever read those?
When I was a kid I had this adventure book where this group of teenagers end up ensnared in some mad scientist's scheme and at several points throughout it they have some problem they need to solve, and just happen to have access to a computer and BASIC and the book pauses and tells you go write a program to solve it. In the back of the book it had example programs that solve it. Like, one was the matchstick game. I forget what the others were. Anybody ever read those?
Holy shit, no. I had tons of those Choose Your Own Adventure books... but this I've never seen. I want this book.
I think it may have been the Micro Adventure series, though I only ever read the one, and at the time I was only in it for the sci-fi geeky adventure stuff and didn't do any of the programming. Occasionally I would try and read the code but only understood a little. These days I really regret not actually firing up QBASIC on our 486 and trying them out. http://grathio.com/2012/12/combining-fiction-and-code-to-teach-programming/
Hey, maybe this here fancy college education is paying off. I just used my knowledge of plain old pure math and applied it to a problem to solve it, all on my own and completely naturally without making a conscious effort to apply math. That's crazy.
The more I refactor this, the more it seems like that about 12/13 of these values are just temporary values used to generate the other 4/5 outputs. In other words, the original code looks something like:
for( int i = 0; i < size; ++i ) d[i] = opA( a[i], b[i], c[i] );
for( int i = 0; i < size; ++i ) e[i] = opB( d[i] );
for( int i = 0; i < size; ++i ) f[i] = opC( e[i] );
for( int i = 0; i < size; ++i ) g[i] = opD( f[i] );
... etc ...
... I might be able to simplify the life out of it (and reduce storage requirements) just by doing one big loop instead of many smaller ones. I'm... just... flabbergasted.
Normally, I'd say that I've missed something, but right now... I'm not so certain...
What's the best way to support Python 2.6, 2.7 and 3.0 (32 and 64 bit) all at the same time?
I have not actually bothered to try, but in general, some combo of `from __future__ import <blah blah blah>` and six is pretty much the standard for 2.6+ and 3.x support. For 32 and 64 bit... are you writing libs where some of the code is in C or C++ or just pure Python? Pure Python should just work.
The more I refactor this, the more it seems like that about 12/13 of these values are just temporary values used to generate the other 4/5 outputs. In other words, the original code looks something like:
for( int i = 0; i < size; ++i ) d[i] = opA( a[i], b[i], c[i] );
for( int i = 0; i < size; ++i ) e[i] = opB( d[i] );
for( int i = 0; i < size; ++i ) f[i] = opC( e[i] );
for( int i = 0; i < size; ++i ) g[i] = opD( f[i] );
... etc ...
... I might be able to simplify the life out of it (and reduce storage requirements) just by doing one big loop instead of many smaller ones. I'm... just... flabbergasted.
Normally, I'd say that I've missed something, but right now... I'm not so certain...
Yeah, that's... special
Why can't they do that stuff in just one loop?
Also, your original idea of a vector of a struct with the five doubles in it seems like a good one. I kind of doubt the original author was optimizing for cache locality and even if they were, they probably shouldn't have been. Putting them in one vector saves you 4x the amount of memory bookkeeping (as performed by std::vector).
If the data sets are really big, consolidating to one vector of one structs will also (probably) gain you performance on vector insert/deletes. Modern implementations of STL (i.e. C++11 or later) finally have the smarts to special case POD types so that it will move them around using memcpy/memmove. And on most platforms those will be really fast. They'll either be implemented as compiler magic and/or SIMD-optimized asm code.
The more I refactor this, the more it seems like that about 12/13 of these values are just temporary values used to generate the other 4/5 outputs. In other words, the original code looks something like:
for( int i = 0; i < size; ++i ) d[i] = opA( a[i], b[i], c[i] );
for( int i = 0; i < size; ++i ) e[i] = opB( d[i] );
for( int i = 0; i < size; ++i ) f[i] = opC( e[i] );
for( int i = 0; i < size; ++i ) g[i] = opD( f[i] );
... etc ...
... I might be able to simplify the life out of it (and reduce storage requirements) just by doing one big loop instead of many smaller ones. I'm... just... flabbergasted.
Normally, I'd say that I've missed something, but right now... I'm not so certain...
That is not the code of someone who understands programming. That is the code of someone who can identify patterns and copy them to get desired results.
identify patterns and copy them to get desired results.
Sounds like a plan! ;-)
Two of my coworkers are leaving their positions this month. The first is moving to PM next week, and should be good for her, imo.
The second accepted an offer at another company to help them get started in automating tests. They told him that he would become a manager or something, once the framework is all set up, and they hire a few engineers under him in a couple years? I just really hope he got that in writing because that sound suspiciously like it will go unfulfilled, and was one of the major factors of him accepting the offer. He at least was told the could work from home once a week, and they sounded pretty lax on PTO
It is in the same boat as PHP, where there are solutions and good practices and books, but is haunted by the shit devs that have left an amazing legacy out there.
Related: I'm currently attempting to tell someone on SO to ditch WordPress because it's fucking horrid, and some dude who apparently makes a living with that pile of shit is getting defensive. Sorry, dude, but The Loop is idiotic outside of a simple blog format, and globals everywhere is both idiotic and dangerous.
PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948 Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
Also, your original idea of a vector of a struct with the five doubles in it seems like a good one. I kind of doubt the original author was optimizing for cache locality and even if they were, they probably shouldn't have been. Putting them in one vector saves you 4x the amount of memory bookkeeping (as performed by std::vector).
If the data sets are really big, consolidating to one vector of one structs will also (probably) gain you performance on vector insert/deletes. Modern implementations of STL (i.e. C++11 or later) finally have the smarts to special case POD types so that it will move them around using memcpy/memmove. And on most platforms those will be really fast. They'll either be implemented as compiler magic and/or SIMD-optimized asm code.
std::vector bookkeeping overhead is generally not a significant concern as it is ~128bits iirc. As far as the SIMD-optimization it really depends on the usage of the vectors inside the function. If the functions are doing something simple like:
d[i]= a[i]*b[i]+c[i];
Than the current layout is preferred, and moving to something like boost::simd::pack<T> is fairly trivial.
Cross-compiling Boost to an uncommon platform (MIPS64) sucks balls.
0
GnomeTankWhat the what?Portland, OregonRegistered Userregular
So I bought my own license to ReSharper Ultimate last night. I own licenses for WebStorm and RubyMine, and I don't mind giving JetBrains money. ReSharper Ultimate is pretty nice, it's ReSharper, dotTrace, dotMemory, dotDover and ReSharper C++ in one package. It's not cheap (249 for the single developer license), but I use ReSharper so much, and I'm tired of uhh "borrowing" my work license.
So I bought my own license to ReSharper Ultimate last night. I own licenses for WebStorm and RubyMine, and I don't mind giving JetBrains money. ReSharper Ultimate is pretty nice, it's ReSharper, dotTrace, dotMemory, dotDover and ReSharper C++ in one package. It's not cheap (249 for the single developer license), but I use ReSharper so much, and I'm tired of uhh "borrowing" my work license.
What does it add over Visual Studio?
Genuinely curious about that.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
0
admanbunionize your workplaceSeattle, WARegistered Userregular
I only remember one thing from my one-month trial of ReSharper and it's Sublime-style file switching.
So I bought my own license to ReSharper Ultimate last night. I own licenses for WebStorm and RubyMine, and I don't mind giving JetBrains money. ReSharper Ultimate is pretty nice, it's ReSharper, dotTrace, dotMemory, dotDover and ReSharper C++ in one package. It's not cheap (249 for the single developer license), but I use ReSharper so much, and I'm tired of uhh "borrowing" my work license.
What does it add over Visual Studio?
Genuinely curious about that.
ReSharper? Oh man, I can't even begin to describe everything it does over the top of Visual Studio. It's one of those things that you have to use it to fully understand, and once you've used it, it's rare to want to go back. The real obvious additions are much improved refactoring tools, a unit test runner that blows Microsoft's out of the water, much better code formatting support, in-line code suggestions (such as suggestions to fix overnesting, or to convert a foreach in to a cleaner LINQ expression)...the list goes on and on. It just takes everything that makes Visual Studio a top notch C# environment and turns it to 11.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
0
GnomeTankWhat the what?Portland, OregonRegistered Userregular
edited April 2015
The only caveat to ReSharper I have is that it's not a slouch on CPU and memory usage, because it does quite a bit of static analysis and code tree walking, so if your development machine is under powered, it can cause Visual Studio to be a touch more sluggish than normal. Both at work and at home I have i7 machines with 16GB of RAM for development, so I don't notice...but people on older CPU's with 4GB of RAM, or developing on a VM in an over utilized farm, might notice some sluggishness from Visual Studio with ReSharper going.
large, universally purposeful javascript libraries which have been written in such a fashion that they can only operate on a Node.JS server and not inside of a browser window for no reason at all are the reason the guy at the liquor store knows my name
large, universally purposeful javascript libraries which have been written in such a fashion that they can only operate on a Node.JS server and not inside of a browser window for no reason at all are the reason the guy at the liquor store knows my name
It's probably more that the developer is making use of ES5 features, something he can be guaranteed exist in Node, but not in a browser. Having to do all the polyfilling and/or code refactoring required to support browsers it not always something people want to do.
large, universally purposeful javascript libraries which have been written in such a fashion that they can only operate on a Node.JS server and not inside of a browser window for no reason at all are the reason the guy at the liquor store knows my name
It's probably more that the developer is making use of ES5 features, something he can be guaranteed exist in Node, but not in a browser. Having to do all the polyfilling and/or code refactoring required to support browsers it not always something people want to do.
This is correct. It's ES5 related. I am fortunate enough to be able to tell clients that they can't use stupid browsers tho.
I just feel like there's a way to make these things more universal so that I don't have to run a browserify task and then monkeypatch the file to be window compatible
like.... write your functionality agnostically and then create the appropriate node/browser setups or something
been feeling pretty good about my excel formula resolver. its nice and recursive, got a few basic math functions wired up
then I got to IF.... no problem, just a few extra tokens to keep an eye out for
and then. and then it happened.
"A1=3=D4" is a thing that could happen
this will not be solved at 4:40PM no sir
the formula.js lib has an "IF" helper... but that code just looks... wrong. very wrong. or dependent on some other function that is not in the comments to properly format the logical expression
0
admanbunionize your workplaceSeattle, WARegistered Userregular
edited April 2015
Being called in to debug/fix something in a demo environment and finding out they turned off all the environment VMs.
There are at least 4 physical positions in this system, not including any of the virtual positions.
The variable name is so vague as to be meaningless, and worst case misleading.
Edit:
Protip for Programmers
What is obvious right now in the heat of the moment will not be obvious in a few week's time when you/someone else revisits the code.
Either comment the code, or make it so that there's no ambiguity in your variable/function names.
Personal Opinion: A difference between a good developer and a crappy code monkey is the bolded - you write code not just to solve the immediate problem, but also think about maintenance and how it will interact with other code/people.
This is what I just found. This also has many associated multiple levels of fail - ignoring the obvious WTFs there:
1.) This was inside a header file for an unrelated class. What the header file for a class is doing controlling network output is a mystery.
2.) A "Find in Files" indicates that nothing else references this. Why is this even here in the first place?*
3.) Placed without decoration in a namespace shared between multiple classes. Whhhhy? Why would you hurt another developer and stop them using those names like this?
Thankfully, due to #2, I can just nuke it from orbit.
*sigh*
This day is going to be so good when it's over.
* Yes, it was probably used at one stage. And now it's just leftovers. Should have been removed when the functions that were using it were removed.
EDIT #2:
Hey, guess what I just found by going down a few lines:
Posts
http://grathio.com/2012/12/combining-fiction-and-code-to-teach-programming/
Based on his scripts that I've examined, I would very much doubt his perl abilities...
The more I refactor this, the more it seems like that about 12/13 of these values are just temporary values used to generate the other 4/5 outputs. In other words, the original code looks something like:
... I might be able to simplify the life out of it (and reduce storage requirements) just by doing one big loop instead of many smaller ones. I'm... just... flabbergasted.
Normally, I'd say that I've missed something, but right now... I'm not so certain...
I have not actually bothered to try, but in general, some combo of `from __future__ import <blah blah blah>` and six is pretty much the standard for 2.6+ and 3.x support. For 32 and 64 bit... are you writing libs where some of the code is in C or C++ or just pure Python? Pure Python should just work.
Yeah, that's... special
Why can't they do that stuff in just one loop?
Also, your original idea of a vector of a struct with the five doubles in it seems like a good one. I kind of doubt the original author was optimizing for cache locality and even if they were, they probably shouldn't have been. Putting them in one vector saves you 4x the amount of memory bookkeeping (as performed by std::vector).
If the data sets are really big, consolidating to one vector of one structs will also (probably) gain you performance on vector insert/deletes. Modern implementations of STL (i.e. C++11 or later) finally have the smarts to special case POD types so that it will move them around using memcpy/memmove. And on most platforms those will be really fast. They'll either be implemented as compiler magic and/or SIMD-optimized asm code.
That is not the code of someone who understands programming. That is the code of someone who can identify patterns and copy them to get desired results.
I just found this:
unsigned validPts =0; ... if(validPts < 1) validPts = 0;*sob*
Shut it down, forever...
...
It's hard to believe people fail FizzBuzz until you start reading their code.
Sorry for dumping all this into the thread like this
It's just that I need to vent. =(
I hope that some of you get a chuckle out of this, at least!
Two of my coworkers are leaving their positions this month. The first is moving to PM next week, and should be good for her, imo.
The second accepted an offer at another company to help them get started in automating tests. They told him that he would become a manager or something, once the framework is all set up, and they hire a few engineers under him in a couple years? I just really hope he got that in writing because that sound suspiciously like it will go unfulfilled, and was one of the major factors of him accepting the offer. He at least was told the could work from home once a week, and they sounded pretty lax on PTO
Listen, just because it says unsigned doesn't really mean it was!
I'm wondering if this variable was signed at one point and that was an artifact that got left in when it was.
Related: I'm currently attempting to tell someone on SO to ditch WordPress because it's fucking horrid, and some dude who apparently makes a living with that pile of shit is getting defensive. Sorry, dude, but The Loop is idiotic outside of a simple blog format, and globals everywhere is both idiotic and dangerous.
Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
std::vector bookkeeping overhead is generally not a significant concern as it is ~128bits iirc. As far as the SIMD-optimization it really depends on the usage of the vectors inside the function. If the functions are doing something simple like:
Than the current layout is preferred, and moving to something like boost::simd::pack<T> is fairly trivial.
What does it add over Visual Studio?
Genuinely curious about that.
Which is basically cocaine to me.
ReSharper? Oh man, I can't even begin to describe everything it does over the top of Visual Studio. It's one of those things that you have to use it to fully understand, and once you've used it, it's rare to want to go back. The real obvious additions are much improved refactoring tools, a unit test runner that blows Microsoft's out of the water, much better code formatting support, in-line code suggestions (such as suggestions to fix overnesting, or to convert a foreach in to a cleaner LINQ expression)...the list goes on and on. It just takes everything that makes Visual Studio a top notch C# environment and turns it to 11.
I might be good!
large, universally purposeful javascript libraries which have been written in such a fashion that they can only operate on a Node.JS server and not inside of a browser window for no reason at all are the reason the guy at the liquor store knows my name
I hate that hat, but I only have to wear it about 5% of the time. What are you doing that requires so much writing?
It just feels like it takes forever.
Doing a 24/7 data conversion for another thing and not getting much sleep. Just work up from nap.
It's probably more that the developer is making use of ES5 features, something he can be guaranteed exist in Node, but not in a browser. Having to do all the polyfilling and/or code refactoring required to support browsers it not always something people want to do.
I see what you did there ;-)
This is correct. It's ES5 related. I am fortunate enough to be able to tell clients that they can't use stupid browsers tho.
I just feel like there's a way to make these things more universal so that I don't have to run a browserify task and then monkeypatch the file to be window compatible
like.... write your functionality agnostically and then create the appropriate node/browser setups or something
then I got to IF.... no problem, just a few extra tokens to keep an eye out for
and then. and then it happened.
"A1=3=D4" is a thing that could happen
this will not be solved at 4:40PM no sir
the formula.js lib has an "IF" helper... but that code just looks... wrong. very wrong. or dependent on some other function that is not in the comments to properly format the logical expression
#justthursdaythings
edit: WHY SINUSES, WHY
Better variable names man
What the heck is "position" referring to?
There are at least 4 physical positions in this system, not including any of the virtual positions.
The variable name is so vague as to be meaningless, and worst case misleading.
Edit:
Protip for Programmers
What is obvious right now in the heat of the moment will not be obvious in a few week's time when you/someone else revisits the code.
Either comment the code, or make it so that there's no ambiguity in your variable/function names.
Personal Opinion: A difference between a good developer and a crappy code monkey is the bolded - you write code not just to solve the immediate problem, but also think about maintenance and how it will interact with other code/people.
I kid you guys not.
This is what I just found. This also has many associated multiple levels of fail - ignoring the obvious WTFs there:
1.) This was inside a header file for an unrelated class. What the header file for a class is doing controlling network output is a mystery.
2.) A "Find in Files" indicates that nothing else references this. Why is this even here in the first place?*
3.) Placed without decoration in a namespace shared between multiple classes. Whhhhy? Why would you hurt another developer and stop them using those names like this?
Thankfully, due to #2, I can just nuke it from orbit.
*sigh*
This day is going to be so good when it's over.
* Yes, it was probably used at one stage. And now it's just leftovers. Should have been removed when the functions that were using it were removed.
EDIT #2:
Hey, guess what I just found by going down a few lines:
Well done whoever wrote this. Well done.