4 ms·
Ask HN: A high level language that compiles to VBA ?
I don't have a lot of background in computer science (4 years), but it seems to me that recently, we saw some new languages coming alive.I just heard of Elixir which is built on top of the Erlang VM. Scala is a little bit older (2003) and targets JAVA VM. Clojure(2007) targeting JAVA VM and being compilable to javascript, seems to be a really clever move.
Javascript rising popularity have triggered the rise of transpilers that targets that language.
My point is that designing high level language that transpiles to another seems to be a pretty active field. I guess that tools to do so have evolved in the recent history (I actually would be interested to know about the state of the art, any resources are very welcome). Leveraging an existing platform by adding concept-comprehension at the syntactic level (i'm thinking of list comprehension, for example) seems to add productivity at no cost, no trade-off (?)
OK now, the real topic.
In my opinion, VBA is as annoying to write as it is present in the industry. A lot of companies rely on it (I'm working in the financial industry, so mainly VBA for Excel).
A lot of people uses VBA, a lot of people already have that tool, and struggle to use it,and still use it. VBA allows you to do what you want to do, but I don't think it is optimal to directly write VBA.
I think of it as a telegraph line: the network is already there, Morse code allows you to write anything you want, but it a PITA to work with. Build a tool that automatically encodes and decodes what's on the channel and you're on the internet (OK, oversimplifying here).
Can't we put excitement back in VBA technology by hiding it ? I'm sure we have tools to make it happen.
I really would love to have developer's opinion on that. If you think that nobody has ever been that wrong, please include enlightenments.
- bdfh42 13y agoI suspect that the problem here would be that VBA in Excel is all about the environment (of Excel) and the manipulation of Excel objects and that this would make it an unsuitable target for cross compilation - which is generally successful only for general purpose languages. Your "source" language would have to be so constrained by the limits and peculiarities of Excel that it would be as hobbled and as difficult to write well as VBA. [Edit] Joel Spolsky's FogBugz team did something interesting in this area though (see http://www.codinghorror.com/blog/2006/09/has-joel-spolsky-jumped-the-shark.html http://www.codinghorror.com/blog/2006/09/has-joel-spolsky-ju... for a take on that) but there again he was pretty responsible for the development of VBA when he was at Microsoft.
- zrz 13y agoThat's the kind of answers I was looking for. Does the nature of Excel VBA limits the possibilities of making it simple ? The fact of it being all about the environment means to me that there is room for what I called 'concept-comprehension at the syntactic level'. I mean, I can see myself manipulating Ranges and Arrays in a lot more intuitive way, and that's, in my short experience, the main use of macros. Come on, Excel is a spreadsheet software, it's basically meant to be use for numeric arrays manipulation and it does not offers any syntactic sugar around array manipulation.
- bdfh42 13y agoAfter a bit of thought, I acknowledge that you could conceive of a new language with better syntax that had the modern bells and whistles with the added capacity to view spreadsheets and their cells as a standard data type and with one of the target output windows being a standard Excel spreadsheet. I am not sure that you would then want to compile that down to VBA though - that would be rather "downhill" after all of the effort developing new tools. This http://manns.github.io/pyspread/ http://manns.github.io/pyspread/ was an attempt to start again from a language perspective (Python here) but I suspect you are looking for something that would just drop in alongside the ubiquitous Excel without making the less technical user aware of the difference.
- gruseom 13y agoIf you want to write code to manipulate numeric arrays, why not use an existing high-level language that is good for this? In other words, why are you using Excel? Not suggesting that you shouldn't; just curious to hear what benefits Excel has for you that keep you using it past its sweet spot.
- zrz 13y agoWriting VBA code for users that can't is part of my everyday job, and I guess that it is the job of a lot of support/commando developers. Excel is a great tool foto implement simple investment strategies but it often ends like 'hey could you write what we are trying to do in VBA ?', and most of the time it can be done. But I have that feeling that writing VBA costs more than it should, that VBA is playing against the developer while any other language makes him feel like there's no limits.
- dalke 13y agoThis question comes across as rather meandering, and I wasn't sure what you wanted. As far as I can tell, you've asked only one question: "Can't we put excitement back in VBA technology by hiding it ?" No. That is, why should it? You can write native components as a DLL using OLE Automation, and Microsoft wants people to use .NET. Why target VBA when you can target C#? "it seems to me that recently, we saw some new languages coming alive" - That's a sign of your inexperience with the field. Transpiling has been around for a long time, and is a frequent way to boostrap a new language. For example, the cfront implementation of C++ used to compile to C, and many Eiffel languages do the same. For one of the most advanced projects, see PyPy, which is a system for producing JITs for different language front-ends (the most popular is Python) and backends (the most popular is x86 but Javascript is also possible).
- zrz 13y ago'why should it?' because VBA feels horribly wrong to write, at the opposite of intuition. One can say that this is just my own opinion, but i would be curious to talk to somebody that thinks 'it's like VBA reads my mind!'. When I I switched to coffeescript and less, I wasn't even unsatisfied with js and CSS. But, writing it, I always think they took productivity a step forward. If you can avoid writing things that are implicit, it lowers the probability of faulty code. it saves you time and pain. that is just smart. You mention dlls, C#, PyPy ... those are big tools for writing whole projects. They implicitly request the use of an IDE for the compilation/linking steps. This is definitely not the solution i,'m looking for.
- dalke 13y agoI can't reconcile "it's like VBA reads my mind" with the goal, since it wouldn't be VBA; it would be another language which compiles to VBA. CoffeeScript isn't "Javascript that reads your mind." Scala isn't "Java that reads your mind." CoffeeScript had some difficulties, for that matter. It wasn't until CoffeeScript 1.6.1 that there was a way, in collaboration with browsers which support source maps, to get error line numbers relative to the CoffeeScript source instead of the intermediate Javascript. Any language which isn't VB but which compiles to VB will have the same problems - how do you report report run-time errors in a way that your users can understand them? There's similar problems with debugging. How do you step through your source? How do you inspect intermediate values? These are things that VBA supports, but your language won't be able to support. You might end up with a great language design that ends up taking more time to implement in because it isn't debuggable. Regarding PyPy, the reason I mentioned it was in context of "I actually would be interested to know about the state of the art [in designing high level language that transpiles to another], any resources are very welcome." PyPy is state of the art for that, if you want a JIT.