|
Completely not a question, but holy Christ, Erlang's list comprehensions make Python's list comprehensions look like for loops and I had to post somewhere.
|
# ? Jun 26, 2011 05:25 |
|
|
# ? Jun 9, 2024 06:01 |
|
Misogynist posted:Completely not a question, but holy Christ, Erlang's list comprehensions make Python's list comprehensions look like for loops and I had to post somewhere. I think the word "for" in the python list comps makes them look like for loops
|
# ? Jun 26, 2011 05:38 |
|
Is there already a thread on Amazon web services? I'm beginning to play around with some of their stuff, and it sure would be nice to have one.
|
# ? Jun 28, 2011 00:05 |
|
I'm suddenly really interested in functional programming languages and am already learning Erlang, OCaml and Haskell. What's Scala good at?
|
# ? Jun 28, 2011 03:39 |
|
Misogynist posted:What's Scala good at?
|
# ? Jun 28, 2011 03:57 |
|
I'm writing a program that converts an image into a JPEG. It turns it from RGB to YUV, then does a 4:2:0 chroma subsample, and then does an 8x8 DCT. The problem is, I have no idea if the images it's outputting are correct. edit: Nevermind, figured it out, forgot to increment a variable! Acer Pilot fucked around with this message at 12:09 on Jun 28, 2011 |
# ? Jun 28, 2011 07:39 |
|
Other than performance, are there any good reasons not to use exceptions for flow control?
|
# ? Jun 28, 2011 17:48 |
|
Exceptions have roughly the readability characteristics of a goto.
|
# ? Jun 28, 2011 18:04 |
|
Taken too far it's really easy to end up with incomprehensible spaghetti code that might as well be using goto for everything.
|
# ? Jun 28, 2011 18:06 |
|
In Python, it's pretty common to use exceptions as flow control. Just pick what is the most readable and practical...
|
# ? Jun 28, 2011 18:24 |
|
The only reason goto is ever a problem is when it causes execution to jump backwards through a program. Exceptions are basically glorified breaks or returns, which I'm certain everybody loves.
|
# ? Jun 28, 2011 19:11 |
|
qntm posted:Other than performance, are there any good reasons not to use exceptions for flow control? Keep in mind what a reader of your code will likely expect. If an exception in the given language or domain typically means "terrible things happening", using them for flow control makes it harder for the reader to understand your code. If an exception is raised whenever an iterator completes, however, your reader may be used to seeing exceptions used this way.
|
# ? Jun 28, 2011 19:12 |
|
pokeyman posted:Keep in mind what a reader of your code will likely expect. If an exception in the given language or domain typically means "terrible things happening", using them for flow control makes it harder for the reader to understand your code. If an exception is raised whenever an iterator completes, however, your reader may be used to seeing exceptions used this way. Exactly. It's not syntactically or semantically wrong to use exceptions for control flow, but it's pragmatically very bad.
|
# ? Jun 28, 2011 19:14 |
|
All the C# guidance I've seen is along the lines of "Never use exceptions for flow control. No not even then. We mean it." and in a C# context I can't see any reason why you'd want to. Depends on the language I guess? But in most cases I've seen exceptions ruin readability when used in that way.
|
# ? Jun 28, 2011 19:16 |
|
code:
|
# ? Jun 28, 2011 19:33 |
|
Kill it with fire!
|
# ? Jun 28, 2011 19:38 |
|
code:
|
# ? Jun 29, 2011 08:36 |
|
Those are grotesque. More, please.
|
# ? Jun 29, 2011 09:38 |
|
A good start, but perhaps it could be made into a more generalized solution with templates?
|
# ? Jun 29, 2011 18:17 |
|
Zombywuf posted:
FWIW, this slices the object and will not be caught by either clause. Throwing a pointer wouldn't work either, because throws in C++ always use the static type of the exception expression.
|
# ? Jun 29, 2011 20:20 |
|
I'm learning to program as a hobby, and I spend seven hours a day parked in front of a computer at work. My work really doesn't require much, so I spend a lot of that time here on the forums. I don't have admin access to the computers, so I can't install Ruby or Python on them, so no matter how much time I spend reading about it, I can't get any actual programming practice during that time. My question is, are there any ways I can practice programming over the internet? IE, set up a server on my home computer or something and upload files to it? I could just write stuff all day and test it when I get home, but I feel like I wouldn't really get there with that approach. At the very least, is there a web-based version of IRB (interactive Ruby something something) where I could test my code?
|
# ? Jun 30, 2011 18:24 |
|
Pucklynn posted:I'm learning to program as a hobby, and I spend seven hours a day parked in front of a computer at work. My work really doesn't require much, so I spend a lot of that time here on the forums. I don't have admin access to the computers, so I can't install Ruby or Python on them, so no matter how much time I spend reading about it, I can't get any actual programming practice during that time. There's lots of online python interpreters. Just google "online python interpreter". There's also Portable Python which doesn't require installation.
|
# ? Jun 30, 2011 18:28 |
|
You could try http://codepad.org/, which has ruby and python interpreters. It's not quite the same as IRB, but it's pretty neat.
|
# ? Jun 30, 2011 18:29 |
|
CodePad just made me cackle and clap my hands together like an underage evil mastermind. Thank you!
|
# ? Jun 30, 2011 18:59 |
|
Pucklynn posted:CodePad just made me cackle and clap my hands together like an underage evil mastermind. Thank you! Also look into Ideone, it's what I use for testing code snippets.
|
# ? Jun 30, 2011 21:48 |
|
Pucklynn posted:My question is, are there any ways I can practice programming over the internet? IE, set up a server on my home computer or something and upload files to it? I could just write stuff all day and test it when I get home, but I feel like I wouldn't really get there with that approach.
|
# ? Jun 30, 2011 23:58 |
|
Pucklynn posted:I'm learning to program as a hobby, and I spend seven hours a day parked in front of a computer at work. My work really doesn't require much, so I spend a lot of that time here on the forums. I don't have admin access to the computers, so I can't install Ruby or Python on them, so no matter how much time I spend reading about it, I can't get any actual programming practice during that time. Others have already linked you to online interpreters. Other approaches you can use: - Portable Cygwin does not require admin rights to run, and is a complete linuxy development environment, including python, ruby, lua, etc interpreters and C/C++ compilers. Requires some comfort with the command line. - You can also set up a server at home and use a portable version of PuTTY or NXClient to talk to it from work, either simple uploading/downloading of files, or doing actual development remotely.
|
# ? Jul 1, 2011 00:30 |
|
DJ Bernstein's primegen utility contains this snippet in its source:code:
|
# ? Jul 1, 2011 04:10 |
|
Misogynist posted:DJ Bernstein's primegen utility contains this snippet in its source: Unrolling the loop 4x manually Between that, the fact that register is used (almost all compilers ignore it entirely), and pre-C89 function syntax is used, I'm tempted to think this is originally from something much older, but I wouldn't expect djb to do that given his nature, sooooooooo Also the argument order is kinda curious imo
|
# ? Jul 1, 2011 04:15 |
|
Misogynist posted:Can anyone explain why the loop is doing... uh, whatever it is it's trying to accomplish by putting that same check four consecutive times? It's been unrolled.
|
# ? Jul 1, 2011 04:15 |
|
Note that it's formatted in a confusing way for no good reason. This would've made it obvious that the if's aren't actually consecutive and that n is changing between each:code:
|
# ? Jul 1, 2011 11:04 |
|
Mustach posted:Note that it's formatted in a confusing way for no good reason.
|
# ? Jul 1, 2011 14:12 |
|
Nippashish posted:It's been unrolled.
|
# ? Jul 1, 2011 14:25 |
|
Misogynist posted:I figured as much but was confused about why this would be done by hand instead of letting the compiler optimize it, then I realized that the compiler won't unroll an infinite loop for obvious reasons. Thanks. Even very modern compilers working with finite loops can benefit amazingly from manual loop unrolling, especially if you want to target specific hardware.
|
# ? Jul 1, 2011 15:34 |
|
The code is inefficient on current hardware though, you get better performance with by prefetching the source buffer in parallel and filling the cache line:code:
Similarly you can get more performance by copying with longer words but not always. Best performance is to use the assembler instruction for string copy if the string is long enough to overcome the instruction startup costs. On latest Nehalem chipsets as has been posted about a lot it's actually faster to copy in reverse than forward too. MrMoo fucked around with this message at 16:10 on Jul 1, 2011 |
# ? Jul 1, 2011 16:04 |
|
ChiralCondensate posted:Actually, there's a very good reason: having the same characters right on top of each other makes it easy at a glance to see that the four lines are exactly the same.
|
# ? Jul 1, 2011 19:06 |
|
Mustach posted:That sounds like a worthless reason to me. You are a source code canonicalizationist and you will burn in hell.
|
# ? Jul 1, 2011 19:46 |
|
Are there any Haskell implementations that run from a USB key without too much screwing around?
|
# ? Jul 1, 2011 19:53 |
|
EDIT: Wrong thread.
|
# ? Jul 1, 2011 22:06 |
|
|
# ? Jun 9, 2024 06:01 |
|
shrughes posted:You are a source code canonicalization and you will burn in hell.
|
# ? Jul 1, 2011 22:56 |