Live data from Hacker News

CoffeeScript for TypeScript

civet.dev

11–20 of 143 posts

Re: CoffeeScript for TypeScript

#11

Under "Everything is an Expression": items = (() => { const results = []; for (const item of items) { if (item.length) { results.push(item.toUpperCase()); } else { results.push(" "); } } return results; })(); Seems like they are purposely making the JS version extra long. It could be: items = items.map(x => x.length > 0 ? x.toUpperCase() : ` `) Edit: Just realised the code on the right is the compiled code, not the "…

My kingdom for "everything is an expression" in JS/TS, but that would likely require an entirely new language.

At some point you might as well just use lisp, right? :D

Re: CoffeeScript for TypeScript

#15

Under "Everything is an Expression": items = (() => { const results = []; for (const item of items) { if (item.length) { results.push(item.toUpperCase()); } else { results.push(" "); } } return results; })(); Seems like they are purposely making the JS version extra long. It could be: items = items.map(x => x.length > 0 ? x.toUpperCase() : ` `) Edit: Just realised the code on the right is the compiled code, not the "…

Your version doesn't correspond to the code written on the left side.

Re: CoffeeScript for TypeScript

#17
Not the first time I see the proposed pipe operator syntax but oh my god, did they have to make it so messy?

  data
    |> Object.keys
    |> console.log
when you could have done

  |> data
     Object.keys
     console.log
Or even better, don't introduce new syntax and just make it a simple function instead

  |>(data,
     Object.keys,
     console.log))
Yes yes, I know "|>" is not a legal variable/function name right now, but also, why not?!

Re: CoffeeScript for TypeScript

#18

If I were going to do this, I’d probably go all the way to using ReScript, but it’s a nice idea. I’m quite surprised it’s not called ToffeeScript though.

+1 for tofeescript.

'Civet' certainly implies your code is being processed, but I'm not sure the connotation is desirable.

And all IMHO of course, but significant-whitespace is the worst idea ever.

Re: CoffeeScript for TypeScript

#19

If I were going to do this, I’d probably go all the way to using ReScript, but it’s a nice idea. I’m quite surprised it’s not called ToffeeScript though.

Maybe because ToffeeScript is prior art? https://github.com/jiangmiao/toffeescript

Wasn't super popular, but wasn't unknown either.

Re: CoffeeScript for TypeScript

#20

Under "Everything is an Expression": items = (() => { const results = []; for (const item of items) { if (item.length) { results.push(item.toUpperCase()); } else { results.push(" "); } } return results; })(); Seems like they are purposely making the JS version extra long. It could be: items = items.map(x => x.length > 0 ? x.toUpperCase() : ` `) Edit: Just realised the code on the right is the compiled code, not the "…

Your version doesn't correspond to the code written on the left side.

You are right, I did not realise it was the compiled code.

I thought it was the comparable hand written JS.

Post reply on HN