[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
4Archive logo
The only reason why relatively few people...
If images are not shown try to refresh the page. If you like this website, please disable any AdBlock software!

You are currently reading a thread in /g/ - Technology

Thread replies: 48
Thread images: 4
File: file.png (45 KB, 1052x1052) Image search: [iqdb] [SauceNao] [Google]
file.png
45 KB, 1052x1052
The only reason why relatively few people can program is because it isn't well explained.

Explain the in-for loop to an beginner to prove me wrong.
>>
>>52375147
Its a for-in loop you twat
>>
>>52375147
the reason people cant program is because they dont actually learn how to program. that requires problem solving skills that you would learn through algorithms, discrete math, etc

instead, people are taught semantics and syntax. the languages they learn are so abstracted and high level that everything is already done for them and its basically a front end API for the inexperienced.

there is nothing inherently wrong with that because being able to build programs rapidly is pretty fucking awesome....but when you have no programming foundation? you just contribute to the stereotype that web developers are garbage programmers.
>>
>>52375147
i don't see why this is a problem
>>
>>52375263
as someone with a CS background that's currently doing webdev, this is pretty much correct
>>
>>52375147
In Javascript,
for(property in object)
sets
property
to each key in object and executes the following statement or block of code in the same fashion as other for or while loops.

Example:
var fruits = {
"apples": "red",
"bananas": "yellow",
"cherries": "red"
};
var fruit;
for(fruit in fruits) {
if(fruits.hasOwnProperty(fruit)) {
console.log(fruit + " are " + fruits[fruit]);
}
}


would produce:

apples are red
bananas are yellow
cherries are red


The
hasOwnProperty
call is necessary because Javascript is a terrible language.
>>
>>52375147
I'm halfway convinced that most of the documentation for the vast majority of libraries are written specifically to be difficult to make sense of for people who aren't used to their conventions. There's always been a silly sekrit klub atmosphere with these things, where you have to "prove yourself" by passing arbitrary tests that are less about logical aptitude and more about cultural pruning, i.e., no women or niggers, and only a few chinks and fags.

I'm not sure what else explains it taking two years of lurking /g/ and other places before I could trick an anon into thinking I was a white dude, at which point he let slip the cognitive silver bullet that makes this shit easy for anyone with my natural skill with math. Which makes sense. Language always has a bullshit cultural component that muddies the waters and makes an outsider with a perfectly sound thought process look like Radio.
>>
>>52375544
same, as someone who wants a good programming job i'm cool with there being a shortage of programmers
>>
>>52375639
yeah, it's pretty much the same as

Object.getOwnPropertyNames(someObj).forEach(function(propertyName){
console.log(someObj[propertyName]);
});
>>
>>52375263
Nailed it
>>
>>52375641
Put it back Jamal
>>
>>52375147
Can't find the damn comic but you're doing the Linux forum "angrily say X is impossible so people will prove you wrong by demonstrating exactly how to do X" thing
>>
>>52375641
I agree.
>>
>>52375689
Except not, because you get non-own properties in for...in. Hence the additional check in the post you replied to.
>>
>>52375641
>the documentation for the vast majority of libraries are written specifically to be difficult to make sense of for people who aren't used to their conventions
No, they're written to be EASY to make sense of for people who DO know the conventions. Library docs are reference material for people who already have some idea what they want / what the library does, they're not a tutorial.

>I'm not sure what else explains it taking two years of lurking /g/ and other places before I could trick an anon into thinking I was a white dude, at which point he let slip the cognitive silver bullet that makes this shit easy for anyone with my natural skill with math.
Haha what the fuck. Are you really telling me
>it took you two years to convince people you were white, on 4chan of all places, where people will assume you're white unless you explicitly say otherwise
>you think people need to be taught a particular secret code ("silver bullet"), without which nobody is capable of understanding programming
>the only reason you can program at all is because some random asshole on a chinese cartoon imageboard posted the secret code
Have I got all that about right?
>>
>>52375147
The biggest problem is that programming logic differs from instinctual human logic. A for-in loop is extremely simple in principle, but that's the problem: humans with average or above mental capability don't think in terms that simple. Our minds excel at making judgements based on shitloads of inputs but actually aren't that great at low-input, ultra-repetitive, ultra-simple logic (which is practically the definition of a for-in loop).

Thinking in programming logic is a skill that has to be taught, and some us are better equipped to pick it up quickly and apply it well than others are. Simple as that.
>>
>>52375147
(I'm assuming Javascript's for-in loops work like Python [for x in array:] and that the user already knows what an array is)

You know that arrays are objects that hold many different objects. Each of these sub-objects, or 'elements', has an order in the array. Essentially, think of it like a list of objects.

Say you are in a store and you have an array of grocery items: milk, bread, and eggs. You want to place each item into your cart. How would you go about doing that?

The answer is the for-in loop. It's a statement that says "For each element in this array, do this action." In this case, the elements would be the items in the grocery list, your array.

Such a loop would look something like this: (I think. I'm not a JavaScript expert, but that's not really the point here.)

var groceries = ["milk", "bread", "eggs"];
var cart = [];

for item in groceries {
cart.append(item);
}
console.log(cart);


If you run this code and check the console, you should see that it contains exactly what 'list' contains, in order.

...

It ain't hard, really. It's just that people are too worried about making fancy new things to bother documenting them properly.
>>
>>52375147
i think a major reason that relatively few people can program is that out of any whole population, only a small proportion of people would actually consider it to be appealing.
while being extremely accessible compared to a few decades ago, it's still relatively niche, likely due to a combination of both a lack of exposure and disparity between concepts pushed by academic establishments and both what programming practically is and can, as a skill, be used to produce.
i really think it's more-so due to a conflict of interest rather than an inherent lack of ability in some area like many people seem to suggest, however, naturally, those with intrinsic technical interests are far more likely to be able to grasp core concepts more easily than those without.
most of all, i think the stern face that a majority of large communities seem to wear is off-putting for newcomers, by obscuring possibilities with needless complexity. i'm not suggesting that programming should be easy, i just believe that people could potentially be better educated in order to nullify unrealistic, childish expectations (which youtube video "tutorials", and the like harbour), and that what is accessible to them could also be more immediately apparent.
who fucking cares though. there'll always be various retards who exist to breed misinformation, likely due to computing being one of the most accessible scientific fields, which will inevitably both drive away numerous potential programmers, but also attract an exponentially greater number of retards in doing so.
>>
>>52376183
>that mud blood syntax

though you're right, except for using it with an array. for loop would make more sense in that case.
>>
>>52376097
The expand on this, think of how a non-programmer would approach common programming tasks vs how we approach them.

For example, let's imagine the problem of finding the words in an array of words that begin with the letter "d". A programmer could come up with any number of solutions, but in the end each solution will involve explicitly looking at each word at least once. A non-programmer's solution would probably be something along the lines of "look at the list of words and write the ones that begin with 'd'," because human brains don't do *anything* with a serial queue of singular actions. Instead, our brains take massive swaths of data and process it all at once in a massively parallel manner in such a way that the simpler individual tasks get grouped into tightly-bundled batches.
>>
>>52376183
>I'm assuming Javascript's for-in loops work like Python [for x in array:]
Ha ha ha I fuckin wish. Remember we're talking about a language that was literally designed and implemented in two weeks by a summer intern.
>>
>>52376284
TLDR we're spoiled by our own brains and most don't realize just how stupid computers are or how stupidly far programmers have to break problems down for computers to be able to understand them.
>>
>>52376183
Actually, the idiomatic way to do it in javascript is:
let groceries = ['milk', 'bread', 'eggs'];

let cart = groceries.reduce((list, item) => list.push(item), []);


See? Isn't javascript easy?
>>
>>52376609
Won't work, `push` doesn't return the array
>>
>>52376685
>>52376685
Shit, you're right. Here's my new and improved code:
const groceries = ['milk', 'bread', 'eggs'];
let cart = groceries.slice(0);

The readability of javascript is a wonder to behold.
>>
>JavaScript "programmers".
Every single one of you are mentally retarded, not figuratively but literally.
>>
File: WUT.jpg (1 MB, 4457x3950) Image search: [iqdb] [SauceNao] [Google]
WUT.jpg
1 MB, 4457x3950
>>52376750
You just clobbered the cart mate. What about my previous items?
>>
>>52376771
>not having the intelligence/discipline to write good javascript
>>
>>52376826
I have the intelligence/discipline and experience, that's why I choose not to use javascript. The only situation where a better option isn't available is possibly a web browser, but typescript exists so I don't think its a good choice there either.
>>
>>52376822
There were no previous items. I was just cloning groceries into a new array and pointing out how silly javascript is. If you want, I can assume we might have already defined a cart somewhere else and are merely adding to it.
const groceries = ['milk', 'bread', 'eggs'];

let cart = cart || []; // fuck you

cart = cart.concat(groceries);


I think if you want anything more though, we're going to have to import jQuery.
>>
>>52375263
late night /g/ is the best /g/
>>
>>52376921
>typescript
>a crappy language that compiles to another crappy language
Yeah, have fun debugging that one, champ. Have you even used typescript? If you're going to go with a transpiled language for javascript, at least have the decency to use elm.
>>
>>52376966
What's wrong with Typescript? Seems like a fine choice if you already know Javascript and just want that, but less shitty.
>>
>>52376987
It is this >>52376966 guy is just a whining javascript baby, because typescript is better than javascript, even though both are shit.
>>
>>52376023
>No, they're written to be EASY to make sense of for people who DO know the conventions.
That's not mutually exclusive with what I said.
>Library docs are reference material for people who already have some idea what they want / what the library does, they're not a tutorial.
So where exactly do you go to learn what you should be looking for?

>it took you two years to convince people you were white, on 4chan of all places, where people will assume you're white unless you explicitly say otherwise
Yeah nigga something just gives it away every time namean?
>you think people need to be taught a particular secret code ("silver bullet"), without which nobody is capable of understanding programming
No, it was something about compartmentalizing and logical flow and it just clicked for me. I don't remember exactly what he said, but the way he put it was exactly what I needed to hear to bridge the gap between my personal understanding and the conventions of the tools I was working with.
>the only reason you can program at all is because some random asshole on a chinese cartoon imageboard posted the secret code
Yes. Communicating with people results in profound insight that one's personal musing rarely hits upon alone. This is surprising only to the lonely.

>>52375785
>Agreement
>Post ending in a five
Rolling for a commensurate 5. Preferably high.
>>
>>52376987
There's nothing inherently wrong with TypeScript. It's just like putting a bandaid on a corpse though. It's not a significant enough improvement to justify the added annoyance of having to debug in two different languages.
>>
Why haven't any web engine makers tried providing a native DOM-integrated Lua, Python, or Ruby environment as an alternative to JavaScript? There's no law that decrees that JS has to be the only language for front end web development. All it would really take is for one of the heavy hitters (Mozilla, Google, Apple) to provide a JS alternative. I'm sure there'd be droves of devs flocking to it, much the to the dismay or ardent JSfags.

Yes, I know there are X-to-JS transpilers. They're shit and the web is a shit platform for being so restricted.
>>
>>52375263
I'm third year in CS degree and really you're right. I'm trying to figure out something to select squares in a grid and it's just not happening. Wish I didn't pick a meme degree
>>
>>52377101
It's not that easy. If one of them do it, they all have to do it, otherwise no one will develop for it. And how do they decide on what language to implement? They're making web assembly which will be a much better target for transpiled languages, but that's still a ways off.

For better or worse(so for worse), we're stuck with JS for now.
>>
>>52375639
What if I give it more properties?
>>
>>52377141
Disgusting. Until we have a real language to do front end work with I'm going to keep the bulk of functionality on the server end on my web projects. Users will likely be thankful for not having 50MB of scripts shoved down their throats anyway so I guess it works out.
>>
>>52376609

just because JS can be used as a FPL, doesn't mean it has to be. I feel like I am seeing this shit more and more, just so haskell nerds can stroke their map/filter/reduce e-peens.

(I know you were being facetious)
>>
10.times do
puts "ur a faget"
end
>>
>>52377169
I agree, but the ideas of functional programming are pretty important for JavaScript because of all the async bullshit. I use FP because I'm not smart enough to write OOP that doesn't fall apart when you get an idiot user clicking on a bunch of different shit at once.
>>
>>52377052
>So where exactly do you go to learn what you should be looking for?
Usually libraries ship with example program or have some kind of example code that shows how to use that library. Most likely it does not cover everything but it should get you to a good start.
>>
>>52377177
> 8/10
>>
File: 1452124863352.gif (908 KB, 500x394) Image search: [iqdb] [SauceNao] [Google]
1452124863352.gif
908 KB, 500x394
>>52377177
>Ruby

It's not 2010 anymore
>>
>>52375263
I am a garbage programmer and I want to become a Web developer
Thread replies: 48
Thread images: 4
Thread DB ID: 423832



[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.
If a post contains personal/copyrighted/illegal content, then use the post's [Report] link! If a post is not removed within 24h contact me at [email protected] with the post's information.