Domain: stackoverflow.com
Stories and comments across the archive that link to stackoverflow.com.
Comments · 921
-
Microsoft SQL Server
Or Microsoft SQL Server, whose T-SQL query language appears to have a fairly active question and answer community on Stack Overflow.
-
Rounding already sacrifices associativity
Assuming 0/0=1 gives you inconsistent outcomes unless you're willing to sacrifice associativity of multiplication and division.
Rounding of floating-point multiplication and integer and floating-point division already sacrifices associativity. See legendary a*a*a*a*a*a question on Stack Overflow.
-
Re:I want my division by zero errors to be errors
1/0 is indeed infinity.
No, it's undefined.
The 754 model encourages robust programs. It is intended not only for numerical analysts but also for spreadsheet users, database systems, or even coffee pots. The propagation rules for NaNs and infinities allow inconsequential exceptions to vanish. Similarly, gradual underflow maintains error properties over a precision's range.
http://stackoverflow.com/quest...
The IEEE 754 model treats 0 as very small positive numbers, resulting in infinity when you do divide by zero. Of course, that hack results in much more robust and safer programs as you don't have to deal with (dozens/hundreds) of exceptions in a program.
INT_MAX and INT_MIN are not infinity and would be dangerous incorrect to treat them as such
It is a very rare program that has INT_MAX/INT_MIN as valid values. If your program even reaches close to INT32_MAX/MIN, you usually change the type of variable to a signed 64 bit variable. So, as with IEEE 754, we should have a default value for div by zero by int32 or int64 to allow "inconsequential exceptions to vanish."
-
Wow, they got modules before C++
Surprised they got modules so quickly. Someday modules will eventually make it into C++
...* 2006 http://www.open-std.org/jtc1/s...
* 2014 http://www.open-std.org/jtc1/s...
* 2015 http://www.open-std.org/JTC1/S...
* 2015 (April) https://isocpp.org/files/paper...
* http://www.infoq.com/news/2015...
* http://stackoverflow.com/quest...I see the "use strict" HACK is still optional ("An ECMAScript Script syntactic unit may be processed using either unrestricted or strict mode syntax and semantics. ") but at least in the case of a class is mandatory ("A ClassBody is always strict code.") Someday Javascript will stop being a shitty language. Sadly it won't be this year
... :-/ -
Re:Blame Maven
There's no way to say "I want the latest version of a specific branch" you can only specify a single version. Which means that a project that hasn't changed in years will still pull in the old versions of the libraries, even if it would work with the later versions.
No, Maven does support version ranges: You can say stuff like this: <version>[1.0.0,2.0.0)</version>. Here's a pretty good thread on the subject from StackOverflow.
To be fair, I don't think that most projects do this, but at least it's supported. Also, I'd guess that an analysis of a lot of the other artifact repositories like PyPi, Bower, or npm would produce similar results.
-
Re: PHP is great
My beef with PHP error handling is that certain errors are fatal in PHP that are catchable in Python, such as a syntax error in include_once or a call to an undefined function.
Errors in included files are catchable by running another php interpreter
:function ChkInc($file){
return (substr(exec("php -l $file"), 0, 28) == "No syntax errors detected in");
}See here : stackoverflow
-
Re: BI == Business Idiots
There are three compilers for Go, one based on the Plan 9 stuff, one a GCC front end, and one an LLVM front end. True, none of them use header files, but this is really something that doesn't affect C-family languages if you use precompiled headers. The Plan 9 implementation is fast because it does a tiny subset of the optimisations that GCC or LLVM would do.
This really isn't true. Watch the video I linked. Despite your claim today gccgo is slower than gc in compiled performance. Indeed Go 1.4 has begun to approach Java in microbenchmarks. Most of the C++ slowness comes from the amount of data the compiler has to process due to header files. The reason for this slowness is a well known thing. Try GCC's precompiled headers and be blown away by the difference.
As far as mutability goes, it is extremely easy to enforce... just use an interface. I mean being a clojure programmer I understand your objection, but its never really seemed that much of a problem to me.
-
Re:Due to stupid security warnings, security
Erm, Java has Real-time extensions, so I'm not sure how applicable your rant on medical equipment are. They -apparently- fire frigging missiles with RT-java
http://stackoverflow.com/quest..."it's horrible to program in, but it saves companies from the effects of having truly stupid engineers and even more incompetent managers who don't allow programmers to document their code let alone require it."
Quite the opposite for me. I love Java because I can sit down hammer away at solving problems instead of worrying about bull-shit minutia wasting days of my life writing code I could've solved in an afternoon using Java (though results obviously vary depending on the specific projects involved). This is someone who came from almost entirely C development (never gave C++ a chance and in retrospect, I'm glad from what I hear).
"But a good programmer can accomplish a lot more in a more powerful language."
Details please. How can said individual work more effectively and in which specific languages please? Your single-pointed rant with 0 clarification makes you come off as a troll at best, and an irrationally biased individual at worst. -
Re:bullshit
Implementations try very hard to avoid actually using doubles to implement them for values that are actually integers, because floating point operations are a lot slower than integer ones on modern CPUs
In a general sense, floating point should be slower than integer operations, but in practice it depends on many things including use of cache, multiple cores, SIMD, length of pipelines, compiler optimizations etc.
There's a good discussion of it here:
http://stackoverflow.com/questions/2550281/floating-point-vs-integer-calculations-on-modern-hardwareThe consensus seems to be that it's a wash, and unless you're having noticeable performance problems with FP, there's no reason to favor integer operations.
-
Re:Can they compile from source?
Not only that a lot of source code isn't even reproducible, you can't just check the hash of the resulting file:
-
Re:Yuckhttp://stackoverflow.com/a/245... What's the difference between JavaScript and Java?
One is essentially a toy, designed for writing small pieces of code, and traditionally used and abused by inexperienced programmers.
The other is a scripting language for web browsers.
-
Read Yossef Kreinin's C++ FQA and its rebuttals
You'll get a lot of insights on C++ after doing do.
- http://stackoverflow.com/quest...
-
Re:Yes & the sheer amount of existing code/frahttp://stackoverflow.com/a/122...
Quote about filters in Java from this link:Filter in place or into another collection?
Haskell programmers are crying.
-
Re:Easier to learn != easier to use
I feel that that is true about any well-written code, not a property of the language. If I see a named function, I assume that it does something similar to its name. If I see addition, I assume that it does something similar to addition. If I am replacing a possibly-having-side-effects method call with a possibly-having-side-effects operator, I don't see why it would increase confusion. Heck, C++ has the "const" keyword, which makes it even easier to specify that a function has no side effects.
Ah, I didn't know that about get() being universal. Thank you. I was misremembering this stackoverflow post, which shows how you need to use either the subscript operator, the get() method, or the charAt() method, depending on whether your object is an array, a list, or a string. -
Re:Yes & the sheer amount of existing code/fra
Yeap, of course repeat the type of the object twice, the ugly diamond operators, use else if instead of elif, etc, produces verbosity, but this is not related to be easy or not to understand.
The thing is, I think it is related to how easy something is to understand.
If I can express an algorithm as a single function of 10 lines then, other things being equal, that will be easier to understand than distributing the same algorithm across 5 functions each of 20 lines. You can see the whole thing at once, instead of jumping around within or between files. You don't have overheads of passing around and returning values.
Similarly, if I can express a simple bit of logic as a clean one-liner, while a verbose style requires 6 lines of manual loop/conditional logic and maybe a function wrapped around it, then I'm thinking about what that logic is doing and it how it fits in with the other logic around it while you're still worrying about loop counters.
Here's a version of finding all the items less than 10 in a list, written in Haskell, a relatively powerful language:
items = [1, 15, 27, 3, 54]
result = filter (<10) itemsHere's a slightly more verbose version, written in Python, also a language known for being clean and expressive:
items = [1, 15, 27, 3, 54]
result = [item for item in items if item < 10]And in contrast, here is the best Stack Overflow has to offer about implementing this sort of requirement in Java.
Spoiler: There are basically three kinds of replies. Some write out entire functions to implement the filter using a manual loop. Some use a third party library to do a more clumsy variation of the Python and Haskell examples above. And a few recent ones use Java 8 to do a slightly less clumsy variation of the Python and Haskell examples above. The clear trend is to try to get away from classical, verbose Java to something more powerful and expressive. Like Scala, according to the first comment on the original question...
-
Unit Testing
There is some degree of testing that happens, but it's mostly just the peer review. I'm not sure it's really possible to unit test the kernel, especially when you start talking about interacting with hardware. Also, the kernel is 17+ million lines of code. How many lines of unit tests do you think you would need for adequate code coverage? How many thousands of man-years do you think that it would take to accomplish this? What would happen to kernel development if you tried? For that matter, how long is that test going to take to run?
-
Verbosity is easy?
Really? Having a pile of needless verbosity makes it more difficult to read in the long run simply because one needs to figure out what exactly is being done even for the most trivial client application. To do even just simple fetch of some resource over HTTP requires rather laborious conversion routine from a stream to a string type before most common JSON libraries would be able to use it. In any more modern language it can simply be used right away rather than having to figure out which JSON libraries to use or why toString() doesn't seem to work on InputStream (I mean intuitively shouldn't toString() on a stream get back a string?).
Granted the Apache commons can make this a bit easier, I find it extremely annoying to have to cast things into the right object type just to access some simple JSON object, instead of just doing something like result['collections']['links'][0] which is much easier to understand. Dumbing things down does not necessary make better programmers.
-
Re:If I use an IDE, does it mean I'm a bad program
Go on then. Demonstrate it.
-
Metro apps use strict W^X; no JIT allowed
Google is refusing to make a Youtube or Chrome app for Metro, and Firefox (unwisely) decided to not make a browser for Metro.
It's hard to make an efficient browser when the API sandbox does not let you implement a JIT engine for JavaScript. Like the iOS public API, the Windows Runtime API lacks a counterpart to VirtualProtect. Thus like an iOS app, a Windows Runtime app is subject to a strict W^X policy that prohibits it from translating JavaScript code into efficient native code to execute it. (Source) Or do you think end users would be happy with an interpretive JavaScript core instead of Google's V8 or Mozilla's IonMonkey?
-
Re:Why the hate for VB
I'm not arguing that VB is good, but that's a pretty trivial example of what makes it bad. Here's a discussion of where DIM came from: http://stackoverflow.com/quest... You used to be able to just say "variablename = value" without a dim statement. That's improved in the current syntax for VB.Net. If you want an example or two of what makes VB bad look at some of the legacy VB6 and classic ASP code hanging around out there. PHP has some (most) of the same problems.
-
Re:Doublethink
I think it's more likely to be because people under 35 are the first generation that have no memory of the cold war. People born before about 1980 lived in a world where there was a very strong, clear delineation between us vs them and that divide was seen as an existential struggle between good and evil. Merely by being born into a certain country, you too could take part in an epic ideological struggle between right and wrong. It is perhaps not surprising that people who lived most of their life in such a world instinctively support a strong, authoritarian state and react badly to a "traitor who gave our national security secrets to the Russians" or whatever garbled version of the story they received via Fox News. There's definitely a clear and strong tendency in older populations to support our side regardless of what that side actually does, and things that seem to bring back old certainties strongly appeal to them. Hence the desperate need of the establishment to make "the terrorists" to new Big Evil.
Contrast to people under the age of 35 who don't remember the cold war and have never lived in a world where there were clearly defined conflicts between us/them or good/evil. Instead there has been a series of endless wars started by us against dramatically weaker foes, based on vague and uncompelling justifications, the results of which have mostly been bedlam. Older people love this because it's an attempt to bring back the old certainties they remember. It leaves young people cold because they don't care about the old certainties, as they never had them to begin with.
Combine all this with the fact that the average software developer is 30 years old and the average age of Congress is 57
... nearly double their age .... you have set the stage for an epic showdown between the technology industry and the political establishment. Which is exactly what's happening. -
Re:~1500 App Developers wasted their time
iOS has perfectly functional networking libraries and simple objects that provide an API to them.
Not for doing anything even the slightest bit complex. Like, for example, certificate pinning and certificate validation, which is what AFNetworking fucked up.
Do you think Apple is better? The APIs are shit. They are horribly documented. They don't "just work" with the high level Objective C APIs, but require a lot of low-level tinkering. They don't perform revocation checks consistently.
People use AFNetworking because the standard APIs are not good enough. I would have been using it had I not already rolled my own wrappers long before AFNetworking had the features I required. The average iOS developer cannot do that.
-
And you thought 1500 apps is bad?
What about every app that does a HTTP gets the wrong content-type? http://stackoverflow.com/quest...
-
Re:Flux and colour temperature
Thanks. I've asked on Stackoverflow, so maybe someone will reply. Hey, I'll even chuck in a bounty if no one replies.
If someone replies, I'll give you the honour of testing to see if it works! ;) I presume you've tried and it won't currently work.
Yes I had a C64 too. I remember with the Amiga 500 thinking 640*512 was a really high res, and 1280*1024 was ridiculously large. Now it's painfully blocky. Mind, most screens are bigger these days, so that can bias one a bit I guess ;) -
Re:Don't see it
Oh, I found it *eyeroll*
-
Big Mac Index
It is unfortunate that SO is using the Big Mac index to rank purchasing power in various countries. Sure, it's a fun and easily understandable metric, but it is so flawed that it is practically useless. Those quickly reviewing SO's study won't realize how flawed it is.
-
Re:For both OOM killer and battery use
LOL no, that won't help you understand any better.
Then what would help me understand better? I'm trying to be sincere here. How do apps normally avoid loss of the most recently entered data in case of a shutdown that effectively already happened, such as the last keystrokes before the app is killed? The sequence is supposed to be pause, stop, destroy, but I've read that the OOM killer occasionally skips these steps when under severe memory pressure.
Well, then your assumption is invalid wherever the app doesn't require a login. So if you have to concede that my point is sometimes valid, you can then also address your arguments about it to the cases where it is valid.
Apps that do not require any login whatsoever are likely to be read-only. Read-only apps can use ad-hoc encryption and signing of responses tunneled over cleartext HTTP. I concede this.
But I still see no evidence for your claim of being able to communicate using cleartext HTTP without the INTERNET permission. An answer to this question states that HttpURLConnection requires INTERNET. Google's networking tutorial mentions techniques that require INTERNET. The answer to this question states regarding INTERNET: "Any application that accesses the internet for any reason will have to request this permission."
I concede that I haven't read the entire Android API docs from cover to cover. Is that required before you're willing to begin to help me? If not, what level of familiarity is required?
-
Re:The big advantage of XOR
Yeah, just because it doesn't take a single clock cycle, doesn't mean it's not a single instruction. Even a simple multiplication can take 2-4 clock cycles.
-
Re:ROT13
Everyone knows that real pros use the _strrev function...
Never heard of _strrev function so looked it up, it doesn't look easy to implement for the cross platforms.
http://stackoverflow.com/quest... so yes a real pro would or could make use of it. -
Re:No biggie
-
Re:Java and Python
This is no longer happening in CPython. The naive case is specially handled to have O(n) behavior and is significantly faster than flattening a list of individual strings all at once.
-
Re:Check their work or check the summary?
It's all operating system cached writes, they're not even getting to the disk's write cache.
Python's file flush() function does not flush data to disk. You have to call os.fsync(f.fileno()) for that.
Same problem with the Java code. flush doesn't make sure data is on disk. You have to use sync or force or something.
This is an excellent way to introduce the smart scientist/moron coder archetype to people though, so it's not completely useless.
-
Re:I choose MS SQL ServerNo, you misunderstood what I wrote. I was referring to the fact that MySQL DDL is not transactional. So if you run an 'alter table' command, don't expect to be able to roll it back. Seriously though, even SQLite offers this feature, so MySQL is just a dunce.
The main difference that I see is that Postgres fans generally have the same zeal and lack of experience that Rails fanboys exhibit. I am not sure where you fall but you are doing a disservice to our community by spouting false claims when you do not understand what you are talking about. (That sounds like a rails fanboy to me.)
I'm pretty sure it means you're a moron. Or rather, you should have thought a little before spouting insults.
-
It's used in Stack Exchange
I personally like Trello which is what is being used in Stack Exchange (makers of Stack Overflow and its ilk) http://blog.stackoverflow.com/...
We are an online company: we’ve been remote from day one and still to this day over half of the team (aside from sales) works from home. The only way to make that work is to keep the nexus of activity online: in chat rooms, Google Hangouts, Trello boards, etc. This keeps everyone on equal footing, whether you’re in the office or working from home.
The article was the one that introduced me to the tool and I am impressed by it. Though it still needs some explanation of how to use it. I suggest you look at Kanban but don't mention it as a methodology etc... just explain how to group the work and be done with it.
-
STL
You can argue about whether C++ is a horrible language (I lean toward "yes") in itself, but the libraries are what really push it over the edge. STL is hands down the worst collections framework I've ever encountered. Consider just a few examples of how you do some common operations with it, compared to doing the same things in Java and Python.
1. Check whether a string s ends with a suffix t.
Java: s.endsWith(t)
Python: s.endswith(t)
C++: s.rfind(t) == s.size()-t.size()2. Check whether a collection c contains an element e.
Java: c.contains(e)
Python: e in c
C++: c.find(e) != c.end()3. Split a string s into tokens based on whitespace.
Java: s.split()
Python: s.split()
C++: ... do you really want to know? Ok, check out http://stackoverflow.com/quest.... There you will find dozens of proposed solutions (many of them quite indecipherable), along with lots of debate about which one is best. The top voted solution has a comment on it (with several hundred votes) saying that it's a bad solution and you shouldn't use it.Doing even really basic, common operations with STL requires way too much work and produces absurd, hard to read code.
-
Re:Subtitles and playlists
All of that depends on his browser's current settings and what other software he has installed on his system.
Provided that suitable "other software" is available for the user's preferred platform and the user has permission to install it.
And in which timed text format?
A standard one. And by "standard" I mean a documented, actual, standards-compliant, honest-to-god standard.
What standard might this be? W3C's Web Video Text Tracks (WebVTT) is "not a W3C Standard nor is it on the W3C Standards Track". Timed Text Markup Language (TTML) appears to be supported only in IE; other web browsers that support HTML5 video need shims written in JavaScript.
It's called "a webpage full of links to files that can be clicked in sequence and that a secondary user agent will interpret as audio or video".
So as I understand it, the flow without M3U support would be as follows:
- The user follows a link to a chapter.
- The handler for this URL saves the date and time when this download began and redirects to a video "First a message from our sponsors," followed by a sponsor message, followed by "Now follow the link in your browser once more to view your presentation."
- The user follows the same link to a chapter.
- If enough time has elapsed for the user to have viewed the sponsor message associated with this chapter, the handler for this URL redirects to the chosen chapter. Otherwise, go to step 2.
The flow with M3U support would be as follows:
- The user follows a link to an M3U file.
- The M3U file opens in a video player.
- The video player opens the first URL in the M3U file.
- The handler for this URL saves the date and time when this download began and redirects to a video "First a message from our sponsors," followed by a sponsor message.
- The video player opens the second URL in the M3U file.
- The server keeps the connection open until when the sponsor message video should have finished playing and begins to send the chosen chapter.
But without script, how can the web site determine whether or not the user has a compatible secondary user agent installed?
-
Re:Then, How Best To Learn?
I think this question has been answered pretty well on Stack Overflow. C++ is too deep and complex to learn from a few web tutorials of unknown quality. Get a good tutorial book and just follow along - that's how I learned it. Then get a good reference book for more in-depth knowledge as you move past the basics.
Anything that at least covers C++ 11 is fine, as C++ 14 was more about some minor tweaks that you can learn on your own.
Be careful about learning bad habits from C++ code examples you find on the web, or in older projects. Essentially, if you see the code using new, delete, and raw pointers, it's likely outdated. You may still need these on occasion, but their use is vanishingly rare in modern C++.
-
Re:Some misconceptions
Languages aren't compiled or interpreted: implementations are.
That's true in theory, utterly false in practice. Major design choices hinge on whether the language is intended to be interpreted or compiled. Interpreting languages that are intended to be compiled can be done but it usually amounts to compiling in the background and doesn't work out well. Compiling languages that are intended to be interpreted typically results in an order of magnitude slower performance compared to a language designed to be compiled. The information needed to optimize the compiled code just isn't there so the compiler cannot eliminate type checks, type coercions, bounds checks, overflow checks, etc. Typically all function calls are virtual and many memory accesses are doublely indirect.
Node.js isn't fast. It's concurrent. You can handle many thousands of simultaneous requests, as long as none of them are working particularly hard.
That's not what concurrent means in this context. The word you're looking for is "asynchronous". All of the javascript code you write will execute on a single thread in Node.js. Some APIs are asynchronous with a callback. That style of programming is much older than me and I'm a greybeard. Asynchronous code is great if you need the performance and can deal with the complexity but it shouldn't be the only option. And seriously, Javascript? for performance? really?
Server-side web programming can have a lot of in-flight requests being handled simultaneously, and not much need for synchronization because the requests are relatively independent (and the heavy lifting of dealing with race conditions is being handled by the database, operating system, file system and other libraries not written in javascript.) Real concurrent programming has much more data passing between threads of execution and the Node.js design of one single-threaded process per core is going to really suck for that.
Look at this stackoverflow question about Node.js and multi-core processors (scroll down to the more up to date anwser.)
"Node.js is one-thread-per-process. This is a very deliberate design decision and eliminates the need to deal with locking semantics. If you don't agree with this, you probably don't yet realize just how insanely hard it is to debug multi-threaded code."
That made me actually laugh out loud. Threads were invented because they are easier than asynchronous programming. Asynchronous programming has it's own pitfalls. Writing asychronous libraries is hard, most programmers don't have much experience with it, and many available libraries can't be used because they're not asynchronous. It's all or nothing: one blocking call (or just one long running call) and every in-flight request in that process is stalled and you have one core doing nothing. The node.js people will tell you that if you're writing long running code in javascript, you're probably doing something wrong, completely contradicting the supposed advantage of being able to do client and server code in the same language.
It's an intentional design decision all right, but not for that reason. The fact is that javascript engines like V8 were designed from day one to run in browsers and are inherently single threaded. Now that they've escaped the browser they're trying to make their single threaded nature out to be a feature. They're hyping asynchronous single threaded code because that's the only option. The browser implementers have zero interest in adding multi-threaded javascript support. Adding threaded javascript to browsers would be very difficult to say the least and rich source of new bugs, and the browsers just don't need it. Adding threading to just the server would fracture the language and remove the only advantage Node.js has. So instead Node.js tries to spin the lack of threads as a feature.
The performance "g
-
I always have a chuckle
Whenever I think about this difference given for java and JavaScript given on SO One is essentially a toy, designed for writing small pieces of code, and traditionally used and abused by inexperienced programmers. The other is a scripting language for web browsers. http://stackoverflow.com/quest...
-
Re:Some misconceptions
Node.js is mostly event driven, but it's concurrent in the sense that it can be servicing many thousands of simultaneous requests by doing the parts that aren't currently blocked. It's not quite single threaded, though, as the blocking parts are handled in their own threads.
-
Re:A good language that'll get slammed...
Please stop, this is getting really tiresome. Python has multi-line strings without special escaping:
http://stackoverflow.com/quest...
You just look like an ignorant idiot with an axe to grind with this obsession over a non-existent problem.
Speaking of obsessions, Python programmers don't obsess over forced indentation. It's the people who violently dislike Python who keep harping on it.
-
QEMU processor emulation?
Can't you just emulate the processor with QEMU and run the app in a sandboxed environment ?
https://github.com/hackndev/qe...
------
-
Re:Unintended consequences?
do yum updates (or similar) have a restart service flag (depending on what the update includes)?
The hook is there; at least some packages do this when updated - but I wouldn't be too confident that they all do.
-
Re:GOTO is a crutch for bad programmers
What would you propose as a better alternative to this idiom in a language that lacks exceptions:
I propose this; namely using variables to keep track of the state of resources, and then cleaning up based on the values of those variables. In my experience this is much less error-prone than the "goto" equivalent - for example, reordering the code is much less likely to break the cleanup.
-
Re: BSD is more threatening than proprietary
I think not.
-
Consider mocking frameworks in some situations
While this is in general great practical advice (and no doubt hard won), I can quibble about your point #3 on complex dependency graphs requiring rewrites as the "only way out". Certainly this is more of an issue in C++ than something like Java where code can be more easily replaced at runtime. However, at least in Java, the idea of "mocking" can sometimes be useful to test code even with complex dependencies without (significant) initial rewriting.
I used mocking with JMockit successfully in the large Java project previously mentioned. I tried other frameworks, but preferred that one. JMockit supported creating unit tests for code which was not originally designed to be testable and had complex interdependencies in how objects were constructed. However, JMockit did have a substantial learning curve, even aside from hours spent trying to come up with tests for domain-specific specific code. Eventually I created some supporting code to make the mocking easier for our project, and then another developer improved even further on my work, making mocking our specific application much easier. So, at least in our situation, with a huge complex Java codebase in production, limited developer time, and limited tests initially, mocking was a big win IMHO that let us start to get a handle on everything without having to rewrite a lot of code at first.
That said, in general, code is easier to maintain and understand when it does not have complex dependencies. "Dependency Injection" is a good idea in a lot of cases -- although it can have its own downsides in making object construction code harder to follow:
http://en.wikipedia.org/wiki/D...So, while I'm quibbling about "only way forward" because of the possibility of mocking, I'm not saying rewriting in such situations in necessarily a bad idea or even quicker than mocking sometimes -- especially as mocking can introduce its own issues.
With JMockit, one such unexpected issue was that mocking an object created mocks up the entire class hierarchy (causing issues when you wanted to mock one class but test a sibling class). This was a subtle issue that took a while to understand, and I did not see documented explicitly anywhere (at least in introductory material) although I think there was a bug/feature request about it somewhere.
Another JMockit issue was that mocks were instantiated and removed in relation to threading somehow and there could be issues with mocks remaining in place when previous unit tests had not completely finished running all their threads. This could sometimes lead to unit tests failing occasionally due to thread timing issues and the mocking, when a class that was mocked in one test or with certain "expectations" was then accessed by another unit test which mocked different objects or had different "expectations". Sometimes this (unfortunately) happened embarrassingly on other developer's machines with different OS or hardware or on our Hudson/Jenkins build server just by the force of numbers of times the tests were run. Usually I could get around these cases either by adding delays at the end of the unit test to let all the threads complete or, better, by having improved mocks or other code that ensured the threads were finished before the test ended.
That said, even with both of these issues, both frustrating to understand and then work around, mocking was still a big win for the project IMHO.
I have not used any C++ mocking frameworks so I don't know how well they work or what their limits are. However, for suggestions about some such frameworks see this StackOverflow discussion:
http://stackoverflow.com/quest...The top rated answer there is about "Google Mock" but there are other choices.
https://code.google.com/p/goog...I do not see the word "mock" used so far in this Slashdot d
-
Could it be a threading issue like a a deadlock?
Debugging code that prints or logs may act to synchronize access to some data structure. Sometimes that can prevent a deadlock or illegal pointer access as a side effect:
http://stackoverflow.com/quest...
http://en.wikipedia.org/wiki/D...So yes, complex programs can act in strange ways from seemingly minor changes.
I spent a couple years helping maintain a large complex multi-threaded app (which included message passing between the apps, for another layer of fun) which supported 24X7 operations where a minute's downtime could cost millions of dollars in some situations, and it was not easy. The code base was easily 10X to 100X of what the poster of the story is tasked with maintaining. Versions of the code had been in production for over fifteen years. Much of the code had been ported from C++ & Tcl to Java (although C++/Tcl systems remained), but the threading model was somewhat different between the two, and the port had not taken account of all the differences. It would have been nice to be able to rewrite some key parts of the system to make them more maintainable, but there was never enough time for that in a big way -- and realistically, bigger rewrites likely introduce new issues. Still, eventually we got most of the worst deadlocks and memory leaks and similar such things fixed and the system got to the point where people stopped even remembering off-hand the last time a core part of the system needed to be rebooted (previously a fairly frequent event). But each deadlock could involve days, weeks, or even months of study and discussion, adding log statements, writing tests, lab tests, analyzing quite a few multi-gigabyte log files (and writing tools to help with that including visualizing internal message flow), and so on. And, same as you mention, hardware and OS issues could interact with it all, making some things hard to duplicate under virtual machines for developers. One thing is that to the end user, a system that is more stable may not look that different than one that is less so -- there are no new features, so it is not obvious what is being paid for.
Although obviously if the program you support core dumps from a bad address or stack overflow, rather than just freezes up, it is probably something else. Still, even then, a bad pointer address can sometimes come from one thread freeing a data structure when another thread is still using it. The original C++ in the above mentioned project generally was highly reliable, but it still had some odd issues too. In one rare case, memory was freed in an unexpected way under certain conditions by other code running in the same thread but in code nested way deep with essentially recursive calls processing complex messages. I finally also traced part of that too what looked like maybe a bug in a supporting third-party library (a RogueWave data structure). Because that C++ code had been in production for years, and we were loathe to change it at the risk of introducing new issues, we mostly "fixed" that issue by making changes elsewhere in the system to prevent that component from getting the pattern of data that it had trouble handling. But we would not have known exactly what to change elsewhere without a lot of analysis.
Sadly, just as we got it mostly working well, the new shiny thing of a mostly COTS system that did something similar came along to replace much of it (at a much bigger expense than maintaining the old, but granted with some nice new features).
As I saw someone else comment recently about a "stable" OS, the end user generally cares more about how much work a system lets them get done, not how "stable" it is. A reboot can be acceptable, depending on the situation and the alternatives, even if not desirable. Erlang code is probably the master at that approach of rebooting code when it fails.
:-) Here -
Re:Browser performance
Still has a broken flexbox implementation.
And its devtools suck ass. Just my opinion.
-
Re:What is a cuda core?
A CUDA core is basically an active hardware thread [pool.]
For example my GTX Titan has 2,688 CUDA Cores.
This number is derived from:
Streaming Multiprocessors: 14
* 192 Cores/SM
====
2,688 CoresIn practice that means you have 2,688 threads doing "real work" at any one time.
See this SO question/answer
http://stackoverflow.com/quest... -
Re:Problems in C++
>1) No, that's not the case. The difference between
.at and operator[] is that .at() has a const overload and operator[] is not.Are you sure about that?
http://www.cplusplus.com/refer...
>2) Most high performance apps (eg. games) turn off bounds checking in any case for performance reasons.
Which is fine.
Personally, I'd have preferred it if I could simply enable or disable bounds checking on [], so I could test my code to make sure I'm not going to fry memory, and then disable bounds checking on performance critical code for release.
>Uh, stringstreams? http://stackoverflow.com/quest...
I'm not saying that you can't write your own functions, just that the STL string class is not a drop-in replacement in functionality in string.h