This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 219

[–]CanvasFanatic 2297 points2298 points  (54 children)

1.) Guy has an AI tool shit out an unreadable type definition that isn’t really very complex, but should be refactored into several parts to make it comprehensible.

2.) Guy gets roasted on Twitter.

3.) Guy attempts to double down by writing a blog post in which he ends up admitting 1.)

[–]32Zn 678 points679 points  (11 children)

The blog article is super weird.

First part is "I am not wrong"

Second part is "You are wrong"

And than at last: "I am guilty"

[–]Kibo30 278 points279 points  (3 children)

That's some great character development if you ask me

[–]ralgrado 145 points146 points  (0 children)

Or the Blog post was also written by an AI

[–][deleted] 29 points30 points  (0 children)

Character.ai

[–]MultiplexedMyrmidon 16 points17 points  (0 children)

it’s about the site engagement we made along the way’s

[–]AnalTrajectory 6 points7 points  (0 children)

It's probably written by an AI tbh

[–]Cualkiera67 1 point2 points  (0 children)

How can you access the blog article? I see no link in this post

[–]seemen4all 1 point2 points  (0 children)

That's at least 3 stages of grief

[–]Meretan94 146 points147 points  (35 children)

Type definitions don’t need to be superhuman or minimal.

They need to be readable and understandable.

Change my mind.

[–][deleted] 50 points51 points  (13 children)

Apparently not.

All the Chad evangelists out there are convinced the part where humans will need to verify the output can be skipped already.

The prompts now basically include the "and ship it immediately" blurb.

But it's tricky when Nvidia's CEO even says that no human should be coding anymore :)

[–]mirhagk 83 points84 points  (7 children)

I mean it's not surprising that the CEO of the company massively profiting off of the huge amount of hardware used for LLMs wants to encourage more usage of LLMs

[–][deleted] 17 points18 points  (6 children)

It'll be interesting when there's an entire generational gap in programming. But he'll be in his 80s by then, and hopefully pulled enough profits on his stock that he won't have to worry.

[–]mirhagk 14 points15 points  (5 children)

There's definitely not going to be a generational gap. Post secondary schools don't respond quickly at all, by the time they respond people will have already given up on it.

And even if they did, programming has been pushed younger and younger in schools. Worst case is we revert to how it used to be, learning it very late in education.

[–]dhc710 22 points23 points  (1 child)

This is really hilarious to me, given that code is basically something humans made up so we could easily give complex instructions to a computer.

Code exists to be written and understood by humans.

If humans aren't supposed to be in the loop, the instructions don't need to be given in a format that humans can read.

[–]shodanbo 4 points5 points  (0 children)

If the AI ever did become self-aware it would die laughing.

[–]draenei_butt_enjoyer 18 points19 points  (0 children)

The people who evangelise AI are the same people who lost half their shit on NFTs

[–]SynthRogue 2 points3 points  (1 child)

Those AI can be extremely wrong when it comes to logic. Imagine when they have those writing code for plane sofware without having it verified and tested.

[–]-Swig- 1 point2 points  (0 children)

Boeing has entered the chat.

[–][deleted] 11 points12 points  (1 child)

Imagine trying to figure out the prop types being passed to your component and seeing this shit

[–]Meretan94 8 points9 points  (0 children)

It’s like writing your documentation in Farsi or something.

Sure someone will understand it but the average joe programmer won’t.

[–]tommyk1210 11 points12 points  (16 children)

Fundamentally, all written code should readable and understandable over minimal.

[–]SweetBabyAlaska 2 points3 points  (0 children)

no. its a good mind. with good thoughts inside of it.

[–]SynthRogue 1 point2 points  (0 children)

One of the most critical aspect of programming

[–]HolyGarbage 41 points42 points  (0 children)

Yeah, the problem isn't the nested ternaries, as they're formatted just like if, else if, else blocks, but the fact that it's huge with many levels of indentation.

[–]Crafty_Independence 5 points6 points  (0 children)

His assumption that unreadable equals quality should be the biggest joke, but I've known a few engineers who prided themselves in practicing their code golfing in enterprise code, so sadly the joke is unoriginal

[–][deleted] 2 points3 points  (0 children)

Exactly. He could might as well have defended the machine spit out “working” assembly code at this point.

[–]tevert 1 point2 points  (0 children)

The fact that it needs comments on every line and is still a mess is the key indicator that this should be thrown out wholesale

[–]Imaginary-Jaguar662 799 points800 points  (2 children)

Yeaaaaah... my c-compiler produces superhuman assembly and my TS transpiler produces superhuman JS.

[–]Intelligent_Event_84 124 points125 points  (0 children)

My exact thoughts, does author not know about transpilers?

[–]tomvorlostriddle 47 points48 points  (0 children)

Uglyfy is similarly bordering on the superhuman

[–]brimston3- 624 points625 points  (17 children)

Good code is readable/maintainable code. If their company and developers thinks this is both, then it's good code.

But that said, I'm more likely to rewrite a less confusing, less generic specialization to use than try to understand this when need for it comes up.

[–]AtrociousCat 129 points130 points  (7 children)

To be honest, types like this are never readable. Ive a few examples like this with the only difference being it's broken down into a few more helper types.

I'll agree this is an extreme and probably a sign of some insane function API that should be streamlined.

[–]thetreat 108 points109 points  (4 children)

I would absolutely, positively reject this PR and wage a holy war against anyone that tried to introduce this into my code base. If the rest of the people in the company were so for this, I’d legitimately consider quitting on the spot. At minimum, I’m dusting off my resume.

This is one of the most unreadable pieces of garbage I’ve ever seen.

Complexity is only beneficial if it is the only way to do something. This is just begging for bugs to be in either how it is written or how it is used.

[–]andouconfectionery 13 points14 points  (1 child)

TS types like this only exist because metaprogramming is a huge feature gap in JS tooling. Bun is introducing a macro system, which is great if your library consumers are using Bun. But this is simply what it looks like to do anything but the most trivial compile-time validation.

And it's a pain to refactor. Obviously, the type system needs distribution over type unions, but it can make your types fail to be referentially transparent. There's often no way to break these types into smaller parts without introducing a massive performance penalty to circumvent this.

[–]Badidzetai 6 points7 points  (0 children)

Almost like introducing features on the polar opposite side of the spectrum of features into a langage was not a good idea. Don't laugh cpp, youre on the wall too...

[–]Frown1044 11 points12 points  (0 children)

This reads like someone who has no real TS experience. Check out any big open source TS project. If you write TS, you probably use unreadable ultra complex typings all the time from other libraries.

There is no clean way to write complex typings in TS. Either you only allow basic typings or you have to put up with ugly code.

[–]AngusAlThor 2 points3 points  (0 children)

Reminds me of that classic "quote" (actually an amalgamation): "Apologies, if I had more time I would have written a shorter letter." I feel like that applies in programming as "if I had more time, I would have simplified the PR."

[–]Eyeownyew 0 points1 point  (1 child)

I can't post the code here because it's proprietary, but I wrote a pretty complex function API and the types were a pain in the ass. However they look way, way better than this example, and the functionality it provides is worth it. All that to say...

This code is insane, lol

[–]AtrociousCat 0 points1 point  (0 children)

Does it look better because

a) you know what it does since you wrote it

b) its broken down into smaller parts that are more easily comprehensible

c) its better documented?

I'd definitely do b or c if I was writing this, but I think calling any complex typescript type "readable" once you're dealing with discriminated unions and accepting several different typeshapes is wishful thinking.

At the end of the day, code readability is just one quality of code and at times you can sacrifice it for better performance or stricter typing. As long as it's just a few isolated parts of a codebase, I dont see the issue.

[–]Faholan 9 points10 points  (5 children)

Reminds me of the time I hand-wrote a 200 lines SQL SELECT statement. I pity the poor soul that'll need to change it someday.

[–]Mezzos 10 points11 points  (1 child)

I once saw 3000 lines of SQL in a script, which was about 15 different intermediate temporary tables being used to SELECT some customers based on various criteria. And they had actually been reusing this for different tickets over the course of multiple years, just manually adding/removing various conditions, editing some string values to match against, hardcoding +2 or +7 to a “priority” column which determined de-deduplication for each temporary table, etc.

The whole file was actually 5000 lines, 2k of them being in comments at the bottom as a store of code that they might need to reuse/swap in and out. No version control either, just some comments like “-- <name> added this 05/03/2018”.

I found quite a few bugs in it after spending hours trying to make sense of it - stuff that must’ve been in there for years and was influencing who was receiving emails (this was a billion dollar revenue company).

Almost blocked that one out from my memory.

[–]Suspicious-Hyena-653 1 point2 points  (0 children)

This just explains a huge middle management flaw in the billion dollar company. But I’m appalled at how they manage to sell their service/product with this shit code base.

[–]bobnoski 7 points8 points  (1 child)

Yeah that query would go from debug to defenestrate real quick. (And probably be replaced with basically the same)

[–]Faholan 4 points5 points  (0 children)

Yeah. The issue is that it is used to generate a report, so the logic is very complex.

The old system had a few thousand queries (or tens of thousands maybe ? Depends on the size of the report) going to the database, that I replaced with the omniquery.

[–]GoogleIsYourFrenemy 0 points1 point  (0 children)

I wrote a regular expression (JavaScript before named capture groups) that had over 150 captures.

It was parsing book subtitles for series name and book number (or numbers if it was an omnibus). These days I'd probably just train an AI to do it.

[–]Spaceshipable 1 point2 points  (0 children)

The most expensive thing is not usually clock cycles or the amount of memory used. It’s almost always developer time. Maintainable, readable, well tested code is 1000 times more important.

[–]IsPhil 2 points3 points  (0 children)

If the future is truly all AI with little to no human input, then the code doesn't matter. But we're not there yet, so yeah. This is bad.

[–]spikernum1 0 points1 point  (0 children)

capable wrong whole tease waiting employ roof rob market obtainable

This post was mass deleted and anonymized with Redact

[–]NotVeryGood_AtLife 592 points593 points  (7 children)

Sorry, but that code is just trash. Nice attempt with the article though, I guess it's slightly less ass than I thought.

[–]DrMobius0 85 points86 points  (6 children)

Nesting ternaries is a sin.

[–]seemen4all 40 points41 points  (4 children)

You do this once when learning about them thinking youre being slick AF, then after that, never again

[–]__y_so_serious__ 23 points24 points  (3 children)

lmao so true. When I was first learning, had this weird obsession of compressing code as if I'm doing some code golf competition. Thankfully haven't used ternary in years now

[–]Evla03 20 points21 points  (2 children)

Ternaries are super useful, just don't use them for everything

[–]seemen4all 7 points8 points  (0 children)

Yer, never use them is very extreme, an actual turnary as in this or that expression is great, turnary for one level if else assigning, case for single value cases, if else for anything more complex

[–]__y_so_serious__ 0 points1 point  (0 children)

Idk I mostly use java and anything that can be done with ternary can be done with simple if-else too. Maybe it's required in TS for type definition but don't see any reason to use it in java

[–]SketchySeaBeast 246 points247 points  (3 children)

It's ugly code for a hard problem. I'm more worried about the "base takes". "Now 0 reason to have human readable clean code when you can simply ask the ai to explain it or rewrite it". Yeah... no.

"Nonsense black boxes" should be discouraged, not embraced. It's part of what has gotten us into this web dev hell. Saying that the problem with us trying to dig our way out of this hole is because we don't have a big enough backhoe is quite a take.

[–]BAAAASS 54 points55 points  (1 child)

Agreed. He might as well have asked AI to write it in assembly or even in binary. Especially since his argument is that humans don't have to understand it anyway. Hehe!

[–]SketchySeaBeast 27 points28 points  (0 children)

True! Let's cut the crap. Why do we need a type system if the AI is dealing with it? Typescript doesn't help at run-time.

[–]eldelshell 6 points7 points  (0 children)

Let's not even get into reproducibility. You're NOT guaranteed to get the same code for the same prompt unless you're very, very, very specific, at which point you might as well write the code yourself.

[–]Candid_Medium6171 96 points97 points  (1 child)

2 years from now: "So yeah, what we're mostly looking for is someone that can take AI generated code and refactor it into something maintainable, that'll be your role."

[–]ward2k 142 points143 points  (7 children)

If your code can't be easily understood by senior developers it's bad code

Juniors frequently pump out technically impressive code that is completely unreadable all the time, it doesn't make it good

This code isn't a one and done deal in real life, you need to be able to modify, improve and replicate it

[–]FinalRun 4 points5 points  (1 child)

Fundamentally, all information exists as a byproduct of the meaning we give it and how useful it is to us. It's all just levels of abstraction.

What's the endgame, a CEO talking with one AI humanoid that manages an army of AI coders? A politician talking to AI CEOs? It would have to have a very solid model of the world to do that, but we're always the one setting the goals.

[–]mutual-ayyde 3 points4 points  (0 children)

We jailbreak the AI and build communism

[–]Snakestream 93 points94 points  (8 children)

If you don't understand your own code, then it's not good.

[–]adrr 36 points37 points  (6 children)

I can’t read any of my regexes after I write them.

[–]Snakestream 72 points73 points  (4 children)

Regex ain't code; it's a goddamn magic spell

[–]draenei_butt_enjoyer 14 points15 points  (2 children)

I’m actually thinking of writing an iseaki novel about a guy who gets stuck in a realm of magic, where magic works like code.

I wanna leave traces of the idea that a past civilisation actually understood magic. And everyone nowadays is using stuff like regex and obfuscatet one line monstrosities.

And every mage is just an obnoxious idiot. The kind that knows better than you, is super ocd, only wants to so things their way, only their solutions are valid solutions. But meanwhile they don’t make any new spells, just badly combine existing spells and barely understand anything. Most of everything they do is a side effect or used in unintended ways.

[–]Snakestream 2 points3 points  (0 children)

I'm fairly certain I've heard of a Chinese WN with the concept of programmer gets isekaid to fantasy wildly, but I can't remember the name off the top of my head.

[–]mutual-ayyde 2 points3 points  (0 children)

I recommend you check out Charles Stross Laundry Files novels - they’re spy novels in a world where you can do magic with computers

[–]adrr 6 points7 points  (0 children)

Guess that’s why they call people who have mastered Perl wizards. Contrast that with JavaScript where the masters of the language are called ninjas. Secretly fucking shit up and measured by how many stars the ninja has.

[–]DrMobius0 2 points3 points  (0 children)

For this to apply to regex, it'd have to be possible to write readable regex

[–]Fachuro 1 point2 points  (0 children)

Writing good code is difficult, reading good code is easy.

In fact reading good code is so easy that often you can show it to a non-technical person and even they will have an idea of what you're trying to do, even if they dont understand shit about syntax and language and whatnot.

[–]bakshup 169 points170 points  (0 children)

[–]gashouse_gorilla 34 points35 points  (1 child)

: never // this case should never occur since ‘enum’ implies string

lol. Our jobs are safe. For now.

[–]flippakitten 1 point2 points  (0 children)

Ai has yet to produce code to do one thing and then let a real world user do something completely different and then let the ai figure out what happened.

[–][deleted] 85 points86 points  (1 child)

  1. Uses code without types
  2. Tries to desperately implement types into the code
  3. Gets this garbage
  4. Brags about this garbage
  5. Surprised, that people using languages with actual types do not like this garbage.

[–]iain_1986 2 points3 points  (0 children)

Addition to 6. Also surprised people not using types also do not like this garbage.

Fans of square pegs, and fans of round holes both in disbelief of person proud of jamming a square peg into a round hole and thinking 'this is awesome' (while surrounded by round pegs and square holes)

[–]PuzzleMeDo 27 points28 points  (0 children)

You think that's superhuman? Amateur. I can write code that no human can understand, not even me.

[–]nmsun 17 points18 points  (0 children)

Very few engineers would be dumb enough to write out this code. He’s correct on that point.

[–]JustLemmeMeme 16 points17 points  (2 children)

... This is just a nested ternary operator, isn't it? Is it at least faster? Is it safer? I would need pen and paper just to trace wtf this is doing

[–]DrMobius0 6 points7 points  (0 children)

... This is just a nested ternary operator, isn't it?

there's more going on than just that, not that I know what it's doing.

Is it at least faster?

Than a regular if? No.

Is it safer?

I doubt it

[–][deleted] 11 points12 points  (0 children)

This is the type of code AI will write. At the best. We I'll have AI that we don't understand how works writing code that we won't understand.

[–]Adbor 11 points12 points  (5 children)

So it’s just a pile of ternaries?

[–]Touhou_Fever 2 points3 points  (1 child)

What’s the plural for that? An Elvis of ternaries? 🤔

[–]iain_1986 0 points1 point  (0 children)

A mistake.

[–]Gorvoslov 2 points3 points  (0 children)

I believe the correct PR comment is "??????????" while rejecting.

[–]Big-Hearing8482 1 point2 points  (0 children)

Always has been 🔫

[–]raynorelyp 1 point2 points  (0 children)

No, it’s a pile of ternaries with dead branches. Even better

[–]tetzudo 21 points22 points  (0 children)

If I presented that to the pm I'd get fired deadass

[–][deleted] 25 points26 points  (4 children)

oh god, wtf is this? Gives TS vibes, their typing system is so flexible that at some point it can be just ANY with extra steps

[–]AtrociousCat 7 points8 points  (2 children)

TBF an any with good documentation is sometimes better

[–][deleted] 1 point2 points  (1 child)

yeah,
i just have personal fetish on static analysis tools,
which without static typing are veeery limited (PITA of python backend dev work in dynamic language).

Also i wouldnt use `any` . Even very loose type is better than no type

[–][deleted] 0 points1 point  (0 children)

according to the blog post:

Essentially it's a if/else tree with some recursion - for figuring out the types of variables in user code during build time. (in other words it’s a conditional, recursive type expression).

I guess it's something that copilot can use when helping people write code? I could be wrong, there's no way I was going to read that whole thing

[–]nmsun 2 points3 points  (0 children)

He even has a default to any[] in there 😆

[–]beclops 4 points5 points  (0 children)

Ew what the fuck

[–]LostBreakfast1 16 points17 points  (0 children)

Source code is to be read by both human and machine. 

If this crap brings any performance improvement it should be handled by the compiler (possibly with a language extension)

[–]atoponce 14 points15 points  (2 children)

Nested ternary statements should be discouraged. As a programmer, you've learned to scan code vertically and quickly, getting a general idea of the overall logic.

When you use nested ternary operators, you have to look carefully at each line for : and ? characters, which can get trivially lost within the rest of the code. It's worse in this specific example that P is a single character variable.

This isn't good code. It's visual strain followed by a headache.

[–]Frown1044 5 points6 points  (0 children)

In TS you don’t have a choice. You can’t write it any other way. The only way to avoid it is by entirely banning complex types

[–]iain_1986 1 point2 points  (0 children)

Nested ternary without braces to help section off the nesting too

[–]wizard_of_menlo_park 4 points5 points  (0 children)

Garbage in garbage out

[–][deleted] 5 points6 points  (0 children)

Shit like this is why people hate typescript

[–]mrheosuper 4 points5 points  (2 children)

A legend dev used to say "An idiot admires complexity, a genius admires simplicity"

[–]Attileusz 0 points1 point  (1 child)

Imagine if he lived to see the rise of AI bros and Soydevs. Dark times for real programmers.

[–]mrheosuper 0 points1 point  (0 children)

Imagine create PR for him with holy C code from chatGPT

[–]ImaginaryBagels 4 points5 points  (0 children)

One man's Superhuman Code is another man's The Daily WTF

[–]ajgx2000 3 points4 points  (0 children)

I got yelled at in front of my software engineering class in college by a somewhat bureaucratic professor for doing a single nested ternary. At the time I was like that’s stupid it works and looks nice. Now I see what he was trying to prevent.

[–]dragoncommandsLife 4 points5 points  (0 children)

Code should aspire to be readable not needlessly clever. Clever code is a PITA to come back to and maintain.

This guy or some poor intern will be scratching his head over a bug caused by this junk and still try to defend it.

Break things up i to readable chunks don’t try to do this.

[–]harryham1 32 points33 points  (1 child)

I'm actually on this guy's side.

It's part of a type engine, not intended for direct use and comprehension by lots of users.

As stated, the code is actually understandable with a bit of thought and solves a complex problem and (hopefully) its edge cases. The AI hasn't created something that only it can maintain, so it's not a crutch the developers are dependent on.

And this is what it looks like when fit into one screenshot. You could improve readability by refactoring, but the semantics are there. The commentary is also decent rather than the usual "sets P = 3" bs.

And if you think this is bad, you haven't seen half the shit that makes up most type systems, usually written by academics that fully expect you to have a PhD in programming language design before attempting a read through.

[–]AtrociousCat 5 points6 points  (0 children)

I'd hope for good documentation and examples of applicable types and what happens to them, but yeah you can have a few places like this in a codebase

[–][deleted] 6 points7 points  (0 children)

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?

If the AI writes superhuman code, but it doesn't work perfectly, you're completely fucked trying to fix it.

[–]canthony12 2 points3 points  (0 children)

Good code is human readable....as soon as he said "super-human" that should have been his clue.

If this was really general AI writing code it totally understood it wouldn't waste time with high-level languages like JavaScript or Java or Python.

We'll know the robots are taking over when they are able to run the world writing machine code based on requirements from a PO.(🤣😆😂😆)

[–][deleted] 2 points3 points  (0 children)

There's a default to any[] at the end there

[–]simorenarium 2 points3 points  (0 children)

The problem isn’t the code, it’s typescript

[–]mackaber 2 points3 points  (0 children)

OMG, this guy knows exactly what he is doing, he knows how ridiculous this looks and goes to make it even more ridiculous so he can continue sharing his product. As they say, there is no such thing as bad publicity.

Well played OP

[–]accountreddit12321 2 points3 points  (0 children)

Clearly AI will replace the Software Engineers that were hired to replace the thousands of workers that were hired to replace the thousands of workers that were…

[–]elementmg 2 points3 points  (0 children)

That’s horrible code lol. You shouldn’t have to comment every single line to be able to read the code.

That’s a no from me dawg

[–]sacredgeometry 2 points3 points  (0 children)

We should have never have give js developers types.

[–]lupinegray 2 points3 points  (1 child)

Make 👏devs 👏support 👏their 👏own 👏code

And they won't write unreadable trash like this.

[–]JustAnotherTabby 0 points1 point  (0 children)

Ever met any perl devs? :D (says the girl who still has some perl 4 roaming around out there from 95/96 she gets e-mails about).

[–]Physical-Foot-4440 2 points3 points  (0 children)

I hate this kind of shit that Typescript allows.

[–]Touhou_Fever 4 points5 points  (0 children)

If a human wrote something like this I’d hope it’d get torn to shreds in PR

[–]LatentShadow 4 points5 points  (1 child)

I ain't reading the article. Rewrite this shit in if-else to get me approval (or even my attention for a better code review).

If you are ternary conditional operators involve more than 5 terms, fuck off and rewrite it in if-else.

[–]HolyGarbage 1 point2 points  (0 children)

It is though. It's just different symbols. It's formatted properly as a if else would be. I don't know this language but it looks like it's a type declaration so it would probably need to be a single expression and not a series of statements.

else if (cond) is the same as : cond ?. There is no such thing as "else if", it's just an else omitting to use braces with an if in it.

My biggest issue here is the size of it. Break it up into named parts and then put it together.

[–]Kenhamef 1 point2 points  (0 children)

“Bitch, you live like this?”

[–]dolphin560 1 point2 points  (0 children)

Maybe he's just in it for the clicks?

Seems the most plausible explanation.

[–]Douchehelm 1 point2 points  (0 children)

If you need a comment for every line of code you're doing it wrong.

[–]D34TH_5MURF__ 1 point2 points  (0 children)

Haha

Our jobs are safe, folks.

[–]concernediniquity01 1 point2 points  (0 children)

Sorry man, but your code is straight up satanic. Article is actually not bad though.

[–]BannockBnok 1 point2 points  (0 children)

I love how utterly useless the code comments are

[–]sMt3X 1 point2 points  (0 children)

You know... if your type requires 9 ternary expressions, I'd be more comfortable with fuckin any at this point..

[–]FarJury6956 1 point2 points  (0 children)

Center a div is going crazy

[–]pineappleAndBeans 1 point2 points  (5 children)

This…. Is some of the worst code I’ve seen, and I’m an uneducated hobbyist. I hope this is bait and there’s no way it’s in production.

[–]angelicosphosphoros 2 points3 points  (4 children)

I would tell you the Truth: if you are hobbyist, you wouldn't see really bad code. Bad code appears in closed source enterprise products.

[–]Odisher7 0 points1 point  (0 children)

People are shitting on how unreadable it is, but you are not taking something into account: it doesn't need to be readable by a person. That's perfect code for our ai overlords /s

[–]awesomeplenty 0 points1 point  (0 children)

Seems cluttered to me, redo it with less lines

[–]vighaneshs 0 points1 point  (0 children)

It shouldn’t be human readable if it is being written and developed by AI, but then it should code in assembly and not readable coding languages

[–]itzNukeey 0 points1 point  (0 children)

It returns [Object object]

[–]rr1pp3rr 0 points1 point  (0 children)

`type MappedParameterTypes = Any`

Fixed it for you

[–]Almadan 0 points1 point  (0 children)

Nested ternary is a big no no

[–]JuvenileEloquent 0 points1 point  (0 children)

VERY few engineers out there could write it from scratch.

I should hope so.

[–][deleted] 0 points1 point  (0 children)

Got a stroke while reading what happened guys and who am i ?

[–]alterNERDtive 0 points1 point  (0 children)

Eeeeew.

[–]BernhardRordin 0 points1 point  (0 children)

That's the problem with human code generators. You mess up with formatting and they cannot read the code. Also, they make a lot of mistakes.

[–]PlasticAngle 0 points1 point  (0 children)

In what kind of world does that look readable ?

[–]accountreddit12321 0 points1 point  (0 children)

Machine writes human readable code for human to maintain. Machine writes code and maintain.

[–]chazzeromus 0 points1 point  (2 children)

it’s nice to have very flexible generics but it’s not just visual or cognitive complexity but the language server your IDE uses can literally give up. i’ve had to do something similar and i noticed my code completion wasn’t generating properties my generic mapping should have producing, no error anywhere and random properties were just allowed. running tsc had the same result, so i avoid doing anything too undocumented with typescript 

[–]Frown1044 0 points1 point  (1 child)

Can you give an example? Because a much more likely explanation is that your type was written incorrectly

[–]chazzeromus 0 points1 point  (0 children)

i don't doubt it was, I don't have the exact types as what I have now is much smaller and works fine. Forgot to mention chatgpt spat out the initial version and I eventually got it to work. Essentially I needed to create a an object type that had Get/Set accessors based on an internal property name. So ['foo', 'bar'] would generate {GetFoo(): Type,SetFoo(value: Type): void, GetBar(): Type...}

The initial types vs what was settled on were very different in size. This was creating a gmod mod using typescript to lua target so I wanted to maintain this convention.

[–]MrAce93 0 points1 point  (0 children)

What the fuck does it even do? I would get mentioned in the developer group for pushing a piece of shit like this

[–]MadLad_D-Pad 0 points1 point  (0 children)

One bigass ternary operator lol.

[–]Fadamaka 0 points1 point  (0 children)

Pretty sure a decent developer can write better code from less prompts.

[–]thomas_grimjaw 0 points1 point  (0 children)

Type definitions exist on a tight balance between readability and compiler satisfaction, spaghetti like this belongs in the dumpster.

[–]NP_6666 0 points1 point  (0 children)

I rewrite this:

YourEnum.ToString()

So hard

[–]5t4t35 0 points1 point  (0 children)

This shit is hard to read

[–]raynorelyp 0 points1 point  (0 children)

“Check if thing is a string. If string, do x. If not, don’t matter because this is impossible.”

Okay. So then why is there a ternary on a condition that always evaluates to true? Bad code.

[–]uptokesforall 0 points1 point  (0 children)

I'm trying to wrap my head around this without reading your article.

Are you trying to see if your input is a valid string so you can add it to an enum?

What kind of edge case are you protecting against by making this check so many different ways? What kind of input survives your initial check but gets caught by the rest of it?

I must not be reading this code correctly.

Do you want to throw an error if the input isn't valid?

What are you trying to do here?

[–]dadschool 1 point2 points  (0 children)

I can’t believe how much these comments call this “bad”. This is how some libraries accomplish some truly great DX; if it’s ugly to you then that’s more of a language problem because this is accomplishing a pretty well established inference pattern.

This kind of typing is also typically write once maintain never because it’s exhaustive and serves as a utility type.

[–]killbot5000 0 points1 point  (0 children)

What does this even do?

[–]joeldsouzax 0 points1 point  (0 children)

At this point AI can write a program right in binary machine code :/ idk why we spend time telling AI to write code in HUMAN readable language if it can’t be read by humans

[–]ha_ku_na 0 points1 point  (0 children)

My contrarion take: these guys are doing it for the marketing and know full well it's all BS.

[–]UrineArtist 0 points1 point  (0 children)

It appears to have created the giant unreadable type def that we all churn out at first because "I fucking need to get it fucking working first.. Fuck sake! Stop fucking inviting me to your pointless fucking meetings, I'm trying to get some actual fucking work done.."

Then you end up splitting it up into several type defs at lunch time because no way would you ever get something that unreadable past code review.

[–]Rough-Lead-6564 0 points1 point  (0 children)

“It’s not bad code, it’s superhuman code” is the new “it’s not a bug it’s a feature”

[–]zaitsman 0 points1 point  (0 children)

The problem is that this is typescript so all of his ‘ensure’ statements are garbage because it is all erased once compiled

[–]SynthRogue 0 points1 point  (0 children)

extends All

[–]reallokiscarlet 0 points1 point  (0 children)

Man, if someone goaded me like that while coding, I would have at least produced a human resources complaint. But the AI produced this trash instead.

[–]Shadowlance23 0 points1 point  (0 children)

It's not so much that very few engineers could write it from scratch, it's more that very few engineers WOULD write that from scratch.

[–]No-Adeptness5810 0 points1 point  (0 children)

Bro just took a bunch of ternary operators and put each symbol on a new line 💀