Show HN: Language proposal - dave
davelang.github.com
davelang.github.com
For those who haven’t seen it, the Programming Language Checklist[1] is worth a read. Forgive me my cynicism, but I don’t see the point of Yet Another Block-Structured Imperative Language. It’s nice, and there’s nothing wrong with it, but nothing really sets it apart, and I for one value innovation more highly than remixing.
As for the "yet-another" argument - I know. Convincing developers to switch to a language that is not leaps-and-bounds ahead of their choice language is hard to impossible. The reality is that I'm simply not happy with any of my options and decided it would be an interesting experiment to write my own. I'm not planning on writing any serious applications in it myself -- unless somehow it can pick up a community.
The remixing though I find interesting. This is simply an attempt at making something "better" than the other options. Languages get stuck with broken features in order to maintain backwards compatibility. I see this as a way to take the good parts of any languages and turn it into something I would like to use. I'd rather stick with what works.
[1] http://yannesposito.com/Scratch/en/blog/Yesod-tutorial-for-n...
First--try to make the language as small as possible and as extensible as possible. This means that print should be a normal function rather than a statement and you should be able to add your own types of string encoding.
The ?: operator seems identical to || in JavaScript; I am not sure why you want to have it.
I think having functions return the value of their last statement by default (e.g. making the return keyword optional) makes writing code in a more functional style simpler.
In this same vein, you should have a nice and compact lambda syntax--one of the most annoying things with JavaScript (a language I happen to really like) is that even the simplest of anonymous functions is long, which makes certain types of code harder to read. I personally like Haskell's style (where \ x -> x is the same as function (x) { return x } in JavaScript), but anything short would work.
If everything else uses curly brackets, why does the for loop have a colon? I think you'd find this[1] post by Brendan Eich about braces interesting.
[1]: http://brendaneich.com/2010/11/paren-free/
Have you considered using Haskell's syntax for comprehensions over Python's? I find the former easier to read and it's more extensible. Where in Python you would write [x for x in xs if x > 10], in Haskell you would write [x | x <- xs, x > 10]. This doesn't look much different, but is easier to read in more complex cases. The Haskell syntax can also be used for what they call "parallel list comprehension" which act like a zip rather than a cross product. (So zipWith fn xs ys would look like [fn x y | x <- xs | y <- ys] while the normal version would be [fn x y | x <- xs, y <- ys].)
As far as object oriented features go, if you like JavaScript's approach, take a look at Lua's tables.They're similar to but more flexible than JavaScript's objects.
Something like pattern matching or at least "destructuring assignment"[2] would be nice as well. This makes certain types of code much easier to read and write.
[2]: https://developer.mozilla.org/en/New_in_JavaScript_1.7#Destr...
Overall, I like your idea and wish you luck implementing it.
I want to point at the start of a statement/expression, ask "where does this end?", and get back a single, general answer, like "at the semicolon" or "at the corresponding closing parenthesis".
That is what punctuation is for. Imagine reading an english text with no punctuation, where the author just made sure to end a line wherever he wanted a sentence to end. Do you really want to stop at each line end and have to answer the question whether it ends the sentence?
Yeah, s-expressions should be more widely adopted.
I don't think this is a good analogy considering that each statement usually go on a separate line. Punctuation is helpful if there are multiple statements on the same line, but finishing each statement with semicolon and new line just adds noise.
http://wiki.ecmascript.org/doku.php?id=harmony:quasis
http://www.2ality.com/2011/09/quasi-literals.html
I think they are going further because they can do auto-escaping. From what I see of your language, you still have to do html:"$var". What happens if you mis-type the prefix? Do you get incorrect escaping and a security hole? Some web devs won't even know what language they're writing in.
FWIW I don't think it's worth building an entire language around this concept. It's a feature, not a language. I think using Python plus a template language with good escaping basically solves the problem.
Also, it would be weird if html: and sql: are built in to the language -- that should be a layer on top of a smaller language (just like quasi-literals).
Also, a server-side language with special escaping support doesn't seem compelling, because these days you would want special escaping support on the client too. I'm not sure of the status of quasi-literals, but if they make it into V8 then Node.JS will have this feature on the server.
Basically, having something like var lets you nest scopes. So you can have, say, nested functions and work with variables declared above your current fucntion but not in the global scope.
If you leave out the var, you'll end up with Python's idiotic scoping, which is annoying. (They've added a nonlocal keyword in the new version in an attempt to fix it, but it's still relatively clumsy and awkward.)
Coincidentally, if you use the strict mode in JavaScript (with "use strict";) it will prevent you from using global variables implicitly. This makes it even more clear that var and JavaScript behavior regarding global variables are orthogonal.