Hacker News new | past | comments | ask | show | jobs | submit | more uup's comments login

That’s not true. You can import JS directly into TS or use ts-ignore annotations.


[flagged]


You can directly import any valid JS module using TypeScript if you have “allowJS”: true in the compiler options of your tsconfig.json file. The comparison to FFI doesn’t make any sense. FFI requires compiling a special library that explicitly exports the C types. This is different than TS. Using TS, you can import any valid JS module without any special preparation. Also, you can’t import all compiled languages into each other using FFI. You can only import and export C-based types. There is no way to export a Go struct for consumption via FFI, for instance. All valid JS modules will work with TypeScript.


>There is no way to export a Go struct for consumption via FFI, for instance.

I hope not.

>Using TS, you can import any valid JS module without any special preparation

Why does the DTS ecosystem exist then (https://www.npmjs.com/package/@types/node etc)


d.ts files allow you to add types to imported JS. You’re free to import raw JS as an any type and the compiler won’t complain.


Okay...

    $ echo "export class Foo { a = 1 }" > test.mjs

    $ npx ts-node
    > import('./test.mjs').then(console.log)
      error TS7016: Could not find a declaration file for module './test.mjs'. '/home/user/Lab/test.mjs' implicitly has an 'any' type.

    $ npx ts-node -O '{"allowJs":true}'
    > import('./test.mjs').then(console.log)
      Promise { <pending > }
      Error [ERR_REQUIRE_ESM]: require() of ES Module /home/user/Lab/test.mjs not supported.

    $ echo "module.exports.Foo = class Foo { a = 1 }" > test.cjs

    $ npx ts-node -O '{"allowJs":true}'
    > const { Foo } = require('./test.cjs')
    > Foo
      [class Foo]
    > new Foo
      Foo { a = 1 }
    > function bar (foo: Foo) {}
      TS2749: 'Foo' refers to a value, but is being used as a type here. Did you mean 'typeof Foo'?
No I did not, TypeScript, and that's about as much as it seems to interoperate. I guess in some cases practical migration might be viable - but as for the general case, the out-of-the-box experience seems to speak otherwise.

It's not even viable to write in JS and manually write a DTS - no way to check em against each other. Except idk library in JS, test suite in TS anyway. So not a lot of lateral movement possible in practice.


ts-node isn't an official part of the TypeScript project. It has notoriously bad module support.

Try this:

    // tsconfig.json
    {
      "compilerOptions": {
        "outDir": "dist",
        "module": "es2020",
        "allowJs": true
      },
      "files": ["index.ts"]
    }

    // index.ts
    import('./test.mjs').then(console.log)

    > npx tsc && node ./dist/index.js
    [Module: null prototype] { Foo: [Function: Foo] }


I'm not even talking about the module support. (It just seems to have the default support of TypeScript.)

Yes, it imports the module. No, it doesn't do even basic type inference (knowing that Foo is a class and consequently allowing it to be used as a type name) - which it would, if it was a superset of JS. Instead it seems to import everything as "any", which is... a start, I guess?


Perhaps it's just me, but if I ask myself whether or not the comments on this post, or the article itself, was written by GPT-3, I'm unable to decide one way or the other.


In populated areas, Japanese Knotweed is a pain, but at least people see it and try to mitigate it. I go fishing in upstate NY, and you used to be able to walk along the river banks that were mostly just flat stones deposited during times of high water. Not anymore. Now the river bank is mostly an impenetrable wall of Japanese Knotweed. It sucks.


Pretty sure Chrome also uses libav to play back the media as well, so FFmpeg usage alone isn’t what differentiates this thing from a browser.


So use one of the other 2FA options.


Not always a possibility. Many banks require phone number based 2FA, for example. And you're required to use it any time you want to make a transaction that exceeds some threshold.


We are talking about Google here, right?


(FWIW, my bank does not provide any other 2FA options.)


afair you need to set up a phone number before you can choose to add another 2FA option (which is stupid imho)


Even if this is the case, this isn't a problem for the poster. They have a phone number, it just changes frequently. They can sign up, enroll in a TOTP or U2F system, and then they are set.


Except if you're using e.g. Google Authenticator and you lose that phone, you've now lost your TOTPs. The most unhoused-friendly solution there would be to use something like Authy instead (which is another password to remember, but at least it makes it easy to recover your TOTP keys on a new device without needing the old one); next best would be to use something like andOTP which supports backups (but then you'd need someplace to store those backups, which introduces the same problems as safely keeping a phone on your person).


The context for this post is a person who moves between countries frequently and therefore gets new phone numbers. This person has consistent access to the same phone.


The context of the overall post is the posted Twitter thread, wherein the specific issue is the phone itself being lost/stolen.


It's not stupid - Google wants to track everyone everywhere and a phone number is a good way to link an account to a real world person.


Machine translation works pretty well though. At least into English.


It’s sort of non-shitty which is a glaring indictment of the difficulty of solving problems with AI. Languages are a closed system, the cars have no chance


From what language? Do you speak two languages fluently, so you can compare translations?


I’ve used it a lot from German and Russian. I lived in Germany for a few years. Auto translation was absolutely essential for navigating official things like government websites, banking, flat renting, etc. Now, all of my in-laws are exclusive Russian speakers. When my partner isn’t around to translate, we use Google Translate’s conversation feature. It works great. My partner overhears a lot of our conversation. She’s never needed to clarify anything.


Google translate:

===

One day in the spring, at the hour of an unprecedentedly hot sunset, two citizens appeared in Moscow, at the Patriarch's Ponds. The first of them, dressed in a summer gray pair, was short, well-fed, bald, carried his decent hat with a pie in his hand, and on his well-shaven face were glasses of supernatural size in black horn-rimmed. The second, a broad-shouldered, reddish, swirling young man in a checkered cap twisted at the back of his head, was in a cowboy shirt, chewed white trousers and black slippers.

===

Human:

===

At the sunset hour of one warm spring day two men were to be seen at Patriarch's Ponds. The first of them--aged about forty, dressed in a greyish summer suit--was short, dark-haired, well-fed and bald. He carried his decorous pork-pie hat by the brim and his neatly shaven face was embellished by black hornrimmed spectacles of preternatural dimensions. The other, a broad-shouldered young man with curly reddish hair and a check cap pushed back to the nape of his neck, was wearing a tartan shirt, chewed white trousers and black sneakers.

===

"шляпу пирожком" has been auto-translated to "hat with a pie" - ridiculous and inaccurate AI translation. It is only one of many, many examples.

The example above was from a random book. I knew AI is going to fail.


Machine translation isn’t for translating literature at the moment. Maybe that’s why you’re feeling it falls short. For conversational vernacular or straightforward instruction, it’s great. I can’t remember the last time I used pork-pie hat in a conversation, for instance.

Perhaps you could qualify your initial statement that we can’t translate literature in a way that isn’t ugly. That would be true. But machine translation is a huge asset every day to people in need of understanding important things in a foreign language. Quite a miracle really.


Yes, it is for trivial conversations. I could give you few more examples, technical book - you would say "ah, and it isn't for translating technical books", and so on.

And this is the reason why I'm not buying "the end of classical Computer Science". AI doesn't work with text very well (reference to your comment "Machine translation works pretty well" - no, it isn't), and often can't even translate/recognize conversations. For example, auto-generated YouTube CCs often suck.


> But look at Stable Diffusion. If you had taken a GAN a few years ago and looked at its generative art potential.

Art is a little bit different, since it's subjective, and artist can say "oh, I just see things this way". Fluctuations in an artwork can be always seen as features, not bugs.

With translations you have to be more precise. The same for Computer Science, you often need to understand nuances to do the precise work.

You're saying "few years", but I've started using auto-translating software at least 15 years ago, maybe even more than that. We had this progress 15 years ago: yes, we were able to auto-translate simple conversations.

It's constantly improving, but at the same time there is no breakthrough, and machine translation still sucks.


ML has shown more promise in MT than any classical algorithm. Unless you believe there is a fundamental limitation to ML, or a new frontier on the horizon in classical CS, I don’t see a path for classical CS to hold a candle to ML in the machine translation domain.

Also, I disagree that translations need be precise. I read a collection of short stories recently called the Icarus Gland. I highly recommend it, especially if you can read it in the original language (Russian). The translation was simply comical. Probably it mostly translated via MT. Yet, it was an amazing book.


I’m not really sure how machine translation being less than perfect is related to whether or not the end of classical is near. Unless your argument is that because ML based translation is bad now, it will never be good unless there are developments in classical CS. But look at Stable Diffusion. If you had taken a GAN a few years ago and looked at its generative art potential. You could make the same argument. State of the art ML (at the time) is not good at generative art, therefore classical CS is still relevant. Of course, we know know that’s not a true statement.


no, it doesn't, except for the most trivial things.


I saw this on Reddit and it resonated. Yes, it’s the election season and we’re seeing democracy in action: that’s when elected officials do things you like and then you vote for them again. Not sure why you’re making it sound like a bad thing.


No federal law is changing. This is a one time get out of jail free card. People arrested for the same crimes after he pardons current people in prison don't get the benefit.


No, and that’s because he doesn’t have the power to unilaterally do that, but he is trying to get it rescheduled


> he is trying to get it rescheduled

Do you have a link about this? Because he's shown hostility towards marijuana legalization, promised to veto it if it was sent to him, and in the past supported draconian drug laws.



Tweets do not official policy make. If you need examples, you need but examine his tweets all through 2019 and 2020 - they're loaded with promises and plans. This is certainly not exclusive to POTUS.

Show me a policy document along with a bill from that office and I'll consider it more than an election year symbolic gesture.


This feels like a too mean-spirited take. According to this[0] he may not need a bill, and in fact may have taken the first step

0: https://www.brookings.edu/blog/fixgov/2015/02/13/how-to-resc...


His tweets 2019 and 2020 are indeed "loaded with promises and plans", but that's because he was literally not president at that time. Now that he is president, tweets from @POTUS are intended and expected official statements. Sure he could be completely bullshitting with his tweets, but he could do the same with a "policy document"

(White House and executive offices don't produce "bills", other than signing the ones proposed and passed through Congress)


Policy or not, intent was clearly declared. Not vague statements, but specific actions including a direct callout to the secretary of HHS to initiate the rescheduling review.

Obviously we can only wait to see what comes next, but I'm not sure what more you'd want? The review process has to occur, so there's no additional "policy" to be had at the moment. Obviously there's a possibility that rescheduling doesn't happen as a result of that review, but that hardly seems likely given the current political and social climate around marijuana.

Seemed like a pretty straight-forward way to communicate "and this is step 2, which is a work in progress".


I think there's a huge difference between tweets with "promises and plans" (especially from before he was actually elected), and tweets saying "I have done this thing. I am doing this other thing."

It's reasonable to be cautious about a politician making a promise in anything but the most legally-binding possible way. It's not reasonable to straight-out call that politician a bald-faced liar if he hasn't demonstrated a propensity for such lies (unlike some I could easily name).


People can change their mind.


And when they do it like this it shows the are opportunist



He doesn’t technically have the unilateral power to prevent future people from being charged federally with simple possession, but in reality, he kind of does (while he’s president).


Sends a pretty clear message to any federal prosecutor that is deciding if they want to charge this. Obviously, the prosecutor can spend the time and effort on this if they want, but it’s time that will probably be better served doing something else if they don’t want to see their work wiped away by the stroke of a pen in the future.


Technically it's not a get out of jail free card, as I understand it, no one is actually held in jail for this right now. Though it does remove it from their records.


>no one is actually held in jail for this right now

6000+ people were.


He can and will suggest to the DOJ that they don’t charge anyone for simple possession of marijuana, and they won’t.

Edit: of course that’s temporary.


The scheduling of marijuana is changing.


It's being looked at, but that's not at this point guaranteed


That makes it sustainable.

Now the president can pardon people for this before every election!


It's a solid political play, and I don't recall seeing that done before (I've only been voting since '97). We'll likely see this kind of thing more often now.


Because they stop doing the things you like once the election is over


Sure, but then there is another election. After the election is before the election.


If I elect someone to lead the country for 4 years, I’d prefer they lead the country for at least 3.75 of those years, not for two 4-6 month stints in 4 years.

(Neither party has a monopoly on this BS.)


I use cannabis daily and am all for it being legalized and those in jail released. However, I cannot join you in a victory lap here because Biden's pardon affects nobody. As far as I know, there isn't anybody in federal prison on simple possession charges. That being the case, this smacks of politicking, optics, and opportunism rather than anything meaningful. If Biden wanted to do something substantial, he'd sign legislation legalizing cannabis (including growing your own).


He can only sign legislation presented to him to sign by Congress.


It's bad because there are people that have been sitting in prison that could have been released over a year and a half ago, but Biden would rather let them rot for a while longer just so he could score political points at a more convenient time.


Shit's illegal and people are mad. Dude tries to cut some folks a break and people are mad. Conclusion: some people are born mad and gonna stay that way regardless.


Hm.. can you imagine homosexuality being banned and people being mad just cause they pardon only a certain type before elections?


Intentionally or otherwise you're equating lifestyle choices with sexual orientation and that is not a good look for all the same reasons that the rationale behind conversion therapy is garbage.


Who got a break in this deal exactly? There isn't anybody in federal prison for simple possession charges. It's like him giving every man, woman, and child in Antarctica a pony, only not as efficacious.


Yeah he totally should have issued state-level pardons for possession. What in the hell is wrong with this guy...


Someone higher up in the tree said there wasn’t a single person sitting in federal pen for this. I’m not sure, but I can’t imagine it’s frequently charged federally


From a legal point of view, when is marijuana possession a federal offence and when is it a state offence?

Presumably if you're caught with weed in DC then it's federal. But under what circumstances could you be found in possession with marijuana anywhere else and have it be a matter for the federal government, not the state one?


Federal park land?


The difference is that if they were winning they wouldn't do this. This is textbook vote buying. They are absolutely terrified of the election season after the market collapse, inflation, housing situation, war in ukraine, etc. Easy to lock in quite a few votes throwing a bone. Republicans did the same thing last election season and capitulated (temporarily) on a lot of their positions in order to pull in the independents.

I wish you were correct. But there's a difference between doing something because you know it's right (implore congress to pass legislation on marijuana immediately) and because you need the votes. Only one of them is virtuous even though both ostensibly benefit the people.


The test was mandatory for all HS students to take, but I do think there is an element of selection bias. Those who took the test on the weekend may have been more invested in the result. They certainly dedicated at least an extra weekend's worth of time.


It was "mandatory", but still had only an 85% compliance rate. I would bet that almost none of the most academically inclined students were in that 15%.


> only pay for about half

That's a lot. From your own link, a vast majority of schools are regressive, i.e poor people get less.


Some of the worst districts in my state have the most funding and highest teacher pay.

The best teachers still don't want to work there because being called the c-word by 1st graders or having a 3rd grader threaten to stab you (and seem like they really mean it) and not being able to do anything about it because the two fights and one baggie of drugs admin's had referred to them by noon today has them too busy to spend any time on "minor" stuff like that, plus having lockdowns with police patrolling the halls and yelling at anyone who so much as pokes a head out a door without clearing it with them first, due to credible threats of violence, several times per year, makes you want to do literally anything else as a career in a hurry. 15-20% higher pay than the next-best-paying district doesn't make it worth it.

Schools can't fix poverty and ghettos no matter how much money you give them, but trying that is simpler than fixing the real problems that cause very, very "bad" schools, so that's what we do, even though it will never work.


The 50:50 figure is in aggregate. You would not be able to infer if the distribution is a regressive based on that number alone. The linked article does not say that the vast majority of schools are regressive.

"A handful - Nevada, Wyoming and Illinois are weakly regressive, and the majority have a weakly progressive distribution of funding to poo vs non poor students"


I see, I didn't realize the graph of progressive / regressive changed as your scrolled the page.

Actually, looking at the data further, you can't really draw a conclusion about whether or not the funding is regressive or progressive. The local funding is definitely regressive, but you'd need to know how state and federal funds were distributed across schools to know if the end result was progressive or regressive. For instance, if federal funding was evenly distributed to every school, that would still be regressive.


That guy has a really good sense of proportion.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: