3 ms·
Speaking of madness, James Hague drives me a little crazy. I get it - people tend to focus too much on performance. But it seems like his blog is a series of
by chadaustin 11y ago
Speaking of madness, James Hague drives me a little crazy. I get it - people tend to focus too much on performance. But it seems like his blog is a series of repeated arguments that nobody needs maximum performance out of their machine. Try compiling your web browser or operating system with -O0 and then tell me the performance is satisfactory. Or your video encoder. Or VMware. There is a huge market for high-performance software where performance comes from more than a few inner loops, and optimizing compilers, while complicated and huge and occasionally buggy, are necessary for the user experience we desire.
- rtpg 11y agoI think this advice is for people who don't necessarily need it. I don't know if there's a name for it, but I've started reading "Don't do X" as "Don't do X unless you have a realllllly good reason to." Nothing in life is absolute, after all. Similar advice is "Use a GC". There are (similar) use cases where you shouldn't use a GC. But if you don't have a strong case for paying the price of not using a GC (in terms of potential bugs and code complexity), then using a GC by default is pretty good advice. But yeah, if you're writing VMWare, you're hopefully also skilled enough in the domain to know that you should try to get maximum performance. But if you're writing some shell scripts or webapp, a lot of the time your bit-twiddling optimisations will be noise relative to the variation from I/O alone.
- vmorgulis 11y ago> But it seems like his blog is a series of repeated arguments that nobody needs maximum performance out of their machine. Not false. He seems sometimes contradictory. http://www.dadgum.com/james/performance.html http://www.dadgum.com/james/performance.html
- junke 11y agoI don't understand what is contradictory here. > The golden rule of programming has always been that clarity and correctness matter much more than the utmost speed. Very few people will argue with that. And yet do we really believe it? If we did, then 99% of all programs would be written in something like Python. Or Erlang. Even traditional disclaimers such as "except for video games, which need to stay close to the machine level" usually don't hold water any more. He claims that you can usually choose any language you want to develop your software and that it will not make any visible difference. Systems are so fast nowadays that the trying to optimize for speed will need to an effort that is probably not justified.
- w0utert 11y agoThat may be true, but suggesting this means you could just as well write everything in python or some other 'simple language' just doesn't make any sense. First of all because they all introduce their own unique set of problems (e.g. no type safety, much less static, compile-time checking, the need for a runtime, etc), second, because the way people typically use them promote programming styles that are inefficient in ways far beyond some constant-time compiler optimizations (using dict or list for everything, for example, or having no concept of data locality and cache-friendliness), and third, because it's perfectly possible to write C/C++ code that is efficient enough, readable, and easy to maintain. I agree that most of the time the performance of the most obvious implementation of some part of a program is more than sufficient, but to me that just proves the point the problem is not with compiled languages like C/C++, as you can use 'readable, maintainable' as the default way to implement things, and only drop back to obscure tricks if you really need to (which is rarely). I don't really get the point the article is trying to get across anyway. I don't care about the complexity of the compiler at all, and 99.99999% of the time I don't care about what the assembly it spews out looks like. I'm just using the compiler as a tool, I don't need or want to know how difficult it was to get it to compile my code. The only thing I care about is that it produces valid code, and that the code gets a speedup when I compile with optimization enabled. That's about the extent of my interest in the compiler, and modern compilers have served me very well over the years. Why complain that they need to be complex to produce faster code?
- vmorgulis 11y ago> Why complain that they need to be complex to produce faster code? Maybe because the resources could be invested in something (like Erlang). I share similar views but for another subject (web browsers).
- vmorgulis 11y agoI wonder if his position towards (optimizing) compilers is not related to the near monopoly of C++ in game programming (he is a professional). BTW I like a lot his blog.
- zamalek 11y agoTake data-oriented design as an example: if you really read into it, it does actually relegate the compiler to something marginally better than a dumb code generator. The mundane optimizations (inlining, constant propagation, etc.) are expected of the compiler and the developer focuses on things like using the stack well (from the article) or being cache friendly. Saying that C++ categorically cannot be used to create good machine code is ignoring much evidence to the contrary.
- pjmlp 11y agoAll good examples, however the problem are those developers micro-benchmarking each code line they write even if the user of the program doesn't care if it takes 1ms or 1s to achieve what they are doing. This mentality is quite common in certain programming circles.
- joosters 11y agoThey can do that all they like as long as the binary still works in all the same situations. Fine by me. I even gave the compiler permission to do it with the -O flags. Or are you trying to dictate what compiler writers should be focusing on? They're free to choose what to work on, so don't use their compiler if you disagree with it.
- pjmlp 11y ago> They can do that all they like as long as the binary still works in all the same situations. Fine by me. I even gave the compiler permission to do it with the -O flags. If we are talking about C and C++, the binary doesn't have to work according to the UB rules. > Or are you trying to dictate what compiler writers should be focusing on? They're free to choose what to work on, so don't use their compiler if you disagree with it Hence why I never code in C unless there isn't any option, and avoid C style code as much as possible when using C++.
- joosters 11y agoIf your program includes undefined behaviour, the compiler cannot magically make your code work, optimisation or not. At best, it can guess what you meant, but guessing is impossible to get completely right. The only way out is to fix your code.
- pjmlp 11y agoI was talking of UB being an open door to break applications, given that the standard allows for "anything goes" in terms of code generation. I bet very few C developers, less than 1% outside ISO tables and compiler vendor teams, know ANSI C from cover-to-cover and are able to write UB free code when one sticks to the letter of the standard.
- deleted 11y ago[deleted]