|
Janin posted:I'm not denying that it's *possible* to write unreadable code in Haskell. Rather, I'm simply stating that properly written Haskell is more readable than properly written Python. Oh hey, I've got some mutable state, and at intermediary mutations of said state I need to print bits of it to stdout.
|
# ? Oct 2, 2010 10:55 |
|
|
# ? Apr 27, 2024 10:32 |
|
NotShadowStar posted:
I don't understand that. Does it define a context or define a handler for a context. Is "when reading an invalid string" special or could it be anything? What the hell is subject, does it send an email in this context? What is :read_ber!? The last line suggests to be that this is defining a test, but then the name of the "context" (whatever that is) seems sheer nonsense. If this is what clear readable code looks like in Ruby I want no part of it. Zombywuf fucked around with this message at 12:18 on Oct 2, 2010 |
# ? Oct 2, 2010 11:00 |
|
Janin posted:"DSL" is what Ruby people call libraries If this is true then my god this is the biggest horror in the thread
|
# ? Oct 2, 2010 14:07 |
|
Zombywuf posted:Oh hey, I've got some mutable state, and at intermediary mutations of said state I need to print bits of it to stdout. Derpes Simplex posted:If this is true then my god this is the biggest horror in the thread
|
# ? Oct 2, 2010 15:11 |
|
Here's one I've never understood with PHP: <? for($i = "A"; $i < "Z"; $i++) { echo "$i "; } ?> output: A->Y <? for($i = "A"; $i <= "Z"; $i++) { echo "$i "; } ?> output: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA AB AC AD AE ... YZ Yes, I know the correct way of doing this, but why does it behave this way?
|
# ? Oct 2, 2010 15:58 |
|
Access Violation posted:Here's one I've never understood with PHP: The first block terminates when $i is 'Z' because 'Z' is not less than 'Z'. The second block doesn't terminate when $i is 'Z' because 'Z' <= 'Z'. Incrementing the string 'Z' in php apparently produces 'AA' because, why not? The sequence continues until 'ZZ' fails to evaluate <= 'Z'. And now that I've convinced you never to use PHP, you'll never have to worry about it again.
|
# ? Oct 2, 2010 16:16 |
|
A A 2 3 5 8 K posted:The first block terminates when $i is 'Z' because 'Z' is not less than 'Z'. The second block doesn't terminate when $i is 'Z' because 'Z' <= 'Z'. Incrementing the string 'Z' in php apparently produces 'AA' because, why not? The sequence continues until 'ZZ' fails to evaluate <= 'Z'. This is the best. PHP is definitely Caligula.
|
# ? Oct 2, 2010 16:38 |
|
A A 2 3 5 8 K posted:The first block terminates when $i is 'Z' because 'Z' is not less than 'Z'. The second block doesn't terminate when $i is 'Z' because 'Z' <= 'Z'. Incrementing the string 'Z' in php apparently produces 'AA' because, why not? The sequence continues until 'ZZ' fails to evaluate <= 'Z'. n ≰ n+1
|
# ? Oct 2, 2010 16:42 |
|
Janin posted:Good thing Haskell makes working with mutable state easy, and can write to stdout! Boy, any language which can't do either of those must be really hard to use. A language that makes it hard to do both at the same time should have been drowned at birth.
|
# ? Oct 2, 2010 21:03 |
|
Zombywuf posted:A language that makes it hard to do both at the same time should have been drowned at birth.
|
# ? Oct 2, 2010 21:45 |
|
Janin posted:Agreed! Boy, I sure am glad Haskell is not such a language. That the best you've got?
|
# ? Oct 2, 2010 21:53 |
|
I don't really know what you're getting at, so yeah. Are you implying that Haskell doesn't support mutable values? That's obviously false -- even ignoring pointers, the standard library has mutable types for various purposes (pointers, memory buffers, hash tables, mutex-protected storage, transactional storage). Are you implying that Haskell doesn't support writing to stdout? I suppose there's a lot of weird propaganda about how academical it is, but come on, give us some credit. If neither of these, then I'm lost about what you're trying to claim.
|
# ? Oct 2, 2010 22:11 |
|
Janin posted:I don't really know what you're getting at, so yeah. Both of those things, at the same time. Hint: monad combinators
|
# ? Oct 2, 2010 22:21 |
|
I don't see what monads or combinators have to do with this. Combining mutable containers and output is trivial:code:
|
# ? Oct 2, 2010 22:23 |
|
Janin posted:I don't see what monads or combinators have to do with this. Combining mutable containers and output is trivial: Wheee, let's just give up on our abstractions and shove everything into the IO monad.
|
# ? Oct 2, 2010 22:26 |
|
Oh no, using IO to perform I/O? That's, like, too much IO! I'd like to hear your suggestions on how to print to stdout without performing I/O. e: also, I am totally going to use "the ___ monad" from now on. this function returns the maybe monad! here we iterate over the list monad!
|
# ? Oct 2, 2010 22:29 |
|
Janin posted:Oh no, using IO to perform I/O? That's, like, too much IO! Data.HashTable posted:
Oh poo poo, how did that IO get there, I am not good with type hierachies.
|
# ? Oct 2, 2010 22:33 |
|
Are you really complaining that a mutable data structure is marked as mutable? Really?
|
# ? Oct 2, 2010 22:38 |
|
Janin posted:Are you really complaining that a mutable data structure is marked as mutable? Really? Yerrrs, the IO monad marks data as mutable. This is why MonadState derives from it. Do you actually know Haskell?
|
# ? Oct 2, 2010 22:41 |
|
If you really want to use a monad transformer or something, it doesn't look much worse. It just performs a little weird because you're not automatically strict in modifications anymore and you no longer have a guarantee of mutable state, only the strong reason to believe that the compiler will choose that particular optimization; you can't guarantee mutable structures outside of ST or IO, because that's what they're for.code:
|
# ? Oct 2, 2010 22:48 |
|
Zombywuf posted:Yerrrs, the IO monad marks data as mutable. This is why MonadState derives from it.
|
# ? Oct 2, 2010 22:51 |
|
ShoulderDaemon posted:If you really want to use a monad transformer or something, it doesn't look much worse. It just performs a little weird because you're not automatically strict in modifications anymore and you no longer have a guarantee of mutable state, only the strong reason to believe that the compiler will choose that particular optimization; you can't guarantee mutable structures outside of ST or IO, because that's what they're for. Also, if you want strict state in a transformer, use Control.Monad.State.Strict.
|
# ? Oct 2, 2010 22:53 |
|
Janin posted:This isn't an example of mutability; Control.Monad.State is actually just a wrapper around (\state -> (result, newState)) -style functions. IO and ST are the only types which support true mutability. Exactly. The compiler may be able to optimize such accesses into mutation internally, but there's no guarantee it'll do so.
|
# ? Oct 2, 2010 22:57 |
|
Janin posted:This isn't an example of mutability; Control.Monad.State is actually just a wrapper around (\state -> (result, newState)) -style functions. IO and ST are the only types which support true mutability. So you can only have mutable state by dropping into another language?
|
# ? Oct 2, 2010 23:02 |
|
Zombywuf posted:So you can only have mutable state by dropping into another language?
|
# ? Oct 2, 2010 23:02 |
|
Janin posted:No, you have mutable state by using the IO and ST kinds. FTFY IO is a monad to let you communicate with the world outside Haskell, for example with the FFI. If you are using it for mutable state alone you are simply referencing another language, not making use of Haskell's support for mutable state.
|
# ? Oct 3, 2010 10:43 |
|
Why are you all being over Haskell anyway? It's Haskell. You do it for a term at uni, scrape a pass in functional programming and drat well make sure you never have to apply for a job where you need to use it again in the real world. I keep my Haskell programming book on my bookshelf as a stark reminder.
|
# ? Oct 3, 2010 13:07 |
|
Zombywuf posted:FTFY Have you ever used Haskell? It's starting to seem like you've only heard about it by reading wikibooks and browsing /r/programming . The FFI isn't "outside Haskell", it's part of the standard language definition, and deals with much more than just language bindings. By your logic, C isn't capable of mutable state or output because pointers and printf() are part of "another language". e: also, ST and IO aren't kinds, they're types. Milotic posted:Why are you all being over Haskell anyway? It's Haskell. You do it for a term at uni, scrape a pass in functional programming and drat well make sure you never have to apply for a job where you need to use it again in the real world. TOO SCSI FOR MY CAT fucked around with this message at 15:54 on Oct 3, 2010 |
# ? Oct 3, 2010 15:26 |
|
Milotic posted:Real programmers [1] use Haskell in the real world. If you thought Haskell was something to discard after one term, well, you're a bad programmer. [1] People doing interesting things, those who don't like languages because of Stockholm syndrome. Janin posted:Haskell Haskell merely specifies how the program should change state. The state is actually changed by the compiled executable .
|
# ? Oct 4, 2010 02:22 |
|
shrughes posted:Haskell merely specifies how the program should change state. The state is actually changed by the compiled executable .
|
# ? Oct 4, 2010 02:34 |
|
Janin posted:The compiled executable merely specifies how the program should change state. The state is actually changed by the hardware . The hardware does not change any state, it's an unchanging four-dimensional object in spacetime .
|
# ? Oct 4, 2010 03:15 |
|
shrughes posted:Real programmers Using this phrase is a horror.
|
# ? Oct 4, 2010 04:54 |
|
Contra Duck posted:Using this phrase is a horror. Agreed. Unless it's meant to be a derogatory description of the kind of people that attend Perl Monks meetings.
|
# ? Oct 4, 2010 05:03 |
|
People stuck in the enterprise acid mines itc
|
# ? Oct 4, 2010 05:59 |
|
shrughes posted:Real programmers [1] use Haskell in the real world. If you thought Haskell was something to discard after one term, well, you're a bad programmer. "Real programmers" use what's on the defined strategic technology path for their company. Also "trap sprung" etc. You chaps are easy pickings.
|
# ? Oct 4, 2010 07:59 |
|
Milotic posted:
that's not at all what this means
|
# ? Oct 4, 2010 08:10 |
|
Milotic posted:the defined strategic technology path Spoken like a true programmer.
|
# ? Oct 4, 2010 08:11 |
|
Net::CUPS loving sucks. In order to get information about a specific job, you have to call getJob, which internall calls the cupsGetJobs C function to get a list of every print job that the printer knows about, then iterates over it to find the appropriate job by checking the jobid. Now, to be fair, this isn't its fault, since CUPS doesn't provide any 'tell me about job N'. What is its fault is that a: there's no sign at all that getJob has this kind of behavior, and b: there's no 'get all jobs'/'get all queued jobs' function, which would be trivial to write using the CUPS API. Instead, you have to call getJobs, which returns the appropriate list of job IDs, then loop over it. Which will wind up being O(n^2) in the number of jobs in the print queue for something that should be an O(n) operation. CUPS itself is lovely; there are functions called cupsGetJobs and cupsGetJobs2, the only difference being that the latter forces you to specify which server to get jobs from. There's also cupsGetPPD, cupsGetPPD2, and cupsGetPPD3, which perform related but different operations. Want a way to remember which does what? Too bad. Opinion Haver fucked around with this message at 08:21 on Oct 4, 2010 |
# ? Oct 4, 2010 08:19 |
|
Janin posted:Sure, learning Haskell won't get you hired at some lovely 50k/year PHP farm, but that doesn't seem like a problem. This one struck me right in the ego. I'll have you know that I'm a real programmer
|
# ? Oct 4, 2010 16:36 |
|
|
# ? Apr 27, 2024 10:32 |
|
Smugdog Millionaire posted:This one struck me right in the ego. I'll have you know that I'm a real programmer I'll have you know that I'm a fictional programmer!
|
# ? Oct 4, 2010 18:10 |