4 ms·
I often wish terraform wasn't written in go. Usually while making a patch to it, or reading the source code. Though not as much as I wish that terraform had use
by thayne 4y ago
I often wish terraform wasn't written in go. Usually while making a patch to it, or reading the source code. Though not as much as I wish that terraform had used an existing "real" programming language rather than creating HCL.
- sofixa 4y agoTerraform not written in Go wouldn't have existed. If it relied on a JVM or Python/Ruby interpreter being present, at the correct version, it never would have gotten as popular, and if it were statistically compiled C/C++ it would have never gotten as far and as quickly. Go offers a nice balance between performance and platform agnosticism, features like parallelism without it being too complex to write. Manual memory management would have been a useless obstacle wasting developer time for little real gain. Fighting the language to have parallel execution, easy crosscompile, etc. why? As for HCL, I'm on the opinion that a DSL is better. It's even in the name, Infra as Code, not with code. You want your infrastructure declarations to be easily readable and supportable. Anyone who has used Terraform can read any HCL; your Python code doing the same could be terrible and unreadable by anyone not already on your team. Too much flexibility for something as critical can end badly, imho. In any case, there's cdktf now, you can mix and match terraform with cdktf. Disclaimer: I work at Hashicorp, opinions my own and have stayed the same since before joining
- azth 4y ago> If it relied on a JVM or Python/Ruby interpreter being present, at the correct version, it never would have gotten as popular, As far as I know, it's not hard to ship a JVM runner with the installer of your program, so this should be a non-issue.
- thayne 4y agoAnd using a "virtual environment" with a specific version of the interpreter is a common workflow for python, and sometimes ruby
- jpgvm 4y agoYeah but Ruby and Python aren't relocatable so it's hard to ship a self-contained interpreter with the program itself. This is due to their reliance on system paths among other things. You can trivially ship a self-contained JVM that is completely isolated within a single directory.
- thayne 4y agoIf it were created today rust might be a good option, although in the early days of rust, it probably wasn't mature enough. Although, it does require some amount of memory management, but to a lesser degree than c/c++. > Go offers a nice balance between performance and platform agnosticism I don't disagree with this. It's too bad the language itself has major problems (which I won't get into here). > I'm on the opinion that a DSL is better The two aren't mutually exclusive. What I want is a DSL embedded in a full programming language, like chef's dsl in ruby. > You want your infrastructure declarations to be easily readable and supportable. Absolutely. > Anyone who has used Terraform can read any HCL; your Python code doing the same could be terrible and unreadable by anyone not already on your team It's possible to write terrible and unreadable HCL too. I know because I've written some. > In any case, there's cdktf now, you can mix and match terraform with cdktf. Unfortunately, I haven't had a chance to look too deeply into it yet, although I definitely want to.
- sofixa 4y ago> The two aren't mutually exclusive. What I want is a DSL embedded in a full programming language, like chef's dsl in ruby. I've seen some atrocious Ruby for Chef, so I'm not sure I'd agree here. The advantage of a DSL is that it limits how far you can go. In the case of HCL pre-v2, it had some limitations around dynamism, but now that's out of the way IMHO it strikes a decent balance. You can write hardcore HCL, but IMHO it's still way easier to parse by a human that bad Python or JavaScript. As for CDKTF, I'd recommend you do. You can mix and match like having a project with CDKTF in e.g. Python or Go use regular TF HCL modules, but also vice versa, defining a module in TypeScript and consuming it from regular Terraform. So you can have the extra flexibility ( with all of it's advantages and risks) on a per module basis, not all or nothing.