Click here to Skip to main content
15,901,666 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: You Know What I Hate? Pin
RJOberg4-Dec-17 4:33
professionalRJOberg4-Dec-17 4:33 
GeneralRe: You Know What I Hate? Pin
Jacquers4-Dec-17 6:19
Jacquers4-Dec-17 6:19 
GeneralKids Coding... Pin
Kornfeld Eliyahu Peter3-Dec-17 20:01
professionalKornfeld Eliyahu Peter3-Dec-17 20:01 
GeneralRe: Kids Coding... Pin
the goat in your machine3-Dec-17 21:31
the goat in your machine3-Dec-17 21:31 
GeneralRe: Kids Coding... Pin
dbrenth4-Dec-17 10:23
dbrenth4-Dec-17 10:23 
GeneralAwesome Pin
Brisingr Aerowing3-Dec-17 18:36
professionalBrisingr Aerowing3-Dec-17 18:36 
NewsExplaining JavaScript and this to people. PinPopular
Jeremy Falcon3-Dec-17 10:31
professionalJeremy Falcon3-Dec-17 10:31 
GeneralRe: Explaining JavaScript and this to people. PinPopular
Marc Clifton3-Dec-17 13:38
mvaMarc Clifton3-Dec-17 13:38 
I think Javascript is such a PITA to learn because:

1) my bias to what I expect. I experience this with Python as well. Anything from differently named functions for string manipulation to the whole abortion called the DOM.

2) too many strings. $("#foo")

3) too many things hard to type. Shift-$. Shift paren. Shift quote. Shift pound. Unshift. The rest of the identifier. Shift quote. Shift close parent. Unshift. Dot. etc...

4) string function name or function or property? $("#foo").val(); vs. event.args.innerText vs. (jqxWidgets example) $("#menu").jqxMenu("close");

5) Standards hell: For example, single quote or double quote: $("#menu").jqxMenu('close');

6) Insane (or is that inane) document traversal:
var parentItemText = $($($("#projectTree1").jqxTree('getSelectedItem').parentElement).children("div")[1]).text();

7) Closure madness (ok, once you get familiar with the syntax, yeah, it makes sense):
myLayout.registerComponent('Output', function (container, componentState) {
  container.getElement().html($("#buildOutputContainer").html().replace("buildOutput", "buildOutput1"));
  container.on("resize", (function (c) {
    var ct = c;
    return function () {
      $("#buildOutput1").jqxTextArea({ width: ct.width + "px", height: ct.height + "px" });
    };
  })(container));
});

8) div hell. OK, not related to Javascript

9) framework hell. Too many, too complicated, too annoying, too idiocentric.

10) Untestable. Except by trying it manually. Yeah, I've tried a variety of test frameworks, even tried writing my own. They all suck.

Should I go on?

These are all barriers to:

1) Really grocking Javascript. For example, I just discovered this cool way to eliminate the stupidity of all these strings for acquiring elements by ID or "class" name:
id = new Proxy({},
  {
    get: function (target, prop) {
      return function () { return $("#" + prop); };
  }
});

Usage: id.menubar().jqxMenu({ width: 600, height: 30 }); instead of this crap: $("#menubar").jqxMenu({ width: 600, height: 30 });

Should I do that or not? Performance penalty vs. readability? Is it more readable? Will it confuse someone who has to maintain the code.

Versus, say, a server-side replacement like !menubar.jqxMenu...

Yet again another kludge that requires that you know something totally outside of pure Javascript to understand what the Javascript is doing.

2) (barriers, remember?) Not just copying and pasting all over the place. I have to force myself to create general purpose methods, even one liners, because they improve readability, but require a ton of typing to get there. Example:
function getSelectedListBoxId(listBoxName) {
    return $('#' + listBoxName).jqxListBox('getSelectedItem').value;
}

function getProjectId() {
    return getSelectedListBoxId("lbProjects");
}

Why do I do this? So I can have a nice function named "getProjectId" that tells me exactly what is going on, without passing in a string and without writing the abortion that looks like this:
$('#lbProjects').jqxListBox('getSelectedItem').value;

and doesn't tell me squat about the fact that "value" is actually the ID of the item in the list box.

And since I do this for a bunch of listboxes on the page, hence the first function which is more abstract.

etc.

I hope you enjoyed this post!
Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages

Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

Artificial intelligence is the only remedy for natural stupidity. - CDP1802


modified 3-Dec-17 19:47pm.

GeneralRe: Explaining JavaScript and this to people. Pin
the goat in your machine3-Dec-17 14:45
the goat in your machine3-Dec-17 14:45 
JokeRe: Explaining JavaScript and this to people. Pin
Jeremy Falcon3-Dec-17 15:03
professionalJeremy Falcon3-Dec-17 15:03 
GeneralRe: Explaining JavaScript and this to people. Pin
the goat in your machine3-Dec-17 15:34
the goat in your machine3-Dec-17 15:34 
GeneralRe: Explaining JavaScript and this to people. Pin
Jeremy Falcon3-Dec-17 15:35
professionalJeremy Falcon3-Dec-17 15:35 
GeneralRe: Explaining JavaScript and this to people. Pin
Marc Clifton4-Dec-17 5:11
mvaMarc Clifton4-Dec-17 5:11 
GeneralRe: Explaining JavaScript and this to people. Pin
Jeremy Falcon4-Dec-17 5:54
professionalJeremy Falcon4-Dec-17 5:54 
GeneralRe: Explaining JavaScript and this to people. Pin
Jeremy Falcon3-Dec-17 15:02
professionalJeremy Falcon3-Dec-17 15:02 
GeneralRe: Explaining JavaScript and this to people. Pin
Rob Grainger4-Dec-17 1:38
Rob Grainger4-Dec-17 1:38 
GeneralRe: Explaining JavaScript and this to people. Pin
Jeremy Falcon4-Dec-17 4:26
professionalJeremy Falcon4-Dec-17 4:26 
GeneralRe: Explaining JavaScript and this to people. Pin
Marc Clifton4-Dec-17 5:19
mvaMarc Clifton4-Dec-17 5:19 
GeneralRe: Explaining JavaScript and this to people. Pin
Jeremy Falcon4-Dec-17 6:05
professionalJeremy Falcon4-Dec-17 6:05 
GeneralRe: Explaining JavaScript and this to people. Pin
Marc Clifton4-Dec-17 11:08
mvaMarc Clifton4-Dec-17 11:08 
GeneralRe: Explaining JavaScript and this to people. Pin
Jeremy Falcon4-Dec-17 12:11
professionalJeremy Falcon4-Dec-17 12:11 
GeneralRe: Hey check this out... Pin
Jeremy Falcon3-Dec-17 15:27
professionalJeremy Falcon3-Dec-17 15:27 
GeneralRe: Hey check this out... Pin
Chris Maunder3-Dec-17 15:43
cofounderChris Maunder3-Dec-17 15:43 
GeneralRe: Hey check this out... Pin
Jeremy Falcon3-Dec-17 16:02
professionalJeremy Falcon3-Dec-17 16:02 
GeneralRe: Hey check this out... Pin
Marc Clifton4-Dec-17 5:22
mvaMarc Clifton4-Dec-17 5:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.