Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
cameronkknight
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
7 ms
·
1.
▲
by
cameronkknight
13y ago
Juxtaposition as an operator is already used by function invocation, e.g. f "Hello" If f were a string, how would I know I wanted to concat it instead of calling?
2.
▲
by
cameronkknight
13y ago
If I ever write JavaScript, then I definitely use JSHint. It doesn't help with some things such as immutable local bindings, type checking, not having to worry about hoisting, or any of the nice syntax features you get with GorillaScri
3.
▲
by
cameronkknight
13y ago
I feel it pretty much holds true when you try to compile any language that was designed without JavaScript in mind into JavaScript, the result is likely to be ugly and/or imperformant. (Not always, e.g. asm.js) GorillaScript is designe
4.
▲
by
cameronkknight
13y ago
Dart reinvents a full type system for itself, with its own environment and paradigms, and if you want to cross-compile to JavaScript instead of running in a dart VM, you have to ship a huge swath of code with it to get it working. GorillaSc
5.
▲
by
cameronkknight
13y ago
That could be possible, you could even do it today, if you wanted: macro operator binary ^$ ASTE $left bitxor $right There are also operators for `and`, `or`, `xor` which act logically. `not` which does a boolean invert. So t
6.
▲
by
cameronkknight
13y ago
Yes, I take a lot of inspiration (with some leeway for personal taste) from Delphi and C#, so I have great respect for Anders Hejlsberg - who I'm now competing with since TypeScript.
7.
▲
by
cameronkknight
13y ago
Actually, here's a better example, if you want defaults. Also nice is that it doesn't have to create a full defaults object at runtime, and each binding would only be evaluated if individually needed: let func-with-named-par
8.
▲
by
cameronkknight
13y ago
I'm very happy you're excited about it. The best thing you could do for me now is to use GorillaScript to make something. Anything. Something big, something small, something with fancy features or minimal ones. I want you to think
9.
▲
by
cameronkknight
13y ago
Currently, no. I do plan on adding warnings (not errors) on a statically-calculated type issue. One thing is that I don't plan on it erroring if you call a function with a value whose type might be an "any" type or a "un
10.
▲
by
cameronkknight
13y ago
I thought about it, but for the most part I used `~` as a way of referring to something in an unstrict way, e.g. `~+` doesn't typecheck, it just adds and auto-coerces both operands to a number. I didn't want to have `~` mean strin
11.
▲
by
cameronkknight
13y ago
Yeah, I hung out there. Also contributed a bit. No, most of my macro ideas come from Scheme.
12.
▲
by
cameronkknight
13y ago
Yeah, class Child extends Parent
13.
▲
by
cameronkknight
13y ago
They have made serious effort with developer tooling, especially with Source Maps.
14.
▲
by
cameronkknight
13y ago
I never claimed for GorillaScript to be a C-like language, because at its core, stripped of syntax, JavaScript is not a C-like language. It more resembles LISP with its macros and closures with nice syntax built around those concepts. I tri
15.
▲
by
cameronkknight
13y ago
Most of the time, string concatenation is unnecessary with interpolation: "$alpha $bravo" means alpha & " " & bravo. The reason `and` and `or` are best in parenthesized groups is that it creates confusion in the
16.
▲
by
cameronkknight
13y ago
Interesting work. Once I refactored GorillaScript to be pretty much fully macro-driven, it made everything super-nice to deal with. Every single syntax construct in GorillaScript is a macro, even `if` and all that stuff.
17.
▲
by
cameronkknight
13y ago
and= isn't all that useful, I agree, but it would be odd to leave out given that there's or=, ?=, ownsor=, etc. \alpha-bravo-charlie == "alphaBravoCharlie" Well, since GorillaScript doesn't require parentheses for i
18.
▲
by
cameronkknight
13y ago
GorillaScript has full support for Source Maps, as any good compile-to-JS language should.
19.
▲
by
cameronkknight
13y ago
Yeah, I stepped away from the Lua world to work on JavaScript-related stuff.
20.
▲
by
cameronkknight
13y ago
In production code, using & for string concat is pretty atypical, since you can use string interpolation: "$(alpha)$(bravo)"
21.
▲
by
cameronkknight
13y ago
Yes, you would, at least in the current state of things. I do plan on adding some compile-time checking (without getting in the way), but it's not there yet.
22.
▲
by
cameronkknight
13y ago
For named parameters, this is the best one can do in JavaScript without constructing a fully static type analyzer: let use-named({ name, age }) -> use-named(name: "ckknight", age: 25) For refinements, what are you referring to?
23.
▲
by
cameronkknight
13y ago
type-checking and such features can be easily disabled by sticking const DISABLE_TYPE_CHECKING = true at the top of your file. It's handy to have in development vs. production.
24.
▲
by
cameronkknight
13y ago
Types are allowed to be any of the primitive types (e.g. Boolean, Number, etc.), null, undefined, any custom "class", a specifically-typed array (e.g. [Number] for an array of numbers), or a specifically-typed object (e.g. {x: Num
25.
▲
by
cameronkknight
13y ago
If anyone would like to look at the slides for a presentation I did on GorillaScript, here you go: http://ckknight.github.io/gorillascript-presentation/ In it, I discuss some of the design decisions. Sadly, there wasn&
26.
▲
by
cameronkknight
13y ago
Macros can be scary. The need for five different syntaxes is because in a non-homoiconic language, positioning and syntax matter, so having an infix operator would be defined differently from a call-like macro. They all act fundamentally th
27.
▲
by
cameronkknight
13y ago
Bitwise operators for JavaScript are unused except in special cases, as JavaScript really doesn't handle bitwise as one might expect. Everything is cast to either int32 (or uint32 in the case of >>>) and then recast back into
28.
▲
by
cameronkknight
13y ago
Actually it does have list comprehensions. You just use a for loop (or any loop) as an expression and it evaluates to an array.