News for hackers. Stuff that matters.
Re:How to Pick a Language by jballanc on Thursday January 22, 2009 @10:07PM (#445858)
Nice and thorough. I only have two qualms:

1. Reading through the Matz book on Ruby (http://oreilly.com/catalog/9780596516178/index.html), there's a very good explanation as to why Ruby/Python/Perl are "scripting" languages as opposed to "programming" languages: no main! That is, whichever file is fed to the interpreter is run (with some exceptions) in order. So these are, and probably always will be, scripting languages.

2. The author vastly underestimates the importance of Javascript...

Re:How to Pick a Language by kragen on Friday January 23, 2009 @01:57AM (#446087)
So if you can just put the main program statements into the file without wrapping it in a function or anything, it's a "scripting language", but if you have to wrap it in a main() function or something, it's not? That's a definition of "scripting language" that includes x86 assembly for MS-DOS .COM files as a "scripting language", but excludes VBScript macros for Microsoft Word, I think.

Now, I don't know what you think, but these two languages seem to me to be almost perfect exemplars of the opposite extremes from how this definition would classify them. x86 assembly for .COM files has no type checking, no type coercion, no strings, no hash tables, very little in the way of runtime support (it pretty much owns the whole machine when it's running, under actual MS-DOS anyway, and you have to build everything yourself), takes months to learn enough about a computer to program in, typically is only used by fairly hard-core programmers, and there are no compatible interpreter implementations. VBScript is strongly dynamically typed, has strings, is used to "script" an existing application, runs in an interpreter, and is typically used by people who don't think of themselves as programmers.

So I suggest that Matz's definition may not really express what people are normally thinking of when they say "scripting languages".

Re:How to Pick a Language by jballanc on Friday January 23, 2009 @11:45PM (#447763)
Yes, but then people are conflating notions of type-system/runtime/vm/etc. with the notion of script vs. program. The key distinction is this: In a programming language you can only have one entry point (the "main()" function), regardless of how the individual files are linked. In a scripting language the entry point depends on which file the interpreter starts with, and the execution model can change depending on how the script is invoked.

For example, the Ruby community uses this trick quite often so that one file can be a library if included by another source file, but can be an executable if invoked by the interpreter directly. See: http://gist.github.com/51337. If you run "ruby a.rb" you'll get something different than if your run "ruby b.rb", even though both are the result of "linking" a.rb and b.rb together.

...let's see you do that with C! ;-)

Re:How to Pick a Language by kragen on Saturday January 24, 2009 @06:11AM (#448009)
This is a different distinction than the one the other poster reported that Matz proposes, but it's not useful either. You can do it in C, even without using the preprocessor; see http://gist.github.com/51416, which does it with weak symbols. Worse, whether C is a "scripting language" or not depends only on the presence or absence of such trivial features.

Your distinction would make Java a "scripting language," because every class can have its own main function, and still leaves x86 assembly as a "scripting language", and now it makes GNU C a "scripting language" too; and given the nondeterministic invocation order of the constructors of static objects, it makes any particular C++ implementation a "scripting language" too.

Re:How to Pick a Language by jballanc on Saturday January 24, 2009 @10:18AM (#448154)
So, I think you're focusing too much on the specific example and not enough on the runtime distinction. The C runtime looks for "main()". If you trick it into looking in different places for it, that's a trick. Ruby (and other scripting languages) goes through the source file sequentially, executing statements and definitions as it goes. There isn't a specific symbol for it to look for. (Well, there is, but that just complicates matters.) The point I'm trying to make is that the distinction between scripting language and programming language shouldn't rely on how it's used, but rather on how it's formatted.

...and by the way, I would consider x86 assembly a scripting language. You're just scripting out the processor's actions...

Re:How to Pick a Language by kragen on Saturday January 24, 2009 @06:51PM (#448536)
I can't prevent you from using that definition of "scripting language" but I don't think it has much in common with the usual meaning of the term.
Re:How to Pick a Language by bioengineer on Saturday January 24, 2009 @03:42AM (#447908)
If I am understanding you correctly, I believe that it is possible in C, using macros. If you include the following in each file:

#ifndef MAIN_ALREADY_DEFINED__

#define MAIN_ALREADY_DEFINED__

int main(){

/* file specific stuff */

}

#endif

Disclaimer: I wouldn't actually do this in practice...

Re:How to Pick a Language by jimbokun on Thursday January 22, 2009 @10:43PM (#445887)
Interesting way to define "scripting" languages.

I didn't mean to underestimate JavaScript, which is why I gave it its own section. Perhaps I was too brief? Implication that its only useful in the browser?

Re:How to Pick a Language by alecco on Thursday January 22, 2009 @11:41PM (#445944)
Love it or hate it, Javascript:

* Is the language having the most important performance gains lately.

* Growing support from both corporate (Yahoo, Apple, Google) and free software (Mozilla) camps.

* Gains market with HTML 5 (just the canvas element alone makes a huge difference for JS based software.)

* Better frameworks for both UI and client-server software.

It's funny how things turn.

Re:How to Pick a Language by catch23 on Friday January 23, 2009 @04:49AM (#446210)
Yeah, it's strange how only 2 years ago or so, both ruby and javascript scored rock bottom on Alioth Shootout, with javascript scoring 4 times slower than ruby, and ruby 3 times slower than python. Two years later and there's 7 interpreters for ruby and 4 for javascript.
Re:How to Pick a Language by silentbicycle on Friday January 23, 2009 @09:44AM (#446408)
There's something to be said for trying to make an expressive language and worrying about how to make it efficient later. Only working with stuff you know you can do efficiently can lead to getting stuck in local maxima.
Re:How to Pick a Language by igouy on Monday January 26, 2009 @12:50PM (#450721)
> ... rock bottom on Alioth Shootout ... Two years later ...

Are they still rock bottom?

Re:How to Pick a Language by jballanc on Friday January 23, 2009 @11:24PM (#447745)
Javascript is a bit of an enigma. Usually, bad languages are made better (or at least tolerable) by the existence of good libraries (see C++, Perl). In the case of Javascript, it's a really elegant language made worse by being so often so dependent on the DOM and all of it's obscurities.

I admire Javascript because it covers so many paradigms, and yet is, at the core, very simple and straightforward. Much as Lisp is to lists, Javascript is to hashes. Also, there are some really interesting projects in early stages that are taking Javascript out of the browser. For example, when Google released the code for v8, Marc-André Cournoyer from the Ruby community slapped together a project that translated Ruby to JS and ran it through v8 (http://macournoyer.wordpress.com/2008/09/02/ruby-on-v8/).

Finally, I think it's worth noting that if you believe the "cloud" is the future, then Javascript is the de facto machine code of the "cloud"...