Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Javascript Pain Points

Steve Losh edited this page · 3 revisions

FOR THE LOVE OF GOD PLEASE GIVE ME NAMESPACES

(ns mylib.core
  (from mylib.util import a b c d)
  (import jQuery as $)
  (import backbone)
  (from mylib.todos import derp as herp))

Iteration Sucks

Iterating efficiently in Javascript is painful. Alienscript should have all the common functional iteration utilities.

map
filter
mapcat
drop 10
take 10
first
rest
last
butlast

What about lazy sequences? Those would be awesome, but complicated to implement.

Trailing Commas

It's 2011, why the hell are trailing commas in data structures still an issue?

[1 2 3]

{ a b
  c d }

Syntax Quirks Like == vs ===

== is evil and should be discouraged.

(= a b)
->
a === b

(kinda= a b)
->
a == b

Multiline and Raw Strings

Python supports "raw strings" and "multiline strings". They're awesome. Let's use them.

(let [s "foo"
      rs r"z\y\z"
      mls """foo
             bar"""] (log foo))

List Comprehensions

Python also has easy-to-read list comprehensions.

[expr for ...bindings... in expr]
[(capitalize name) for name in names]

Object Comprehensions

Python also has easy-to-read dictionary comprehensions. Let's use them for objects.

{ keyexpr, valexpr for ..bindings... in expr }
{ (get 'name' person) (get 'age' person) for person in people }

Logging

console.log is a pain to type. Let's make a log macro that you can just shove into any sexp to transparently log it.

(foo.bar)
(log foo.bar)

OMG Macros!

Yeah, these would be nice.

Something went wrong with that request. Please try again.