News for hackers. Stuff that matters.
Re:A JavaScript parser and interpreter written in Go by recuter on Thursday November 28, 2013 @02:02AM (#6813412)
Alright, 90 points, most comments being meta about the title so I'll be the brave one and ask: What is this actually good for?

I can't think of any reasonable use case. Grab little NPM ditties and incorporate them into your Go binary - Javascript to Go becomes as Lua is to C? Somebody enlighten me.

Edit: Not that this needs a use case per say, just that the intent behind it is underspecified enough for me to wonder about it.

Re:A JavaScript parser and interpreter written in Go by mushroomhead on Thursday November 28, 2013 @02:25AM (#6813463)
We have distributed crawler written in go configurable with xpath and javascript for advanced crawling using javascriptcore-go[1] and also our knowledge engine serves various form of formatted information card scripted in javascript.

Duckduckgo goodies[2] also a good example of what we've been doing.

1) https://bitbucket.org/rj/javascriptcore-go

2) https://duckduckgo.com/goodies

Re:A JavaScript parser and interpreter written in Go by Loic on Thursday November 28, 2013 @03:02AM (#6813541)
In the case of web application, you can have the same templating engine running in the browser and in the server. This means rendering the full HTML at the server level if needed or part of it or just at the browser level. You get a bit of freedom. It is painful to manage two different templating engines between the server and browser sides.
Re:A JavaScript parser and interpreter written in Go by yeukhon on Friday November 29, 2013 @03:34AM (#6818440)
I don't get it. Are you saying - okay let's replace the javascript run time in today's browser to this version in Go?
Re:A JavaScript parser and interpreter written in Go by furyofantares on Friday November 29, 2013 @01:43PM (#6820491)
I don't think he's saying that. I think he's saying your Go server could execute similar JavaScript as the client executes.

Imagine a highly dynamic web page, beyond the initial page load when you interact with the page javascript executes the user's actions then rewrites large chunks of the page. As a developer, you need to write code on your backend that knows how to render the initial HTML for the page, but then you have to duplicate this functionality in JavaScript since the client needs to be able to render any chunk of the page that changes in response to a request.

You have a few options as a developer here. You can live with maintaining two code paths in different languages that do essentially the same thing. Or you can get rid of the backend rendering entirely, making your page less friendly to no-script users and web crawlers (and sometimes making the site flicker a bit as content gets loaded initially for all users.)

Or you can use shared code on the backend and the client for rendering HTML by having a backend that speaks JavaScript.

Re:A JavaScript parser and interpreter written in Go by patrickg on Thursday November 28, 2013 @03:21AM (#6813589)
I distribute a binary that can be extended via Javascript/Lua/... API by a customer. This is great. I don't want the customer to mess with the Go source but I give him the chance to mess with the program by a well defined API.
Re:A JavaScript parser and interpreter written in Go by gouggoug on Thursday November 28, 2013 @02:09AM (#6813427)
Not everything needs a use case. But if you really want one, here's one: I'm a student and I want to write my own interpreter. Well, here's a good example of how to write your interpreter.
Re:A JavaScript parser and interpreter written in Go by mturmon on Thursday November 28, 2013 @03:49AM (#6813663)
That's not a use case.
Re:A JavaScript parser and interpreter written in Go by gouggoug on Thursday November 28, 2013 @02:45PM (#6816092)
You nonetheless understood what I meant, and knew by reading my comment that "use case" was a mis-use of language. That's nit-picking.
Re:A JavaScript parser and interpreter written in Go by jchrisa on Thursday November 28, 2013 @04:06AM (#6813718)
We use it because we have user programmable callbacks, and JavaScript provides a well-known sandboxed language. Otto makes it really easy to expose native functionality to JS.
Re:A JavaScript parser and interpreter written in Go by columbo on Thursday November 28, 2013 @02:06AM (#6813419)
If it was fully functional it could be useful for automated testing. Write your tests in javascript, execute them at the point of integration in Go.
Re:A JavaScript parser and interpreter written in Go by phoboslab on Thursday November 28, 2013 @06:42AM (#6814137)
Reminds me of the early 2000s argument "why do we need another browser? IE is good enough".

This project may not be the fastest JS engine or the one with the most features right now, but if nothing else, it's a really nice project for learning Go and writing interpreters.

Maybe some new ideas will be explored in this engine first, because it's faster to implement them in Go than in the (huge) V8 or other JS engines.

Having new alternatives to established software is always a good thing.

Re:A JavaScript parser and interpreter written in Go by recuter on Thursday November 28, 2013 @07:39AM (#6814271)
I wasn't making any argument, simply asking.
Re:A JavaScript parser and interpreter written in Go by hbbio on Thursday November 28, 2013 @04:01AM (#6813699)
You can scale npm now.