|
Lexical Unit posted:My co-worker told me today that const-correctness isn't worth the speed hit. I'm not a professional programmer or anything (nothing of the sort) but I never make functions const because I've always thought accidentally modifying an object when you didn't mean to would be a fairly uncommon thing, and I always forget to make some const that should be and then have to search through files adding const to other functions that were called by const ones. I've always gotten by fine, is this a horrible thing? I do use const when passing by reference though I guess.
|
# ¿ Dec 10, 2008 01:36 |
|
|
# ¿ May 13, 2024 11:16 |
|
True, but that's surely an unintentional bug and therefore not (quite) so much of a coding horror.
|
# ¿ Dec 2, 2009 13:01 |
|
Lumpy posted:
Woah, why have I never thought of the !! operator before? Since it doesn't do anything you can pepper it around your code to indicate the important bits!
|
# ¿ Nov 11, 2010 12:22 |
|
qntm posted:I guess !! is equivalent to a boolean cast? Like, if the input was appState.length, which is an integer from 0 upwards, !!appState.length will be FALSE if appState.length was 0 and TRUE if appState.length was greater than 0. Yeah, of course, I was just thinking about with boolean expressions I guess
|
# ¿ Nov 11, 2010 16:18 |
|
I kind of agree in principle but really references are an awesome language feature and IDEs these days should totally be able to pop up a signature with the &s there for you to see as soon as you type the ( edit: Compromise! Use const references, and pointers for mutable stuff. Either everybody wins or nobody wins depending on what your priorities are seiken fucked around with this message at 05:01 on Feb 16, 2012 |
# ¿ Feb 16, 2012 04:57 |
|
Yeah that's why I kind of agree in principle.
|
# ¿ Feb 16, 2012 05:18 |
|
Haha, you can run the output through it over and over to produce arbitrarily large and slow-executing equivalent code.
|
# ¿ May 12, 2012 20:18 |
|
I love a lot of the boost libraries, but it can be pretty hit-or-miss. I would never even consider using Spirit over something like YACC.
|
# ¿ Sep 11, 2012 10:02 |
|
Suspicious Dish posted:
The comment is perfectly correct but yes, this weird idiosyncrasy is probably the one reason it might qualify as a horror (still pretty mild, though).
|
# ¿ Sep 24, 2012 22:53 |
|
Never mind whatever bullshit about magic quotes which shouldn't come near an interview, I think doing an interview in PHP at all is a pretty huge horror (especially for a PHP position)!
|
# ¿ Oct 5, 2012 01:06 |
|
Look Around You posted:The fact that SQL queries even are strings in the first place is pretty horrible. Using a binary API like most other things would be exponentially better. Programs in most languages are just strings but the difference is people don't usually build C source code by concatenating arbitrary user input together. seiken fucked around with this message at 20:21 on Oct 15, 2012 |
# ¿ Oct 15, 2012 20:18 |
|
WHOIS John Galt posted:If I'm reading this correctly, his definition of a prime number is... a number N for which all numbers N-1...0 are also prime? Nah, the code is actually technically correct, I guess, just the variables are terribly-named and like 80% of the lines are unnecessary (and it doesn't break early).
|
# ¿ Jan 2, 2013 22:01 |
|
Suspicious Dish posted:That way it's more secure. This is an interesting thing I didn't know about before, at the same time as being a completely ludicrous defense of the actual code in question. Well done seiken fucked around with this message at 22:59 on Jan 2, 2013 |
# ¿ Jan 2, 2013 22:56 |
|
ivantod posted:And it's also not necessary to test numbers all the way up to N-1, it's enough to go to sqrt(N) because if there is no divisors by that point there can't be any afterwards. Not to mention many other possible optimisations. seiken fucked around with this message at 23:17 on Jan 2, 2013 |
# ¿ Jan 2, 2013 23:14 |
|
Seeing as we're talking about Lua embedding in the coding horrors thread, I may as well share this definite horror I just wrote:C++ code:
Then the lua_ macros get re-#defined into completely different things and the file is included a second time from inside of a function body, expanding into a function which automatically registers all the function names and their addresses onto a passed Lua state (so there's no need to maintain a duplicated list of function names "hello", "multiply" or function pointers anywhere in order to expose them to Lua) Edit: mainly a horror because the error messages are going to be loving nonsensical seiken fucked around with this message at 00:21 on May 2, 2013 |
# ¿ May 1, 2013 23:57 |
|
Jabor posted:I do think it's a worthwhile idea to have a lighter-weight language for level designers and such to use to wire things up. Push-button-to-open-door doesn't seem like the sort of thing you need a programmer for, and having to stop designing to ask someone else to wire it up for you seems like it would definitely slow things down. I think the trick is to deliberately make it crippled enough that no-one is tempted to try and implement any actual game functionality in it. Even if you agree that nobody but programmers should write code (which I for the most part do, actually), having a scripting language for real programmers to write real code in still brings you all the flexibility advantages along the lines of iteration without recompilation, easy hot-swapping & so forth. Whether these advantages outweigh having to maintain the interop stuff depends on your project (choice of host language, especially) I guess but they're worth considering even if you're not explicitly focused on the mod scene shindig seiken fucked around with this message at 00:34 on May 2, 2013 |
# ¿ May 2, 2013 00:31 |
|
How the gently caress do you make 20K line commits, I don't even get it. Is he just doing huge find+replaces all over the project or what, I don't know.
|
# ¿ May 4, 2013 19:06 |
|
I stumbled across this thread on another forum that's from a year and a half ago so it's kind of old, but it's too good not to share. Your opinion on the functionality of a template dynamic list Basically, a clueless C++ guy ranting for several pages about how terrible the standard library is (while completely misunderstanding it) and showing off his crazy hand-rolled replacement where pretty much every function is called operator=. Some choice excerpts: quote:For example, some time back I had a linked list that took probably about 2000 - 3000 lines of code riddled with memory allocation crashes and various pitfalls. C++ code:
C++ code:
quote:I had the last iteration code up to the point where, barring some optimisation, this would have been valid: quote:I am not sure what there is to maintain? It's straight forward enough to use - assignment operators mostly.
|
# ¿ May 7, 2013 12:52 |
|
Novo posted:I hear this all the time, and yet vim purists act like it's everyone else who can't adapt to unfamiliar things. It's not that IDEs are unfamiliar (they're of course trivial), it's that they're obviously inferior. I definitely used to use IDEs and now do everything in Vim. vvv subjectively obviously inferior. And I'm only talking about the text editing seiken fucked around with this message at 18:25 on Jun 4, 2013 |
# ¿ Jun 4, 2013 18:22 |
|
https://github.com/search?q=extension%3Aphp+exec+%24_GET&type=Code&ref=searchresults
|
# ¿ Jun 5, 2013 12:00 |
|
LoseThos is now TempleOS and has an incredible video on the front page.
|
# ¿ Jul 3, 2013 15:31 |
|
God likes six-forty by four-eighty because it's good for children doing art.
|
# ¿ Jul 3, 2013 16:39 |
|
C++ code:
|
# ¿ Jul 7, 2013 22:02 |
|
Thermopyle posted:Am I the only one who had to look this up? You're not, it's also my new favourite word. Thanks Scaramouche!
|
# ¿ Jul 25, 2013 00:02 |
|
Reality posted:I inherited a rather voluminous JavaScript code base. There were tons of functions called "set_up_[thing]". I kept spelling setup correctly and I was always wrong. I have a Python codebase where almost every class has a method like that except it's called either "SetUpX" or "SetupX" completely at random.
|
# ¿ Jul 25, 2013 19:02 |
|
Crosscontaminant posted:If you don't have malware and you don't have bugs, protection just slows things down and makes the code complicated. To be fair, an operating system used by one person ever is unlikely to be plagued with malware.
|
# ¿ Aug 19, 2013 06:42 |
|
This was posted on Stack Overflow under the title How to create an array? It's now deleted. I present it here without comment.quote:You are about to be provided with information to start your own Google. seiken fucked around with this message at 20:40 on Aug 22, 2013 |
# ¿ Aug 22, 2013 19:58 |
|
Lurchington posted:dammit javascript and/or V8's implementation of javascript I'm not sure why you'd find either of these surprising. Edit: I mean it's bad as far as loose typing and implicit coercions are bad wherever they pop up, but the parsing stuff is pretty much sensible (same thing happens in most languages, also with - and --) seiken fucked around with this message at 20:00 on Sep 9, 2013 |
# ¿ Sep 9, 2013 19:57 |
|
I'm still bemused at the awful, terrible syntax of that language, the overblown writing, and preposterous terminology (I burst out laughing at quote:A pier is an Urbit virtual machine that hosts one or more Urbit identities, or ships. When you run vere -c, it automatically creates a 128-bit ship, or submarine. I wouldn't compare it to TempleOS which is an actually crazy person trying to make a substitute for the whole of Windows.
|
# ¿ Sep 25, 2013 01:31 |
|
Multiplying by booleans is perfectly concise and natural, e.g. http://en.m.wikipedia.org/wiki/Kronecker_delta and if you think it's terrible code you need to get out
|
# ¿ Dec 17, 2013 20:33 |
|
Opinion Haver posted:But you don't write (i = j) * 2, you write \delta_{ij} * 2. The analogy would be if you wrote boolToInt(i == j) * 2, which isn't unreasonable. This kind of failure to be comfortable with the most basic rules of your language is why we end up with poo poo like if (bool_value == true) ....
|
# ¿ Dec 18, 2013 11:54 |
|
PleasingFungus posted:...endless rambling about python... I don't see what this has to do with a bunch of code examples that were very obviously not Python. That you had to switch to a different language (which, in this context, behaves completely differently) in order to argue makes it clear you prefer a cargo cult approach over considering code on its merits. Using bools as 0 and 1 in C is "code golf" my loving arse vv or c++ or any language where you can treat the result of a comparison as 0 or 1 seiken fucked around with this message at 19:12 on Dec 19, 2013 |
# ¿ Dec 19, 2013 15:43 |
|
Opinion Haver posted:What? Pleasing Fungus's examples are in Python: Yes. Nobody else was talking about python.
|
# ¿ Dec 19, 2013 21:37 |
|
Suspicious Dish posted:The same thing is true in C as well. (C99, 6.5.13p3) "The && operator shall yield 1 if both of its operands compare unequal to 0; otherwise, it yields 0." You are programming by superstition.
|
# ¿ Dec 20, 2013 08:27 |
|
"Asking forgiveness instead of permission" is among the most terrible of all terrible nonsense "pythonic" rules. Exceptions are dynamic non-local gotos that obscure control-flow and spread the logic of your program across arbitrarily-distant functions. They should be used for exceptional circumstances and absolutely not as a matter of course. If you're forced to use exceptions for control-flow it's because Python is a bad language
|
# ¿ Jan 16, 2014 17:03 |
|
Munkeymon posted:No There's not really any reason it would be less of a horror in Python. If you don't abuse it and only catch the exception one level up as above of course that's not too bad, but when you start depending on control-flow like that it's inevitable the catches will start moving further and further away from the raises and the program will become harder to reason about locally. vvv that's ridiculous, naming has nothing to do with it. Control flow exceptions are poo poo no matter what the language is or what they're called seiken fucked around with this message at 18:52 on Jan 16, 2014 |
# ¿ Jan 16, 2014 18:03 |
|
tef posted:I love hearing this argument because I imagine a programmer going LA LA LA I CAN’T HEAR YOU when they discover that exception handling is a form of control flow. what? Of course they're a form of control flow. They're a really bad form of control flow that you shouldn't use unless you run out of memory or can't open a file, that's the whole point
|
# ¿ Jan 17, 2014 19:10 |
|
Tesseraction posted:After sleeping on it and coming back I realise I misread the original code, but I'm still not sure how changing a jlt instruction to a cmp then jz isn't considered changed semantics? The language does not define semantics in terms of instructions.
|
# ¿ Feb 5, 2014 19:35 |
|
How haven't I heard about Espruino until now? Let's run Javascript on a microcontroller. Let's reparse everything every time it's executed. Don't put comments or whitespace in loops, it'll slow things down! Watch out, arrays and objects are linked lists so lookup is O(n)! We're all about saving ram, but bools are going to take 20 bytes unless you put everything in a string! This might be the worst programming trainwreck I've ever seen. How on Earth did it get Kickstarter'd for £100000?
|
# ¿ Feb 6, 2014 17:23 |
|
|
# ¿ May 13, 2024 11:16 |
|
Cancelbot posted:
That's bizarre and I don't know why you'd bother. Now you have to add wrapper methods for each Dictionary method you want to use. A nested dictionary like Dictionary<K1, Dictionary<K2, V>> is equivalent to Dictionary<K, V> where K is a struct with two elements K1 and K2 though, which is a much more useful way to avoid nested generics if you really dislike them for some reason.
|
# ¿ Mar 31, 2014 22:59 |