|
I'm not so sure, could be witchcraft
Signature ready for installation. Please Reboot now.
|
|
|
|
|
They should make it more interesting. Instead of a thumb drive, select a politician. And tattoo them, or laser inscribe them, with all the names sent in! Selecting the politician is left for the soap box, though!
|
|
|
|
|
David O'Neil wrote: Selecting the politician is left for the soap box
Why bother selecting just one? Send them all!
Ad astra - both ways!
|
|
|
|
|
No but I've got an ex I'll donate.
Everyone has a photographic memory; some just don't have film. Steven Wright
|
|
|
|
|
Obligatory Names Song
Their Names Escape Me.wmv - YouTube[^]
My name's not in there, but only 'cause I didn't know about it until after the fact.
"Go forth into the source" - Neal Morse
|
|
|
|
|
I actually sent my name to the Sun. Now the Oracle retains it.
|
|
|
|
|
No need - I have a Facebook account, my name is everywhere.
|
|
|
|
|
So Javascript is actually pretty cool. Queue "Join the dark side, Marc".
Working with arrays and dictionaries is really easy, particularly with functions like map, reduce, and Object.entries. I still have to give our own Sander's Javascript LINQ a whirl, but for now I haven't needed it yet.
set/get is incredibly useful.
this and bind is someone's idea of hell, but once you figure it out, it works.
Being able to pass functions as parameters is incredibly useful, and creating partial functions is also really useful.
partialOnDrag(anchors, anchorElement, onDrag) {
return (function (anchors, anchorElement, onDrag) {
return function (dx, dy) { onDrag(anchors, anchorElement, dx, dy); }
})(anchors, anchorElement, onDrag);
}
It let's you get away with murder. Good grief, I can create/assign a class' function to a completely different function with "=". Well, functions are functions!
It drives me nuts (as with any scripted language) to have to figure out if I wrote the code correctly by actually running it. Things like typos, forgotten this. and other stupid mistakes a compiler would catch. I need to explore some Lint apps.
Dealing with attributes, which are strings, when you want them as numbers to do math on. Ugh. And crazy workarounds, like +"1" is actually the number 1.
Classes are cool, but then there's the "class-like" hack of creating an object with key-value pairs where the key is the function "name" and the value is the function. Is that old school?
var vs. let . Riiight. That was useful to know about.
I haven't even touched what looks like the cesspool of prototype . Probably something I should learn.
But overall, I'm actually starting to get comfortable with what I'm doing. Meaning that I'm actually starting to spend more time debugging my code logic than debugging my stupid syntax mistakes or quirky Javascript behaviors.
Anyways, just thought you'd like all like to know what I've been learning writing my next article on dynamic SVG and creating a bare-bones diagramming app.
Latest Article - Contextual Data Explorer
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
|
|
|
|
|
Question #1: Who are you, and what have you done with our Marc Clifton?
Question #2: Why didn't you bring enough to share, dude?
Software Zen: delete this;
|
|
|
|
|
Subject: Javascript
Marc Clifton pulls pin, rolls grenade into forum...
With just one simple word.
|
|
|
|
|
JavaScript can be pretty neat, but with lots of rough edges.
> Classes are cool, but then there's the "class-like" hack of creating an object with key-value pairs where the key is the function "name" and the value is the function. Is that old school?
That's one old school way to do it, but it's not quite equivalent. Creating an object where the function names are the keys in the key value pairs is equivalent to creating a class with nothing but static methods in C#. Of course, using ES2017+ syntax, you can just create static functions in your JS class.
So something like this:
const AnObject {
aFunction: function() {
console.log("hi");
}
}
ends up being exactly the same as
class AClass {
static aFunction() {
console.log("hi");
}
}
The old school equivalent to a class declaration would look like this:
function MyClass(abc) {
this.abc = abc;
}
MyClass.prototype.printAbc = function() {
console.log(abc);
}
Which ends up doing the same as:
class MyClass {
constructor(abc) {
this.abc = abc;
}
printAbc() {
console.log(abc);
}
}
In either case, the following code will have exactly the same result:
let something = new MyClass();
something.printAbc();
The class syntax is mostly just syntactic sugar; at the end of the day, the JavaScript runtime ends up doing what's shown in the first example, i.e. creating a constructor function and then adding the class's methods to the constructor function's prototype.
Understanding protytypes is pretty useful. Understanding them means you understand how the entire JS class system works. And fortunately, protytypes aren't that big a cesspool if you've got a good teacher. Probably the best resource on the topic (even though it's quite old now) is JavaScript: The Good Parts. It's an easy read, and enjoyable because the author is a bit of a grump and isn't shy about noting the bad parts of JS along with the good ones.
The book predates some of the newer syntax, like let, const, and even class. But if you keep in mind that the class syntax is really just using prototypes under the hood, then almost everything in the book will be very relevant to what you're doing now.
One thing the book won't cover is Promises, along with how the new async/await that simplifies using Promises. Its very, very similar to how the async/await syntax in C# makes it easy to work with Tasks.
|
|
|
|
|
That was a fantastic write-up!
Latest Article - Contextual Data Explorer
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
|
|
|
|
|
Next to the book of Douglas Crockford, I would also recommend the videos on youtube "Crockford on Javascript". It is fun to watch and gives a good insight where Javascript comes from.
If on the otherhand you want a compiler, please do evaluate typescript. It is a language which is strongly typed and compiles to Javascript.
Have fun with Javascript.
|
|
|
|
|
I spend 2 years on a project using Typescript (from 0.8.xx to 2.x) along with JavaScript. At the end, on new projects, I went back to pure JS. I felt like the static type in TS is getting in the way and hinder me from what I want to do sometime. It reminded me back when I was coding using Assembler and C for kernel development. Man I feel old.
|
|
|
|
|
What did you drink Mr.Clifton ?
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
|
You may as well just change over to VB at this point, and be done with it. Hippie.
Typeless languages are for people that lack the mental fortitude to work within strongly-typed constraints.
I bet you drink coffee at Starbucks, instead of out of a boot, or a rusty can (like real men).
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 22-Mar-18 14:48pm.
|
|
|
|
|
John Simmons / outlaw programmer wrote: I bet you drink coffee at Starbucks, instead of out of a boot, or a rusty can (like real men).
Even worse, I drink tea, not coffee! Earl Grey at that!
Latest Article - Contextual Data Explorer
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
|
|
|
|
|
Marc Clifton wrote: Even worse, I drink tea, not coffee! Earl Grey at that!
BAH!
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Let me buy you a Zima, then! LOL
|
|
|
|
|
LOL.
That's how I feel about Garbage Collected Languages... Or, er, "Managed Code".
|
|
|
|
|
Great topic!
The tools available these days for debugging are awesome compared to around 20 years ago when I started learning/using javascript. Alert() was my only friend! Some of those earliest javascript functions I wrote have survived mostly unchanged.
That said, I was frustrated the other day at the lack of built-in date/time formatting...you want a nice looking date, you have to roll your own function! Yeah, it has it's quirks, but once you understand them, it's amazing what you can do with javascript/css.
It's also amazing to me how many javascript developers don't error-proof their code, apparently being content to let the browser eat the exceptions...except that some clients (don't ask me why) have enabled debugging and get to see all those nasty little undefined and NaN errors, and even get the opportunity to debug it. Yeah, this really confuses the end users, 'cause they're really not sure what to do as this is not covered in the product documentation...so they call, or send a screenshot...and I think to myself:
a: why do they have debugging enabled in the first place
b: the question is quite clear to me...to debug or not to debug (internal voice sarcastically, 'are you a f*%king programmer? Of course you dumb twit, you should click the Cancel button!)'
What's painful is setting up for debugging, then using that browser in the real world. Cancel...Cancel...Cancel...Cancel...∞
"Go forth into the source" - Neal Morse
|
|
|
|
|
my favorite feature is using || to override missing parameters!!!
var timerSetting = paramTimer || userTimer || systemTimer || 500;
the functions as parameters... That was a Throwback to CLIPPER days, where you had code snippets:
{|| code} you could pass as parameters for event handlers, etc. Way cool... First language that I ever saw that in (probably because I took LISP later)... But you cdr guessed that. LOL
I am HOPING that JavaScript replaces VBA as the internal scripting language of ALL programs!
The more I use it, the more I like it. Kinda like JSON. The more you get used to it... the less you want to kill someone...
|
|
|
|
|
Kirk 10389821 wrote: my favorite feature is using || to override missing parameters!!!
Thanks, haven't tried that!
My favorite feature is writing a function that creates a new document on the fly, including functions/handlers of it's own, which in turn, creates functions/handlers for another new doc... but it works! (great way to control prints on tables)
"Go forth into the source" - Neal Morse
|
|
|
|
|
Marc Clifton wrote: this and bind is someone's idea of hell, but once you figure it out, it works.
This perfectly sums up how I feel about this as well.
Marc Clifton wrote: I haven't even touched what looks like the cesspool of prototype . Probably something I should learn.
It's really not that bad
When it comes to inheritance, JavaScript only has one construct: objects. Each object has a private property which holds a link to another object called its prototype. That prototype object has a prototype of its own, and so on until an object is reached with null as its prototype. By definition, null has no prototype, and acts as the final link in this prototype chain.
|
|
|
|
|