@pjh They're all different from each other; they've got different numbers written on them. GENIUS!
dkf
@dkf
The background picture in my profile is one I took myself. It's taken at Niarbyl in the Isle of Man, and is looking south-west along the coast. It's a splendid place, though it tends to be a bit… bracing most of the time; the picture was taken on one of the rare relatively calm days.
I do software engineering to support scientists at a research university. I get to work with a lot of fields and see many (usually small) WTFs. I also write software for fun. There's a really good chance you're using something I've written right now and you don't know it. That pleases me a lot.
Am I a polymath as well as a software engineer? If that means someone who gets to dabble on lots of areas of human endeavour without having to spend ages learning masses of background, then maybe? It'd be pretty cool if it was true!
Best posts made by dkf
-
RE: Spot the difference: Chickens.
-
RE: Guy leaves programming career because he wants to change the world... meditating
@Jarry said in Guy leaves programming career because he wants to change the world... meditating:
he decided he wants to make the world a better place, meditating.
Well, if he's stopped writing shit that other poor folks have to maintain, he will have made the world a better place.
-
Shuffling off this mortal coil
One of our (thankfully now former) developers was writing some code to randomly distributed things over a grid. That developer was someone who loved to write what he thought were super-fast algorithms that were simultaneously as Pythonic as possible. He never met an advanced feature of a programming language that he didn't want to work into what he was doing, whether or not it was useful, and Python is a language that gives you a lot of rope for mischief indeed. Why would you use classes when you could use something custom? Why would you write a simple sort when you could use a complex list comprehension instead? His code was often extremely short and had a beautiful surface reading, yet would open great chasms of bewilderment once you poked under the covers.
Now, the grid was of reasonable size, but 256×256 really isn't exactly massive. The only real nuance was that the things that were being distributed would sometimes be much fewer than the number of grid cells, and other times would end up needing to cover the whole grid; a few orders of magnitude of difference in the number of items.
Now, there's a well known algorithm for doing random placing of a dense collection: shuffle the items or the places and just match them up against each other. It's been around forever and is pretty simple: shuffle the grid points in a big list and then match off against the set of things to be placed. It takes linear time; nice and efficient, no surprises. The only time you ought to consider picking anything else is when the number of items to place is much much smaller than the number of points you could use, when you'd pick random places and hope that there were no collisions. That'd happen some of the time with our application, but often there'd be a lot more loading.
But the developer in this little story just couldn't see past the fact that that algorithm would need to quite a bit of work in the case that there were very few points, so he decided to use the random selection algorithm for all the items. He'd just kept a set of locations that he'd already used and retried placing if the point had already been used.
Sure, his code worked fine with the test cases he ran, and was extremely fast. But as the number of points increased, things would go strange; the amount of time to place the items would increase massively. (What was happening was that as the number of used points increased, the probability of choosing an unused point would decrease and the number of iterations would increase. Massively so, as the target loading factor approached 1.) This was unacceptable! Being under a bit of pressure due to his impending departure for pastures new, and unwilling to admit that an up-front shuffle would be better, he came up with a “clever” adjustment to his algorithm to stop the infinite looping problem. He put an upper bound on the number of iterations used. That pesky apparently-infinite loop gone: the amount of work required was now strictly bounded and everything was fine!
Our (enormously more competent) intern had a good look at this code yesterday, and noticed that it would tend to not place all the items; a random selection would simply get forgotten. She realised that the code, which could have been using that classic shuffle and been working correctly with a few hours coding, had instead started out using a Bad algorithm (which would produce a right answer eventually) and then, under mild pressure, had been converted to a Fail of a non-algorithm that didn't produce even a vaguely correct answer.
I don't remember our intern actually facepalming before.
Our former developer's code is gradually being converted into things that work with more conventional code and less crazy, and in the process is becoming often orders of magnitude faster. Smartass coding is all very well, but paying attention to what costs and what you can cache actually works better.
-
CSVs ought to be in ASCII
Sometimes, Microsoft just makes you wonder what they are thinking.
I happen to have some code that generates a CSV that contains, among other things, a list of student names (it'll also contain automatic marking info). Some of those student names contain diacritics (because that's how things go). No big deal, just make sure the CSV is written out as UTF-8 (the system encoding on Macs and Linux) and write it out like that. Job done.
Then double-click on the resulting file to open in Excel for Mac to get the mojibake experience! Because when opening a CSV you don't use the platform's default encoding! It doesn't even work when you put a BOM at the beginning of the file or choose an explicit import using UTF-8 (unless you like the diacritics converted to underscores). Huh.
What about if we export a file from Excel with these characters in? Surely that will work. Well, on output it generates the file using Mac Latin (:WTF:?! Nobody else has used that in the OSX era.) and when reading it back in, the same file it generated, it really assumes that it's CP1250, the Windows Western European encoding (a.k.a., not-quite-ISO8859-1). Well done, Microsoft, you've made some software that can't even round-trip with itself let alone with any sane tool, at least not without making a whole bunch of twiddly adjustments along the way.
What's better, the bug report on this has a truly pathetic corporate response:
Excel for Mac does not currently support UTF-8.
If this is a feature you’d like to see in future versions of Office for Mac, be sure to send your feedback by clicking “Help” > “Send Feedback…” in any Office application or by clicking on the link below:
The link is the standard feature request one. Total failure to understand what is going on here. Idiots.
-
RE: The International Space Station is finally getting a printer upgrade
@gąska said in The International Space Station is finally getting a printer upgrade:
They're one of the most technologically advanced organizations in the world. Why print out anything?
They are part of the US Government. They have to print things out to show that they are conforming to the Paperwork Reduction Act.
-
RE: Which is better? Australia or Maths? There's only one way to find out....
@pjh He ought to try repealing the Law of Gravity and then proving his success by stepping off the top floor of a high building.
-
RE: WTF Bites
@tsaukpaetra said in WTF Bites:
"C:\WINDOWS\system32\rundll32.exe" Shell32.dll,Control_RunDLL input.dll,,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}
DISCOVERABLE!
-
RE: In other news today...
@PJH Sounds like they've emulated the behaviour of human BMW drivers perfectly!
-
RE: Signs your code is unmaintainable
For a bad code practice, the monkeypatching done widely in the Ruby-on-Rails community is a classic example of how something that makes things appear easier on the surface can really shit on long-term maintainability. The core of the issue is that it makes things so massively magical that when things go wrong, it's very hard to figure out ways to fix them in a sensible amount of time/effort. You end up with something that starts out great but progressively converts into codethulhu's pet black hole and nobody can figure how you got there because every step along the way seemed like a great idea at the time.
Latest posts made by dkf
-
RE: (are (arguments for (using lisp)) (still valid?))
@Kamil-Podlesak said in (are (arguments for (using lisp)) (still valid?)):
@dkf said in (are (arguments for (using lisp)) (still valid?)):
You end up having to write a whole load of bloated observer stuff just to work around the lack of a feature. I've written that in the past, but it's ever so nasty.
Yeah... with a little bit of foresight, this can be part of classes used by parameters, but it is a bloat. And what's worse: it's hard to read/understand and I have very hard time explaining what does it do and even why. Some well-established term for the concept would help a lot (and even better, a good explanation from someone who can actually explain stuff).
The easiest way is a chain of
isinstance
tests that call an interface with methods for each of the interesting subclasses that you are dispatching on. Defaulted methods in the interface make that a lot less horrible (when you don't care about most of the possible types most of the time) and doing it all in an interface means you keep the crud out of the classes with real logic. (I think this can be improved a bit with pattern matched sealed hierarchies, but that requires a more recent language profile than I've used.)But it is ugly. Native multiple dispatch would be nicer, even if it requires making the dispatch slower in this case (no shit, the cost is there anyway, and having to write it out by hand sucks).
-
RE: (are (arguments for (using lisp)) (still valid?))
@Kamil-Podlesak said in (are (arguments for (using lisp)) (still valid?)):
May I ask what is that trick?
Something with an operation related to implementing scripting languages in .NET. I remember reading about it in someone's blog, but not the details or where I read them.
Sorry I can't help more than that; I've never needed to write C# for work purposes. Tricky edge cases are things I'll have to leave to others.
-
RE: (are (arguments for (using lisp)) (still valid?))
@Kamil-Podlesak said in (are (arguments for (using lisp)) (still valid?)):
Just to be sure: I mean the whole concept of Design Pattern. The specific ones are kinda meh anyway.
What they should have been: here's a common name for a particular shape of solution in this type of programming language, with common consequences described. What they became for too many: a quest to shove as many buzzwords as possible into the code, whether or not doing so was either correct or made sense, and without regard for the consequences.
Yeah, almost everyone missed the "common name" and considered it a "metaprogramming", which leads to argument that "LISP and C++ don't need that because they have templates"
My first reaction on encountering design patterns was mainly "hmm, I've been doing that for a while; I didn't know this sort of thing had a proper name". That's why I've always regarded them as nice but not forcing me to use them or something; I'm able to take them for what they really are, scholarship about how programs are formed.
The one pattern I miss from Java is doing dynamic dispatch by the real types of the arguments (as you can do with CLOS); using reflection to do it is very tricky (unless you're using a sealed type tree) and there isn't anything like the trick you can do in C# to achieve it (which I believe is nasty). You end up having to write a whole load of bloated observer stuff just to work around the lack of a feature. I've written that in the past, but it's ever so nasty.
-
RE: The Official Status Thread
@topspin said in The Official Status Thread:
Aren’t you already getting a bit too old for that?
Too old to be like this?
-
RE: (are (arguments for (using lisp)) (still valid?))
@Kamil-Podlesak said in (are (arguments for (using lisp)) (still valid?)):
The best illustration is the ultimate Java thing, the worst thing about it and endless source of woe: Design Patterns. The GOF Book has been published in 1994!
They were things that were always rather abused, mostly by people not understanding them much. What they should have been: here's a common name for a particular shape of solution in this type of programming language, with common consequences described. What they became for too many: a quest to shove as many buzzwords as possible into the code, whether or not doing so was either correct or made sense, and without regard for the consequences.
-
RE: When your actions influence the outcome in a videogame it's always meh. And when there are multiple endings they are all meh too
@Captain I liked the Impressions city builder series, or at least PLEBS ARE NEEDED! after the PLEBS ARE NEEDED! first Caesar. PLEBS ARE NEEDED!
The pinnacle of the series was definitely later though.
-
RE: I, ChatGPT
@sockpuppet7 said in I, ChatGPT:
Much of the advance of neural networks is because it's possible to accelerate it with GPUs, whatever you're doing is probably a lot harder to hardware away
[Apart from the fact that I'm not doing that any more anyway...]
This is stuff that you pretty much need fancy hardware to tackle at all, not so much for computation but rather for communication. The number of messages involved is very high, and physical reconfiguration is simultaneously both much harder and critical to how real brains work. That's why brains aren't computers.
-
RE: WTF Bites
I'm not sure if this is a or if it's a clever shorthand I should add to my repertroire. ()
-
RE: WTF Bites
@Tsaukpaetra said in WTF Bites:
Yeah, first time I encountered that I was scratching my head so fucking hard because I didn't have video output and the fucking post codes made no sense for where I thought the boot progress was.
I had to resort to reading the printed documentation to figure that one out.
It was also a bit awkward to get that system set up as I needed to persuade the BIOS that the contents of the disks weren't to be used for booting (because the drivers were hosed by the previous mobo) yet the setting to do that broke the installer on the USB stick. But that was still less awful than guessing which port on the machine would actually produce video output before the video drivers were installed...
-
RE: When your actions influence the outcome in a videogame it's always meh. And when there are multiple endings they are all meh too
@sockpuppet7 said in When your actions influence the outcome in a videogame it's always meh. And when there are multiple endings they are all meh too:
I heard of LSL but didn't play
I played the first one a few times and gave up on the series as being obviously lame (the later ones were worse that way). Still don't know where the thing I was missing to get 100% was; I always ended up one point off...