> It think this is silly on multiple accounts. I'll claim that there's not real thing such as a "language brain" or "math brain."
It seems plainly obvious that this language just means “areas of brain that activate when dealing with math problems” vs “areas of brain that activate when dealing with language problems” and yes there is hard evidence that there is a difference between them.
Please reread my comment in full. I'm willing to bet we disagree on the definition of math. I'll strongly insist that the one I'm using is common among mathematicians. If you'd like to retort by saying it's about semantics then congrats, we're on the same page (and can be verified by reading you sibling comments and/or my replies to some of them)
It has nothing to do with the definition of math. If you put people in an MRI and give them random problems then you’ll notice a distribution in the patterns of brain activity that are distinct. Some of these groupings we’ll call “math like” because the problems are more like mathematics than linguistics. And in the other distribution we’ll call them “word like” because the problems fall into the category we associate with word problems.
The fact that we see separate patterns of brain activity is the interesting part not any semantic argument about what you or mathematicians feel should be defined as being math or not.
> And, importantly: if/when those folks are making more than the rest of us, it’s because they’re selling a lot — a result that can be celebrated by everyone!
This is such a toxic mentality. Yes sales always sits at the end of the value stream, but they aren’t selling thin air. Everyone in the company contributes to making that sale possible. The waiter gets a tip because “everything tasted amazing” but the chef gets stiffed because “he just made it”
As always, they have equality but some are more equal than others. And they are transparent, but obviously not on the parts where transparency would expose the inequality because that wouldn’t be popular.
You can’t hire sales people without a carrot, and the variable component is very much a part of the sales mindset since they are all used to have immediate feedback on their success and have an unshakable belief that they control how much they earn by succumbing to the “gotta catch them all” impulse.
It’s addictive, and, ultimately, far more toxic than what you describe.
> In addition, I hope that the tooling ecosystem will adapt to support t-strings. For instance, I’d love to see black and ruff format t-string contents, and vscode color those contents, if they’re a common type like HTML or SQL.
This is such a strange take on t-strings. The only way for anything to infer that the template string is supposed to turn into valid HTML or SQL is to base it of the apparent syntax in the string, which can only be done in an ad-hoc fashion and has nothing to do with the template string feature.
The way the feature has been designed there is no indication in the string itself what type of content it is or what it will eventually be converted to. It’s all handled by the converting function.
As others have added, something like sql”select * from {table}” would have been able to do this, but there’s not even any guarantees that something that is in a template that will be converted into valid sql by a converting function should be any type of valid sql prior to that conversion. For all you know t“give me {table} but only {columns}” might be a converted into valid sql after the template is processed.
As Paul mentioned, we spent quite a lot of time considering these issues as PEP 750 came together. In the end, we concluded (a) the PEP leaves open quite a few potential approaches for tools to adopt (not just the one you suggest, as others here have pointed out), and (b) it's ultimately something that the broader tooling community needs to rally around and should probably be out of scope for the PEP itself.
So, with that background in mind, I am indeed hopeful we'll see the ecosystem adapt! :-)
I get that. But that “ecosystem might adapt” has absolutely nothing to do with t-strings is what I’m saying. Anyone who wants to validate sql will have to just look through strings guess that it’s sql and validate and highlight it. This could be done before and after just the same. The template strings by nature of just being “strings that will turn into something else at some later point” do nothing to further this in any way.
And highlighters and static analyzers will key off of this.
JavaScript's tagged template literals are actually about as flexible as this, since you can dynamically choose the tag function, it's just very rare to do so, so tools assume a lot based on the name of the function. Python tools can basically do the same thing, and just not support t-strings that aren't nested inside a well-named processing function.
> And highlighters and static analyzers will key off of this.
Then the t is redundant and we don’t need t strings involved in any way. This would work just as well. In fact better by using html("<h1>Hello</h1>") and have it return a html object instead of returning a just a string which is what t-strings will do. So literally the only contribution from t-strings in that context is to make things worse.
If they had just standardized some way of putting semantics into the template everything would be better. Let us define a “sql = temlate(….)” and use sql”…”
The original PEP and the original discussion had this in scope. We removed it to let this emerge later. There are different ways to signal the language -- some more friendly to tooling, some more robust.
PyCharm (as well as the other JetBrains IDEs) has for at least 10 years supported language injection in Python strings using a comment [0]. Worst case scenario there's no reason whatsoever that that couldn't be used by formatters to apply auto-formatting in a structured and deterministic way.
But that's far from the only option, either! IntelliJ for Java also supports annotations on arguments [1] that then mean that you get syntax highlighting everywhere you use a string literal with the given function:
public void query(@Language("SQL") String sql)
In Python, typing.Annotated appears to have been specifically designed for purposes like this [2]:
> If a library or tool encounters an annotation Annotated[T, x] and has no special logic for the metadata, it should ignore the metadata and simply treat the annotation as T. As such, Annotated can be useful for code that wants to use annotations for purposes outside Python’s static typing system.
So something like this should be perfectly viable:
SQL = Annotated[Template, "language", "SQL"]
def query(sql_query: SQL):
# do stuff with Template to sanitize
query(t"SELECT * FROM foo WHERE bar={bar}")
Now, where you're right is that we shouldn't actually require template strings to accomplish this! As noted, JetBrains has been doing this since forever. But maybe template strings will be useful enough for purposes like this that the tooling will actually evolve to support it in formatters and other editors (and maybe PyCharm can get some of the better support that Java has from JetBrains).
Couldn’t you do this with a type annotation? e.g. SQLAlchemy could have a SQL type so tools like mypy could see a Template instance and confirm you’re using it safely but Black, Ruff, or SQLFluff could look for the more specialized Annotated[Template, SQL] to realize that the template could be formatted as SQL, and something like Django could even have Annotated[Template, Email], Annotated[Template, HTML], or Annotated[Template, JSX] to indicate what context the same templating syntax is targeting.
This is what we discussed in the first revision of the PEP (the use of `Annotated`.) But we found out: linters don't know anything about the Python type system.
We hope to get a community around all of this, stuff at PyCon US, EuroPython, etc. and work some of this out. The JSX/TSX world really has good tooling. We can provide that for those that want it, perhaps better on some aspects.
Interesting, thanks for the background. I’ve been curious what Astral is going to do in the space but also worry about what happens when their funding runs out.
> The only way for anything to infer that the template string is supposed to turn into valid HTML or SQL is to base it of the apparent syntax in the string
Not the only thing. You can also look at how it is used. Your editor could know of how some popular libraries use t-strings, track which t-strings get passed into functions from those libraries, and use that to assume what grammar the t-string should follow.
Is that cheating? In some sense, yes, but it also is useful and likely will be worth it for quite a few programmers.
You could already do everything you are proposing t-strings will make easier with just strings or f-strings.
‘query: SQL “Select …”’
“Wait” you’ll say “then the function taking the string has to parse the string and will have to add ugly logic grabbing variables from globals()!” Ah yes. That’s such an ugly solution… let’s instead codify just that as the official best practice and sell people on it by prefixing a t to the string so they don’t notice…
> People just want to know why it's x and not something else or how a letter can have value.
The way I was taught it and the way that worked now for my now 3 year old is just to say pirates buried a number under the X, and that we need to guess what they buried. If the concept of a number being hidden is a barrier to understanding for anyone they have seriously bad teachers.
What opposition? The recklessness of Trumps political agenda is benefitting the rich elite and despite appearances both parties leadership consist of those in the rich elite. America doesn’t have a party representing the workers because anyone getting any traction in politics almost immediately leaves the working class. That’s why the level of political opposition is currently at “let’s all wear matching ties to show our disapproval of this political development that will absolutely make us tons and tons of money but which we need to look like we oppose”
> That’s why the level of political opposition is currently at “let’s all wear matching ties to show our disapproval of this political development that will absolutely make us tons and tons of money but which we need to look like we oppose”
Don't forget the "let's all hold little signs up and make frowny faces" strategy from actual elected Democrat Congresspeople. What a joke!
I’m. Sorry that you feel that way. We applied an algorithm and since 40 of the other 100 people who share that opinion with you committed drug related crimes we have decided to put you in jail without chance of parole. I hope you understand that while this may seem unfair this decision is not good or bad, it’s just the outcome of the algorithm saved in a computer.
1) what are my rights, I.e. Against what constraints was the algorithm implemented?
2) "we have decided": who is "we", it's actually good that a particular entity is responsible for the output of the algorithm, computers can't be responsible for things.
3) is there appeal or human review?
If a bad algorithm is part of some process that affects me I'm going to ask what my rights are, who's responsible and where I can appeal, not the specifics of the algorithm.
Your original argument was that an algorithm cannot be bad, and now you are countering my point by arguing that the algorithm is bad if it ignores your rights, is solely responsible for the implemented outcome and doesn’t include any input for human review or appeal.
Funny enough I read not that long ago about a case where an algorithm broke all those three points! Can’t remember where of the top of my mind, I think it was the Louisiana Prison board or something like that.
But never mind that, you are arguing against yourself so I’ll kindly step aside and let you at you.
Don’t know about you, but personally I want the extensions I create to be available widely. The fact that vs code market place is used as an easy place for me to distribute it only to limit the reach based on the business needs of Microsoft sure does feel like being embraced extended in the attempt of extinguishing usecases that I do in fact support.
Can’t fault cursor for letting people install extensions when most of those, if not all of those, developers want their extensions on cursor.
This is about closed-source extensions created by Microsoft, and those always had strings attached which Cursor apparently ignored.
I would rather ask Cursor why they decided to fork VSCode when they could simply have written yet another VSCode extension to provide the same functionality. Seems shady AF tbh.
Doesn’t Microsoft handicap extensions by not giving them the full access that co-pilot gets? You’d be crazy to compete when the other side literally owns the platform.
They couldn't have done and it gets tiresome to repeat the technical limitations on extensions for vscode again and again (which don't apply to Microsoft owned extensions like Github Copilot) when you can google it yourself.
This seems so fake. They suddenly decide to go on a vacation and want to return on a small inexpensive plane that then crashes with their entire family on it in Switzerland less than 2min from takeoff?
Call it a conspiracy but I won’t at all be surprised when someone discovered they have transferred a large amount of funds to some “family friends” that look suspiciously like them but live in the Cayman Islands.
It’s evidence that your password leaked. What are you on about? You think they just randomly guessed his password?
reply