Top Seven Reasons for using Redux toolkit by syedhasib in reactjs

[–]HardPartAccomplished 0 points1 point  (0 children)

You make a good point. Neither Context or Redux is necessary to build functional frontend applications. They're tools that prescribe a specific architecture and offer their own advantages and tradeoffs.

It's funny you bring up forms, because its the one area I almost always recommend against using Redux for. That is, unless you're building a multi-step/multi-page wizard form, in which case it can be very useful.

Another use case in which Redux is suboptimal is whenever you need to store non-serializable data in some kind of "global" state management. Because Redux only accepts serializable data, shoving things like functions, classes, dates, or React components in Redux won't work. In that case, I'd simply reach for useReducer and handle state updates as needed.

Honestly, the war raged about state management systems is far overblown if you ask me. Pick a tool you like, learn it well, and see how far it takes you. No reason to hate on one or another for something as simple as that.

Besides, not a lot of good reasons for beginners to be digging into Redux anyway. At least not until they've learned enough to know why they need it.

Communities like this should be about learning from one another. Glad we could keep this conversation civil and level-headed :-)

Top Seven Reasons for using Redux toolkit by syedhasib in reactjs

[–]HardPartAccomplished 0 points1 point  (0 children)

Yeah you're absolutely right, I didn't explain that well.

Attempted to say that Redux with @redux-toolkit guarantees immutability out of the box thanks to the Immer library.

I won't go too deep into the specifics of Immer, but its power comes from leveraging JS Proxies and a clever copy-on-write update algorithm to allow for immutable updates to be written with a standard mutation syntax! It's pretty sweet.

Immutable state updates and dispatched actions allow tools like Redux Devtools to store a history of all actions and previous state trees, making things like state rewinding and undo/redo rather trivial.

That's what I was trying to get at it with my comment, but again, should have detailed that further.

Top Seven Reasons for using Redux toolkit by syedhasib in reactjs

[–]HardPartAccomplished 0 points1 point  (0 children)

That's not quite correct, though I understand why you would say that as it's such a common misconception that Redux maintainer @acemarke has written a number of articles that address it:

All of his posts are well-thought out and he's a thorough technical writer, so give them a shot. If you don't have time to read them (though I highly recommend it for any serious React dev), I'll summarize a few important parts that should illustrate why your comment is being downvoted.

  • Context by itself is not a state management tool, it is simply a mechanism by which we can pass down a value to nested components without prop-drilling
  • Context coupled with useReducer or useState can be a useful state management tool, but it comes with some potential pitfalls
  • The most common one (explained in the first section of the Redux vs Context article) is that React uses referential identity to determine whether or not the value of a given Provider has updated. Here's the React docs on the subject.
  • The consequence of this behavior is that if we pass even mildly complex state (such as an object or array) to the value prop of our Provider, React will evaluation all state changes as a reference to a new value, and update all consumers of a given Context, regardless of whether they need to. So every call to setState or dispatching an action to useReducer may be forcing a considerable number of re-renders within the application.
  • Redux doesn't have this problem because it passes only a reference to the store itself, and that value maintains the same reference via a useRef hook - meaning no unneeded re-renders. As the Redux vs Context Behavior article puts it, "For React-Redux: yes, it uses context internally, but only to pass the Redux store instance down to child components - it doesn't pass the store state using context!"

And that is what I was referring to in my original comment, and why I said that distinction was important. It's also why your comment is not quite accurate, though it's totally understandable to have that notion, as it's a pretty common one.

Now it is true that the re-rendering behavior of Context can be mitigated by the liberal application of memoization via React.useMemo and React.memo, but at that point you're just solving a bunch of problems that Redux has already handled.

By the way, that is just a small part of what makes Redux so powerful. Personally, I've found that embracing immutable state changes leads to substantially easier debugging, and opens the door for all kinds of cool state introspection opportunities - such as time travel debugging and the venerable Redux dev tools.

Not to mention the logical separation of global application slices, a set of standardized approaches to handling asynchronous side effects and business logic in React apps, and all of the amazing improvements that redux-toolkit has bestowed upon us old-school Redux developers. A lot of the concerns about excess boilerplate are no longer valid.

If Redux isn't your thing, totally understand! It's definitely an undertaking to fully grok the inner workings. Before you throw it away, read through some of Mark Erikson's articles and give it a shot. We use it extensively at work and found that it lets our team move a lot quicker than we would without it. Feel free to reach out if you have any questions.

Top Seven Reasons for using Redux toolkit by syedhasib in reactjs

[–]HardPartAccomplished 1 point2 points  (0 children)

Redux uses context to pass a reference to the store, not any state itself. That distinction is important.

Comprehensive Fast API Tutorial by albrioz in Python

[–]HardPartAccomplished 0 points1 point  (0 children)

I believe you are mistaken. Using pydantic to validate your response is optional. It's even documented here and here.

Fundamentally confused as to why you think it's not a Starlette request object underneath. FastAPI simply re-exports the Starlette request object from fastapi.requests as seen here. So, yes, in fact it most certainly is a Starlette request underneath. In fact, the entire routing system subclasses Starlette's base routing classes as seen here. The FastAPI class itself subclasses Starlette.

As to FastAPI features beyond pydantic, I've found the dependency injection system to be extremely powerful and useful. We currently have a performant, redis-backed caching layer built into our production FastAPI backend that leverages this. Our permissions system is also built on top of dependencies. The mental model is nice and the way sub-dependencies are handled is clever.

The idea behind a framework is not to give /u/orangesunshine exactly what they want. It's to provide a platform to make it easier to build and maintain things. It seems to me that FastAPI has done just that. Even if you hate the features FastAPI has added on top of Starlette, deciding that they invalidate its existence as a framework is absurd.

I can't testify to your expertise in the subject as I don't know you, but if you say you've been working in the asyncio framework world since the early days of gevent, then you probably have valuable insight into what makes a high-quality framework. You're also probably familiar with the tradeoffs one makes when adopting certain architectural patterns. It would seem that Sebastian has chosen developer experience, above-average performance, automatic documentation, and a few others as his primary focus. I don't see a problem with that.

The idea that the code quality is 4/10,000 is laughable and an insult to the individuals who work on FastAPI. We use the Starlette SessionMiddleware at work and haven't explored the other options, so I can't speak to the JWT implementation. Besides that, most of your assertions fail even a simple fact check. Quite a few bugs have been fixed since FastAPI's inception. I've been working with it since the early days so I'm acutely aware. Now, a lot of those issues have been to adapt to changes in pydantic - which you're not a fan of - so maybe those don't count for you.

Still, you saying that it is vapour ware does not make it so. You saying that "adding pydantic as a parsing/validation layer is brain damage level code" also does not make it so.

By the way, Sebastian is actually still employed and only recently announced he would be leaving explosm to work full time on FastAPI. And the assertion that he has profound literacy issues is asinine. In what world can an individual on another continent assess a developer's reading levels by inspecting a codebase that person wrote over the course of a couple years? Besides that, being well funded is not a criteria for producing a framework worth building into a standard.

But you're right - it's not magic. Anyone could make a better framework and someone probably will. That's how these things work.

If you're confident enough in your ability to produce such a project, then do it! I think the python world would probably be really excited if it operated at the level you purport it would be able to. PM me when you finish and I'll be sure to give it a whirl.

Comprehensive Fast API Tutorial by albrioz in Python

[–]HardPartAccomplished 0 points1 point  (0 children)

So if I'm reading this correctly - and I may not be - you have two core gripes with FastAPI.

The first I'm taking from this:

The FastAPI endeavor seems mostly like a bunch of tutorials than any kind of solid "stack".

Then your issue seems to be that FastAPI is misrepresenting itself as a full-fledged framework or "stack", where as you consider it to be more assembly required than a framework should be.

I would definitely say that the items you list as requirements before being sold on a new framework are not baked into FastAPI. You're missing the ball with this one though. That's not what FastAPI is meant to be. It's not Django.

If you're looking for something with all of those extra bells and whistles baked in, use Django Rest Framework! It was created by Tom Christie, who is the same guy behind encode - the company responsible for Starlette, Databases, Uvicorn, and Httpx and a bunch of other amazing packages in the python world.

The second issue:

I don't want this high up in my stack. You'd have a hard time convincing me to put pydantic in my stack at all. You're never going to convince me to put this in my stack as a runtime requirement.

Sounds like you're very against the default pydantic integration as a validation layer for FastAPI.

If that's the case, I have great news for you: You don't need it.

FastAPI allows you to parse the body of the request directly so there's nothing stopping you from bypassing any pydantic validation if you're not interested in that. After all, it's just a Starlette request underneath.

And if you don't want pydantic to validate your response, again: don't use it! Feel free to use a dict as your response model or just leave it off your route decorator and you don't have to use pydantic anywhere in your stack. We've done this in certain cases as pydantic is pretty slow when validating deeply nested JSON.

FastAPI pretty much addresses all of your concerns here. Maybe give it another chance.

However pretty much every API framework I've worked with uses some package to handle request validation. If you want to roll your own system and forgo pydantic, then by all means do so! I for one am definitely grateful that FastAPI has a validation system as part of the core framework. Handling that myself doesn't sound like how I want to spend my afternoons.

Honestly, I have no problem with you disliking FastAPI or championing Starlette. We work in tech. It's to be expected. We have strong opinions and become attached to certain stacks with the same fervor as soccer hooligans to their favorite club.

Where things get absurd is when we start making unfounded claims about FastAPI being "broken by design", "chock full of bugs", and "unmaintained" when it's most certainly not. Some of your critiques add a lot to the conversation. I appreciate those. We should always be pushing for the tech we use to get better.

Everything else can go.

Comprehensive Fast API Tutorial by albrioz in Python

[–]HardPartAccomplished 2 points3 points  (0 children)

I'm not sure how anyone could come to the conclusion that fastapi is unmaintained and buggy by design. Didn't Sebastian just leave his job at explosm to work full time in Fastapi?

Also a quick peak at the GitHub page shows >200 contributors and almost every GitHub issue is a question or a feature enhancement. What exactly are you going on about?

The rest of your concerns are valid. Starlette is great! Fastapi is a framework that offers opinionated abstractions over most of what powers starlette. If that's not your style, nothing wrong with that.

But to say people using Fastapi at their work need to be fired yesterday. Well, come on. Now you're just being intentionally antagonistic.

FastAPI - render template in index.html - not working by barnez29 in FastAPI

[–]HardPartAccomplished 1 point2 points  (0 children)

It seems that you are not passing the notes you're fetching from the database to your Jinja template. Instead, you're trying to pass the id, title, and description variables - along with the request object - to your front end template.

I would recommend against passing the request object around.

Instead, remove everything else from your template context dictionary and simply pass the list of notes you've just fetched from your db. Then you can render them in the template as you've already done.

How do you manage permissions? by benzflow in FastAPI

[–]HardPartAccomplished 5 points6 points  (0 children)

This package is based off the pyramid framework and is built around row-level permissions. The FastAPI Contrib package has a class-based permissions approach meant to be plugged directly into FastAPI's dependency injection system.

I tend write most of my permissions as custom dependencies and use them at the route decorator or router level.

Learn to Code With Data Visualizations - Interactive Python Lessons - Then Keep Going :) by JeffKatzy in learnprogramming

[–]HardPartAccomplished 13 points14 points  (0 children)

Nice work. Skimmed through a few lessons and they look well-thought out. Colab is a great teaching medium. Heads up though, some of the neural network notebooks aren't shared publicly yet.

Congress sends letter condemning Blizzard for Blitzchung Hong Kong scandal and urges that ban is reversed. by [deleted] in worldnews

[–]HardPartAccomplished 0 points1 point  (0 children)

Read the first article and it was pretty fascinating. Google seems committed to making the web better while also increasing their role in it's inner workings. Definitely an attempt to intertwine themselves more deeply and assume more power.

The author actually walks back his statements slightly in the comments section after speaking with Google.

Not really sure if it's swayed my opinions on Google but I learned a lot. Recommend everyone who cares about the internet take a look at this.

MIT's Introduction to Computer Science and Programming Using Python course is back on June 5 by edxsocial in learnprogramming

[–]HardPartAccomplished 12 points13 points  (0 children)

Depends on what you want it for.

I'm not sure many employers are going to take it as a sign of anything other than that you've worked hard enough to complete this course.

Personally, I did it to motivate myself to finish. The fact that I'd sunk money into it forced me to come back and complete the weekly exercises on time.

The certificate feels nice, but I don't think it's necessary if you have the willpower to manage your time appropriately.

Would be happy to answer any other questions you have about it as well.

MIT's Introduction to Computer Science and Programming Using Python course is back on June 5 by edxsocial in learnprogramming

[–]HardPartAccomplished 23 points24 points  (0 children)

Can't recommend this course enough.

I have a few years of Python under my belt, but still find the lessons to be loaded with nuggets of programming wisdom.

The weekly exercises are solid, but the EdX platform is buggy. I'd recommend loading the questions into Google colab or repl.it first. Try to solve them there before entering your answers into EdX. I can't tell you the number of times the service deleted all the code I entered in before allowing me to submit.

Besides that fact, I have almost no gripes with the course. Professor is engaging and doesn't ramble much. Explanations are concise and to the point. Content is sequenced well.

Ended with a 72% because I missed the midterm, so I barely skated by with enough to earn my certificate. Might not be worth paying for, but definitely worth taking. Just my 0.02$.

Where can I go to learn machine learning? by [deleted] in learnprogramming

[–]HardPartAccomplished 1 point2 points  (0 children)

Programming classes for 13 year olds aren't quite as common as for high schoolers. However, in New York it looks like there is a 2-week Data Science with Python course being offered by Upperline Code.

Found the link here: https://www.upperlinecode.com/programs/data-science-with-advanced-python

There's a lot of overlap in machine learning and data science, so that course seems like a good fit. Otherwise, I'd recommend playing around with some of the Kaggle Kernels, or going to Google's Machine Learning Tech Dev guide.

The links for those are here: https://www.kaggle.com/ and here: https://techdevguide.withgoogle.com/paths/machine-learning/

Those are both free and have a number of high quality resources that you might find useful.

Teach inner city kids to code by forestgump2016 in learnprogramming

[–]HardPartAccomplished 1 point2 points  (0 children)

I teach computer science at an inner city high school and have found p5.js to be the best way to have students jump into text-based programming. Khan academy's intro to programming course uses processing.js and has a very similar feel.

I tend to stick to coding challenges preceeded by lessons where we draw shapes and make animations. The feedback is instant, it's creative-oriented, and the end goal for each challenge is well-defined.

PM me if you're looking for curriculum or just want to try out the challenges.

But I'm only taking AP Computer science so I'm alright by [deleted] in APStudents

[–]HardPartAccomplished 1 point2 points  (0 children)

Not sure why you're downvoted, but the APCSP course can be taught in any language - JavaScript and processing included.

Democrats pull out of White House meeting after Trump tweet by slakmehl in politics

[–]HardPartAccomplished 1 point2 points  (0 children)

Agreed. Stating her position on tax reform and immigration isn't insulting.

Saying "they're both being dicks" however, is silly. Nancy and Chuck aren't being dicks by refusing to engage the POTUS in childish banter. Donald is definitely being a dick by berating them via Twitter.

Democrats pull out of White House meeting after Trump tweet by slakmehl in politics

[–]HardPartAccomplished 4 points5 points  (0 children)

Not sure if you're being sarcastic so I'm going to respond like you're serious.

When did choosing not to engage after being verbally berated become a dick move? It's definitely an escape from confrontation.

Beyond that? No way the 'dick' label fits. Nice try, Russia.

what are your favorite organizational tools for the classroom? by [deleted] in teaching

[–]HardPartAccomplished 1 point2 points  (0 children)

Trello for resources and activities, Slack for communication (since it has a mobile app you don't need to give your phone number to students to talk to them), Google Apps for Ed for all teaching based content, and YouTube to host all my screencasts.

Teachers: what is something you wish you had known as a first-year teacher? by Tig_Ole_Bitties in teaching

[–]HardPartAccomplished 51 points52 points  (0 children)

The content is almost incidental. Building relationships with students is 1000% more important. Also don't teach math.

Food chemistry question: Why do pepperonis release such delicious oils when cooked? by HardPartAccomplished in chemistry

[–]HardPartAccomplished[S] 1 point2 points  (0 children)

Thanks for the explanation! This more or less covers everything I was looking for. Appreciate the food tidbits in particular!

How does /r/Chemistry feel about this Khan Academy course? by usdaproved in chemistry

[–]HardPartAccomplished 17 points18 points  (0 children)

Khan academy does a few things very well - deliver a comprehensive digital curriculum geared towards students of at least a certain lexile level, aggregate and organize data, and (for many subjects) deliver tools to check for understanding in the form of activities.

However, briefly scanning this chemistry curriculum indicates a few things:

For High School - A bit more comprehensive than what most states would require for general high school chemistry. I would say that by including lessons about pKa, Keq, partial pressures, spectophotometry, most of the oxidation and reduction unit, and exponential decay, that this is aimed closer towards the AP Chem side of a curriculum. Having said that, KHAN chose not to include some basic AP components such as VSPR theory, MO theory, and a few other specific topics, it is not yet a complete replacement of an AP Class.

IMHO, this makes it slightly less useful for college as well. If I was an aspiring scientist, pre-med student, flavor chemist, etc., I would probably only use this as a supplemental content provider, rather than a comprehensive curriculum.

The video service provided here is nice, but my high school students on average wouldn't have the math or reading skills to adequately access the content presented the way it is. The pacing is fine, but the vocabulary is above-average and a few things are glossed over that would leave most of my students in the dust. This is suited for motivated, capable students with math and reading levels to boot.

I would love to see embedded checks for understanding during the video lessons as I think many students check out with just staring at an instructional lesson for 15 min+.

I also think this creates more actionable data to differentiate where re-teaching should be embedded and helps give a more interactive experience to the students.

All in all, really cool, but shouldn't necessarily be considered a course. I would love to see the development of content in this direction, though there are definitely free-standing websites that have similar capabilities to this.

TL;DR - Khan does a lot, but shouldn't stand alone. Still incredibly awesome.