|
Internet Janitor posted:For comparison, here's somebody else's C implementation based on the spec: Am I allowed to think this is very elegant code?
|
# ? Apr 4, 2012 20:01 |
|
|
# ? Jun 10, 2024 10:30 |
|
Internet Janitor posted:For comparison, here's somebody else's C implementation based on the spec: That's not the same thing though. That screenshot from before was definitely a 6502 emulator (even the opcodes match), this dcpu thing is completely different. It's got different registers, all of which are 16-bit, opcodes and ops are different (has stuff like multiply and divide but missing other things), etc. mjau fucked around with this message at 20:33 on Apr 4, 2012 |
# ? Apr 4, 2012 20:26 |
|
Threaded code? Pffft. Should be writing a jiter to get some actual performance or something, I mean I don't see any timing data or anything to indicate he's going the cycle-accurate route.
|
# ? Apr 4, 2012 21:12 |
|
Jabor posted:Threaded code? Pffft. Should be writing a jiter to get some actual performance or something, I mean I don't see any timing data or anything to indicate he's going the cycle-accurate route. I think I remember someone that did an emulator which just translated the instructions to JVM opcodes but it seems like it'd be a bitch to actually split everything into procedures when developers historically could and did just screw with the stack.
|
# ? Apr 4, 2012 23:41 |
|
welp a game designer writes terrible code
|
# ? Apr 5, 2012 01:31 |
|
tef posted:welp a game designer writes terrible code I didn't know you were a game designer!
|
# ? Apr 5, 2012 01:39 |
|
mjau posted:(has stuff like multiply and divide but missing other things) My BCD arithmetic mode! But yeah, I should've recognized the 6502 register set in his locals panel in that screenshot. Whoops.
|
# ? Apr 5, 2012 02:51 |
|
1337JiveTurkey posted:I think I remember someone that did an emulator which just translated the instructions to JVM opcodes but it seems like it'd be a bitch to actually split everything into procedures when developers historically could and did just screw with the stack. I doubt that ever could have worked. JVM performs validation on every branch to make sure that local types and stack lengths/types match up as well. You would have to out-clever the original developers by padding stacks and knowing when to pop.
|
# ? Apr 5, 2012 02:58 |
|
1337JiveTurkey posted:I think I remember someone that did an emulator which just translated the instructions to JVM opcodes but it seems like it'd be a bitch to actually split everything into procedures when developers historically could and did just screw with the stack. They didn't just screw with the stack, they also used lower-address portions of the stack space to do scratch calculations on the assumption that those memory locations were probably not holding valid stack data. Considering that things like the 6502 had a 256 byte stack that must have been tricky. To sperg on about 6502 stuff: If you read through the ROM source code for the Apple II, you'll find comments where Wozniak divided his team into 'perverts', meaning software guys, and 'non-perverts' meaning hardware guys. He would lock off sections of the hardware interop code with comments like "Perverts may not pervert the following code for any reason" and then end the section with a comment "Perverts may pervert the following code for any purpose". Before there was Subversion, they used Perversion as source control. Internet Janitor posted:My BCD arithmetic mode! The very concept behind BCD is a coding horror that belongs in this thread.
|
# ? Apr 5, 2012 03:38 |
|
PDP-1 posted:The very concept behind BCD is a coding horror that belongs in this thread. How so? A BCD encoding makes it far more efficient to format a number for display, at the cost of some additional complexity in performing arithmetic on it. It's the correct tradeoff to make in some situations.
|
# ? Apr 5, 2012 04:06 |
|
I like how almost every time someone posts a horror someone else knows why it's not a horror or not as horrible as it first seems. I think it means there are no horrible programmers.
|
# ? Apr 5, 2012 04:21 |
|
mjau posted:That's not the same thing though. That screenshot from before was definitely a 6502 emulator (even the opcodes match), this dcpu thing is completely different. It's got different registers, all of which are 16-bit, opcodes and ops are different (has stuff like multiply and divide but missing other things), etc. the "DCPU" is the cpu you can program in his new game, which is apparently basically a 16-bit 6502 clone. So I think they are the same thing.
|
# ? Apr 5, 2012 05:40 |
|
And now there's already a JS web-based version.
|
# ? Apr 5, 2012 07:31 |
|
evensevenone posted:the "DCPU" is the cpu you can program in his new game, which is apparently basically a 16-bit 6502 clone. So I think they are the same thing. In no way is this a 6502. Note that Notch originally wrote a 6502 emulator to see if that would be viable for his game (which is what's featured in the screenshot), but realized that the 6502 both provided a lot of functionality that he didn't want, and didn't provide functionality that he wanted.
|
# ? Apr 5, 2012 07:42 |
|
Suspicious Dish posted:I doubt that ever could have worked. JVM performs validation on every branch to make sure that local types and stack lengths/types match up as well. You would have to out-clever the original developers by padding stacks and knowing when to pop. For very early systems I doubt that even if someone did get something working it'd be faster than interpretation due to all the edge cases that have to be tackled. Less limited systems seem more amenable because there's less pressure to take extreme measures for performance and some particularly troublesome options become impossible. For example self-modifying code in an architecture with a split cache and jumping into the middle of an instruction with a RISC instruction set. I did find a project called JPSX which according to reports demonstrated full speed emulation of the Playstation using byte code translation with software graphics rendering to boot. There's a Google Code page for it with absolutely nothing though.
|
# ? Apr 5, 2012 08:57 |
|
code:
|
# ? Apr 5, 2012 11:57 |
|
Thermopyle posted:
I think it means we're all horrible programmers.
|
# ? Apr 5, 2012 13:02 |
|
Internet Janitor posted:For comparison, here's somebody else's C implementation based on the spec: Broken link, it can now be found on: https://github.com/swetland/dcpu16/blob/master/emulator.c Much nicer and probably faster than the notch botch. edit: spoke too soon: code:
|
# ? Apr 5, 2012 16:11 |
|
Beef posted:Broken link, it can now be found on: Maybe it's just me but that looks like it sticks to the semantics of the (fictional) ISA fairly well. That code is implementing the JSR instruction, and it's fairly readable I think. Using a switch statement for one case is odd, but other than that it doesn't look terrible for interpreting machine code. Actually, on thinking about it, the switch may be there for adding future "non-basic" instructions, as JSR is the only one specified right now.
|
# ? Apr 5, 2012 16:37 |
|
tef posted:
The only way this makes sense is if you need to mock up a third party's response during unit tests or something. At least that's the only way my brain will let me comprehend it. VVVV Just read through httplib.py and now I see what you mean. Captain Capacitor fucked around with this message at 19:20 on Apr 5, 2012 |
# ? Apr 5, 2012 17:05 |
|
It's what happens when you try to parse http messages 'offline' from files. Nearly every parser is intertwined with socket code.
|
# ? Apr 5, 2012 19:02 |
|
There's always this if you can use it.
|
# ? Apr 5, 2012 19:22 |
|
code:
This is government code. This code is protecting your borders. This is only one line of a 8000 line file containing similar methods
|
# ? Apr 5, 2012 20:03 |
|
baquerd posted:Any of these are fine: code:
|
# ? Apr 6, 2012 10:04 |
|
CGameProgrammer posted:I think a good compromise is: code:
code:
fishbacon fucked around with this message at 10:11 on Apr 6, 2012 |
# ? Apr 6, 2012 10:09 |
|
Captain Capacitor posted:There's always this if you can use it. The raw object in requests points to the underlying urlib3 structures. Which in turn wrap httplib. Which has socket code entangled with the parser. There are two parsers afaik that aren't intertwined with socket code http-parser - contains a wrapper around nginx c code & a pure python parser the pure python one doesn't seem to be rfc compliant or worse, reality compliant (specifically some servers send LF only and not CRLF, and a few get defate/gzip mixed up, head responses don't have a body but will have a content-length, and 204, 304 will not contain a body but can contain a length parameter) and the http parser I ended up writing that has been battle worn with some terrible websites edit: and sometimes you get crazy loving http messages - an earlier version of wget with warc support, decided to preserve the headers but unwrap the body, so you have to be able to skip specific headers when parsing. tef fucked around with this message at 10:29 on Apr 6, 2012 |
# ? Apr 6, 2012 10:22 |
|
PHP's == will convert arguments to floats if they look like numbers, even if both arguments are strings. That site has a lot of PHP WTFs, but this is the first time I've seen this one and I'm floored.
|
# ? Apr 7, 2012 01:31 |
|
I see we're back to the PHP part of the spiral... That WTF is actually worse than it looks at first glance. See, it's not silently converting the string to a float, it's converting the string to an integer, failing to do that because the number is too large to store as an integer, then converting it to a float.
|
# ? Apr 7, 2012 02:53 |
|
Hahaha, the PHP Sadness guy turned off commenting on his site. I guess too many people called out too many of his whines. I remember one where it was pretty clear he'd never understood what static meant. e: to be clear about what I am saying: there is much to be sad about in PHP. This guy just couldn't be told that his complaints were themselves horrors.
|
# ? Apr 7, 2012 03:44 |
|
http://www.codinghorror.com/blog/2012/04/speed-hashing.htmlcodinghorror posted:Hashes are designed to be slow codinghorror posted:In reality the usable space is substantially less; you can start seeing significant collisions once you've filled half the space, but half of an impossibly large number is still impossibly large.
|
# ? Apr 7, 2012 05:27 |
|
shrughes posted:http://www.codinghorror.com/blog/2012/04/speed-hashing.html I am struggling to understand why he describes checksums as being a way of assuring "uniqueness", or why he describes them as being like somebody's full name. The older article linked to in his second paragraph demonstrates that he does understand the purpose of a checksum, but the comparison to people's names seems fatuous.
|
# ? Apr 7, 2012 05:54 |
|
shrughes posted:http://www.codinghorror.com/blog/2012/04/speed-hashing.html codinghorror posted:If Moore's Law anticipates a doubling of computing power every 18 months, that's like peeking 10 years into the future. Pretty amazing stuff, isn't it?
|
# ? Apr 7, 2012 05:58 |
|
It's funny because he has a good point at the end: use long passwords for yourself and use bcrypt or something for your password hashes. It's just cloaked in the usual Atwood bullshit.
|
# ? Apr 7, 2012 06:08 |
|
Jeff Atwood has been publicly struggling with passwords for several years, and with pontificating on subjects of which he has little understanding for his tenure as a blogger
|
# ? Apr 7, 2012 06:10 |
|
Otto Skorzeny posted:Jeff Atwood has been publicly struggling with passwords for several years, and with pontificating on subjects of which he has little understanding for his tenure as a blogger Dog barks, news at 11
|
# ? Apr 7, 2012 06:16 |
|
Het posted:Oh come on That doesn't seem too far off. I get 10.84 years using his numbers, so he's in the right ballpark.
|
# ? Apr 7, 2012 06:38 |
|
Hammerite posted:That doesn't seem too far off. I get 10.84 years using his numbers, so he's in the right ballpark. That would be along the lines of saying "between the ages of zero and nineteen, I never scored. But one time when I was twenty, my friend had sex (with a woman). That is infinitely more sex than I ever have had. My mom was wrong. This is the future."
|
# ? Apr 7, 2012 09:58 |
|
Oh jeff
|
# ? Apr 7, 2012 12:55 |
|
hieronymus posted:That would be along the lines of saying "between the ages of zero and nineteen, I never scored. But one time when I was twenty, my friend had sex (with a woman). That is infinitely more sex than I ever have had. My mom was wrong. This is the future." What? He's clearly giving an analogy to those who aren't familiar with the power of GPGPUs for this sort of processing: "this is how powerful your CPU will be in ten years"
|
# ? Apr 7, 2012 16:34 |
|
|
# ? Jun 10, 2024 10:30 |
|
Suspicious Dish posted:What? He's clearly giving an analogy to those who aren't familiar with the power of GPGPUs for this sort of processing: "this is how powerful your CPU will be in ten years" Incidentally, it isn't. The corollary (really a misinterpretation but whatever) of Moore's Law has been dead for years, and now Dennard scaling is gone too
|
# ? Apr 7, 2012 18:40 |