5 ms·
> select "std" a = readln() show a I hate the usage of strings here. I think it's important to distinguish between strings and symbols. It makes about as much
by Pet_Ant 4y ago
> select "std"
a = readln()
show a
I hate the usage of strings here. I think it's important to distinguish between strings and symbols. It makes about as much sense as conflating strings and numbers. String is an abstraction overload well past it's breaking point.
- samatman 4y agoIn Lua, a symbol is just a string which is subject to certain parsing constraints by the interpreter. One of my favourite things about the language in fact.
- packetlost 4y agoI mean, pretty much all code is just strings subject to certain parsing constraints by the compiler/interpreter/lexer. What GP is talking about is semantic difference, which is super important in programming.
- onlyrealcuzzo 4y agoIsn't the difference just mutable vs immutable?
- packetlost 4y agouhhh... no? The difference depends on the language, but really it boils down to semantic meaning behind certain strings. x == y has different semantic meaning than "x == y" but both are literally strings of text.
- Pet_Ant 4y agoWell strings in various languages are immutable in many programming languages so that's not it. In strings I'd say the _content_ matters. If the value needs to be preserved at runtime that is a string, if after compilation the value doesn't, it's only used for binding at compilation time then it's a symbol. So, semantic litmus test I'd propose: if you search and replaced the value and recompiled, would you notice?
- onlyrealcuzzo 4y agoWhy are strings overloaded past their breaking point?
- sleeplessworld 4y agoI also don't know why. But I like the wording. This can be a new meme for programming language afficionado-skeptics: feature [...] is overloaded past its breaking point. Sent to the demi-gods at the meme ™ registrar office.
- Pet_Ant 4y agoThere seems to be some interest, so this isn't the best written, but here you go: Strings are too flexible. They can be used for anything and there should be semantic guard rails to types. Just like you never actually need booleans and enums, you could just use integers for both of those. I have seen developers instead of use strings instead of lists and just comma separate them. Strings are just a collection of characters with no restrictions to them. If you are going to add restrictions make them something else, create a better abstraction. I mean you wouldn't make a database just be nvarchar even if you could, because you aren't capturing semantic intent. Symbols do not have to be preserved at runtime, but do need to align during compilation. I mean should you be able to do string concatenation on a string in an import statement? How about to upper-case on it. If it doesn't behave like a string then it shouldn't look like one.