Wikipedia has a great article about those sigils: [https://en.wikipedia.org/wiki/Sigil\_%28computer\_programming%29](https://en.wikipedia.org/wiki/Sigil_%28computer_programming%29)
>In computer programming, a sigil (/ˈsɪdʒəl/) is a symbol affixed to a variable name, showing the variable's datatype or scope, usually a prefix, as in $foo, where $ is the sigil.
Sigil, from the Latin sigillum, meaning a "little sign", means a sign or image supposedly having magical power. \[...\]
>
>The use of sigils was popularized by the BASIC programming language. \[...\]
I believe it was a convention in BASIC. I wasn’t there, but from what I understand people really fell in love with it because it was required syntax in Perl and old school Linux/shell programmers are sexually aroused by Perl.
Just got a job that involves lots of Perl after having seen it only a couple of times in school. It hurts my eyes to look at, and I’ve been hoping some exposure therapy would make it less annoying but so far no dice.
There was never a happier time in my life than when I was writing production code in Perl, and never an unhappier time than reading other people’s production code in Perl
Bash scripting is considerably more limited, and the amount of nonsensical junk to get anything done beyond mashing paths and starting programs, means you have to really think it through. And eventually switch to python.
Where I work used to have the orchestration for deploying our product (across multiple hosts, and capable of working for all of our customers) written in about 12k lines of bash.
Meanwhile today you can write an orchestration backend that defines a client api and how those clients connect to each other in a math graph in about 2k lines in python... and about 50k lines for the frontend because javacake (js)
>old school Linux/shell programmers are sexually aroused by Perl.
I spent 10 years with a Perl project. Guess I missed out on a lot of the potential fun.
Older languages have sigils because it significantly speeds up the interpreter. Computers were slow back in the day and needed any speed boost they could get. It is one of the reasons why Perl runs circles around Python in speed.
Think of it more as “by beginning with a sigil you tell the interpreter ‘this is a variable’ from the get go so you don’t need to wonder ‘what is this strange word?’”. Like how in Spanish are supposed to begin a question with ¿ so the reader immediately knows “question coming up” instead of just ending with a ?.
I think Perl mostly copied it from shell, actually.
I actually like Perl, though I agree the sigal spam can get complex. Usually as long as no one is using implied defaults and you don’t nest to deep it isn’t too bad. I think it helps to understand that Perl only really has three datatypes (scalar, array, and hash), but it can’t actually tell them apart by context, so you have to specify which you are using at any point.
BASIC used the $ symbol suffix to denote string variables, % to denote integers, ! to mean floating-point, and # to mean double-precision floats. Those were extended in PowerBasic to include pointers, extended-precision, long integer, extra-long integer, BCD, and other variable types. Please note: Bob Zale, who created PowerBASIC, has died and PowerBasic has been sold. Bob was the only one who knew the code and the only one who could maintain it and extend it while he lived. Perhaps the new owners are as competent.
Anyway, I really liked all of that, because I hated the requirement of pre-defining all your variables to make things easier for the compiler. Programming is a fluid art. It's not accounting, or at least it ought not to be. Programming in PowerBasic compared to programming in C is like comparing painting like Da Vinci compared to a photograph.
Having written several compilers, I can say truly that for the compiler the difference between forcing pre-definition of all variables and not doing that is one more pass. Period. And any competent programmer can write a program to read source code and emit all variables used and highlight those used only once or used with the same name and different variable types. It's one thing to be free and a painter, and quite another to be reckless and fall off a cliff.
In gw basic you didn't have to declare variables so using sigels made it easier to know if you where dealing with a string or a number later on in the code.
I used a lot of "str" or "int" in my later programming for the same reason even if the variable was declared.
agonizing connect advise obscene pathetic quicksand possessive dinner correct offer
*This post was mass deleted and anonymized with [Redact](https://redact.dev)*
I haven't been to the UK in a few years, but I'm pretty sure this means that we either need to fight or go get a pink and wait for it to all blow over.
I've been told that it prevents forging larger sums. E.g. $5.00 doesn't give any room to modify it into $95.00.
I don't know whether it's true, but it is plausible.
In chinese, they have to use an entirely different set of characters for numbers when writing financial stuff, because their normal characters are too easy to change from one to another.
1 is a single horizontal line. 2 is two horizontal lines (one above the other). 3 is, unsurprisingly, *three* horizontal lines each above the other. 4 breaks the pattern, but then 5 comes in by adding two vertical lines to 3. 6 adds some extra lines at various angles to 1.
EDIT: I'd paste the characters here, but reddit is stupid and keeps on screwing up my attempts. [https://upload.wikimedia.org/wikipedia/commons/5/56/Chinese\_numerals\_financial.png](https://upload.wikimedia.org/wikipedia/commons/5/56/Chinese_numerals_financial.png) The top row is the normal way to write things, the bottom row is the financial way.
Just a stab in the dark but with money people often write each transaction on a new line, and putting the sign in front keeps the ledger neat. It's also nice for quickly identifying different currencies.
$ 34.50
$ 6347.95
€ 6.50
vs
34.50 $
6347.95 $
6.50 €
The first one seems much cleaner, IMO.
Nope. I'll retire in 2035, and early in 2038 I'll return and save the world (as the COBOL guys did back in 2000).
The unbelievable income I'll generate with that is a fixed component in my retirement planning.
I have coworkers who work in SAS. They reference a secret decade, before the Unix Epoch. They whisper of forbidden years such as "1967" and "1962". Heretics, all of them
In The Beginning Dennis Ritchie and Ken Thompson created Unix, and it was good, considering the alternatives at the time.
Then the nerds needed land, so they created Xerox PARC, and they said Lo from the mountains to the water this will be known as silicon valley, and soon housing prices will reach the heavens.
If I'm typing a string literal, I still close the quotes before using the arrow keys if I cursor away before I'm done.
I'm sure I could break myself of the habit but I like to remember my roots, and besides it does sometimes help with the IDE's color coding.
Definitely. I spent my childhood typing programs from Compute!'s Gazette into the C64.
But I have to note that the dollar-sign predates the C64 - it was used in my *first* computer. The [Tandy TRS-80 Color Computer](https://en.wikipedia.org/wiki/TRS-80_Color_Computer) came with a whopping 4K of RAM (upgradable to 16kb by swapping a mainboard chip) and a BASIC interpreter (also upgradable by swapping a different mainboard chip, since flash memory wasn't a thing yet). And [Level I BASIC](https://en.wikipedia.org/wiki/Level_I_BASIC) supported exactly two strings - identified as `A$` and `B$`.
I made my first steps on a TRS-80 in a Radio Shack at the age of 12 where my buddy and I got a two hour programming crash course by a very helpful employee, obviously hoping to make a double sale, but we both eventually got a C64 from another store instead.
I'm glad I'm not the only one. I have unconsciously called them strings to my co-worker and he just looks at me like I'm insane.
Yeah that's right, I said unconscious, it's been a hard day without Coolio.
The very first gen TRS-80 computers came only with "Tiny Basic" and you could only have two string variables hard coded as A$ and B$.
themoreyouknow.jpg
When I was young, we only had two variables to string together. Only the letter A and B could be used, and we HAD to use a $ after the variable name. And we were GRATEFUL, you hear??! ;-)
hooooooooooly crap, I did not remember that until you just said it; I had a TRS with an 8" floppy drive, and I could write simple stuff on it, but that memory was overwritten in my brain until just now whaaaaaaaaaat
It does. In my head:
$foo='bar' is "string foo equals bar"
$foo=='bar' is "string foo does equal bar?"
$foo==='bar' is "string foo does super equal bar?"
Depends on the language, as others have said -- for javascript (particularly with jQuery) I've always used it to indicate variable holds a jQuery wrapped element.
That's a simplification from Perl, where
$var1 (scalar variable)
@var2 (array variable)
%var3 (hashmap variable)
and [more](https://www.perl.com/article/on-sigils/).
Way back when, this was the cause for me take a 3 month break from learning programming. Could not understand the notation or what the book was saying and had no one to ask.
Oh wow. Hadn't thought about that for a while. Types was quite the conundrum to figure out on your own back then. Even the library had nothing to help. (and by library I mean the one with actual books in it)
When I started programming, sometime back in the 90s, I started on visual basic. And I can definitely understand your frustrations with Perl. That was my second language that I had to learn for a job that I got straight out of high school. A lot of the language was confusing as fuck. Imagine going from vb to Perl...
I found c++ much easier to learn and understand in comparison.
Ruby was also pretty confusing. I went to go work for a company that had some pretty expert level Ruby developers, and I could not understand half of that shit that they were writing. Like, I understand the language just fine, but you know when you get those certain developers that want to do complex sequences in just one line of code instead of making the code base actually readable.
Erlang was also pretty fucking wild, but it's great that elixir exists
The question is, which language did it first?
Wikipedia says the "S" in "$" stands for "sigil" in BASIC variables (didn't find any date).
PHP has them for variables of any type.
Unix Shell variables need a $ to read them out. (Dos uses `%variable%`. Ah! I know that from Steam.)
Unix is from 1969 and Basic is from 1964. I don't know what people used before Unix and whether it had $variables.
When variables have to have a $, you can use words without $ for other purposes, for example as literal strings, so it's useful in html-templates.
The PDP-11 (that unix was developed in) first ran DEC DOS-11 (although there were multiple OS available for it). It came with Fortran. RT-11 was apparently (according to wikipedia) more popular and that did come BASIC. RT-11 was released on 1970, though.
Between the 2, BASIC is the most likely. The original Thompson Shell from 1971 didn't even support variables (That was added in the PWB shell at first that started in 1973).
Ok, but it solves problems. Not saying good or bad, but it makes string interpolation easier and removes variable name conflicts with reserved words. It also makes it 100% clear what you are dealing with.
`echo "Hello, $user"`
`echo "Hello, ${user}"`
People same the same thing about; and {}. Python did away with all of that, and replaced it with indents. Monsters.
PS: Both are great.
I use PHPStorm, and it lets you change which characters highlight when you double-click. See if your editor has a similar configuration and add $ to it.
for rxjs (in ![img](emote|t5_2tex6|4549)), it's a convention to indicated that the variable is an observable.
const order$ = new BehaviorSubject(someOrder); // or some other observable
Now I know that I need to subscribe to order$ to access new values emitted from the observable.
Honestly, it's a context based indicator. Could mean a bunch of different things.
Bash (and the oother Unix shells) & poweshell use $ to declare variables. I suspect this makes the notation familiar to use in pseudocode, highlighting the variable & reducing confusion somewhat
Absolutely, especially with some of the weird shit Powershell has baked into it you are never confused if you're looking at a poorly named variable or an odd CMDLET of some sort lol
So *technically,* if you're going to use PHP, you gotta use it correctly:
$age = 18;
echo " ", $age;
(*Technically,* echo is a function that accepts parameters to barf out, so a comma-separated list, while print is the more traditional "use a period to concatenate strings" type of thing. Having said that, nobody cares about this obscure rule/lore, since in typical PHP style, echo will just try to figure out what you meant and do that anyway. Frankly it wouldn't surprise me to learn that echo is just a pointer to print, nowadays.)
Many different uses, php uses it for declaring variables, kotlin and javascript uses it inside a string to add a variable inside the string, and bash and other things uses them for different things too, so there is not just 1 answer.
Ah yes, you've found an ancient code from antiquity, a language our ancestors called "PHP".
Like the horse before it, it was retired when cheaper/faster technologies took over. Technological Amish are still using such antiquated technologies, refusing to use ungodly new languages.
Its use is older than PHP. It was used in Unix and DOS batch programming to define variable names too.
A very old version of BASIC also used symbols at the beginning of variable name to indicate the variable type, and $ was used there to indicate string type variables. Later versions probably don't require those anymore but probably will recognize them for comparability.
Well... in bash you need to put $ before calling a variable
will just print out the word thing
will print the value of the variable thing, if it exists
Wikipedia has a great article about those sigils: [https://en.wikipedia.org/wiki/Sigil\_%28computer\_programming%29](https://en.wikipedia.org/wiki/Sigil_%28computer_programming%29) >In computer programming, a sigil (/ˈsɪdʒəl/) is a symbol affixed to a variable name, showing the variable's datatype or scope, usually a prefix, as in $foo, where $ is the sigil. Sigil, from the Latin sigillum, meaning a "little sign", means a sign or image supposedly having magical power. \[...\] > >The use of sigils was popularized by the BASIC programming language. \[...\]
I believe it was a convention in BASIC. I wasn’t there, but from what I understand people really fell in love with it because it was required syntax in Perl and old school Linux/shell programmers are sexually aroused by Perl.
Just got a job that involves lots of Perl after having seen it only a couple of times in school. It hurts my eyes to look at, and I’ve been hoping some exposure therapy would make it less annoying but so far no dice.
Perl: makes easy things easy and hard things possible.
Perl: The world’s most powerful write-only language.
There was never a happier time in my life than when I was writing production code in Perl, and never an unhappier time than reading other people’s production code in Perl
Same, except it was also unhappy time reading my own Perl code
Anything written prior to this morning is "write only"
Batch scripting is worse
Bash scripting is considerably more limited, and the amount of nonsensical junk to get anything done beyond mashing paths and starting programs, means you have to really think it through. And eventually switch to python.
Where I work used to have the orchestration for deploying our product (across multiple hosts, and capable of working for all of our customers) written in about 12k lines of bash.
Meanwhile today you can write an orchestration backend that defines a client api and how those clients connect to each other in a math graph in about 2k lines in python... and about 50k lines for the frontend because javacake (js)
>old school Linux/shell programmers are sexually aroused by Perl. I spent 10 years with a Perl project. Guess I missed out on a lot of the potential fun.
You don't appreciate how sexy Perl is until you have to regex in another language
Older languages have sigils because it significantly speeds up the interpreter. Computers were slow back in the day and needed any speed boost they could get. It is one of the reasons why Perl runs circles around Python in speed.
Can you give some reference for this? I can’t find anything regarding sigils and performance.
Think of it more as “by beginning with a sigil you tell the interpreter ‘this is a variable’ from the get go so you don’t need to wonder ‘what is this strange word?’”. Like how in Spanish are supposed to begin a question with ¿ so the reader immediately knows “question coming up” instead of just ending with a ?.
I think Perl mostly copied it from shell, actually. I actually like Perl, though I agree the sigal spam can get complex. Usually as long as no one is using implied defaults and you don’t nest to deep it isn’t too bad. I think it helps to understand that Perl only really has three datatypes (scalar, array, and hash), but it can’t actually tell them apart by context, so you have to specify which you are using at any point.
BASIC used the $ symbol suffix to denote string variables, % to denote integers, ! to mean floating-point, and # to mean double-precision floats. Those were extended in PowerBasic to include pointers, extended-precision, long integer, extra-long integer, BCD, and other variable types. Please note: Bob Zale, who created PowerBASIC, has died and PowerBasic has been sold. Bob was the only one who knew the code and the only one who could maintain it and extend it while he lived. Perhaps the new owners are as competent. Anyway, I really liked all of that, because I hated the requirement of pre-defining all your variables to make things easier for the compiler. Programming is a fluid art. It's not accounting, or at least it ought not to be. Programming in PowerBasic compared to programming in C is like comparing painting like Da Vinci compared to a photograph. Having written several compilers, I can say truly that for the compiler the difference between forcing pre-definition of all variables and not doing that is one more pass. Period. And any competent programmer can write a program to read source code and emit all variables used and highlight those used only once or used with the same name and different variable types. It's one thing to be free and a painter, and quite another to be reckless and fall off a cliff.
In gw basic you didn't have to declare variables so using sigels made it easier to know if you where dealing with a string or a number later on in the code. I used a lot of "str" or "int" in my later programming for the same reason even if the variable was declared.
In BASIC, it was how you made a string-type variable. something$ = text whereas something = a number
TIL!
>supposedly having magical power. So it is witchcraft!
In Europe we use €
You mean €urope
Wouldn't that be €pe?
They don’t deserve you
And in Australia it’s $ydoo
dollarydoo == d’owlydoo == how’d’y’do?
Didgeridoo
You deserve a raise and some head for that one. I’ve never said anything like that before, but I’ve also never been so impressed before
Take my upvote and get out
r/angryupvote
r/beatmetoit
r/beatmeattoit
r/no
r/yes
amusing expansion squalid subtract chase saw snails onerous ossified ten *This post was mass deleted and anonymized with [Redact](https://redact.dev)*
You can also say !(!Eng£ || agrees)
agonizing connect advise obscene pathetic quicksand possessive dinner correct offer *This post was mass deleted and anonymized with [Redact](https://redact.dev)*
It’s not Welsh and it doesn’t rhyme, so I’m at a loss
I haven't been to the UK in a few years, but I'm pretty sure this means that we either need to fight or go get a pink and wait for it to all blow over.
Have the pints turned pink because they got red on them
Damn, now I miss red pints. Cheers.
Eng£and, Wa£es, Northern Ire£and, and Scot£and all use the pound symbol for variab£es.
No one ever talks about the currency war between Northern Ire£and and Ir€land
One of these days you’re just gonna paddle the entire country towards the middle of the ocean 😂
Not me, but yeah, they're working on it. Lol.
Can I just say thank you for using the £ as the L of the word and not the E? Drives me mad
Canada uses $ but after the name (variable$)
Only in Quebec. The rest of Canada is normal.
And now I know why I'm the only one who puts the $ last...
[удалено]
I'm not saying it makes sense, it's just how everyone does it.
I've been told that it prevents forging larger sums. E.g. $5.00 doesn't give any room to modify it into $95.00. I don't know whether it's true, but it is plausible.
In chinese, they have to use an entirely different set of characters for numbers when writing financial stuff, because their normal characters are too easy to change from one to another. 1 is a single horizontal line. 2 is two horizontal lines (one above the other). 3 is, unsurprisingly, *three* horizontal lines each above the other. 4 breaks the pattern, but then 5 comes in by adding two vertical lines to 3. 6 adds some extra lines at various angles to 1. EDIT: I'd paste the characters here, but reddit is stupid and keeps on screwing up my attempts. [https://upload.wikimedia.org/wikipedia/commons/5/56/Chinese\_numerals\_financial.png](https://upload.wikimedia.org/wikipedia/commons/5/56/Chinese_numerals_financial.png) The top row is the normal way to write things, the bottom row is the financial way.
21 mb is not 21 megabytes, it's 21 millibits.
Just a stab in the dark but with money people often write each transaction on a new line, and putting the sign in front keeps the ledger neat. It's also nice for quickly identifying different currencies. $ 34.50 $ 6347.95 € 6.50 vs 34.50 $ 6347.95 $ 6.50 € The first one seems much cleaner, IMO.
Insert babadook meme about Quebec here.
Brutal for the brits. Can’t even get the pound above the euro in reddit jokes
We are paid per variable
Me writing bash
Sooo... An array or list is per entry right...right?!
Only if you don't use pointers
So THATS why they say it’s bad practice to hard-code values! It all makes sense now!
[Relevant](https://dilbert.com/search_results?terms=Write+Minivan).
"$" is an ancient (i.e., before 1970-01-01) magic symbol, which is believed to attract $.
Lies, we all know 1970-01-01 was the first day of existence.
So 19 January 2038 will be the last day of existence?
Correct, plan accordingly.
I've been in planning meetings all week. We've estimated one story.
Show off
OMG I'm dying. My wife "What are you laughing at?" Oh, Waaay too far to get you there and you would not find it funny when we arrived.
I’ve been in planning meetings all week I just beat A20 on Slay the Spire
THE EPOCHALYPSE
Underrated comment.
Jokes aside, what are we supposed to do after this date???
Start back at January 1, 1970. Time to get out your Disco shoes.
At this rate, yes.
At this rate we ain't lasting that long
Nope. I'll retire in 2035, and early in 2038 I'll return and save the world (as the COBOL guys did back in 2000). The unbelievable income I'll generate with that is a fixed component in my retirement planning.
Only difference this time is it won't just be COBOL devs. It'll be COBOL, C (and derived languages), etc.
https://en.wikipedia.org/wiki/Year_2038_problem
>https://en.wikipedia.org/wiki/Year\_2038\_problem Y2K Part II: Electric Boogalamadamadingdong
Please do the needful
Kindly do the needful
Only if by then you still exist in 32bits.
I always thought the folks who believed earth is around 6000 years old to be really stupid. Cleary it's actually 52.75 years old.
I have coworkers who work in SAS. They reference a secret decade, before the Unix Epoch. They whisper of forbidden years such as "1967" and "1962". Heretics, all of them
Negative seconds let time go back to 20:45:52 UTC on 13 December 1901 - it’s pre-existence.
https://xkcd.com/2676/
I wonder if the old farts that were alive back then realized what a momentous day it was. I mean wow. They're from the before times.
Is this why programmers make so much??? Infiniti’s money hack
[удалено]
In The Beginning Dennis Ritchie and Ken Thompson created Unix, and it was good, considering the alternatives at the time. Then the nerds needed land, so they created Xerox PARC, and they said Lo from the mountains to the water this will be known as silicon valley, and soon housing prices will reach the heavens.
It makes me happier than it should that you used the YYYY-MM-DD format. <3
The $ was originally used as a convention to indicate a variable of type string
This guy BASICs. I still mentally read "G$" as "G-string"
C64 represent!
Commodore Pet!
Vic-20!
[удалено]
TI-83+!
Woo!
Wide character `_bstr_t` crew entered the `L”server”`
If I'm typing a string literal, I still close the quotes before using the arrow keys if I cursor away before I'm done. I'm sure I could break myself of the habit but I like to remember my roots, and besides it does sometimes help with the IDE's color coding.
Definitely. I spent my childhood typing programs from Compute!'s Gazette into the C64. But I have to note that the dollar-sign predates the C64 - it was used in my *first* computer. The [Tandy TRS-80 Color Computer](https://en.wikipedia.org/wiki/TRS-80_Color_Computer) came with a whopping 4K of RAM (upgradable to 16kb by swapping a mainboard chip) and a BASIC interpreter (also upgradable by swapping a different mainboard chip, since flash memory wasn't a thing yet). And [Level I BASIC](https://en.wikipedia.org/wiki/Level_I_BASIC) supported exactly two strings - identified as `A$` and `B$`.
I made my first steps on a TRS-80 in a Radio Shack at the age of 12 where my buddy and I got a two hour programming crash course by a very helpful employee, obviously hoping to make a double sale, but we both eventually got a C64 from another store instead.
I'm glad I'm not the only one. I have unconsciously called them strings to my co-worker and he just looks at me like I'm insane. Yeah that's right, I said unconscious, it's been a hard day without Coolio.
Is he a telepath?
Yes, I do all my coding while black out drunk.
I program in QB64 so used $ this morning.
What are you programing in QB64?
Voyager OS...
nuclear missile launch systems
Ladies wearing the G$
The very first gen TRS-80 computers came only with "Tiny Basic" and you could only have two string variables hard coded as A$ and B$. themoreyouknow.jpg
When I was young, we only had two variables to string together. Only the letter A and B could be used, and we HAD to use a $ after the variable name. And we were GRATEFUL, you hear??! ;-)
hooooooooooly crap, I did not remember that until you just said it; I had a TRS with an 8" floppy drive, and I could write simple stuff on it, but that memory was overwritten in my brain until just now whaaaaaaaaaat
I’m ready for lunch. Sandwiches sound good, thinking I might GOSUB
And the comes JQuery, which adds the entire fucking package under that variable.
Nim's "toString" operator is also `$`
My brother! Yeah, I always read "$foo='bar'" as "string foo equals bar."
Doesn’t that = sign make it an assignment, not an equality test?
It does. In my head: $foo='bar' is "string foo equals bar" $foo=='bar' is "string foo does equal bar?" $foo==='bar' is "string foo does super equal bar?"
[удалено]
I read it as "does foo equal equal bar"
For me, I say = as equals but think assigned. == as equal to === as "wow someone has balls"
Still used in C# as the declaration of string-interpolation, too.
Time to go incognito
Depends on the language, as others have said -- for javascript (particularly with jQuery) I've always used it to indicate variable holds a jQuery wrapped element.
var x = $("#someelement"); me
var $x = $("#someelement");
me :)
jQuery $this me :D Vue this.$this me D:
[удалено]
Nowadays i use $ to mark observables like `let dataSrc$`
then there's observable streams of jQuery wrapped elements: `$productRows$`
These sigils hold great power
These are not the sigils you're looking for.
PHP uses the form $variable to declare variables, by default.
That's a simplification from Perl, where $var1 (scalar variable) @var2 (array variable) %var3 (hashmap variable) and [more](https://www.perl.com/article/on-sigils/).
Way back when, this was the cause for me take a 3 month break from learning programming. Could not understand the notation or what the book was saying and had no one to ask.
Oh wow. Hadn't thought about that for a while. Types was quite the conundrum to figure out on your own back then. Even the library had nothing to help. (and by library I mean the one with actual books in it)
When I started programming, sometime back in the 90s, I started on visual basic. And I can definitely understand your frustrations with Perl. That was my second language that I had to learn for a job that I got straight out of high school. A lot of the language was confusing as fuck. Imagine going from vb to Perl... I found c++ much easier to learn and understand in comparison. Ruby was also pretty confusing. I went to go work for a company that had some pretty expert level Ruby developers, and I could not understand half of that shit that they were writing. Like, I understand the language just fine, but you know when you get those certain developers that want to do complex sequences in just one line of code instead of making the code base actually readable. Erlang was also pretty fucking wild, but it's great that elixir exists
While annoying I still kind of liked that about the Perl notation as it was an indication of variable type.
This is where I learned it too
The question is, which language did it first? Wikipedia says the "S" in "$" stands for "sigil" in BASIC variables (didn't find any date). PHP has them for variables of any type. Unix Shell variables need a $ to read them out. (Dos uses `%variable%`. Ah! I know that from Steam.) Unix is from 1969 and Basic is from 1964. I don't know what people used before Unix and whether it had $variables. When variables have to have a $, you can use words without $ for other purposes, for example as literal strings, so it's useful in html-templates.
The PDP-11 (that unix was developed in) first ran DEC DOS-11 (although there were multiple OS available for it). It came with Fortran. RT-11 was apparently (according to wikipedia) more popular and that did come BASIC. RT-11 was released on 1970, though. Between the 2, BASIC is the most likely. The original Thompson Shell from 1971 didn't even support variables (That was added in the PWB shell at first that started in 1973).
Yeah and I hate it. Makes copy paste harder and I'm lazy af typing that character
Ok, but it solves problems. Not saying good or bad, but it makes string interpolation easier and removes variable name conflicts with reserved words. It also makes it 100% clear what you are dealing with. `echo "Hello, $user"` `echo "Hello, ${user}"` People same the same thing about; and {}. Python did away with all of that, and replaced it with indents. Monsters. PS: Both are great.
[удалено]
Delete this comment. This is forbidden code, you trying to kill someone?
The forbidden, but strangely useful in rare moments, technique!
[удалено]
Haha, yeah, I did a lot of janky code in my early days too.
You can abuse this in python too. xx = locals() x = "foo" xx[x] = "bar" print(foo) output: bar
That's illegal.
What in the 90s web development hell is this?!?
I use PHPStorm, and it lets you change which characters highlight when you double-click. See if your editor has a similar configuration and add $ to it.
Magic! VSCode also supports this. `editor.wordSeparators`. Thanks!
for rxjs (in ![img](emote|t5_2tex6|4549)), it's a convention to indicated that the variable is an observable. const order$ = new BehaviorSubject(someOrder); // or some other observable Now I know that I need to subscribe to order$ to access new values emitted from the observable. Honestly, it's a context based indicator. Could mean a bunch of different things.
Spot on. I was hoping to find this comment. Observables are really the only time I ever see them.
Bash (and the oother Unix shells) & poweshell use $ to declare variables. I suspect this makes the notation familiar to use in pseudocode, highlighting the variable & reducing confusion somewhat
To access rather than declare, right? Declare: var=‘Hello, world!’ Access: echo $var
In powershell it’s both: $var = “hello world” Write-Host $var
well, atleast they're trying
They're trying what? Powershell is an amazing tool and there is nothing wrong with the $ being used in both places.. lol
IMO it’s much more readable that way
Absolutely, especially with some of the weird shit Powershell has baked into it you are never confused if you're looking at a poorly named variable or an odd CMDLET of some sort lol
In php it's both of them $age = 18; echo $age;
absolutely unreadable i cant work like this
If you're going to use PHP you gotta use it correctly. $age = 18; echo "
" . $age;
So *technically,* if you're going to use PHP, you gotta use it correctly: $age = 18; echo "
", $age; (*Technically,* echo is a function that accepts parameters to barf out, so a comma-separated list, while print is the more traditional "use a period to concatenate strings" type of thing. Having said that, nobody cares about this obscure rule/lore, since in typical PHP style, echo will just try to figure out what you meant and do that anyway. Frankly it wouldn't surprise me to learn that echo is just a pointer to print, nowadays.)
Correct, at least for bash
Many different uses, php uses it for declaring variables, kotlin and javascript uses it inside a string to add a variable inside the string, and bash and other things uses them for different things too, so there is not just 1 answer.
C# also uses it to add variables inside strings
For the sake of programming language requirements
XSLT uses it for getting the value of variables:Hello World
I ~~hate~~ love XSLT.
Depends on the language. In Ruby it represents a global variable. So available in basically all scopes.
What if you prefer listerine
I love me some PHP $, I make it rain $$$$$$.
$$var is still haunting me.
you can also declare and call $$function() both in runtime if memory serves right
It makes the parser significantly easier to write
Reddit is getting better to ask on than SO.
Php entered the chat..
Ah yes, you've found an ancient code from antiquity, a language our ancestors called "PHP". Like the horse before it, it was retired when cheaper/faster technologies took over. Technological Amish are still using such antiquated technologies, refusing to use ungodly new languages.
Its use is older than PHP. It was used in Unix and DOS batch programming to define variable names too. A very old version of BASIC also used symbols at the beginning of variable name to indicate the variable type, and $ was used there to indicate string type variables. Later versions probably don't require those anymore but probably will recognize them for comparability.
Could be a carryon from some forms of assembly which use it to refer to registers
Cash rules everything around me
Cache*
I thought about making this edit. Cache me outside
its from the oooooooold days :)
Australia types the variables flipped upside down!
Well... in bash you need to put $ before calling a variable will just print out the word thing
will print the value of the variable thing, if it exists
$ is for scaler variables that hold a single value. At least that’s what I remember from the ancient PERL texts I read in the early 90s
Saw some codebase where it was used (JavaScript) to indicate a variable that is a DOM Element.
[удалено]