having to explicity declare variables as local really clutters the syntax of what could be a very simple and easy to language to work with. New Javascript compilers like V8, Spidermonkey, dscript are just as fast and embeddable as Lua, Id rather use that. I prefer the syntax of Ruby to Lua also.
I like the syntax for using a closure as an iterator, and how multiple return values are handled, but I suppose you can find this in a lot of other languages too.
>>11 define "good"
not OP, but if youre stuck on an island with a solar powered laptop and you have the choice of only the following compilers, which do you pick:
Perl
PHP
Python
Ruby
Lua
Javascript
which do you pick? and lets assume their are no libraries that go along with the compiler except simple I/O, no CPAN in Perl, no "batteries included" in Python. No cheating like writing a Lisp interpreter in one of these languages
>>10 having to explicity declare variables as local really clutters the syntax of what could be a very simple and easy to language to work with. New Javascript compilers like V8, Spidermonkey, dscript are just as fast and embeddable as Lua
var var var var
let let let let
Name:
Anonymous2011-07-25 19:03
>>15
var is optional in Javascript, I dont use it, I dont use ; delimiters in Javascript either.
let in functional languages is a good feature, its wasted on a simple scripting language like Lua
Name:
Anonymous2011-07-25 19:15
>>16
If you never use them, then you probably don't understand when you should use them, which means you're probably a shitty programmer.
What about scripting languages for embdedded, resource-constrained systems? Most of the suggested languages are way too heavy, and Lua at least has the reputation for causing excessive heap fragmentation (though I believe this has been improved somewhat).
>>19 Lua at least has the reputation for causing excessive heap fragmentation
what. maybe as compared to assembly/C.
Name:
Anonymous2011-07-25 20:35
>>17 If you never use them, then you probably don't understand when you should use them, which means you're probably a shitty programmer.
ok, when should I use them? I dont think it affects scope in any way
>>22
to answer my own question, I just found out variables declared inside functions are not local to that function unless declared with var
Name:
Anonymous2011-07-25 22:22
>>22 var does affect scope. Observe (from the Chromium JS console):
var a = 42; (function() {var a = 66;})(); a;
42 var a = 42; (function() {a = 66;})(); a;
66 (function() {var b = 99;})(); b;
ReferenceError: b is not defined (function() {b = 99;})(); b;
99
So essentially, every variable in your program is global. It's wasteful and can lead to bugs, especially if those variables contain DOM elements.
Name:
Anonymous2011-07-25 22:23
>>24
and Lua has the exact same behavior except that "local" is 2 more letters to type.
>>24
>So essentially, every variable in your program is global. It's wasteful and can lead to bugs, especially if those variables contain DOM elements.
which is why I use the coffeescript syntax translater, because it fixes that problem
Name:
Anonymous2011-07-26 0:01
>>27 coffeescript
Oh god. Macbook with Textmate as your editor, correct?
Moving right along...
Name:
Anonymous2011-07-26 0:06
Oh god. Macbook with Textmate as your editor, correct?
no I dont use all the "make js look like haskell" features of coffeescript like:
square = (x) -> x * x
I just use it because I think variables inside of functions should be local to that function by default, anything else is absurd
Name:
Anonymous2011-07-26 3:04
>>29
does it do it the Ruby way or the Python way?
that is to ask: does it disallow shadowed variable names or does it have a pig-disgusting "nonlocal" keyword?
>>29
You don't use the only features that make Coffeescript nicer than JS?
Name:
Anonymous2011-07-26 20:50
>>30 does it do it the Ruby way or the Python way?
Coffeescript starts lexical scope at the point of inititialization, I dont know how its done in Python or Ruby
indentation is used instead of curly braces, as in Python and Haskell.
Don't want.
Name:
Anonymous2011-07-26 23:20
C/C++
printf("Matthew says 'Ba-ba-ba!'")
CoffeeScript:
class Human
constructor: (@name) ->
class Baby extends Human
say: (msg) -> alert "#{@name} says '#{msg}'"
say_hi: -> this.say('Ba-ba-ba!')
matt = new Baby("Matthew")
matt.say_hi()
Name:
Anonymous2011-07-26 23:29
>>41 Implicit variable declarions:
Kaffeine (like most other scripting languages) does not require variables to be declared, as (let (x 123) ...) in Lisp or int x = 123 in C/C++. This means that Python can't even detect a trivial typo - it will produce a program, which will continue working for hours until it reaches the typo - THEN go boom and you lost all unsaved data. Local and global scopes are unintuitive. Having variables leak after a for-loop can definitely be confusing. Worse, binding of loop indices can be very confusing