JavaScript is a scam

I can appreciate that you’re an agitated troll who likes a good rant, but now you’re just being ignorant. Read up: http://en.wikipedia.org/wiki/Prototype-based_programming

What you seem to be actually angry about is the fact that JavaScript tends to rely on duck typing rather than “Foo implements Bar”

JavaScript web workers use the actor model.

WTH, when did duck typing and OO become mutually exclusive?

JavaScript is bad because it lacks simple constructs that developers need.

Actors as an external library exist even in Java, it is not as good as having the language itself do it for you (like in Erlang or my own language).

JavaScript as it is today, it is simply unsuitable for serious development.

Comparing JavaScript with Java, C++, etc. is totally pointless. Way different target platforms and uses.

I get the loose impression he thinks Java and JavaScript are related.

It’s not an external library, it’s a standardized part of the JS runtime.

Well, the workload of generating websites is perfect for this. Your own code always waits for the database/disc/caches/network/whatever. With an event loop you can do something else in the meantime and there is virtually no overhead.

I like it for scripting/automation. I.e. things I used to do with Python, batch files, or even small Java programs.

I wonder why so many people hate the lack of real inheritance with javascript. The language is not designed to work like any OOP language. Though the prototype way is somehow more powerfull for a language like javascript.

The most powerfull thing in JS is imho the fact to write any function and attach it to any literal you or the specs defined. Thats power :wink:

I kinda agree that inheritance feels like a flimsy hack in JS. It reminds me of going back to C and having to write v-tables manually - unnecessary extra work for something that feels like it should be built-in at a language level.

In my head I know that it’s a different style of language and so you have to do things differently - that it’s not a ‘traditional’ OO language (whatever that is). But when you’re just trying to Get Things Done it’s very easy to get frustrated as it makes you type a bunch of boilerplate again and again.

I suspect a large amount of this head problem may be the syntax. I don’t have this problem with Python or Ruby because they ‘feel’ so much different. It’s much easier to get into a different mindset while using them. JS ‘feels’ too similar to Java or C++, so you start expecting to be able to do the standard things that you can do in those languages (like built-in inheritance).

When you write to much javascript code, then you might have to overthink your idea or change the behavior. When i look back at some old javascript code i feel really awkward about is. Because today i know ways to make it smaller, faster and neater and without any use of inheritance needed.

The Prototype Object itself does work like inheritence. Any object that has been derived from another objects prototype will inherit its magic, but so far i haven’t had much use for inheritence in javascript yet despice the small stuff provided by those js frameworks.

I think OrangyTang hit the nail on the head there. The uncanny valley of languages. It’s part of the reason I hate going back to C++ so much these days.

Cas :slight_smile:

I think you’ve missed my point - Cas has summed it up nicely, it’s an uncanny valley where I’m (and I suspect others) are seeing two different languages at once.

When I write Ruby code, half my brain is thinking “ah, functional language. Write functional code” and the other half is thinking “ah, functional syntax. Write functional code”. All is well.

When I’m writing JS code, half my brain is “ah, functional language, Write functional code”, whereas the other half is “I know this syntax! Curly brackets! Write OO code with inheritance! Where’s my static typing? Why does my code look like shit? WHERE’S MY INHERITANCE? RAGE!”. The C/C++/Java side having much more brain-hours wins every time.

I’ll let you guess which one is more fun to program in. :wink:

Yea, thats true, a point i missed out. Syntax tends to mislead on the path…

Though fun is neither language. For example I really miss closures in Java.

Maybe its easier for me as i have to write php applications at work and as all know, php does not have real inheritance. And the code get bloated all the way when start using it.

In general see two main complaints against JS. The first is that people insist on thinking in terms of an OO abstraction model, when it isn’t. And the second is that they fail to recognize that JS is designed to be a “scripting” language and not a general purpose one. (NOTE: Yeah I know prototype based is a special case of OO, but that just confuses too many people).

Yes. Very many and they all worked out just fine.

There are two major reasons for unmanageable codebases. The first is wrong choice of major paradigm and the second is bad design. Of these two “bad design” is by far the bigger of the two problems. If one doesn’t understand the given language(s) one is writting in, then the design will invetitably be “bad”. WRT: “OO is a necessity”. Not at all. It is not well suited to a wide range of problems. There is no one paradigm that address all problems. IMHO multi-paradigm languages haven’t been a big success at large projects. This is not to say that languages like Ocaml are not useful…just pretty much everyone ignore the OO functionality. And if meta languages were the solution then we would have stopped at LISP variants. It’s quite rare for any large project for me to be happy with a single paradigm, static vs. dynamic typing, etc. This is why I’d love to have a good multi-paradigm high level IR with good inter language-OP support. Choose the best tool to attack the given sub-task.

SEE: Is a scripting language. I certainly wouldn’t open up access to raw concurrency related functionality in any wide target audience scripting language that I’d design. With the exception of coop-task switching hints in an actor like framework. If the embedded app wants to provide this kind of functionality…it can.

Well I’m far from clueless and I think that if one was creating a user-extendible single player game engine, then it would be difficult to beat embedding V8 in a native application.

Unless it’s a learning exercise I’d suggest not bothering. If you want actors in Java, just use kilim.

If the author of kilim (as well as some external people) are to be believed, then kilim outperforms Erlang.

SEE: Is not an OO language. (OK, OK…class-based OO)

This is a true statement about the both abstraction models of both OO and prototype based. The only difference is where the data is stored.

I find the “this is more OO than that” argument silly. But it’s hard to argue that there is a more “OO” language than SmallTalk. JS is closer to SmallTalk than Java is.

Maybe that’s what the author of JS was intending to say with the choice of names.

Not really.

Functional programming and OO aren’t mutually exclusive.

The problem is what some Java people mean by “functional programming” are ugly hacks involving stuffing functions inside of objects at runtime.

Functional programming != stuffing functions inside of objects.

Functional programming has to do with programming without side-effects, as in mathematics. Mathematical functions don’t change state. JavaScript is not even functional by definition.

This whole thing looks like a cheap Java clone built by Perl developers. Where they ditched all the stuff that makes Java good in order to make it more “Perl-like”.

I would suggest you to reread my comment. Who said OO alone is the solution?

[quote=“Roquen,post:94,topic:37455”]
Yes, and that’s why Javascript is unsuitable for any serious development.

Off the top of my head I can think of many options that would beat that.

I don’t want it “in Java”. I want a programming language where I can express what I need without having to go through pain like Javascript.

Java is cool as it is. But another language would be better to complement it in areas where it lacks.

And that proves… what?

Actually, Erlang is pretty good and having actors as part of a language is just as handy as having multithreading, like Java does.

It just makes more sense.

EcmaScript/JavaScript harmory get’s class-oop - http://wiki.ecmascript.org/doku.php?id=harmony:classes

It’s pretty easy to write large JS code bases where most of the functions are free of side effects. I have tonnes of re-entrant functions in my projects for handling logic.

You also need some side-effects, or nothing would appear on the screen.

The one thing I really disagree here is the idea that JavaScript can only be used for little scripts, and can’t be used for building anything more advanced then that; yes it can! Google Docs is a pretty trivial example of this.

There are issues with writing JS projects, mainly around having no standardized way of modularizing your project, or building it across multiple files (there are strategies you can use, but no built in ‘package’ or ‘import’ which handles it all for you like in Java). But there are also huge gains, such as having the easiest distribution model of any runtime (as most people do run a modern browser, and it’s much easier to write cross platform JS then cross platform Java).

Hmm, Google docs eh?

The same bugridden, inconsistent, slow, inferior, monstrous bit of code I’ve been using? And even if it is bugridden, inconsistent, slow, inferior and monstrous I wouldn’t call it trivial. And let’s not forget it lives inside the DOM and rendering engine of an incredible bit of technology itself, the browser.

Cas :slight_smile:

There was a time when Java was considered slow and inferior, same was also true with JavaFX. The fact that you have an advanced rendering system at your disposal is part of my point; JS + HTML5 + CSS allows you to build quite a lot!