Feeds

back to article JavaScript is everywhere. So are we all OK with that?

The JavaScript programming language has been in the wars over the years. Oft derided for security concerns, its ‘amateur’ web designer following and for ‘borrowing’ its name from the beefier brew that is Java itself, it has been a rough 19 years or so. Despite all this, JavaScript is still on every 'predictions for 2014 in tech …

COMMENTS

This topic is closed for new posts.

Page:

JavaScript's OK ...

... if a bit reliant on confusing messing around with functions.

"If a mobile developer can use HTML5 and JavaScript to build a potentially 'ubiquitous' app capable of running everywhere, then why wouldn’t they?"

Maybe in a few years you'll be able to do that. Maybe.

4
4
Silver badge

Re: JavaScript's OK ...

"If a mobile developer can use HTML5 and JavaScript to build a potentially 'ubiquitous' app capable of running everywhere, then why wouldn’t they?"

Maybe in a few years you'll be able to do that. Maybe.

Depending upon exactly what said app needs to do it's sometimes possible now. Trust me, I've done it. It's not always possible by any stretch of the imagination, but there are some really useful JavaScript powered webapps running around that just really don't care what device you use to access them.

1
0
Anonymous Coward

Not to mention Qt Quick

Or perhaps best not to mention Qt Quick ;-)

2
0

10 alert('Hello');

20 GOTO 10;

1
1

If your language has its lines numbered, theres no point completing them with semi-colons.

8
0
Bronze badge
Coat

IIRC, the semicolon tells it to put the next 'Hello' on the same line. But of course the parentheses aren't needed and you'd use double quotes. And surely they meant "PRINT" and... I'll get my coat

3
1
Anonymous Coward

Interpreted?

"this interpreted programming language"

Javascript hasn't been interpreted for several years now. Its JIT compiled, which is why its actually fast enough to be usable for proper applications.

6
2

This Javascript tutorial

almost tempts me to lean a new language

https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript

But my normal language is Perl, and my trade is mostly quick-and-dirty...

1
1
Silver badge

Re: my trade is mostly quick-and-dirty...

then you should get on with JS!

0
0

"too expressive in some ways, with features like closures..."

Closures are its main bloody asset! It's a functional language and the moment you treat it as such instead of trying to bend it into it isn't (like Java), it actually becomes quite pleasant to work with.

If Eich had got his way at Netscape, Javascript would have looked more like Scheme/LISP than a C descendent.

15
0

Re: "too expressive in some ways, with features like closures..."

Yes, but it takes a programmer to understand that and the speaker being quoted was an analyst.

10
0
Silver badge

Re: "too expressive in some ways, with features like closures..."

Functional programming would be great assuming Javascript were multithreaded but it hasn't gained such ability until recently and there are severe restrictions on how it can be used that way. Closures in JS have been used more to make the lack of OO functionality by attaching some functions to an object, a little like using a prototype although there are differences.

Anyway, be glad it resembles a language people are familiar with. If it had resembled Scheme or Lisp it would have been DOA.

2
0
Silver badge

Re: "too expressive in some ways, with features like closures..." @Matt Bucknall

Exactly!

"with features like closures that make it less readable and more difficult to debug"

bloody moron. You can encapsulate and abstract beautifully with these and other functional features to make things so simple debugging becomes much less needed.

Why are the clueless allowed to opine in areas not their own? And doubtless get paid more than us to do so for that matter.

5
0
Silver badge

Re: "too expressive in some ways, with features like closures..." @DrXym

Multithreading is almost irrelevant to functional programming features, which are invaluable on their own. Immutability is more important for threading.

3
0

Re: "too expressive in some ways, with features like closures..."

Javascript is not a functional language (look at F# etc. for functional language), it is a scripting (the clue is in the name) language and was deisgned not for developing main stream applications!

0
6
Silver badge

Re: "too expressive in some ways, with features like closures..." @pjc158

javascript has all the pieces need to program in a functional way. Therefore it *can be* a functional language, depending how you use it. But I guess your point is that it isn't a strictly functional language; I buy that.

1
1

Re: "too expressive in some ways, with features like closures..."

"Closures in JS have been used more to make the lack of OO functionality"

Closures are nothing to do with OO functionality, they're to do with capturing execution scope. If all you want to do is attach some functions to an object call() & apply() are perfectly adequate.

One of the successes of JS is the fact that so many patterns are possible. The downside of the expressiveness is that many people have little appreciation of what they're actually doing. The current obsession of seemingly declaring everything inside a closure is a case in point.

5
0

Re: "too expressive in some ways, with features like closures..."@pjc158

Whether a language is a scripting language or not is related to the level of operations programs written in the language are intended to perform - It has nothing to with the paradigm(s) a language supports. A scripting language can be procedural, object-oriented and/or functional just as much as a systems language can be.

Indeed Javascript is more than a purely functional language, but that really stems from Netscape's insistence that Eich create something that looked more like Java (because that's what the cool kids were using) than Scheme, which is what he had originally wanted to implement and which is more than apparent if you use it functionally.

The point I was originally trying to make was, the primary reason Javascript seems to receive so much bad press is because programmers come to it expecting to be able to structure their code into hierarchies of classes, the way they're used to. They find they have a hard time getting Javascript to work that way, because that's not how it was really intended to be used, so dismiss it as being crap. They fail to discover that, by changing their approach to suit Javascript instead of the other way around, it is actually quite a well thought-out and nice language to work in.

8
0
Silver badge
Coat

Re: "too expressive in some ways, with features like closures..." @pjc158

> it isn't a strictly functional language; I buy that.

So what we need is... browser-based Miranda?

1
0
Silver badge

Re: "too expressive in some ways, with features like closures..." @DrXym

I didn't say multithreading was irrelevant to functional programming. I said the main use of functional programming in JS was to make up for its lack of proper OO classes, to tack "methods" onto an object and use it like a class. It's being used as a bandaid because JS has grown up in a fairly organic manner. Even within JS, using a prototype is still recommended because it has a lower construction overhead (since it doesn't bind new closures to each time an object is made).

As for immutability, it has very useful properties for ownership and so forth, But it can also suck big time which is why most languages leave the choice up to the developer. A simple example, would be a game which in the course of one loop might construct thousands of points, lines, planes for all its geometry and physics and all this would be massive overhead. Hence the game would use mutable objects which could be reused over and over.

It is examples like this that doubtless explain why pure functional languages are largely confined to niche purposes and always will be.

0
0
Silver badge

Re: "too expressive in some ways, with features like closures..."

"Closures are nothing to do with OO functionality, they're to do with capturing execution scope. If all you want to do is attach some functions to an object call() & apply() are perfectly adequate."

Oh dear, someone can't read. I said that's how they are used in JS. A common pattern (or anti pattern if you prefer) is write a "constructor" for an object which tacks on a bunch of closures which are bound to that new object and called as if they are methods. It's actually more efficient to use a prototype but some people use closures since they look a bit neater and use things like instanceof. It is very easy to look this up for yourself. I'm also aware of what a closure is in its wider definition.

0
0
Silver badge

Re: "too expressive in some ways, with features like closures..."

Javascript is not a functional language (look at F# etc. for functional language)

Care to back that up with any actual arguments? And yes, I'm amply familiar with both the LISP family (LISP, Scheme, etc) and ML family (SML, OCaml, F#, etc) of functional languages.

it is a scripting (the clue is in the name) language

Utterly irrelevant, as others have noted. Do you have any idea what you're talking about?

was deisgned not for developing main stream applications!

No, apparently you don't.

1
0
Silver badge

“the assembly language for the web”

Shudder.

As an assembly language programmer and web developer I resent that remark!

14
0
Silver badge

Re: “the assembly language for the web”

I think it would be more accurate to say ' the C language for the web'

i.e Not the best language for large projects and missing many feature of it's more modern cousins, but ubiquitous and not going to be replaced soon.

4
0
Silver badge
FAIL

Re: “the assembly language for the web”

As a C programmer I resent that remark

3
0
Silver badge

Re: “the assembly language for the web”

I think it would be more accurate to say ' the C language for the web'

I think it would be more accurate to say "the JavaScript language for the web", though "the ECMAScript language..." would be more accurate yet.

Really, what is this quixotic urge to analogize programming languages? Just stop, folks. The comparison is always more misleading than it is meaningful.

1
0

Re: “the assembly language for the web”

The writer seems think this phrase is complimentary. It emphatically was not intended that way by the guy who coined it (James Gosling? not sure). He meant that it's a reasonable compilation target but that nobody in their right mind would choose it as a source code language (sorry assembly language guy). So the analogy actually is quite apt given what he was trying to say.

1
0

Does anyone remember DHTML ?

1
0
Anonymous Coward

Sadly, yes!

3
1
Silver badge

I still occasionally find myself fixing DHTML apps. Yeah, we've got some web apps that have been around that long and are still being used. I'm slowly getting them replaced with newer versions, but when you've got an app that's been around that long there's always some resistance to the new version.

0
1
Bronze badge

RE: Does anyone remember DHTML ?

Eh, what do you use nowadays then?

1
0
Bronze badge
Pint

I have to admit the only reason I started messing about with JavaScript again was because I fancied playing with the fun stuff in jQuery. JS isn't as bad as it was 10 years ago, it's not great but then this is the usual "VHS was crap, Beta was better but VHS won on pure saturation!" argument all over a again!

2
0
Silver badge

jQuery

I have to admit the only reason I started messing about with JavaScript again was because I fancied playing with the fun stuff in jQuery.

That's a bit like deciding to start eating meat again so you can enjoy McDonalds' hamburgers.

I mean, really, jQuery? A horrible overgrown pile of crap written by people who don't understand the language they're using, can't be bothered to read the specification, and throw hissy fits when someone else does and points out how wildly wrong their assumptions are?

jQuery's the best reason to avoid JavaScript.

2
2

Re: jQuery

> A horrible overgrown pile of crap written by people who don't understand the language they're using

So it isn't just me.

Then again, Michael, one could say the same about much of code :(

Or maybe we are talking about the documentation. I reported 2 examples (by email) that had errors which beginners would be extremely confused by (on top of being obviously wrong). Instead of changing less than 10 characters of text, they put it up with my email that I assumed 'might' be kept private in the bug section for over a week before it was fixed.

end_jQueryRant().chainABunchOfShit().startJSPraiseMachine();

I don't do non-HTML5 anymore, so jQuery-type libraries (I liked YUI 2.somethinglate, but that was its own can of worms) have given their way to stuff like D3 (which I credit for my switch to HTML5) for quick testing, but anything proper is pure JS brutally shortened. Funny how going from testing in IE6 and Firefox to try to get alignments has switched to Firefox and Chrome to optimize UI performance and playing with 3D CSS.

The way I now think of what a web page can do is miles from before (assuming same time input from me). Freed from the constraints of early JS lack-of-portability (damn you IE), I can make apps that will work on well over 90% of devices in the Western world with decent fall back and no extra crap. The sequences are not shortened. Nay, I have put a 250ms delay on certain actions because the response was too jarring:

makeItAsFastAsiPhone(); // just kidding, I think

1
0

Flash's ActionScript just being repurposed Javascript is quite a stretch. It may be close for ActionScript 2, but while AS 3 is ECMAScript-based like Javascript, it is the dropped version 4 that supports strong typing and proper classes among other things.

1
0

I am not okay about running any unsigned, badly tested, insecure code in my browser or any place on my computing devices.

These days, I can't always avoid it. But my default is noscript, flashblock etc. If a site needs to use my cpu cycles to display its adverts, I need a very convincing case to allow it,

My preference would be for signed code running in secure and auditable sandboxes.

It is crazy that so many people give JS a free pass to execute on their machines, Until it is proven safe, it remains a risk.

18
1

Coudn't agree more

Nothing annoys me more than a site that won't actually operate without me allowing code to be executed on the machine I'm using. A site should be able to offer it's core function without JS and this isn't actually that hard to do. Not if I can manage it.

18
3

This post has been deleted by its author

Silver badge

Re: Coudn't agree more

A site should be able to offer it's core function without JS and this isn't actually that hard to do. Not if I can manage it.

This is exactly why I shake my head in disbelief when I see people using JS for things like rollovers. CSS can do those and not break when someone has JS disabled. CSS3 can even animate them nicely, all without any scripts being executed.

10
0
Silver badge

Re: Coudn't agree more

"Nothing annoys me more than a site that won't actually operate without me allowing code to be executed on the machine I'm using. A site should be able to offer it's core function without JS and this isn't actually that hard to do. Not if I can manage it."

Quite.

What would be nice is if I visit a site and I have JS disabled (which I do because I use NoScript), instead of a message appear at the top of the page saying "Your browser appears to have JavaScript disabled, but this site works best with it enabled" (or words to that effect), the websites would actually say something more like:

You appear to have JavaScript disabled. We understand why you might wish to do this, but this site does need JavaScript enabled in order to work best. The scripts we use are:

* domain/address of Javascript file - summary of use

* domain/address of Javascript file - summary of use

* etc

That way, I can decide which scripts to allow for this particular page, looking at those scripts if I feel it necessary. Otherwise I have to work this out for myself, by looking at the Noscript menu and/or page source, which is going to take longer. Often I can't be bothered and I look elsewhere - but presenting the information to me like that would probably encourage me to take the time to look/give this site a chance.

12
1
Bronze badge

Re: Coudn't agree more

The only time I have JavaScript on a page is to put the user control into the first web control on the page.

It's a little neater like that, but that's the only time I would ever use it.

3
0

Re: Coudn't agree more

Hahaha. You're going to pay to access these sites right? You know, actual hard currency that the developers who would then have to actually spend time writing and maintaining these summaries of every individual JS file they're using (and presumably working around you deciding you like X but not Y) to accommodate your particular 1 in 10,000 visitors preference can use for things like food and housing?

There's a browser sandbox for a reason. If there's a security hole that lets a site do something horrendous - then that's an issue for the browser and thanks to automatic updates it's one that's finally addressed pretty much universally these days without you having to care.

I love the admission that you can't be bothered using Noscript - but you'd stop and read the summaries of every individual JS file before reading a blog post?! Sites that require Javascript to work properly require Javascript to work. Other websites are available. ;)

5
8
Silver badge
FAIL

Re: Coudn't agree more

"Hahaha. You're going to pay to access these sites right?"

Indirectly, yes - indirectly because the payment might, for example, take the form of me buying something being sold via the site versus, say, going somewhere else and buying that something.

"You know, actual hard currency that the developers who would then have to actually spend time writing and maintaining these summaries of every individual JS file they're using"

How positively evil of me. Next thing you know, I'll be expecting developers to put comments in their source code, or something crazy like that.

"I love the admission that you can't be bothered using Noscript - but you'd stop and read the summaries of every individual JS file"

Way to twist what I said into something I didn't. Go you.

I said detailing those scripts would encourage me to do so. It would be a positive step by the developer, and make me feel more positive about using the site, and gives me the opportunity to make a more informed decision.

I'm intrigued, as well, how the fact that I use NoScript can be interpreted as me saying I can't be bothered to use NoScript. I guess you're suggesting that I can't be bothered to look at the menus - but the menus are next to useless for deciding which scripts are necessary, which are frills, which I'd rather not trust, and so on. All they do is tell you the domains in question and give you the option of allowing or denying them. That is not an informed choice.

"before reading a blog post?!"

Poor example, but I'll take it on the chin because I should really have specified commercial sites: It's commercial sites on which I'm more inclined to want to make an informed choice about what scripts are in use and what they are doing.

When it comes to things like blog posts and basic/more static sites, I'm much less worried about what the Javascript is doing - because I'm much less likely to be inclined to enable it for those sites anyway. Which itself neatly counters your opening paragraph and your objection to all these poor web developers having to spend time writing their summaries, without getting anything in return to pay the rent: these web developers/site owners aren't being paid much, if anything (myself included), but by the pure magic of the types of site, they don't have to worry about JS declarations.

Having said that:

1) many (most?) will likely be using CMSs developed by others, who may very well be making good money doing it - and it's these people who could build that functionality into those CMSs. (They're more likely to know what the systems use, too, than Joe Blogger who is using it for his site.)

2) those websites will quite often work without Javascript; it might be less functional, but IME they are usually still readable, so it becomes irrelevant.

"Sites that require Javascript to work properly require Javascript to work."

Except when they don't, and the Javascript is there due to cluelessness - where javascript is used for basic functionality like links.

"Other websites are available. ;)"

Well done for basically telling me what I said when I said I can look elsewhere if a site doesn't work without Javascript.

5
0
Bronze badge
Alert

Re: Coudn't agree more

Nothing annoys me more than a site that won't actually operate without me allowing code to be executed on the machine I'm using. A site should be able to offer it's core function without JS and this isn't actually that hard to do.

Any website that requires you to enable javascript should be liable for any damage (e.g., drive-by downloads) caused to your system.

3
0
Silver badge
Mushroom

The clue's in the name...

I'm still hoping against hope that this current craze for javascript is nothing more than a fad. At the end of the day, it's a scripting language that has grown out of control. Anything more than small snippets that enhance a web page's performance start rapidly getting messy, making debugging a chore - whole applications based on this are the stuff of nightmares!

What the web desperately needs is a properly structured programming language that allows full implementation of basic requirements (eg: inheritance, properties etc.), rather than continual hacks that further twist javascript in an attempt to maintain it far beyond its scope or purpose.

13
6

Re: The clue's in the name...

SpiderBASIC (currently a very stable Alpha) looks interesting. Syntactically similar to the companies other more mature language "PureBASIC", SpiderBASIC *compiles* into JavaScript & CSS to allow rapid development of *WebApps* - check it out: http://www.purebasic.fr/english/viewtopic.php?f=14&t=58020

0
0
Silver badge

Getting started in programming

“If I was just getting started in programming, and I didn't know what language to pick, I would pick JavaScript,"

I think that would depend on what you want. If you want to learn a programming language that is used a lot, and in many contexts, and allows you to do some nice stuff quickly, JS is fine, I suppose. If you want to learn to programme, I am not sure JS is the obvious choice. We prefer to teach imperative programming first, and then proceed to OO and functional languages (and of course parallel programming). Other curricula start out at the OO level immediately. Whatever the order, once you understand the principles, learning any language that implements these principles is comparatively easy. Many of our students use JS without ever having taken an official course. We flatter ourselves that this may have to do with us teaching them the fundamentals.

8
0
Silver badge

Re: Getting started in programming

If you want to learn to program learn at least three different languages. Then if your language of choice doesn’t have some features you can add them.

And you can do OO in JS - people don’t but its not that hard.

Would have been a lot easier if certain companies hadn’t tried to kill it at puberty.

1
0
Silver badge

Re: Getting started in programming

“If I was just getting started in programming, and I didn't know what language to pick, I would pick JavaScript,"

Personally I tell people to start with Python. Sure, it's not real popular, but it has an advantage for newbie programmers that no other language I've seen has: it forces you to develop good whitespace management habits. (I have a friend who started by teaching himself C++ and never was introduced to the concept of using whitespace till he asked me for help with a program. The only reason he had multiple lines was because of word wrap in his IDE. It was frightening to say the least.)

Plus you can treat Python as a very simple language or as an OO language, so you get a couple different techniques with it. Once you learn one programming language (any language really) it's much easier to move on to others.

3
0
Silver badge

Re: Getting started in programming

it forces you to develop good whitespace management habits.

And that's why I have total disdain for Python's style. It might be a nice language, but I'm totally uninterested in any coding language that gives a shit about where and how many times I hit the spacebar, tab or enter keys (or even carriage return, to be a complete pedant). Especially after trying code samples from web sites or other media that may have mangled the original whitespace.

Good luck debugging that, especially if you're a complete newbie.

1
1

Page:

This topic is closed for new posts.