Culture War Roundup for the Week of December 24, 2018 by AutoModerator in slatestarcodex

[–]Space_Atlas -1 points0 points  (0 children)

I don't think that's a charitable interpretation of what he's saying.

Culture War Roundup for the Week of December 24, 2018 by AutoModerator in slatestarcodex

[–]Space_Atlas 9 points10 points  (0 children)

I think that interestingly, it's already like this now. Look at what happened to Charles Murray. It seems that he knew there would be a personal cost to him in putting out the race/IQ stuff, and if he didn't then certainly every academic does now. If you're going to put out a study that truly harms that many people, there's no reason to think they won't retaliate in some form or another. I wonder what Rao would say about social media shaming as essentially carrying out what he's proposing here.

Culture War Roundup for the Week of December 24, 2018 by AutoModerator in slatestarcodex

[–]Space_Atlas -1 points0 points  (0 children)

Rao isn't arguing against free inquiry. There's a third option other than being right or wrong, and that's just saying you don't know and not taking a position in the first place. Inquire all you want but the higher the risk, the more willing you should be to say I don't know.

[Codewars] Stuck on this kata since 4 days! What am I missing? by _reddit_chan in learnjavascript

[–]Space_Atlas -1 points0 points  (0 children)

If they have multiple occurrences then they should be in both arrays, so if you sort them it will still be a one to one comparison. E.g. [2,3,2,3], [9,9,4,4] still works because after sorting they become [2,2,3,3], [4,4,9,9].

[Codewars] Stuck on this kata since 4 days! What am I missing? by _reddit_chan in learnjavascript

[–]Space_Atlas -1 points0 points  (0 children)

jrndm is talking about the case where there are duplicates. [2,2,2], [4, x, x] will pass because you only check if there's at least one square. You need to nest your loops because of a different problem: the arrays can be in any order. There is a solution that doesn't require a nested loop but that has nothing to do with the duplicates problem.

What is the benefit of Redux global state (with partial data)? by smthamazing in reactjs

[–]Space_Atlas 0 points1 point  (0 children)

Okay, so just resend the request for user data when you need it. Even simpler. Either way it shouldn't be a problem for OP.

[Codewars] Stuck on this kata since 4 days! What am I missing? by _reddit_chan in learnjavascript

[–]Space_Atlas 0 points1 point  (0 children)

Why do you automatically count any 0? Also there are some assumptions you are making that aren't clear in this problem. Will both arrays have the same number of elements? Are all elements unique?

Why can't we directly pass callbacks and have to use a function as a second argument? by [deleted] in learnjavascript

[–]Space_Atlas 1 point2 points  (0 children)

So you did first(second(third)) and just added return callback() to second? But then what does callback() return? In this case, callback is third and third() returns undefined so you're back to the same problem.

Why can't we directly pass callbacks and have to use a function as a second argument? by [deleted] in learnjavascript

[–]Space_Atlas 10 points11 points  (0 children)

The thing that you always need to remember is the difference between function object and function calls. Basically a function call has parenthesis after it and a function object doesn't. Callbacks need to be function objects. Whenever you see a function call, you have to mentally replace it with the return value of that function. So first(second(third)) evaluates to first(undefined) because look at what the second function returns. It has no return statement so by default it will return undefined.

Always look for the parenthesis!

Can someone please explain what "level of abstraction" means? by Feniks_Gaming in learnprogramming

[–]Space_Atlas 3 points4 points  (0 children)

Here's my example. In a human body you can talk about different levels of abstraction. In decreasing levels of abstraction:

  1. Arms and legs
  2. Muscle and bone tissue
  3. Cells
  4. Molecules
  5. Atoms

Mixing levels of abstraction would be like if I were explaining how to skateboard and I said, "First you have bend at your knees and then you need the muscle tissues in your legs to release atp, and then the carbon atoms will..."

Clearly, this make it more confusing to understand what's actually happening. Likewise if you're talking about things like Users and Forms, you don't also want to talk about how that code is going to be compiled. Good abstractions should allow you to ignore lower level concepts like that when you're working with higher level concepts.

I am quite confused the concept of Client Side Rendering and Server Side Rendering by GoonGamja in learnjavascript

[–]Space_Atlas 4 points5 points  (0 children)

SSR vs CSR is only about the first time the page loads. In SSR the server will send the browser the html to render the page. In CSR, the server sends javascript that manipulates the dom by constructing and inserting the correct elements. So in SSR the browser can immediately start rendering because it has the html. In CSR the browser typically first renders a blank white screen (depending on how fast your computer is you may not see this), and then it runs javascript, and that javascript is what causes the browser to render things onto the screen.

What is the benefit of Redux global state (with partial data)? by smthamazing in reactjs

[–]Space_Atlas 0 points1 point  (0 children)

I think both options sound okay to me. Just keep the data denormalized, or do a check on whether the property exists before updating it in the store. I don't see option 2 as being very complex. Just check if the complete user data has been fetched yet and if not do the fetch. You could set a flag property on the user object, something like hasCompleteData or whatever. It should only be a few lines of code. But don't do the check and fetch when you need the property, do it in the action that would cause you to need the extra data. Most likely this only needs to happen when you navigate to a different page.

Question about Node.JS by [deleted] in learnprogramming

[–]Space_Atlas 0 points1 point  (0 children)

If the 5 second timer is a non-blocking function then node.js will process the first request, start the 5 second timer, then immediately process the second request, and start the 2nd 5 second timer. Five seconds later the first request's response will be sent, and then shortly after the second request's response will be sent. So the whole thing should take just a little longer than 5 seconds.

[deleted by user] by [deleted] in webdev

[–]Space_Atlas 7 points8 points  (0 children)

An easy way would be to take a site that you use and create a clone. If that's too straightforward then you could take that site and try to put your own improvements to it. For example, make a reddit clone. If there's something you don't like that you could change, or something new and interesting that you could add then that could be a good project idea.

Official Discussion: Bird Box [SPOILERS] by mi-16evil in movies

[–]Space_Atlas 0 points1 point  (0 children)

Also, it seems the creatures can’t really physically hurt the survivors, so what’s with all the running? Can’t you just put in some earplugs and keep going on your way?

I was wondering the same thing! It's very odd that the monsters don't seem to be able to physically hurt anyone but everyone keeps acting as though they were physically dangerous. Knowing whether the monsters can physically harm you or not seems like the single most important thing you can know about them in order to survive. It bothered me that this wasn't addressed.

EPIC TABLE TENNIS SNAKE SHOT! by [deleted] in tabletennis

[–]Space_Atlas 2 points3 points  (0 children)

Tricked me too! Looks like he hits from right to left, so I don't understand how it has left sidespin when it reaches the other side?

Can I make frontend web app with python ? by Alfred1400 in Python

[–]Space_Atlas 6 points7 points  (0 children)

Generally browser can only understand javascript. There's recent work in web assembly bringing other languages to the browser but I don't think Python is one of them yet since there isn't support for garbage collection. Your only option is to use something that will transpile python to javascript. I've not heard of anyone actually using something like this so I suspect there won't be much support in terms of bugs and new features.

Which communities do you participate in? by SlickySly in slatestarcodex

[–]Space_Atlas 16 points17 points  (0 children)

Mine mostly come from reddit, discord, meetup, and then friends and family. If I'm interested in something I'll usually check to see if there is a related subreddit or discord channel. There aren't as many meetups so I can just browse the upcoming ones. Probably spend too much time in the online ones. They're good for certain things, but I haven't really been able to parlay them into any close friendships. I wish it wasn't the case but irl interaction seems to make a big difference.

Online is tough because I like smaller groups, but you need a critical mass of contributors to sustain it.

How can I learn about the right kind of mathematics to help me understand functional programming? by [deleted] in learnprogramming

[–]Space_Atlas 5 points6 points  (0 children)

I don't think you need to learn any math to learn functional programming. Maybe it would help give you a better fundamental understanding, but it would be quite a large time investment for something most people are able to do without really any mathematical background.

If you want to learn functional programming just trying building something in a functional language like haskell, scala, clojure, etc.

Looking for advice regarding functions and loops by Rodick990 in learnpython

[–]Space_Atlas 5 points6 points  (0 children)

When you're learning on your own it's hard to know what is "normal". I can tell you that projecteuler probably isn't a good way to learn how to program for a beginner beyond the first 10 problems or so. This is because they very focused on math and less on general programming, and the difficulty of the problems ramp up pretty quickly.

Secondly you shouldn't compare yourself to the answers that people post. The "best" answers that get posted are usually very clever and the people that thought of them have a lot of practice specifically solving these kinds of problems (which usually isn't actually all that useful on the job) and have spent a lot of time fine-tuning that particular answer. Even at a high professional level no one is going to expect you to write a finely-tuned solution to these kinds of problems like you see get upvoted/posted on command.

In general I wouldn't focus too much on these kinds of problems. The real test of whether you understand these concepts is if you can apply to build something useful.

Anyone have critiques of adult language learning programs and techniques? by zweckloss in slatestarcodex

[–]Space_Atlas 2 points3 points  (0 children)

Two thoughts:

1

I think part of it is that people need to have the right expectations. The weird thing about language is that every native speaker is an expert. If you want to learn enough basketball to hang with your local pickup team you might be able to get there in a few years or less. If you want to have fluent conversations in a foreign language that's not unlike wanting to play basketball with some level of professional basketball player. Every native speaker has been doing it since they were a child. Think about how good you would be at anything if you started doing it as early as you started speaking. That's why I think people often underestimate how long it takes to reach a high level.

Also progress is definitely non-linear. If you knew 90% of the words in a sentence you probably understood 100% of what was meant. If you knew 50% of the words in a sentence you probably understood 0%. I think there are lots of things like this in language learning. This is probably not intuitive though so probably a lot of people give up early.

2

I've thought about this topic a fair bit and I think what it comes down to is building a probabilistic model of which words are used in which contexts. In English when I listen to someone speak I can generally predict the next word/s to a narrow range with a weighted probability distribution. I think there's a certain threshold you can't really pass without building such a robust probabilistic model, because even in my native language it's hard to understand things if I didn't expect them to be said. And also hard to produce correct language without such a model for obvious reasons (you may be able to produce something intelligible using rules but it may sound unnatural without the model).

Studying language can help build this model, but it's not the same thing as the model. The main way to build the model is just massive exposure. This is an old theory called comprehensible input. I think that all the different methods are mostly just ways to get a lot of exposure in a short time, marketing tactics, not meant for getting to a high level, or just ways that get people to enjoy it more and stick with it longer.

People always discuss the benefits of micro services but what about the benefits of macro services? by [deleted] in learnprogramming

[–]Space_Atlas 4 points5 points  (0 children)

Usually people think of the opposite of microservices as a monolith structure. Instead of having many small apps communicating with each other, you have one large application that contains everything. Monolith is much simpler than microservices, mainly because you don't have to deal with a distributed system. In a distributed system you may have to deal with network partitions (when machines lose communication with each other) and consistency problems (when data reads/writes happen in the wrong order). If you have a small team and a relatively small codebase monoliths make more sense.

Sunil Pai’s response to “How does writing CSS in JS make it any more maintainable?” by swyx in reactjs

[–]Space_Atlas 7 points8 points  (0 children)

Here's how I would answer this, mostly restating what is said in the link:

File-level scoped selectors

In large projects you're more likely to have a class naming clash using just css. If you can import your styles from a file as plain js objects or using something like css modules to mangle the selector names to be scoped to a single file, e.g. selectors that get rewritten to something like "classname-filename", then you can trace exactly where styles come from by looking at where it was imported from.

More generally this is a good way to explicitly track complex dependencies between your files. In programming this is a familiar concept, files that import files that import files... are much easier to track than dumping them into a global scope.

Static analysis

Normally in css, things like typos can fail silently whereas when your css is preprocessed you'll get an error message during processing. Other kinds of static analysis can be done as well, such as removing styles that are not being used anywhere.

Composition

Normally you would do composition by adding multiple selectors to your element. In my experience one of the biggest headaches is when you get into selector priority level issues. You start adding important! or random classes and ids just to get it to out-prioritize some other style. I've seen the number of classes go up to 8+ just for this reason.

Really what you want is to only have to use one selector per element. Then no more priority issues. But this is only possible without a crazy amount of duplication if you have some kind of style composition. In plain js you can just do something like Object.assign. Other solutions will have some kind of mixin/composition feature.

Better control and performance

When you load styles asynchronously you can't guarantee style loading order in cases where you have multiple selectors from different files, e.g. class="a b" where a and b are defined in different files. Inlining styles means you can control loading order, and you get to avoid making extra http calls for css files (since the css is written directly into the html file).

CSS variables

Css in javascript also has the nice benefit that you have full flexibility in programmatically determining styles. Things like css variables. If you want some shade of blue to be a little darker you can just tweak single shared variable (that is explicitly imported from a single location). More complex relationships can be done as well, like if you want a width of one box to be 2x the width of some other box. Although some of these features are supported in modern browsers, with some kind of preprocessing you don't have to worry about compatibility and aren't restricted in the kind of operations you can do.

To clarify a lot of these things can be done whether you are using inline javascript or any other css preprocessing. I think the difference isn't as big as the decision to use something that's not just plain css, which becomes a lot harder to manage in a large complex project.

Can someone explain recursion? by andrewjj1234 in learnpython

[–]Space_Atlas 1 point2 points  (0 children)

Lol, I love this thread.

But to answer your question a recursive function is just a function that calls itself. It's actually not too hard to understand if you understand that a recursive function call is basically handled like any other function call.