Hacker Newsnew | comments | show | ask | jobs | submit login

I am impressed but I'm also wondering why people try to avoid learning new stuff -- to potential downvoters, no rant intended. I am just surprised how many people try to circumvent JS: Rubyists with Coffee, Closurists with ClosureScript, etc. instead of just using JS directly. I don't believe the main motivation is JS' potential inferiority and that you could employ much better design pattern with languages compiling to JS. Neither, JS' syntax is bad or ugly. I assume that's it's the fear of learning something new, to be again a beginner. JS has its quirks but in general it's a very modern and beautiful language and offering more innovation than traditional scripting languages. And V8 is so blazingly fast that I sometimes think this feels more like C compiled code which would be just another reason rather to switch to JS in the backend.



>JS has its quirks

Indeed it does. Its one of the hardest modern language I have ever tried to teach someone. All the minor trip-wires (like http://stackoverflow.com/questions/1995113/strangest-languag...), but the worst part is that there are always at least 5 ways to do something.

Out of those 5, two is bad and should never be done but you would be lucky if any book mention this fact. Of the three left, only two is ever considered as good through noone can agree which one is the preferred way. One solution ends up being neither hated or praised enough to be worth mentioning in a book or ranting article.

So to figure out which ones to avoid, and which ones to use, one can either use what ever superstitious choice one learned by a previous teacher, or read massive amount of javascript articles and books to get a "feel" for it (no guarantee through). When you try to teach a student all the different methods, they will get information overload so one is simply forced to avoid large part of the language and hope they act like "don't think, just do what I say".

Python in the browser would just be a clear improvement over javascript.

-----


You chose a good example showing that JS is not perfect but I think every language has some quirks and needs time and energy to get familiar. Of course such strange behaviour demotivates beginners and yes JS can be hard but it's still a great language and there so many good parts you didn't mention. Besides, teaching a language is also very hard since the best way to learn a language is practise, practise, practise and having problems: sometimes when I am stuck with a problem for hours or even days, googling, asking on IRC, StackOverflow I gain so much knowledge I wouldn't get in a 2h class.

-----


Accusing everyone who avoids javascript that they can't be bothered to learn it is pretty extreme.

I personally would choose any other modern language over javascript.

ANY.

I've learnt it and used it 8 or 9 years now, to me it just sucks. And still no-one knows how to write it well, no-one agrees how to structure it and every 2 years there is a whole new way to write javascript that comes out. I'm beginning to suspect it's because there is no good way to write it.

-----


I can't speak to ClojureScript, but in my experience, CoffeeScript is primarily used by people who already know JavaScript. You can't use CoffeeScript effectively without understanding JavaScript. Most of us who use CoffeeScript instead of JavaScript appreciate CoffeeScript's syntactic shortcuts, which for us makes it quicker to write and improvise with new ideas, as well as its enforced whitespace, which makes it easier to write maintainable code.

Otherwise, as someone whose first and second strongest languages are Python and Javascript, I agree with you. JavaScript is a beautiful language that accommodates a variety of programming styles. As you mention, JavaScript is also much more performant than Python, which makes me questions whether Python would ever be a viable replacement for JavaScript in the browser. Add to that JavaScript's excellent webworker API compared to Python's choices for parallel programming.

Now, Lua, on the other hand, would be an excellent browser language (specifically the LuaJit implementation). Lua is close enough to JavaScript that folks could easily pick it up, and its blazing fast. But it will never happen.

Besides, there are so many great JS libraries now that in most cases, I wouldn't want to switch to Lua in the browser and face re-inventing the wheel (same reason why I generally use Python instead of Lua elsewhere). But its fun to think about.

-----


> JavaScript is also much more performant than Python

This is not true. Some Javascript _implementations_ are definitely faster than some Python _implementations_, but nothing about either language makes one inherently faster than the other.

And in the Brython case, the Python is being translated to Javascript, so it is getting the same benefits out of a fast, JIT-compiled implementation that Javascript normally gets.

-----


> nothing about either language makes one inherently faster than the other

You can't make such a statement confidently unless you examine the specs of both languages.

For example, Python integers promote to bigints automatically while JS numbers don't. For one more, in Python you can overload attribute access, while in JS you can't. Both of these are language features rather than implementation details, and both potentially affect performance. There are probably others.

-----


> makes it quicker to write and improvise with new ideas,

I've never thought about that but could make sense.

> as well as its enforced whitespace, which makes it easier to write maintainable code.

This is something I've never understood and where I tend to disagree. When starting with "whitespace" languages like Coffee, Ruby or Python people initially are please with clean and tidy looking code but in the long run this code is not maintainable since all the white space makes the code looking not distinctively enough. In contrast, bracket based languages like C or JS give much better orientation. I can quickly see where code blocks start or I can immediately recognise functions etc.

> Lua, on the other hand, would be an excellent browser language

Totally agree

-----


"in the long run this code is not maintainable since all the white space makes the code looking not distinctively enough."

Where do you get this? The only instance where I see Python becoming unreadable due to whitespace is when a developer abuses whitespace where it's not needed e.g. a = [ 'a', 'list' ]

Another example could be chaining method calls Java-style, but all of this is alleviated by just following PEP8.

The significance of whitespace has no effect on the readability of a language.

-----


Ruby is not a significant indentation language. do not comprehend how Indentation is not visually distinctive.

-----


I didn't mean the indentation, I meant leaving away brackets.

-----


CoffeeScript doesn't try to circumvent JavaScript, it tries to enhance JavaScript. Its constructs and clarity boost my productivity, especially in large projects. Though I wouldn't recommend it to someone who hasn't learned JavaScript yet.

-----


> I am impressed but I'm also wondering why people try to avoid learning new stuff (...)

Quite the opposite. The more you learn about Javascript, the more you realize how it's a giant hack.

> Neither, JS' syntax is bad or ugly.

Languages are more than syntax. The problem is the excess of boilerplate, lack of good APIs and general lack of consistency.

Tell me a language where this is acceptable: https://gist.github.com/4471029

-----


> Tell me a language where this is acceptable: https://gist.github.com/4471029

=> Underscore, 4KB in production and gives you _.sortBy and _.difference among other amenities

-----


It's two things: 1. Sharing code between server and client 2. JavaScript sucks, badly. Many people would really much rather not have to deal with its many, many flaws.

-----


Its rather the other way around; a lot of people who must target the browser, and do learn Javascript, would rather not be using Javascript. This is why there are so many alternatives being baked up - clearly the people baking them up are scratching their own itch and are competent at JS.

-----




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: