HN user

zanethomas

469 karma

zane.thomas@gmail.com

Posts4
Comments265
View on HN

The difference in performance is negligible for all but the most demanding applications. In which case I would still use factory functions, but just be more careful.

Fair points. I do use classes exposed by libraries. I don't like it but it beats the alternative.

I really like the flexibility of factory functions, that is the main point of the article imo.

COM/OLE ... that takes me back to the early 90s, a place I hoped to never visit again!

:)

closures can encapsulate state and methods classes are syntactic sugar

emulating classes is, imo, exactly the problem

using factory functions which create and return an object, with variables passed to and created in the function, handles encapsulation

and there is no `this` to deal with

Does it compile something like this into a c++ class?

makeThing(options, usethistoo) { let foo = options.foo; let thistoo = usethistoo;

  return {
    functions...
  }
}

I wonder why it seems natural to you? I'm guessing JS wasn't your first language and you didn't learn the power of composition instead of classes.

Sure, but imo unless one is creating very many objects each with their own set of functions it's not really a significant issue.

Sometimes programmers spend way too much time optimizing code which doesn't really need it.

In my experience how data is structured is almost always the most important factor when it comes to performance.

Good data structure + simple code === performance.

I don't understand the need for the ever-growing list of "enhancements" to JS. Take Class for example.

Class is entirely unnecessary and, essentially, tries to turn JS into a class-oriented language from its core which is object-oriented.

I never create classes. I always create factory functions which, when appropriate, can accept other objects for composition.

And I don't use prototypes, because they are unnecessary as well. Thus sparing me the inconvenience, and potential issues, of using 'this'.

In my dreams those who want to turn JS into c# or Java should just create a language they like and stop piling on to JS.

But, at least so far, the core of JS has not been ruined.

That said, there are some new features I like. Promises/async/await, Map, Set, enhancements to Array being among them. But to my way of thinking they do not change the nature of the language in any way.

Hmmm, odd. I was under the impression they used cosine similarity based on page content. Once upon a time, based on that 'memory', I created a system to bin domain names into categories using cosine similarity. It worked surprising well.

Regardless, well done!

I knew a woman who in 1970 was pulled over by the police in Altadena CA. They were particularly aggressive when it came to "hippies" and so she swallowed her entire cargo of LSD, which was, iirc, somewhere in the neighborhood of 20 hits.

She was out of commission for roughly 72 hours and months later still not back to normal, according to what she told me.

[dead] 3 years ago

is the code on github? if not i'm not going to touch it :)

I would be very unhappy with a suggestion to replace javascript. I like that I can mix functional, object-oriented, and procedural type code where each seems to be the best fit.

If something else comes along, gains a lot of traction, and develops its own ecosystem then javascript could conceivably eventually just fade into the background. But that's going to take time.

In the early 90s I was working in downtown Seattle. The manager of the project I was on was married to a product manager at Microsoft. One morning he showed up with a beta copy of VB 3.0.

There was a young, brilliant, programmer, James Shields, who was my partner working on a project. We took one look at VB3 and both immediately saw the potential of vbxes.

At lunch we came up with a couple of initial ideas for custom controls, wrote them, and began selling them on Compuserve for $5 each.

Soon I wrote some controls for working with the just-released Sound Blaster card, which gained some interest on Compuserve's music-related forums, I actually traded messages with Jerry Garcia one night.

But our first big hit was Message Hook which I wrote to overcome some of the limitations of using the Windows API when using VB. That lead to Mitch Waite (publisher of many popular computer books in those days) contacting me to revise the Visual Basic How To. The result was the Visual Basic 3.0 How-To, which was almost all entirely new material.

My approach to writing that book was to think about the things that one would want to program in Windows apps but could not easily accomplish with Visual Basic ... and to solve those problems. Message Hook featured heavily, a copy was included with the book's diskette.

Soon enough the internet came online and I wrote a number of internet controls which allowed thousands of Visual Basic programmers to add, primarily, email and ftp to their programs, however there were controls for more obscure protocols as well.

Visual Basic 3.0 was magic! It was an entirely new idea and several companies, including Mabry Software which was founded by me and my programmer buddy, had a good business until .net blew up the entire ecosystem.

I think it's probably fair to say that VB 3.0, and our internet controls, made a significant contribution to the evolution of the internet.

This might be a previously unknown bit of NeXT and Windows history.

While Windows 3 was in development I was in the next building working on os/2. (not bragging <g>)

I spent a lot of time in a lab that had a lot of hardware. One day a NeXT machine showed up in the lab.

The next day there was a line of Windows developers waiting for their chance too look at it. (we'll forget the fun I had grabbing a screen shot of the desktop which i then left displayed full screen)

It was a mere matter of days before a build of Windows with 3d buttons came out, and the rest is more history.