News for hackers. Stuff that matters.
Re:Programming Languages Are Simply Not Powerful Enough by rayiner on Friday March 01, 2013 @12:45AM (#5303013)
The popularity of programming languages is entirely a matter of historical accident. C flourished while Pascal languished because UNIX was written in C. Was there really a deep technical reason for preferring C to Pascal? No, not really. Indeed, for most of early history, Pascal had far superior tooling to C.

How else do you explain the popularity of languages like Javascript and Objective-C? Javascript is an objectively terrible language, hacked together by Brendan Eich in an afternoon. Yet, it's a tremendously popular language, and tremendous amounts of money and time have gone into building good tooling for it. Same thing with Objective-C. It's a shitty, ad-hoc, cobbled-together patchwork of C and Smalltalk, yet it's tremendously popular now because that's what the iPad is programmed in.

Re:Programming Languages Are Simply Not Powerful Enough by bad_user on Friday March 01, 2013 @03:28AM (#5303382)
Pascal (or more precisely Borland's version of it) was my first programming language that I learned in school. I also used it when I was participating in the CS Olympiads.

Going from Pascal to C was like a breath of fresh air. Pascal is like a combination of everything I hate in all programming languages that I know and I'm glad that the world moved on. C is small, elegant and portable. It's a systems programming language that does what it's supposed to do.

> Javascript is an objectively terrible language

Our tastes are different and all proof to the contrary, as Javascript proved that it's an objectively good programming language, that has been burdened with legacy, incompatibilities due to the browser wars and more recently slow evolution due to its huge popularity and the stagnation of IExplorer. It has quirks and it isn't what it should have been, but considering the context it's the best outcome we could have had.

Name one other programming language that's (1) a true standard governed by a standards body with multiple platform-independent implementations and (2) has less problems than Javascript.

With Javascript your argument falls flat on its head too, because all of the competing technologies failed because of really good technical and political reasons ... lets not forget VBScript, Java Applets, Flash and Silverlight. Yes, technologically speaking Javascript was and is better than all of them.

Re:Programming Languages Are Simply Not Powerful Enough by PommeDeTerre on Friday March 01, 2013 @07:49AM (#5303960)
There are a lot of problems (not merely "quirks", but outright problems) with JavaScript that have absolutely nothing to do with past or present browser-based implementations. They're problems that are inherent to the language itself.

I'm talking about things like its extremely broken equality operators, its extremely broken array handling (especially the behavior of the length property), semicolon insertion, its broken scoping, its lack of support for proper class-based OO, its lack of support for proper namespacing and modularity, its lack of proper typing, and so forth.

These are far worse, and in many cases much stupider, than any problems we see with C, C++, Java, C#, Python, Ruby, Erlang, Perl, Haskell, Scheme and whatever other mainstream or semi-mainstream language you want to choose.

PHP is perhaps the only widely-used language that exhibits the same kind of idiocy when it comes to many core features. But at least it has been moving in the right direction, with its much more sensible support for OO and namespaces, for instance. We keep hearing about how ECMAScript 6 will finally bring at least some sensibility, but this is still very much up in the air.

It's incorrect to say that JavaScript is an "objectively good programming language". It's objectively terrible, and all of the evidence proves this very conclusively.

Re:Programming Languages Are Simply Not Powerful Enough by AnIrishDuck on Friday March 01, 2013 @12:45PM (#5305710)
Most of your peeves are addressed by correctness checkers like JSLint, or have been alleviated by community projects. There's a lot of hate here, so I'm going to address your points one by one:

> I'm talking about things like its extremely broken equality operators,

Don't use language features that are broken. Use === and !== instead. JSLint complains about this.

> its extremely broken array handling (especially the behavior of the length property),

You're going to have to elaborate here, I have no idea what you're talking about.

> semicolon insertion,

Put semicolons at the end of each line manually. Or don't use crazy multiline expressions. JSLint will flag this down for you. Other languages like C force you to do this, why the JavaScript hate?

> its broken scoping,

Never put things in the global scope. Always use var. Global-by-default is annoying, but very easy for static tools like JSLint to flag and nag about.

> its lack of support for proper class-based OO,

Javascript's objects are very minimal; they can easily emulate semantics of other OO languages. In my code I usually emulate the Python copy-superclass-on-class-creation semantics of subclassing.

> its lack of support for proper namespacing and modularity,

RequireJS has effectively solved this problem for me. As per above, you should never put things in global scope anyway.

> its lack of proper typing,

If you're looking for built-in static typing, you came to the wrong place. I think it's important to remember that JavaScript the language was designed to be very minimal (IIRC the entire initial language was created in a week); in that regard, it at the very least is not a good fit for static typing. I personally wish that it had stronger types, and can agree with you here that ideally this would be different.

> and so forth.

I guess I don't see your concerns here. I prefer writing JavaScript over C and Java; it allows me far more leeway for creating abstractions through closures and anonymous functions. Think of JavaScript's problem statement: create a simple minimal universal browser-based language. It's hard to imagine a better language in JavaScript's place (Scheme is the only realistic alternative I can think of). Here's a nightmare scenario for you: we could have ended up with Visual Basic instead.

JavaScript isn't perfect, but what language is?

Re:Programming Languages Are Simply Not Powerful Enough by KingMob on Saturday March 02, 2013 @02:27PM (#5310666)
While I don't quite agree with the parent poster, half of your points involve a) best practices, which require programmer discipline, not parser smarts, b) a lint-checker, which again, is not as good as the parser itself forbidding something, or c) using certain libraries, which is not as portable and easy as direct language support.

While I agree that these issues are surmountable, I don't think you've rebutted the point that they are issues with the language itself.

That being said, no language is perfect and for being whipped up in a day, Javascript's pretty nice.

Re:Programming Languages Are Simply Not Powerful Enough by pjmlp on Friday March 01, 2013 @03:58AM (#5303441)
> Going from Pascal to C was like a breath of fresh air. Pascal is like a combination of everything I hate in all programming languages that I know and I'm glad that the world moved on. C is small, elegant and portable. It's a systems programming language that does what it's supposed to do.

I hate C with its lack of proper arrays handling and brain dead string manipulations that open the door to so many security exploits. Additionally the lack of modules/namespaces is a joke.

Mac/Turbo Pascal, Ada, Modula-2, Modula-3, Oberon(-2) are all examples of system programming languages done right.

Re:Programming Languages Are Simply Not Powerful Enough by PommeDeTerre on Friday March 01, 2013 @07:56AM (#5303984)
C's array and string handling is extremely compact and powerful in many ways. It does, however, require at least some understanding of pointers. But once you understand how it all works, you can do significant string manipulation with relatively little effort, while still retaining exceptional runtime performance and minimal memory usage.

That said, if you're the kind of person who doesn't understand pointers, there are numerous libraries out there that'll provide a variety of functions for working with arrays and strings more easily. C itself doesn't prevent you from using these alternate approach, but rather it enables them.

Re:Programming Languages Are Simply Not Powerful Enough by sixbrx on Friday March 01, 2013 @09:26AM (#5304323)
The problem with C, for most application domains, is not that it requires pointer knowledge, but that it requires constant attention to this knowledge.

Combined with the fact that there's no warning when you've stepped outside the bounds of an array, I think makes it an extremely dangerous language to use for large scale programming.

Years back, a friend was maintaining a system collecting and processing scientific data, in C. Several papers have been published on this data over the course of many years. I remember the sinking feeling we both got - mixed with real fear - when he told me he had discovered an error where an array's bounds had been miscalculated. I don't even want to think about the possible ramifications of that...

For some application domains low level control is necessary of course, or for others the performance gain may make the tradeoff worth the cost.

Re:Programming Languages Are Simply Not Powerful Enough by bad_user on Friday March 01, 2013 @10:25AM (#5304661)
The problem of people building on top of C is that C is not a language meant for applications. A system collecting and processing scientific data is too high-level for a language like C.

In fact no application should be written on top of a language that doesn't do garbage-collection by default, unless you've got the resources of big companies. Any language that doesn't do garbage-collection by default is dangerous for large scale programming.

On array bounds checking, you can't do such bounds checking at compile time, so you have to rely on runtime checks and metadata. As my highschool professor kept telling us, C is a medium-level programming language. It's optimized for moving bits around in memory, while the code remains reasonably platform-independent. Adding array-bounds checking by default doesn't make sense for a language like C, because it stays in the way of moving bits in memory.

Re:Programming Languages Are Simply Not Powerful Enough by pjmlp on Friday March 01, 2013 @11:06AM (#5304988)
> Adding array-bounds checking by default doesn't make sense for a language like C, because it stays in the way of moving bits in memory.

Any proper language for systems programming allows to turn off bounds checking if required-

This is the way it should be done, disabling the bounds checks on the few spots that require them being disabled, after profiling if they being on really affects the performance of the application.

Re:Programming Languages Are Simply Not Powerful Enough by sixbrx on Friday March 01, 2013 @11:35AM (#5305194)
I think we're in violent agreement. It's not the language it's the usage outside of where it's appropriate.
Re:Programming Languages Are Simply Not Powerful Enough by pjmlp on Friday March 01, 2013 @11:07AM (#5304996)
All the languages I mentioned have the same expressive power as C for pointer manipulation, when required to do so, while being a lot safer by default.
[deleted]
Re:Programming Languages Are Simply Not Powerful Enough by lucian1900 on Friday March 01, 2013 @06:55AM (#5303822)
While they are both flawed, JavaScript is nowhere near as terrible as PHP.
Re:Programming Languages Are Simply Not Powerful Enough by pjmlp on Friday March 01, 2013 @03:51AM (#5303432)
> The popularity of programming languages is entirely a matter of historical accident. C flourished while Pascal languished because UNIX was written in C. Was there really a deep technical reason for preferring C to Pascal? No, not really. Indeed, for most of early history, Pascal had far superior tooling to C.

C and Pascal were developed almost in parallel.

Being the UNIX's systems language, it meant if you wanted to develop on UNIX C was the default option for most developers.

> How else do you explain the popularity of languages like Javascript and Objective-C?

There is no other option to target the browser, as JavaScript is the only language natively supported in browsers.

Objective-C is the only proper way to develop iOS applications, thus you need to use it if you really want to fully explore the platform.

All the languages you mentioned only became famous because developers were forced to use them commercially.

Back in the MS-DOS days I had zero need for C, Turbo Pascal was enough for everything (with a bit of Assembly).

But the commercial sucess of UNIX meant eventually I was forced into the realms of C. Luckily C++ was around the corner and provided an escape path for a saner language.

I still miss Pascal and the derivative language (Ada, Delphi, Modula-2, Modula-3, Oberon(-2), Active Oberon).

Re:Programming Languages Are Simply Not Powerful Enough by mturmon on Friday March 01, 2013 @02:30AM (#5303260)
The version of Pascal I learned on (early 1980s) had the problems Kernighan refers to in this piece:

http://www.lysator.liu.se/c/bwk-on-pascal.html

Most awfully, "length of the array is part of the type of the array". This made some programming rather painful (strings and numerical programming, for example). Maybe other dialects of that time didn't have this problem, I don't know. I do know I found C to be a great relief.

Javascript is a good example of historical accident, on the other hand. It's got just enough extensibility that its flaws can be worked around. But its popularity is not due to its careful design.

Re:Programming Languages Are Simply Not Powerful Enough by krichman on Friday March 01, 2013 @01:22AM (#5303116)
I upvoted you for talking about historical accident, but regretted it when you started in on Javascript and Objective-C. Yes they have some questionable decisions but they are by no means objectively awful.
Re:Programming Languages Are Simply Not Powerful Enough by rayiner on Friday March 01, 2013 @01:33AM (#5303137)
Given that Javascript was designed in 1994, not 1974, I think it rises past "questionable design decision" not to just use Scheme's lexical scoping rules (i.e. the only sensible lexical scoping rules). Although to be fair, scripting language designers keep getting this wrong for some reason.
Re:Programming Languages Are Simply Not Powerful Enough by mercurial on Friday March 01, 2013 @04:35AM (#5303520)
Frankly, 'var' is fine most of the time. Keep writing small functions and all that. Besides, you have 'let' now.

I have much a bigger beef with the type system (or lack thereof), the array-and-hashes-as-one-datatype stupidity and the lack of a module system.

Re:Programming Languages Are Simply Not Powerful Enough by krichman on Friday March 01, 2013 @03:29AM (#5303384)
Yeah that's a problem. I thought you could get proper scoping by writing "var" in front of everything?
Re:Programming Languages Are Simply Not Powerful Enough by mercurial on Friday March 01, 2013 @04:32AM (#5303512)
That's function scope, not block scope. You can use the "let" keyword to get block scope since Javascript 1.7.
Re:Programming Languages Are Simply Not Powerful Enough by PommeDeTerre on Friday March 01, 2013 @08:10AM (#5304028)
It still took over a decade to get what should have been available from the very beginning. That's a pretty serious problem that repeats time and time again with JavaScript.
Re:Programming Languages Are Simply Not Powerful Enough by mercurial on Friday March 01, 2013 @11:02AM (#5304952)
Oh, definitely. But I haven't found it overly problematic in practice. I'll point out that Python, a language much more appreciated than Javascript on HN, has no scope smaller than function scope. Which is mostly fine as long as you stick to small functions, which you should anyway.
Re:Programming Languages Are Simply Not Powerful Enough by alpatters on Friday March 01, 2013 @04:19AM (#5303485)
Well you have missed the point that they chose C over Pascal to implement Unix. I don't think that was by accident.
Re:Programming Languages Are Simply Not Powerful Enough by arthurrr on Saturday March 02, 2013 @03:21AM (#5308945)
To call Objective-C a shitty language is, oh I don't know, really really ignorant. It's one of the nicer languages in my opinion.