If you're thinking of the class keyword, that's just sugar for a constructor function with a few extra limitations (like making sure you can't invoke it without new)
@mega6382 TypeScript does have the concept of a class, it has a meaning further than just an object factory when I create a class (it adds a type, I can pass the class around and TypeScript will know it's not a normal function, etc).
The TypeScript compiler will not let me call it without new even though the runtime would let me (assuming it compiles down to a constructor function, if my target is ES5 or ES3)
@ircmaxell sorta-kinda, it conceptually fulfills the same objective, but it falls differently in the layers of abstraction in my eyes
A class gives you certain guarantees (for example, that all objects created from it will have all of the methods and properties defined on it for the entire lifetime of the class), which an object equivalent does not guarantee
Also, in JavaScript, I can create an object without a prototype
I didn't say it's identical with a PHP/Java notion of a "class". But it's functionally incredibly similar, especially when you look at classes in languages like Smalltalk
@ircmaxell When you ignore certain abilities (which, admittedly, most of us in JS do, you don't see much modern code that overrides prototypes past the first tick), then yes.
class A {
public function add(int $a, int $b) : int { return $a + $b; }
}
class B extends A {
public function add(int $a, int $b) : int { if ($a > 1) throw new Exception('...'); }
take a look at Ruby for a better view of the middle ground that connects the two
@ircmaxell How is it not an accurate blueprint? If you do new A() you get an object matching the A blueprint, and if you do new B() you get an object matching the B blueprint.
1, 2, 3, 4, 5, 6 - this number is growing linearly. 1, 2, 4, 16, 256 - this number is growing exponentially. 1!, 2!, 3!, 4!, 5!, 6!, 7! - this numbers is growing 'factorially'.
Is that a word or is there an actual phrase for that growth pattern?
Also, still, just because you can think of them as classes, and they kinda-sorta fulfill the same purposes, does not mean that you have classes in the language
@MadaraUchiha true, but prototypes are a form of "class" as well, almost identical (except in runtime resolution) to Ruby's class system. The only reason JS is thought to "not have classes" is because people see the class construct and think it's a class. but there are subtle differences
people see the class keyword, and make all sorts of assumptions about what that means. And they see the lack of it and make a whole bunch of assumptions about that as well
Take a look at with, and while you're at it, think on variable variables in PHP.
@ircmaxell Hmm, sure. One of the arguments against adding the class keyword to begin with was that people will assume things without understanding that it's still prototypal under the surface.
@MadaraUchiha You'd be surprised. When I graduated high school I overheard someone introducing their favorite teacher (FFA teacher) to their parents. I heard them say, "I'm so glad Mr. **** was here to learnt me."
For that matter, there's a very little practical difference between a constructor function that you invoke with new, and just a regular ol' function that returns an object literal, that you invoke by calling normally.
class Foo {
constructor() {
this.x = 42;
}
getX() {
return this.x;
}
}
// vs
function Foo() {
return {
x: 42,
getX: function() { return this.x; }
}
}
// very little actual difference in the end.
The reason JS seems so odd is that it's (almost) a Lisp-like language with C-like syntax, that's designed to look like Java.
2
However, that fact that we've (collectively, as a community) managed to make JS into a relatively orderly and sane language (the sanity of which is further augmented by TypeScript), is nothing short of a miracle in my eyes.
Watching the transformation from a "script kiddies" and "make the cursor sparkle" language into an actual real thing was a pretty fun experience to have.
No! WebAssembly is designed to be a complement to, not replacement of, JavaScript. While WebAssembly will, over time, allow many languages to be compiled to the Web, JavaScript has an incredible amount of momentum and will remain the single, privileged (as described above) dynamic language of the Web. Furthermore, it is expected that JavaScript and WebAssembly will be used together in a number of configuration
Plus the whole concept of asking parent instances for values seems to break encapsulation to me. Also weird that you have to have a whole string of parent objects that are actually instantiated in order to use a single child instance.
Also I don't particularly like front end so I'm just in general bias against JS.
@MadaraUchiha This seems like it could get really hairy when you have additional named constructors.
Question regarding website directory structure: is there an argument for using numbers as names for subfolders, which indicate the sublevel of a folder in the URL path?
Is there some school of thought that suggested doing this?
it seems like something that would come out of the Wordpress lot
@Allenph "indicate the sublevel of a folder in the URL path" is what I was told. The intention being to separate files into a folder from other stuff... or something. I'm trying to understand where this vendor picked up this idea...
and explain a better way of doing it... I'm wondering if this practice was started somewhere down the line with Wordpress
I agree. It's convoluted, and during the meeting I was trying to understand why they did this rather than just naming the folders based on the topic, and creating index files inside those folders, with other pages associated with that topic.
We're using a push CMS, so what we build inside the CMS, gets pushed to another server as static files which hosts the public website: HTML, CSS, JS, asset files, even PHP files...
From what I understand, there are ways to build dynamic paths, but it's not a true router.
The application is like... software to build a CMS pretty much, and the way the vendor is building the CMS for us to use is... becoming unpleasant and possibly a downgrade from what we have already. It could be designed/structured so much better, but in fairness, we're all new to this product, so they're probably applying what they've done with other clients' sites to this. Which in some cases, they shouldn't.
numbering folders like this is one...
I don't know what is out of scope of our contract with them though, I'm not sure if I can ask them to restructure it.
@tereško I cannot tell if they're joking. I'm assuming they're not. Funny comment in feed in reference to using "Feeding a fed horse" rather than "Beating a dead horse." "Feeding an already fed horse actually results in colic, resulting in extreme abdominal pain and the need for invasive surgery and sometimes even death in horses!!"
The application is built in Java, and I can't manipulate the source code, it's closed-source. But I can add programmatic logic with Velocity, to tie parts together. Also there's the option to add PHP/ASP.NET/ColdFusion code, but it'll only be able to work with simple stuff, not full classes .... at least that I've seen ...
@StatikStasis Peta rarely jokes about this stuff, they were pushing the whole "milk is racist" crap several weeks ago
I guess I always hope they have a marketing department that just tries to come up with some of the most absurd campaigns in order to get people to look but are more rational in reality.
hey @kelunik I can see you have quite a nice progress on AoC, mind sharing your solutions via github, so I can see how other's are approaching the same problems as me
Hey guys. I've been experiencing pretty annoying issues with gettext on php7.2. Mostly with updates, reloading the page to see my text changing between new and older versions randomly, etc. What are your thoughts? Should I fix it or just switch to a library? If so, which one?
Every solution (1, 2, 3) suggests changing the domain to get rid of the cache problem, but this will create lots of out-of-date cache in memory.
So I dug into the gnu-gettext source for details on the cache strategy (bindtextdom.c:78.)
When bindtextdomain(domain, dirname) is called, it will ch...
Yeah, I'm working on an old system that uses php arrays with numeric keys to do the job and was looking for a nice quick replacement so I don't go nuts.
@Allenph Oh, I don't use those capabilities almost anywhere
While there are a few things that runtime type-information are good for (the most obvious use-case is DI with minimal configuration), it's not something I usually need in a programming language
@MadaraUchiha I swear I got the right answer for pt2 but it's not taking it, maybe they are wording it oddly but I didn't have enough time to keep going over it
@Alesana If you've got part one, it's literally just run it 26 times, once for each excluded letter of the alphabet, and see which has the lowest length at the end.
It's usually a nicer twist than just "run it 26 times"
Mine also takes a long time to computer, over a minute for sure. I remember reading that it shouldn't be over 15 seconds so I might be doing even part 1 a weird way.
Part 1 only takes 3 seconds, part 2 takes maybe 3 minutes, something is not adding up...
The abstractions are simply different in a lot of the cases, you have a lot more standalone unit-ish functions that do stuff with one another, than you have these large entities that keep lots of state and talk to each other through layers.
Like I said, JS is a Lispy language trying to masquerade as Java. It makes sense that the adopted patterns are more Lispy in nature than they are Java-y, at the end.
@Alesana It doesn't
It used to be the case that the dependency tree was directly represented in the directory tree
But now it flattens the dependencies pretty well
It only nests when two packages as for two incompatible versions of the same package.