News for hackers. Stuff that matters.
Re:Glimmer.js: What’s the Deal with TypeScript? by uranian on Thursday April 13, 2017 @09:13AM (#14106514)
>At the end of the day, though, JavaScript is the language of the web.

And when webassembly arrives that will be over, and Typescript will be deprecated. I can't wait for a better modern language like Haskell, Python, Livescript, etc.. built on top of webassembly. Then we can finally stop trying to fix Javascript's flaws with new language features.

Re:Glimmer.js: What’s the Deal with TypeScript? by untog on Thursday April 13, 2017 @09:58AM (#14106919)
And I can't wait for the rude awakening anti-JS developers have when they realise the vast majority of issues (particularly, performance) come from the DOM, not JavaScript. (And the first version of WebAssembly can't touch the DOM anyway)

If people start writing Python for the web for no other reason than they just dislike JavaScript we're going to be forcing users to download a dozen different runtimes, just because of developer preference. This isn't a good thing.

Re:Glimmer.js: What’s the Deal with TypeScript? by recursive on Thursday April 13, 2017 @11:30AM (#14107809)
My complaints about JS have nothing to do with the DOM. Like weird `this`, no integer types, surprising type coercion rules, and so forth.
Re:Glimmer.js: What’s the Deal with TypeScript? by bauerd on Thursday April 13, 2017 @06:01PM (#14111241)
>we're going to be forcing users to download a dozen different runtimes

Why would users need to download a runtime, given that we'd have WASM as a compilation target for Python, the language?

Re:Glimmer.js: What’s the Deal with TypeScript? by pryelluw on Thursday April 13, 2017 @10:43AM (#14107352)
What would you replace the DOM with?
Re:Glimmer.js: What’s the Deal with TypeScript? by untog on Thursday April 13, 2017 @11:16AM (#14107676)
I honestly have no idea. It does so much that I don't know where you'd start - but I suspect that's also the problem.

I remember seeing a demo of React Canvas a few years ago - basically, recreating a "DOM" of sorts inside a canvas tag - and the performance was crazy. Beautiful 60fps touch interactions. But, of course, it only does a tiny subset of what the DOM does. I'm still waiting for a good reason to use it myself to try out how the API feels.

Re:Glimmer.js: What’s the Deal with TypeScript? by pryelluw on Thursday April 13, 2017 @03:00PM (#14109930)
I feel the same. Dunno wth we gonna do but we need something more performant.
Re:Glimmer.js: What’s the Deal with TypeScript? by coltonv on Thursday April 13, 2017 @11:04AM (#14107553)
To run python on WebAssembly you would have to compile the entire CPython executable, and every single dependency it has, into WebAssembly, then ship that giant executable with every page so you could then run Python code with it. You would then also most likely need a special library, which at some point someone will have to write or you'll have to write it yourself, to give Python a clean interface to the DOM. All of this together would be at absolute minimum 4.5 megabytes, which is absolutely unacceptably large for a frontend bundle.

WebAssembly is very cool techonology, but it's not going to deprecate Javascript because Javascript will be, at least for a very long time, the only scripting language that runs efficiently on the web, and also will always be the most well supported.

With WebAssembly you could write in any AoT compilation language that can compile on LLVM, but I, and many many other developers, have no interest in very low level languages like C, C++, or Rust in the browser, even though we acknowledge the flaws in JS. Maybe one day higher level languages besides Javascript will be practical, but that's a ways away.

Re:Glimmer.js: What’s the Deal with TypeScript? by mi100hael on Thursday April 13, 2017 @12:13PM (#14108278)
> To run python on WebAssembly you would have to compile the entire CPython executable, and every single dependency it has, into WebAssembly, then ship that giant executable with every page so you could then run Python code with it.

I mean, that's kind of already the case when you want to ship a Python project as a stand-alone package to run on the desktop. Alternatively, I could see a method of installing runtimes into your browser like plugins so it doesn't have to be shipped over the wire every time. Not saying I'd ever want to do something like that, just that alternatives exist. Browsers are moving more and more towards VMs that transcend the context of a single synchronous request/response.

Re:Glimmer.js: What’s the Deal with TypeScript? by coltonv on Thursday April 13, 2017 @01:15PM (#14108936)
I could see the plugin system working, but we're years away from that. So saying JS/TS will be deprecated soon is still pretty incorrect.
Re:Glimmer.js: What’s the Deal with TypeScript? by 6a68 on Friday April 14, 2017 @08:14PM (#14118503)
Just FYI, this has already been done with emscripten a while ago, and it does work. See: http://pypyjs.org/
Re:Glimmer.js: What’s the Deal with TypeScript? by goatlover on Thursday April 13, 2017 @01:50PM (#14109283)
But by the time you'll be able to do this, maybe most people have gigabit fiber and wifi. At some point in the future, a few megabytes isn't going to matter.
Re:Glimmer.js: What’s the Deal with TypeScript? by pimterry on Thursday April 13, 2017 @09:46AM (#14106812)
>> At the end of the day, though, JavaScript is the language of the web.

> And when webassembly arrives that will be over,

I really don't think this is true. I certainly agree that JavaScript isn't the perfect language, but it's a _very_ popular language. Even on the server-side, where right now you already do have the freedom to use languages like Haskell, Python, etc, you see a majority of developers now opting for Node.js. Even for desktop apps and data scientists, it's the most popular contender (all according to the latest SO survey).

You can argue about reasons all you like, but I don't think the people using JavaScript on the web are doing so only because webassembly isn't easily available yet. I think they're doing so because, for better or worse, they genuinely want to be using JavaScript (or very closely related languages like TypeScript).

Re:Glimmer.js: What’s the Deal with TypeScript? by ken47 on Thursday April 13, 2017 @11:14AM (#14107666)
Have you actually used Typescript? It's definitely better than Python, and I'd personally prefer it to Haskell / Livescript. I would love to hear what people actually think the "flaws" are with ES6 Javascript and Typescript, because they have been disappearing fast over the past two years.

WebAssembly will be great, but as a complement to Typescript, not as a replacement. I would love to import a native module for the small chunk of my code that needs to do heavy lifting. And I don't see any reason why the Typescript team couldn't eventually build a WebAssembly compatibility layer.

Re:Glimmer.js: What’s the Deal with TypeScript? by camus2 on Thursday April 13, 2017 @09:52AM (#14106860)
> webassembly.

is basically a better way to do ASM.js . How many Python,Haskell,Livescript have been built on top of ASM.js ?

Do you really believe you can make your users download 10s of megabytes of binaries each time they visit a website just to bootstrap a language? And i'm not even talking about the runtime...

Right now, the only viable languages for webassembly are the ones that don't use garbage collection and have a limited runtime, Rust,C and C++ .

Re:Glimmer.js: What’s the Deal with TypeScript? by douche on Thursday April 13, 2017 @10:07AM (#14106997)
We make our users download tens of megabytes of shitty unoptimized JS for tracking, ad networks, unoptimized images, autoplaying videos, and so on and so forth now.
Re:Glimmer.js: What’s the Deal with TypeScript? by Enginerd3 on Thursday April 13, 2017 @10:40AM (#14107316)
Those aren't necessary for the site to function so you can use some sort of content blocker and still access the material. You're talking about downloading megabytes of data just to go through the door for your website.
Re:Glimmer.js: What’s the Deal with TypeScript? by xamuel on Thursday April 13, 2017 @11:12AM (#14107648)
>better ... language ... Python

ES5 was a dumpster-fire. But ES2015+ is an amazing language. You just have to take the time to systematically study it.

If you're choosing a language you'll spend thousands of hours with, you shouldn't use "initial learning curve" as sole criteria.

Re:Glimmer.js: What’s the Deal with TypeScript? by uranian on Thursday April 13, 2017 @12:49PM (#14108677)
Amazing?

make an object:

in ESx:

  var myObject= {
  	a: {
  		b: {
  			c: {
  				d: 'some value'
  			}
  		}
  	}
  }; 
in Coffeescript or Livescript:

  myObject= a: b: c: d: 'some value'

now use it:

in ESx:

  console.log myObject.b.c.d			// crash, myObject.b does not exist
how to prevent?

  if ( myObject.hasOwnProperty('b') and myObject.b.hasOwnProperty('c') ){
  	console.log myObject.b.c.d		// undefined
  }
in Coffeescript or Livescript:

  console.log myObject.b?.c?.d		// undefined
I can write almost a book with too many of such examples. So, NO it's not an amazing language, I wrote for many years in it and it sucks all the way.
Re:Glimmer.js: What’s the Deal with TypeScript? by Macha on Thursday April 20, 2017 @04:39PM (#14160627)
It's cheating a bit to indent the JS option only. I don't think:

myObject= a: b: c: d: 'some value'

Is really _that_ much of an improvement over:

myObject = {a: { b: { c: { d: 'some value' } } } }

especially combined with an editor that will match those closing brackets for you. And the reality is that if you have object literals that deep, chances are the inner values will also be large enough to justify expanding it anyway.

Also lodash plugs a large number of holes in the standard functionality. In most projects I work at, I'd write something like:

_.get(myObject, 'b.c.d')

for your second example.

Re:Glimmer.js: What’s the Deal with TypeScript? by Enginerd3 on Thursday April 13, 2017 @09:44AM (#14106787)
At the end of the day, JS will always be the language of the web. You're still going to be doing DOM manipulation through JS. WASM is really going to benefit people who want to do more heavy duty edge cases such as image processing.
Re:Glimmer.js: What’s the Deal with TypeScript? by weberc2 on Thursday April 13, 2017 @10:26AM (#14107194)
Is this because browsers won't expose DOM manipulation at the WASM level, or is there a different reason?
Re:Glimmer.js: What’s the Deal with TypeScript? by Enginerd3 on Thursday April 13, 2017 @10:35AM (#14107280)
DOM manipulation is going to be available at the WASM level in the future but it's going to be inefficient to do so just as it is inefficient to do image processing in JS right now. The only difference is that JS is the only viable option now if you want to do image processing on the web. WASM exists to solve this problem and complement JS. Hell, look at WASM's and JS's logo. They're two puzzle pieces that fit together.
Re:Glimmer.js: What’s the Deal with TypeScript? by Rusky on Thursday April 13, 2017 @01:31PM (#14109085)
Your analogy doesn't sound right to me- there's nothing about wasm that would make it slow to manipulate the DOM, while there is plenty about Javascript that makes it slow to process images.

Manipulating the DOM from wasm shouldn't be any slower than Javascript. Slow in general because of the DOM, perhaps, but not because of wasm.

Re:Glimmer.js: What’s the Deal with TypeScript? by mixedCase on Thursday April 13, 2017 @09:35AM (#14106693)
WA with a performant web API, you mean. First iteration of WA won't let you touch things like the DOM without jumping through JS-land.
Re:Glimmer.js: What’s the Deal with TypeScript? by whatever_dude on Thursday April 13, 2017 @10:13AM (#14107060)
> And when webassembly arrives that will be over, and Typescript will be deprecated. I can't wait for a better modern language like Haskell, Python, Livescript, etc.. built on top of webassembly.

Much of that is already possible and guess what, neither TypeScript nor JavaScript are deprecated.

Re:Glimmer.js: What’s the Deal with TypeScript? by zengid on Thursday April 13, 2017 @09:47AM (#14106821)
IMO I feel like it is going to be a challenge to integrate the GC of another language with the GC of the JavaScript/DOM, and if so we'll be keeping JavaScript going for a while.
Re:Glimmer.js: What’s the Deal with TypeScript? by weberc2 on Thursday April 13, 2017 @10:31AM (#14107247)
WebAssembly doesn't have a GC, And I don't see any reason why the DOM should be subject to a JS GC.
Re:Glimmer.js: What’s the Deal with TypeScript? by zengid on Thursday April 13, 2017 @02:15PM (#14109520)
Correct, but python (or haskell or java or whatever) running on top of WASM would, and there are plans to integrate WASM with the other GC's in the browser, however:

    "'compile the VM' strategies increase the size of 
     distributed code, lose browser devtools integration, can 
     have cross-language cycle-collection problems and miss 
     optimizations that require integration with the browser" [1].
My prev comment was speculative, but my point is that its not going to be a piece of cake to just drop another high-level language on-top of WASM and use it as a 'better' scripting language without having to pay some overhead costs, one being GC issues.

[1] https://github.com/WebAssembly/design/blob/master/FAQ.md#is-...

Re:Glimmer.js: What’s the Deal with TypeScript? by weberc2 on Friday April 14, 2017 @12:11PM (#14115278)
I don't know what is meant by "there are plans to integrate WASM with the other GC's in the browser". Is the idea that the browser runs a GC for DOM elements that is separate from the JS VM GC? I wonder if they could follow a model like operating system resources (e.g., file handles) where the process is responsible for managing the resource lifetimes. This would make resource management trivial, and running (for example) Python on WASM would simply mean emitting WASM instructions instead of x86.

Of course, lots of other problems remain, for example, downloading an entire runtime or "putting Python on WASM isn't going to magically make it fast". But I don't think the GC should be a particularly large challenge.

Re:Glimmer.js: What’s the Deal with TypeScript? by mhd on Thursday April 13, 2017 @10:07AM (#14107001)
We'll just have a Babel of dialects, pun intended. There might not be a technical reason for having JS, but there's a social one -- we've got plenty of people who call themselvs "JavaScript programmers", and people tend to be set in their ways to an awful degree.

I mean, on the backend, there's no ultimate technical reason why you couldn't switch -- the closest you can come to the browser situation is the limited PHP hoster of the early oughts -- and still we don't see a rapid progress away from awful languages. Just more people duct taping said languages into something slightly more sane.

We'll get the same for JS. It's the new Pascal/C in that regard.

Re:Glimmer.js: What’s the Deal with TypeScript? by talmand on Thursday April 13, 2017 @09:38AM (#14106729)
Yep, then we can focus on other language's flaws by implementing new features.
Re:Glimmer.js: What’s the Deal with TypeScript? by Rapzid on Thursday April 13, 2017 @01:02PM (#14108793)
I'd take the experience of working with TypeScript over Python any day of the week. All the days really; every day.