
Google's Code Editor - obilgic
https://docs.google.com/macros
======
kjhughes
The link title will attract developers anxious to see what Google is offering
or Googlers are using to edit code, but this is just an online editor designed
for Apps Script editing. It's been around a long time and is less interesting
than the link-bait title suggests.

Google Apps Script is very useful in conjunction with Google's online apps and
their rich libraries. JavaScript makes for a good customization language.

One non-obvious irritation, however, is that scripts cannot be shared. So, for
example, one has to duplicate code between multiple spreadsheets rather than
being able to import it as one would expect. There's an issue open, but even
with a high priority, it's two years old:

[http://code.google.com/p/google-apps-script-
issues/issues/de...](http://code.google.com/p/google-apps-script-
issues/issues/detail?id=40)

~~~
roguecoder
That model does work reasonably well for use cases like roleplaying game
character sheets, where individual players may want to tweak the scripts for
their specific character.

It is incredibly useful in general, but definitely not news.

~~~
notJim
I have a financial spreadsheet that I use to track the distribution of my
portfolio. I follow a system where I have a target allocation for each of a
small number of assets, and then I buy or sell shares when any given asset
gets beyond a certain tolerance of its target allocation.

Using Google Spreadsheets and the Google finance API available with Google
Apps script, I was able to automate every part of this except syncing it with
my account (since there's no API to access my financial records.) All I have
to do is click a button, and the cells change color based on whether I should
buy, sell or hold.

~~~
niqolas
I'd be really interested to see how your set-up works. Would it be possible
for you to share your files/code and a short description of how you
implemented your set-up? I am happy for you to remove/sanitize sensitive
details relating to your portfolio. However, I would love to understand how I
can develop a solution like this for myself.

Thank you for your help.

~~~
notJim
What I have is a sheet which says how many of each asset I own, and the
desired allocation. Then, there is a cell that calculates the current
allocation, based on the number of shares, and the current price of the share.

The current price of the share is fetched from _another_ sheet using a
vlookup. _That sheet_ is populated by the script. The script is here!
<https://gist.github.com/2717042>

The overall system is based on research I found here:
[http://seekingalpha.com/article/15134-the-seeking-alpha-
etf-...](http://seekingalpha.com/article/15134-the-seeking-alpha-etf-
investing-guide)

------
sshrin
Google has had what they call "Google Apps Script" for quite some time. From
the documentation page at <https://developers.google.com/apps-script/guide>:

"Google Apps Script gives users a new level of control over Google products.
Now you can access and control Google Spreadsheets and other products using
JavaScript scripts that you write yourself and can share with others. Unlike
browser-based JavaScript, the scripts you write run directly on Google servers
in order to provide direct access to the products they control.You can also
use Google Apps Script from Google Sites."

This online code editor seems to be a new and improved UI for creating /
editing apps scripts. That said, this editor isn't proprietary. A quick look
at the source shows that they're using CodeMirror (<http://codemirror.net/>).
We've tried out various code editors for unclassroom.com (where I work) and
code mirror has been the best to work with in terms of features, ease of use
and comprehensive documentation. The second version (CodeMirror2) is really
top notch compared to other alternatives out there.

------
selectnull
Last year I've used Google Apps Script to automate a spreadsheet, it worked
very well and that spreadsheet is still used inside my company. It's not very
complex, all together maybe 200 lines of code, with tests.

But, I'm not sure if I would do it again.

Development style is not enjoyable, coding inside textarea with syntax
highlighting is simply not good enough. I would prefer to use my text editor
and some way to deploy changes without the need to copy-paste from editor to
browser. I want to use my

Also, tell me exactly what language and what runtime is being used on the
server. I remember searching the docs and it was "it's javascript". Maybe it's
better now, I haven't looked since. Or just use node, after all it's V8.

In ideal world, this is what I would like (and really use):

* let me code offline: my editor. my source control.

* give me some SDK to run code offline like app engine

* give me a way to push changes to server

* great documentation

Without these, it's just too much like VBA in the nineties.

edit: 200 lines of code

~~~
gouranga
NOTE: this is NOT a troll.

I know a great tool for the job.

It works fine with source control and allows documents to be diffed and
merged.

The editor is 100% offline as is the product or it can be 100% online at will.
No need to push changes to server - just replicate/copy. If you fancy
collaboration tools you can use use extensive ones on a subscription basis.

It's got a well documented SDK and an interface that you can call.

Documentation is wonderful.

Automation can be done with PowerShell, VB.Net, C#, Python, Ruby, VBScript,
JScript/JavaScript, Java or even Common Lisp if it takes your fancy.

Seriously just use Excel - it's just what you've asked for.

~~~
dewitt
I don't think you're trolling; Excel is certainly an option.

But for two things:

    
    
      Excel for Mac - $129 (http://www.amazon.com/dp/B003YCOJBC)
      Excel for Win - $121 (http://www.amazon.com/dp/B0039L2XG6)
    

And you need a Windows box or Mac with Excel installed. I personally have
access to dozens of machines, literally none of which have Excel. _All_ of
them have a web browser, and thus access to Google Spreadsheets and Google
Apps Script _for free_. To me, and many others, that makes all the difference
in the world.

~~~
gouranga
That's not a major issue.:

You can use Office 2010 web apps FREE from a SkyDrive account and openly
collaborate with people or you can pay $20 a month per seat for Office 365 and
you will get Sharepoint and ALL Office 2010 desktop apps.

The office web apps work perfectly in all browsers (I've tried Chrome, Firefox
and IE).

Considering the cost of playing around with Google spreadsheet with those
restrictions, it's possibly a good idea.

~~~
sad_panda
Does the Excel web app support VBA? I was under the impression that the 365
apps offer a subset of the functionality of their desktop counterparts.

~~~
gouranga
They don't support VBA directly.

I've always used Excel to publish result data to a spreadsheet rather than the
entire thing. Data collection is done using InfoPath so you get the following
workflow:

[www:InfoPath Office 365] -> [dt:Excel]-> [www:Excel report on Office 365]

It depends on your use case. I'd be tempted to use a sharepoint list with a
custom report for anything more complicated.

------
grok2
This really is a "Google Apps Scripts" editor for writing JavaScript to
manipulate stuff in Google docs...see [https://developers.google.com/apps-
script/guide_writing_scri...](https://developers.google.com/apps-
script/guide_writing_scripts)

------
alecbenzer
Is there an article explaining this or anything? I couldn't seem to get to it
anywhere from the main google docs/drive page (although I didn't look very
hard). 'docs.google.com' also isn't being translated to 'drive.google.com'
like it normally is.

I hope they end up expanding this and using it for things like phone code
interviews, though. Coding via the regular google docs interface was a bit of
a pain.

~~~
darrhiggs
Checkout the help menu, it has links to:

The documentation[1] And the old support channel[2]… …which is now officially
at[3]

[1] <https://developers.google.com/apps-script/guide> [2]
<http://productforums.google.com/forum/#!forum/apps-script> [3]
<http://stackoverflow.com/questions/tagged/google-apps-script>

------
crazygringo
This is actually pretty cool, one step closer to making Google Docs a worthy
competitor to Office. If they combine this with an Access-type database app,
it could be a great tool for businesses.

Although using the interface builder brings back memories of VB...

~~~
recursive
The UI designer from old-school VB the best part about it. Obviously, the
language part was crap. I think that forms designer still represents a rapid
UI development environment that many languages/environments have not reached.

~~~
prplhaz4
Probably not a very popular opinion here on HN, but the raw productivity you
can achieve in the VBA/Office world is hard to reach anywhere else.

------
iamchrisle
I use Google Docs code a lot at work in "production". Here's my experiences:

Yes, you can do more than a few hundred lines of code. My in house library is
now about 5k LOC. Yes, it's basically straight JavaScript. Everything is there
except for the DOM. Yes, the online editor sucks. I don't use it at all. (see
below how) No, you cannot use jQuery/Prototype, etc (there's no DOM or Window
class). No, you cannot use long running methods. Google Docs cuts you off at
around 30 seconds of execution. No, you cannot share code. (see below)

\-- How I develop on Google Docs:

1\. I develop it outside of Google Docs using Sublime Text 2

2\. I test using Node.JS + assert() + methane.js (see below)

3\. I then minify it using Google Closure Tool

4\. Then I copy and paste it into Google Docs

This works well because the online editor blows when you're doing anything
semi-complex.

\--- Testing in Google Docs

I use node.js + assert() + methane.js. What is methane.js? It's a little piece
of JS that mocks some of the Google Apps classes and functions. I can then
override that mocked method to return the value I expect Google to return and
test my own methods.

It's here: <https://github.com/chrisle/methane>

Consider it alpha code. It's not very well documented. It works for
me!(tm)....

\-- Sharing code in Google Docs:

Inside of onLoad() I've seen people use UrlFetch and then eval() the response
string as a way of getting shared code to work. Not ideal, but it works. I
personally don't share code or use this method.

------
rmason
If you want to look at another editor using CodeMirror check out Adobe's
Brackets:

<https://github.com/adobe/brackets-app/>

It's early in development and not ready for general use yet.

Unlike Google this one is open source and it runs as a desktop app built
primarily with JavaScript, CSS and HTML5.

------
fierarul
I guess 2013 will be the year of the OnlineIDE? It would be pretty great to
use ChromeOS for some actual work.

~~~
blahbap
Cloud9 is pretty decent - especially being able to deploy directly to Heroku
and Azure

~~~
Andrex
Don't forget Git and GitHub.

------
noinput
The script manager can be very useful. For a project, I needed to get
translations in 4 languages and the client wanted to handle all of it. I wrote
a quick script to pull id's and all the columns and format it exactly how I
needed, than email me the file. Anytime there are language updates, they send
me a note, I run the script and commit the language file changes.

The same logic applies to another where I let the client update SEO
keywords/meta/OG info. Of course I could have built a CMS for it, but then
again, they already have a google account and revision history with gdocs is a
nice touch.

------
samet
It has also an interface builder:

File -> Build a user interface.

~~~
maxxpower
disabled on mine

~~~
figital
works for me using Aurora 14.0a (Firefox) ... save your script first ... then
it might be enabled.

------
alexis-d
That will better for phone interviews will Google than the "plain" Google Doc
(which is just terrible for writing code -and that's normal-).

------
shanemhansen
This is an awesome tool. Has anyone tested to see if it supports collaborative
editing the same way other google docs tools do? If so, this would be a great
alternative to screen in some cases, and would definitely go in my
interviewers toolkit.

~~~
objclxt
FWIW, Google used to (still do?) use Google Docs as their recruitment tool for
code screening.

~~~
briancurtin
Yep. That was the case when I went through two years ago, and a friend went
through the process within the last month and also used Docs.

------
juddlyon
This opens up some great possibilities. I noticed a jQuery plugin the other
day that ingested JSON or could pull data from a supplied Google Doc. Seemed
odd but makes sense when you see the direction Google Docs is headed.

------
veidelis
I cant seem to be able to run a closure. The editor says: no functions to run.

Consider this code: var i = (function () { var k = 1; return function () {
return ++k; } } () );

i();

------
Juha
They just need a Git integration with syntax highlighting for other languages
and this might actually be useful. Although there are many web-IDEs simple
tool like this would still be useful.

------
dkhenry
Well this would form a good basis for an on line code editor. I am surprised
they are using javascript instead of Go, Dart, or Python

~~~
gnarbarian
JavaScript is already supported by the browsers, it seems like the obvious
choice for me. Especially since it's supposed to be for manipulating google
docs, which live on the browser. The alternative would be to run the code
server side which seems silly when you have a js interpreter right there
already.

------
obilgic
They even have gui builder <http://cl.ly/0t4740472r2p1E2p2F1N>

------
obilgic
Google is new Microsoft, They have no idea which products/apps they have...

------
bananaoomarang
Wow, why don't they publicise this and get Go and Dart working?

------
silasb
Funny, I ran into this this morning while trying to figure out to do condition
formatting in Google Docs.

------
luminaobscura
if you need excel-like desktop app, but with a decent scripting support (VBA
sucks) check <http://www.resolversystems.com/products/resolver-one/>

------
woodchuck64
Why use anything but its-all-text and vim?

------
pyrotechnick
It's CodeMirror - <http://codemirror.net/>

~~~
drivebyacct2
Tis a shame, there are far more comprehensive and impressive displays of what
Code Mirror can do than this. CodeMirror makes the OP's link extremely trivial
to implement.

edit: Sorry, this isn't meant to be a dig on the Google's Code Editor as much
as it's meant to be praise of how impressive I find CodeMirror (and it's
competitor/friend Ace).

~~~
rkwz
> there are far more comprehensive and impressive displays of what Code Mirror
> can do than this.

Can you give some examples?

------
pjmlp
Yuck

~~~
Trufa
Please collaborate to the conversation, you're obviously allowed to not like
it but please explain why. "Yuck" just doesn't cut it.

~~~
pjmlp
I consider all these editors in the cloud a waste of effort.

The right place for a code editor is as a native application.

------
ibadet
Filim Malena

