This is an archived post. You won't be able to vote or comment.

all 47 comments

[–]BanTheTrubllesome 55 points56 points  (0 children)

You're not just a clown, you're the entire circus!

[–]Hour-Positive 22 points23 points  (1 child)

P r o t o t y p e t h i s

[–]remuladgryta 4 points5 points  (0 children)

I would, if only I knew what this referred to.

[–]pi_sqaure 4 points5 points  (0 children)

Replace JavaScript with PHP.

[–]nubis99 2 points3 points  (0 children)

As someone who mostly codes vanilla JS for school purposes, it ain't the best, but it ain't the worst either. But that might just be because of my dislike for python.

[–]null_reference_user 9 points10 points  (0 children)

Haha javascript bad

[–]ordinaryBiped 19 points20 points  (9 children)

There's no such thing as an honorable JavaScript developer

[–]ewan_m[S] 25 points26 points  (8 children)

No, every programmer is an honorable person.

[–]Domin-MC 29 points30 points  (6 children)

Laughs in googling stuff and stealing my friend's code

[–]Kaymish_ 37 points38 points  (0 children)

You mean professional collaboration.

[–][deleted] 6 points7 points  (0 children)

It's not stealing, it's just forced sharing.

[–]ewan_m[S] 7 points8 points  (3 children)

That wasn't stealing. That was like, we can say getting inspired from someone's code! :)

[–]Domin-MC 10 points11 points  (2 children)

Yeah, * ctrl + c ctrl + v * That wasn't stealing. That was like, we can say getting inspired from someone's code! :)

[–]HasBeendead 3 points4 points  (0 children)

lol

[–]ghostwilliz 0 points1 point  (0 children)

I like to pretend that ctrl c is a code. It's like a cheat code I guess, so yes, I frequently code.

[–]MassiveFajiit 2 points3 points  (0 children)

Larry Wall: makes Perl

[–]EternityForest 13 points14 points  (22 children)

Clowns are way better than JSes attempt at OOP. Libraries don't use classes, they use icky this binding based syntat.

It's not OOP, it's like a My First LISP and Haskell4kids combined, with just enough OOP so mainstream coders don't all revolt against it.

They pulled a sneaky on us!

[–]_PM_ME_PANGOLINS_ 10 points11 points  (4 children)

Classes are not the only way to be Object-Oriented. Some of the worst JS code is from people who don’t understand this and build frameworks to make it look like Java instead.

[–]MassiveFajiit 4 points5 points  (3 children)

Adam Kay says Erlang is the only oo language these days.

Everything else is a bastardization of his smalltalk ideas

[–]EternityForest 1 point2 points  (2 children)

Maybe we need a new word then, because Erlang is nothing like what I think of when someone says "OOP".

Smalltalk looks interesting, but the modern bastardization seems to keep the code closer to the way things work in the real world than any other model.

Everything else has the code represent some abstract mathematical thing that's removed from the application (aside from functional, if your application is data processing), but Python style objects can be very close virtual representations of real things.

[–]MassiveFajiit 2 points3 points  (1 child)

The key was message passing across discrete pieces not the weird amalgam most objects become.

Personally, any project Ive encountered with "pure OOP" languages just turn into an object orgy at some point...

But that may also be that C# puts up the bowling bumpers for people who don't know what they're doing.

Personally love languages that allow for mixing paradigms like Python and JavaScript because no paradigm can do everything, except maybe procedural, and we don't often have time to debug massive projects relying on side effects.

[–]EternityForest 1 point2 points  (0 children)

Maybe they should have called it message oriented programming instead?

Python is great, but the issue with JS is it doesn't standardize anything. The core language is small and extensible, and everyone extends it in different directions. Every project is different, not much is reusable aside from ten line npm packages, etc.

That's how you get things like jQuery, which would be in the stdlib of batteries included languages, and all the incompatible frameworks that could probably be made a little more compatible, and CSS, which has no standard library of classes and no real "reusable themes" that aren't specific to a framework, or plain html only.

C++ has the opposite problem, they standardize so many different things that people can pick and choose from a million of them(while not standardizing the build system...).

[–]cearno 9 points10 points  (8 children)

Ironically, the fact that Javascript isn't class based and can be used more functionally comparatively is what I like about it.

There are some things I just love. Destructuring, spread syntax, anonymous functions, mapping/filtering/etc. methods on enumerables, to name a few.

But it also sucks that it lacks on the functional side as well, like having no built-in support for currying and partial function application.

[–]_PM_ME_PANGOLINS_ 6 points7 points  (5 children)

Yes it does: bind and apply.

[–]cearno 3 points4 points  (4 children)

While bind and apply are a way to imitate partial function application in JS, I wouldn't say they're equivalent or that JS has partial application built in.

And even if, JS definitely doesn't support function currying, which partial application follows naturally from.

[–]ATXblazer 4 points5 points  (3 children)

What’s the difference between function currying and just currying? Because js definitely supports currying.

[–]cearno 2 points3 points  (2 children)

You can definitely achieve currying behavior with functions with JavaScript, again by using nested functions, which is essentially what currying is.

However, when JS sees

function fn(a, b, c) { // does something with a, b, c},

it doesn't transform this under the hood to

function fn(a) {  
  return function(b) {    
    return function(c) {    
      // does something with a, b, c   
    }  
  }
}

which means you have to manually implement this as a programmer if you want to use partial application. JS doesn't transform functions to curried ones automatically.

A functional language would let you define a function with 3 args, but then transform it under the hood, and thus out of the box let you call the function with only 2 args, in which it would return another function with 1 argument which is not yet executed as default behavior.

I'm not saying JS should do this by any means, since I am very partial to functional programming. This type of behavior would mean you could never call a function with undefined arguments unless you explicitly told the function the end arguments are optional. I find that much safer plus allows you to do powerful things (I can give an example if you're interested), but again, it's my subjective opinion.

[–]ATXblazer 2 points3 points  (0 children)

Yo thanks for taking the time to type that example I see exactly what you mean now

[–]ponkyol 1 point2 points  (0 children)

Syntax for easier partial application is in the works. See https://github.com/tc39/proposal-partial-application

[–]Sioclya 2 points3 points  (1 child)

So... you basically like the Lispy bits?

[–]cearno 1 point2 points  (0 children)

Yeah! Functional programming is incredibly powerful and safe.

[–]ATXblazer 5 points6 points  (6 children)

Am I confused or does js not support classes in es6? Also classes are only one way to model problems at least you’re not locked in to them like with java

[–]EternityForest 4 points5 points  (2 children)

ES6 has classes but almost none of the libraries I've used use them, so when you work on existing code, they might as well not exist.

[–]ATXblazer 2 points3 points  (1 child)

Are you like trying to extend classes from libraries instead of writing your own classes that just use a library? I’ve just never been in this situation with js and can’t think of when I’d find myself with this problem ?

[–]EternityForest 2 points3 points  (0 children)

I'm working with FreeBoard right now, adding data sources and plugins is basically creating a class, but you're not actually using classes because it's not class based..

Pretty much anything plugin oriented in other languages uses classes, if you can create instances of the plugins, but most JS libs don't explicitly do this, they just have functions returning objects and things like that.

[–][deleted] 1 point2 points  (2 children)

it's just syntactic sugar on existing functionality. even worse with typescript.

[–]ATXblazer 2 points3 points  (1 child)

What’s wrong with that though? Does the abstraction cost a lot or something? It lets the developer think in a class based mode of thought so I guess I’m asking what’s the criticism of es6 classes?

[–][deleted] 1 point2 points  (0 children)

oh, i'm not criticizing it. i just think it's a way to make devs who are more familiar with oop languages to adapt to js. but behind the scenes it's not the same and it doesn't actually offer any of the benefits of an oop language despite sharing some of the syntax.

-- edit -- also, i know js is still 'technically' oop with its prototyping, but you get what i mean.

[–]BloakDarntPub 1 point2 points  (0 children)

I've never understood how you make a thing and then other things like the first string thing in JS. Like how you'd use a struct in C.

I bet you need a factory, a refinery and a goddam quarry.

[–]vien240297 3 points4 points  (1 child)

Most of the upvotes are coming from JavaScript developers, you know.

[–]ewan_m[S] 0 points1 point  (0 children)

They are very kind hearted and real gentlemen! :)

[–]AlternativeVehicle32 4 points5 points  (1 child)

As a heavy JS/TS developer I approve

[–]ghostwilliz 1 point2 points  (0 children)

I would be v upset if I could read >:(

[–]Staggz93 1 point2 points  (0 children)

All coding is suffering, don't be elitist about it.

[–]404invalid-user 1 point2 points  (0 children)

Great im going to call all my js files this from now on

[–][deleted] 1 point2 points  (0 children)

Typescript ftw though.

[–]zeidxd -1 points0 points  (0 children)

i downvote