News for hackers. Stuff that matters.
Re:Dragon Programming Language by Pet_Ant on Tuesday March 07, 2023 @09:30AM (#35055725)
> 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.

Re:Dragon Programming Language by samatman on Tuesday March 07, 2023 @09:48AM (#35055912)
In 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.

Re:Dragon Programming Language by packetlost on Tuesday March 07, 2023 @09:55AM (#35056013)
I 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.
Re:Dragon Programming Language by onlyrealcuzzo on Tuesday March 07, 2023 @10:53AM (#35056739)
Isn't the difference just mutable vs immutable?
Re:Dragon Programming Language by packetlost on Tuesday March 07, 2023 @02:31PM (#35060025)
uhhh... 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.
Re:Dragon Programming Language by Pet_Ant on Tuesday March 07, 2023 @02:33PM (#35060037)
Well 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?

Re:Dragon Programming Language by onlyrealcuzzo on Tuesday March 07, 2023 @10:54AM (#35056747)
Why are strings overloaded past their breaking point?
Re:Dragon Programming Language by sleeplessworld on Tuesday March 07, 2023 @12:35PM (#35058304)
I 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.
Re:Dragon Programming Language by Pet_Ant on Tuesday March 07, 2023 @02:26PM (#35059949)
There 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.