|
Also, smash the state. No, that's wrong. Smash state.
|
# ? Sep 8, 2017 05:46 |
|
|
# ? May 21, 2024 04:25 |
|
Foxfire_ posted:
The difference is that it'd be legal for the C program to format your hard drive because it's undefined behavior, not just implementation-specified, but not for the Python program to do so
|
# ? Sep 8, 2017 05:52 |
|
any project as large as CPython probably has undefined behaviour lurking somewhere, so the interpreter might just decide to format your hard drive anyway
|
# ? Sep 8, 2017 06:06 |
|
Foxfire_ posted:Only real difference is that C doesn't specify an order to its + operator and Python does.
|
# ? Sep 8, 2017 07:32 |
|
If you made your lists immutable none of this would be an issue.Python code:
I don't want to be religious about the no side effects thing. Imperative programming is fine too, but constructs like this that both modify and return are trying to have it both ways and just asking for trouble. Why should x.append(1) return anything? KernelSlanders fucked around with this message at 03:44 on Sep 9, 2017 |
# ? Sep 9, 2017 03:33 |
|
KernelSlanders posted:Why should x.append(1) return anything? It doesn't.
|
# ? Sep 9, 2017 03:35 |
|
Suspicious Dish posted:It doesn't. heh, that's what i get for replying to a post without evaluating it critically I guess
|
# ? Sep 9, 2017 03:45 |
|
and that's what I get for writing examples while tired without running them everybody pretend I wrote this instead please code:
|
# ? Sep 9, 2017 03:59 |
|
KernelSlanders posted:Why should x.append(1) return anything? It does return something. It returns None.
|
# ? Sep 9, 2017 05:39 |
|
This is where Haskell shows its superiority. The operations with potential side effects live in the IO monad, so they have to be explicitly sequenced, and thus cannot have an undefined or implementation-dependent evaluation order.
|
# ? Sep 9, 2017 07:46 |
|
Zemyla posted:This is where Haskell shows its superiority. The operations with potential side effects live in the IO monad, so they have to be explicitly sequenced, and thus cannot have an undefined or implementation-dependent evaluation order. Comedy response: until you call FFI C code
|
# ? Sep 9, 2017 07:49 |
|
FoiledAgain posted:It returns None.
|
# ? Sep 9, 2017 08:54 |
|
Zemyla posted:This is where Haskell shows its superiority. The operations with potential side effects live in the IO monad, so they have to be explicitly sequenced, and thus cannot have an undefined or implementation-dependent evaluation order. What is the result of code:
|
# ? Sep 9, 2017 11:16 |
Zemyla posted:This is where Haskell shows its superiority. The operations with potential side effects live in the IO monad, so they have to be explicitly sequenced, and thus cannot have an undefined or implementation-dependent evaluation order. Wait, but isn't the evaluation order still really important in Haskell because of how laziness works? For example it's important that && evaluates its first argument first, so that if you evaluate false && some_expensive_predicate then some_expensive_predicate isn't evaluated.
|
|
# ? Sep 9, 2017 17:52 |
|
VikingofRock posted:Wait, but isn't the evaluation order still really important in Haskell because of how laziness works? For example it's important that && evaluates its first argument first, so that if you evaluate false && some_expensive_predicate then some_expensive_predicate isn't evaluated. Since && is a library function, this is entirely up to how you do the pattern matching. For example, this definition would not be short-circuiting: code:
code:
|
# ? Sep 9, 2017 18:34 |
|
Linear Zoetrope posted:Comedy response: until you call FFI C code Non-comedy response: FFI C code should have its signature return an IO value if it is impure.
|
# ? Sep 9, 2017 18:44 |
|
Hey, it's that time again! Nothing quite like sprinkling an existing data interchange format with a generous helping of new features. It's irresistable!
|
# ? Sep 10, 2017 05:46 |
|
The lack of trailing commas in JSON is a legit complaint. Comments, unquoted keys, and the other stuff aren't nearly as irritating, and IIRC there are good reasons to not support comments (though I forget what they are). Given that, I'm still not dumb enough to try to make a new version of a standard, especially a non-backwards-compatible one.
|
# ? Sep 10, 2017 05:55 |
|
Within a particular schema comments can be added trivially by simply ignoring a particular key. I'm fond of "//".code:
|
# ? Sep 10, 2017 06:10 |
|
KernelSlanders posted:Within a particular schema comments can be added trivially by simply ignoring a particular key. I'm fond of "//". What's the use case there, though? Comments only seem helpful to me in say config files, and there I'd rather change my application to use a parser that handles some JSON variant that allows comments (we use HOCON), than have to write custom logic to handle special keys in any arbitrary object, while severely limiting the number and location of comments. Perhaps there's something else I'm missing?
|
# ? Sep 10, 2017 06:15 |
|
My two principle use cases are config files (although I too will use HOCON when I can) and annotating JSON unit test fixtures.
|
# ? Sep 10, 2017 06:47 |
|
JSON is fine for what it is, and HOCON is really good for config files that people will edit. Just not YAML, anything but YAML
|
# ? Sep 10, 2017 07:11 |
|
Sedro posted:JSON is fine for what it is, and HOCON is really good for config files that people will edit. Just not YAML, anything but YAML lol. literally the only thing that matters to me as a dev is that I'm way more likely to have a Yaml deserialization library available than a hocon one meanwhile as a user, hocon still has braces and commas and poo poo, so I'd much rather edit yaml, tyvm. if you're worried i might be an rear end in a top hat and do the weird corner case stuff you can find in the yaml spec, then toml is an acceptable substitute
|
# ? Sep 10, 2017 09:20 |
|
Durrcode:
And YAML... I've had to work on an application where someone decided to use it as a configuration format. It's a complete pain. The spacing is just about as ridiculous as Python's inability to understand program grouping, and it's really cute when the YAML parses beautifully and successfully until it's passed to Python where there's a bunch of parse errors because PyYAML gets confused (at least I seem to recall that's the module that was being used). Then one day I was using abbreviations only to find out that the app designer choose YAML despite the transport mechanism being SOAP (there's another horror story, I suppose), and it doesn't pass data unmodified because it's XML. Woohoo, let's blast all the ampersands! (on the way in but not on the way out) Myself, I'm still partial to ASCII 0x1c--0x1f. PhantomOfTheCopier fucked around with this message at 10:08 on Sep 10, 2017 |
# ? Sep 10, 2017 10:04 |
|
We should start classifying data formats as "human-writable" instead of "human-readable". Because every plain-text data format is human-readable, but users will gently caress up anything that's not as basic as an INI file.
|
# ? Sep 10, 2017 15:11 |
|
I wish all my config files were .nix! Stop the .toml madness!
|
# ? Sep 10, 2017 15:22 |
|
XML isn't human readable.
|
# ? Sep 10, 2017 16:09 |
|
Ranzear posted:There was probably some debug logging stuffed in there at one point. You could just do this in that case: code:
|
# ? Sep 10, 2017 16:44 |
|
pseudorandom name posted:XML isn't human readable. <butt size="fat" scent="foul"/> ? Unreadable garbage fit only for robots. But {"butt":{"size":"fat","scent":"foul"}} is good and very human friendly.
|
# ? Sep 10, 2017 17:03 |
|
Internet Janitor posted:Hey, it's that time again! Man, I saw that first sentence and immediately thought "oh gently caress," but I actually did cook up something that works exactly like the handlers parameter in JSON plus for a project a few years ago, I guess I should've made it a standalone library.
|
# ? Sep 10, 2017 17:18 |
|
TooMuchAbstraction posted:The lack of trailing commas in JSON is a legit complaint. Comments, unquoted keys, and the other stuff aren't nearly as irritating, and IIRC there are good reasons to not support comments (though I forget what they are) Except YAML. YAML sucks balls.
|
# ? Sep 10, 2017 22:22 |
|
Vanadium posted:I wish all my config files were .nix! You may want to look into dhall, a typed, functional, total language with a toNix converter. Actually, I think I've heard it grew from a project of adding types to nix? I'm still not sure 100% if this is a horror, but weirdly, it can also import expressions by url, and its prelude is hosted on ipfs. code:
|
# ? Sep 10, 2017 22:54 |
|
always define your own human-readable data containers and don't tell anyone else how they work
|
# ? Sep 10, 2017 22:55 |
|
QuarkJets posted:always define your own human-readable data containers and don't tell anyone else how they work Adjust the value of "human" as appropriate
|
# ? Sep 10, 2017 23:06 |
|
I usually encode data so that it's readable by dogs
|
# ? Sep 10, 2017 23:10 |
|
QuarkJets posted:always define your own human-readable data containers and don't tell anyone else how they work
|
# ? Sep 10, 2017 23:20 |
|
PhantomOfTheCopier posted:There is nothing better than Data:: Dumper. quote:If it's not quite clean enough for you, I recommend Acme::Bleach.
|
# ? Sep 10, 2017 23:46 |
|
Maybe the constraints on data interchange formats and config file formats are sufficiently different that they deserve two different file formats?
|
# ? Sep 10, 2017 23:55 |
|
KernelSlanders posted:Maybe the constraints on data interchange formats and config file formats are sufficiently different that they deserve two different file formats? Config files are just serialized behavior, though.
|
# ? Sep 11, 2017 01:05 |
|
|
# ? May 21, 2024 04:25 |
|
Absurd Alhazred posted:Config files are just serialized behavior, though. So are files containing code, both as written by humans and compiled code. So let's just use JSON for everything!
|
# ? Sep 11, 2017 01:10 |