|
Personally, I find having two acceptable string delimiters useful. If you're building a string that needs to contain double-quotes, you can use single-quotes to delimit it, and vice versa - avoiding having to use an escape sequence in many cases, and improving readability.
My gripes with JavaScript are many - but this isn't one of them. Douglas Crockford enumerated them well: Bad Parts: Appendix B - JavaScript: The Good Parts - O'Reilly Media[^]
Some of these are remedied in ES6, as detailed here (5 JavaScript “Bad” Parts That Are Fixed In ES6 – freeCodeCamp[^]), but not all mainstream browsers support all of these yet.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
I totally agree with you there man.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: Clearly, you're looking at code written by a 5 year old that doesn't know anything about CSS selectors or jQuery.
You're off by 50 years. And this is exactly why Javascript is so hard to learn. There are no (and no good) resources for how to do things other than SO, CP, and dubious forums by 3rd party vendors. Why? Because who the heck is going to write a book on how to do X when, given the multi-dimensional landscape of web development, describing where X is in this trans-dimensional space is pretty much impossible.
Granted, all my examples are related to using jQuery and 3rd party frameworks, but it's impossible to disentangle Javascript from those things when doing web development.
Jeremy Falcon wrote: but the whole $($($($($('#omg'))))) thing can be avoided.
Beats me how to do it. The content of the tree (a jqxwidget) is programatically generated and I haven't figured out a simpler way of getting the text (not to mention the freaking ID) of the parent for a selected node. One option is to represent the tree as a Javascript structure, this would be simple enough to map ID's in the structure to the DOM that jqwidgets creates. And heaven help me if I have to learn one of the Angular/React/etc/ frameworks that jqwidgets claims to support. More obfuscation on top of nebulous indirection.
Yup -- I'm an old fart.
|
|
|
|
|
Marc Clifton wrote: You're off by 50 years. And this is exactly why Javascript is so hard to learn. There are no (and no good) resources for how to do things other than SO, CP, and dubious forums by 3rd party vendors. Why? Because who the heck is going to write a book on how to do X when, given the multi-dimensional landscape of web development, describing where X is in this trans-dimensional space is pretty much impossible. You're absolutely right about that. One of the pain points I have with React learning is simply finding good resources on it. And to top it off, once you find one, it's out-of-date. And to top it off even more, it's not exactly places teach you production ready stuff. It's a royal PITA. The web really is a hodgepodge of kiddie playground crap where nobody wants to agree on anything. About the only reason I was able to even start making any sense of all this crap was a couple years back I pestered a coworker of mine for literally like a year asking him tons of questions.
Marc Clifton wrote: Granted, all my examples are related to using jQuery and 3rd party frameworks, but it's impossible to disentangle Javascript from those things when doing web development. Yeah totally. It is getting better at least, but the web is slow to migrate to new stuff. Being so popular and all there's a lot of existing crap to change before we make way for the new crap. And of course, by that time the new crap will be out-dated.
Marc Clifton wrote: The content of the tree (a jqxwidget) is programatically generated and I haven't figured out a simpler way of getting the text (not to mention the freaking ID) of the parent for a selected node. Having never used that lib, you'd think they'd expose that somehow. Go figure.
Marc Clifton wrote: And heaven help me if I have to learn one of the Angular/React/etc/ frameworks that jqwidgets claims to support. More obfuscation on top of nebulous indirection. But... but... React!
Marc Clifton wrote: Yup -- I'm an old fart. At least you can laugh about it. You reach an age where it's ok to laugh at stuff. That's called maturity. And I'd say I'm 39 so I understand, but I'm sure you'd call me a youngin'.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: You reach an age where it's ok to laugh at stuff.
Yeah, works well with one's partner too.
At the end of the day, I end up treating these technologies like everything else, even C#/.NET:
1) Figure out how to do stuff the hard way
2) Look at how to make it easier and learn from others
3) Create a toolbox that mitigates some of the pain points
4) Liberally sprinkle code with // TODO: Kludge! and // TODO: There has to be a better way!
|
|
|
|
|
Marc Clifton wrote: Liberally sprinkle code with // TODO: Kludge! and // TODO: There has to be a better way! I do the same thing too.
Jeremy Falcon
|
|
|
|
|
Just to give you an idea of where the web is headed, here is some ES2015 code...
import React from 'react';
import {Link} from 'react-router';
class Layout extends React.Component {
static propTypes = {
children: PropTypes.object.isRequired
};
render() {
return (
<div className="container-fluid">
<p>header here and all</p>
{this.props.children}
</div>
);
}
};
export default Layout; Btw, that's not HTML inside the render method. It's just syntactic sugar to look like it. It gets transpiled down to JavaScript. But the only strings you'll see here are in the imports (which isn't much different than C/C++ includes) and the properties that will be spit out to the browser such as "container-fluid". Well, there is the literal there too, but none of the $($($($('omg')))) stuff.
Now, I'm not saying everything is perfect with the web. But new-skool web development (especially as WASM gets more popular) is nothing like old-skool web development.
Jeremy Falcon
|
|
|
|
|
(and now I feel guilty about not finishing up the React colourising definitions...)
cheers
Chris Maunder
|
|
|
|
|
Muwahahahahahah. Then my work here is done.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: ust to give you an idea of where the web is headed,
Could you provide a translation? That is all but unintelligible.
I have two reactions. I'm sure I can learn this, and maybe even like it. On the other hand, I really don't want to.
|
|
|
|
|
Marc Clifton wrote: On the other hand, I really don't want to. I know what you mean man. I'm very selective about the tech I learn these days too. There's more to life than just tech ya know.
Marc Clifton wrote: Could you provide a translation? That is all but unintelligible. Um, in English that means as the web grows up, it's trying more and more to be like real programming environments. How's that?
Jeremy Falcon
|
|
|
|
|
I enjoyed it! Virtually all of your complaints are about jQuery. I don't use jQuery
|
|
|
|
|
I got a chuckle out of that as well.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I think you're conflating JS with web programming. Lets not forget NodeJS baby!
1. While the DOM technically is part of JS, it's only in the context of web programming.
2-7. These were all JQuery, which is not the same as Javascript. I know I speak on behalf of many a JS purist when I say JQuery can die in a hole.
8. Well you already answerd this one.
9. Agreed, frameworks are dumb. But blaming JS for frameworks is like blaming Tim Berners Lee for 4Chan.
10. I don't really have an argument for this one. Obviously I use JS but I've been doing it for so long that *humble brag* I generally don't write code that doesn't work. My IDE tells me when I make a typo though...
TBH it seems to me that you have more of a problem with Jquery. And if this is the case, I think we are in furious agreement.
|
|
|
|
|
grolarbear wrote: I think you're conflating JS with web programming.
How can Javascript be separated from web development?
grolarbear wrote: Lets not forget NodeJS baby!
Yeah. Right. I will never write anything in NodeJS. It's absurd to me to even consider using Javascript for back-end development. Actually it's absurd to me to even consider using Javascript for anything, but there's little choice in that for web development. I do have a choice in server-side stuff.
grolarbear wrote: These were all JQuery
True. I was realizing that when writing the post. But even if you want jQuery to die in a hole, it's seems so standard (it's pretty hard to find examples that don't use jQuery, particularly examples of 3rd party libs by those very same 3rd parties) and so is again, for web development, entangled.
|
|
|
|
|
|
Beats me. I haven't touched Perl in a loooong time. You're on your own.
Jeremy Falcon
|
|
|
|
|
Now explain closures and you'll have everyone halfway there.
And of course the obligatory WAT video whenever Javascript weirdness is raised.
Wat[^]
cheers
Chris Maunder
|
|
|
|
|
Chris Maunder wrote: Now explain closures and you'll have everyone halfway there. You'll hear 40 million different definitions online about that. And most of them try to sound smart, but put simply it's a function within a function. People will try to tack on crap with scoping etc. to that definition when "explaining" it, but that's irrelevant to the core concept of it IMO.
Chris Maunder wrote: And of course the obligatory WAT video whenever Javascript weirdness is raised. Ok, that dude is hilarious.
I have no idea why the object stuff in JavaScript turned out the way it did, but I can at least explain the 'wat' + 1 thing. The plus sign is used for string concatenation and arithmetic. The minus sign isn't. So in the former example, the interpreter assumes you're trying to concatenate using the most compatible types between the two operands, which is usually a string. The minus sign only only used for arithmetic and so it's NaN.
Jeremy Falcon
|
|
|
|
|
|
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: I have no idea why the object stuff in JavaScript turned out the way it did .
Because Mozilla were insane enough to give a dev just 2 weeks to write a language. It's amazing it works at all.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
You have a good point.
Jeremy Falcon
|
|
|
|
|
Javascript has become a powerful language. With this comes responsibility
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Wisdom you speak. Wisdom you speak...
Jeremy Falcon
|
|
|
|