Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
barkbell
Apr 14, 2006

woof

Video Nasty posted:

I know, it's great! All the documentation to ever be written about it is already published and available online.
It's part of the engine in the software I use for work, so we're restricted to ECMA5 and I'm happy as a clam about it.

lol

Adbot
ADBOT LOVES YOU

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Video Nasty posted:

I know, it's great! All the documentation to ever be written about it is already published and available online.
It's part of the engine in the software I use for work, so we're restricted to ECMA5 and I'm happy as a clam about it.

Not only that, but you don't have to wake up one day and hear "oh, you really should be using hooks instead of components, please rewrite all your code." All JS frameworks should ideally be EOL.

smackfu
Jun 7, 2004

Heh, React is a funny example since their releases have slowed to a crawl. Yeah, they released hooks **three years** ago, but they haven’t done any releases for 11 months at this point.

https://github.com/facebook/react/blob/main/CHANGELOG.md#1702-march-22-2021

gbut
Mar 28, 2008

😤I put the UN🇺🇳 in 🎊FUN🎉


Video Nasty posted:

I know, it's great! All the documentation to ever be written about it is already published and available online.
It's part of the engine in the software I use for work, so we're restricted to ECMA5 and I'm happy as a clam about it.

Isn’t that ES4? ES5 is what ActionScript in Flash ended up being, if I remember correctly.

Video Nasty
Jun 17, 2003

gbut posted:

Isn’t that ES4? ES5 is what ActionScript in Flash ended up being, if I remember correctly.

It's whatever Angular1.5 left us with, but I could've sworn it was a little more recent than ES4. Happy to be corrected there.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

smackfu posted:

Heh, React is a funny example since their releases have slowed to a crawl. Yeah, they released hooks **three years** ago, but they haven’t done any releases for 11 months at this point.
Sure it's slow-updating now, but you know the instant *I* used the modern way of doing something with any third-party framework, that way would be immediately outdated by a new release.

barkbell
Apr 14, 2006

woof
did you finally learn to use flexbox instead of tables

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

barkbell posted:

did you finally learn to use flexbox instead of tables
To some extent. It still seems like a lot more effort for negligible benefit, but whatever. Why, did that just become outdated?

fsif
Jul 18, 2003

Not trying to hate, I get the allure of knowing what you know and then never having learn new stuff again.

But aren't you guys ever worried about, like, losing your jobs? And then becoming unemployable? I would never consider hiring a dev in 2022 that wasn't ES6 fluent.

Is there just enough legacy Angular work out there to last?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
Ah, I don't do front-end stuff for a job, I only do it for my own personal project, so I can use whatever I want that does the job the best and easiest. Which it turns out is whatever doesn't require redoing the whole bastard thing every 6 months when some jerk changes the framework out from under me, and whatever doesn't involve fixing open-source poo poo that doesn't actually do what it's supposed to.

(The back end stuff I do for a job *does* involve fixing open-source poo poo that doesn't actually do what it's supposed to, but then I don't mind because I'm getting paid for my time so I don't really care if getting it working takes longer than it should. I mean it's frustrating at the time, but I just have to remember to think of it in money terms.)

If you're doing it for a job then there's no personal cost to using whatever the new hotness is, because you can just change project when the framework changes and then that becomes someone else's problem (seen this a lot). And that keeps the job market hot for all of us, by creating a lot of busywork. But I've made the mistake of using new hotness for my personal project more times than I should have, it's taken me like 5 times of getting burned to finally realize "never use any loving framework" is far more effective in the long run. (Well, the last time wasn't a framework, the final lesson was "never use any library controlled by Google". I thought flatbuffers would be safe enough, but no, even that turned out to have a shifting API.)

Video Nasty
Jun 17, 2003

fsif posted:

Not trying to hate, I get the allure of knowing what you know and then never having learn new stuff again.

But aren't you guys ever worried about, like, losing your jobs? And then becoming unemployable? I would never consider hiring a dev in 2022 that wasn't ES6 fluent.

I’m fluent in the latest vanilla JS goings-on but it isn’t necessary for my job or a potential future job in the same market at least for the time being.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

fsif posted:

Not trying to hate, I get the allure of knowing what you know and then never having learn new stuff again.

But aren't you guys ever worried about, like, losing your jobs? And then becoming unemployable? I would never consider hiring a dev in 2022 that wasn't ES6 fluent.

Is there just enough legacy Angular work out there to last?

Web dev poo poo has so much churn that of any given new framework that people talk about, it'll just go through phases of "everyone thinks this is good and fresh out of college children advocate it" "oh, this actually kind of sucks and you need to start doing things differently to solve some problem that we didn't think of before", "this is outdated and you shouldn't use it, we do it this way now."

What I've found is that generally, as stuff has progressed, it's become easier and easier to cotton onto a new web frame work and use the new stuff. I personally thought angularjs was dumb when that stuff was released, and never touched it, and that turned out to be a good instinct. But nowadays, almost every framework I touch is so much better than what was being used towards the beginning of my career that the choice almost seems irrelevant.

I also don't really care about updating my resume with latest buzzwords etc. because frankly the people who pigeon-hole their career with language/framework specificity seem to get paid less than people like me. If I need to learn a framework to do a job or work on a new project, I'll do it, and I'll learn that poo poo better than the people who actually like the framework and advocate for it, but I'm not just going to arbitrarily pick a new framework for a project at work and use it just for the sake of learning it, and if I get filtered by some shithole job that wants ten years of experience in a framework that's only existed for one, that company was probably hosed anyway.

fsif
Jul 18, 2003

Bruegels Fuckbooks posted:

If I need to learn a framework to do a job or work on a new project, I'll do it, and I'll learn that poo poo better than the people who actually like the framework and advocate for it,

Considering your last post suggested that code bases needed to be rewritten when React hooks were released, I'm skeptical.

I had to collaborate with a developer at another company on a project about six months ago who I suspect would echo the same sentiments the last several folks on this page have. He needed to use React for the first time and he ended up being less productive than our junior developer, even as we purposely steered him towards projects he felt like he'd be better equipped to handle. Plus, you know, his code ended up being a complete mess and I had to spend an hour or so everyday helping him troubleshoot.

For all this hand wringing about silly coding noobs chasing "the new hotness," the tech mentioned in the last series of posts (React, ES6, flexbox) has been dominant and/or standard for the better part of a decade now.

gbut
Mar 28, 2008

😤I put the UN🇺🇳 in 🎊FUN🎉


I see that exact same scenario a few times a year. Especially because my company likes to shuffle teams in order to make the workforce fungible.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

fsif posted:

I had to collaborate with a developer at another company on a project about six months ago who I suspect would echo the same sentiments the last several folks on this page have. He needed to use React for the first time and he ended up being less productive than our junior developer, even as we purposely steered him towards projects he felt like he'd be better equipped to handle. Plus, you know, his code ended up being a complete mess and I had to spend an hour or so everyday helping him troubleshoot.
For the full story though you have to recognize that the junior developer's code was *also* a complete mess, as was yours. Because there is no such thing as code that isn't a complete mess, not even back when people were constrained to fit their entire application in a kilobyte of punch-cards.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

fsif posted:

Considering your last post suggested that code bases needed to be rewritten when React hooks were released, I'm skeptical.

I was being facetious with that example. I like hooks better than components too. I'm not going to go back and rewrite a bunch of poo poo that already works using hooks though just because I'd be afraid of being "behind the curve."

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I'm having a lot of fun and I want to share it with you.



There is equal space between these grey boxes regardless of zoom level, zoom level is modulated with the scroll wheel. Zoom level affects only the size of the grey boxes and the space between the grey boxes stays the same. When I zoom in or out it needs to do so without the cursor moving.

Usually this isn't too difficult.

I've got the cursor position, I've got the dimensions of the page. But what I'm having a heck of a time with is the space not changing between the items that are all over the place. If the cursor is somewhere between the first and second column, then when I zoom out it's going to be over the second column somewhere. I need to take into account the amount that the pixels in the first column changed, but not the pixels in the space between it and the second column.

Like.

If I'm way down the page and there's 100 items in a column and I zoom in. I need to take into account the amount of space that remained unchanged between all these grey boxes. I more or less have to calculate how many grey boxes down the page my mouse cursor is. Which involves taking into account the height of every grey box above it. Have I lost my mind and all I have to do is scroll half the difference between old scrollHeight and scrollWidth and new scrollHeight and scrollWidth?

Because I feel like I thought that scenario out already and decided it doesn't work.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Yeah there really is no way to figure out where the cursor is supposed to be without iterating over all the grey boxes above and to the left of the cursor. Guess I'll just, go ahead, and do that.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Figured out that a big part of my problem is while zooming the columns will adjust in size differently from one another.

10 grey boxes in one column 20 grey boxes in another column, zooming creates a bigger difference in the column with 20 grey boxes. Because the dang space between the grey boxes doesn't change. What I've been spending all this time on doesn't necessarily make sense. Even if it looks as good as possible, grey boxes in columns are going to be moving up and down a small amount while zooming.

Anony Mouse
Jan 30, 2005

A name means nothing on the battlefield. After a week, no one has a name.
Lipstick Apathy

roomforthetuna posted:

Because there is no such thing as code that isn't a complete mess, not even back when people were constrained to fit their entire application in a kilobyte of punch-cards.

I feel sorry for devs who think this way or believe this is some kind of wise truism. Consider it possible that you have had the misfortune of only working with terrible developers in the past, or *hushed whisper* might be one yourself.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Anony Mouse posted:

I feel sorry for devs who think this way or believe this is some kind of wise truism. Consider it possible that you have had the misfortune of only working with terrible developers in the past, or *hushed whisper* might be one yourself.
Yes, everyone who works at Google is terrible, everyone who works at Dropbox is terrible, and all open-source developers of every library I've ever looked at is terrible. What misfortune, to have worked at such second-rate places with such low standards.

To be fair, Bernstein's DNS and its helper libraries are actually not horrible, so I may have overstated slightly that everything is bad, just *almost* everything is bad.

Summit
Mar 6, 2004

David wanted you to have this.
All code is terrible and needs careful management and validation to not explode at the worst possible moment.

camoseven
Dec 30, 2005

RODOLPHONE RINGIN'

Summit posted:

All code is terrible and needs careful management and validation to not explode at the worst possible moment.

Actually my code is perfect every time

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

camoseven posted:

Actually my code is perfect every time

Mine is too. Ignore the fact that a few days ago I was trying to figure out how to code an algorithm that doesn't make sense, I've improved since then.

Ola
Jul 19, 2004

My current code is perfect, but my past code is terrible.

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
Crossposting from the Web Design thread.

Okay, perhaps I'm an idiot noob at this poo poo, but using dataTables.js, how in the literal actual gently caress do I apply custom CSS? My Flask app theme is shades of blue, and having white/lightsteelbluerows in a table is jarring. Specifically, I want the <thead> to be steelblue and the rows to be lightsteelblue/cornflowerblue.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Ola posted:

My current code is perfect, but my past code is terrible.
A really weird thing is that some code I wrote like 25 years ago, in Perl, turns out to be remarkably elegant and maintainable every time I look at it. I think maybe when the language itself is hideous you have to go out of your way to be extra clear? Or maybe I was just really good 25 years ago.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I've got these sort of helper functions in typescript.

https://github.com/Kequc/kequapp/blob/0.2-wip/src/addable/create-route.ts
code:
import { extractParts, extractHandles, extractMethod } from '../router/helpers';

function createRoute (...params: unknown[]): IAddable {
    const method = extractMethod(params);
    const parts = extractParts(params);
    const handles = extractHandles(params);

    function route (): Partial<TAddableData>[] {
        return [{
            parts,
            handles,
            method
        }];
    }

    return route as IAddable;
}

export default createRoute as ICreateRoute;
With some types that look like this.

https://github.com/Kequc/kequapp/blob/0.2-wip/types.d.ts
code:
interface ICreateRoute {
    (pathname: TPathname, ...handles: THandle[]): IAddable;
    (method: string, pathname: TPathname, ...handles: THandle[]): IAddable;
    (method: string, ...handles: THandle[]): IAddable;
    (...handles: THandle[]): IAddable;
}

type THandle = (bundle: TBundle, routeManager: IRouteManager) => Promise<unknown> | unknown;

type TBundle = {
    req: TReq;
    res: TRes;
    url: URL;
    context: TBundleContext;
    params: TBundleParams;
    getBody: IGetBody;
};
But when I use them, Typescript isn't respecting the `ICreateRoute` interface, it says no matter what parameters I put in there they're all type `any`. When I hover My use of `createRoute` it says it's type `ICreateRoute`.

https://github.com/Kequc/kequapp/blob/0.2-wip/examples/basic/app.ts
code:
    createRoute('POST', async ({ getBody }) => {
        const body = await getBody<{ name: string }>();
        return `User creation ${body.name}!`;
    })

    // `getBody` is type any for some reason it should be of type `IGetBody`

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
It is quite possible I being a dummy, but don't you have to import the types where you use them? I don't have much (read "any") experience with d.ts files, so maybe there is some magic that is supposed to be happening and it's not?

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

Lumpy posted:

It is quite possible I being a dummy, but don't you have to import the types where you use them? I don't have much (read "any") experience with d.ts files, so maybe there is some magic that is supposed to be happening and it's not?

yeah you can declare them globally with d.ts files. It's the reason (for example) react types (and every other package with @types) just "work" without you having to import them because the "@types/react" package builds d.ts files

but for actually source code you're writing, it's a bad pattern. You don't usually want to do it because you have to go digging where the types are. But YMMV

teen phone cutie fucked around with this message at 19:53 on Mar 1, 2022

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I'd assume types weren't working at all except that `ICreateRoute` is correctly registered by my IDE. Which means there's maybe something wrong with my types file, and not registration of my types file.

HootTheOwl
May 13, 2012

Hootin and shootin
I've started trying to code websites and I am confused how the className property can somehow be used to make a JSX element have different properties.
I know a lot of C# and C++ and it makes no sense. Telling the code that you're of the Width class and of the Color class somehow makes it true? using strings?
What? Help.

I R SMART LIKE ROCK
Mar 10, 2003

I just want a hug.

Fun Shoe
well what you're referring to is actually a function of how CSS works: https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors

the className property is just setting a class on the DOM element

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender
1. Define a CSS class with an arbitrary name, and arbitrary properties: .foo { border: 1px black solid; color: green; width: 100%; }
2. Create an HTML element with a class attribute that's just a string of space-separated CSS class names: <p class="foo some_other_class bar">blah</p>. (JSX is just syntactic sugar for defining an associative array describing an HTML element, and it uses className instead of class because class is a reserved word in JS).
3. When the browser renders the HTML element, it looks for any CSS classes with names specified by the element's class attribute, and applies them to the element.

What's not to get?

HootTheOwl
May 13, 2012

Hootin and shootin

I R SMART LIKE ROCK posted:

well what you're referring to is actually a function of how CSS works: https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors

the className property is just setting a class on the DOM element


minato posted:

1. Define a CSS class with an arbitrary name, and arbitrary properties: .foo { border: 1px black solid; color: green; width: 100%; }
2. Create an HTML element with a class attribute that's just a string of space-separated CSS class names: <p class="foo some_other_class bar">blah</p>. (JSX is just syntactic sugar for defining an associative array describing an HTML element, and it uses className instead of class because class is a reserved word in JS).
3. When the browser renders the HTML element, it looks for any CSS classes with names specified by the element's class attribute, and applies them to the element.

What's not to get?

Thanks

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Nolgthorn posted:

I've got these sort of helper functions in typescript.

Is it because I'm using `export default foo as IFoo` and `export as` is actually javascript, typescript just happens to have the identical notation for casting? But I don't think there's such thing as `export default as` in javascript.

Regardless. Maybe it's getting confused.

Types work in my src directory, strangely enough when imported from the same place... but not outside the src directory... even though my types file is outside the src directory. I've tried moving things around and using different notation but I'm not sure I'm closer to a solution. If anyone has any ideas I'm all ears.

I think it might be a bug in typescript? But I'm also not sure how to create a test case for the problem.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I was writing a big post with examples of things I tried. Adding `"examples"` (the directory I was having trouble with) to my tsconfig works. But I don't want to include the examples directory in my dist.

code:
  "include": [
    "examples",
    "src",
    "types.d.ts"
  ]
I don't really understand why I need to include it since types work fine in my tests directory without it.

Roadie
Jun 30, 2013

Nolgthorn posted:

I don't really understand why I need to include it
Typescript only includes the files and folders you have in include. That includes global type definitions in your repo.

Nolgthorn posted:

since types work fine in my tests directory without it.
Whatever testing framework you're using has its own configuration instead of using tsconfig.json to decide what to include.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I'm only talking about intellisense in the IDE picking up the types and having them work properly. The test suite isn't running, I'm just working with types while fiddling around in a directory.

What is the difference between `/examples` and `/tests` with regard to picking up types from imported files?

Nevermind, only some types work in my tests directory too.

Typescript! :arghfist:

Everything coming from an Interface is type `any`, return values or properties. Unless I include the directory in my tsconfig's includes.

Nolgthorn fucked around with this message at 00:34 on Mar 7, 2022

Adbot
ADBOT LOVES YOU

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Common wisdom seems not to make a `types.d.ts` file and instead use normal imports for types. I thought I'd try something different because I felt it was cleaner but it's causing problems I'll switch back.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply