github.com/sercand/please@v13.4.0+incompatible/docs/faq.html (about) 1 2 <h1>FAQ</h1> 3 4 <h3>Can I run it on my computer?</h3> 5 6 <p>If you're running Linux, OSX or FreeBSD, definitely; we actively support those platforms.<br/> 7 Installing Please on either Linux or OSX is as easy as <code>curl https://get.please.build | bash</code>. 8 Further dependencies shouldn't be necessary after that, assuming you have what you need for 9 the languages you want to work on (e.g. you'll need a JDK to use Please for Java).</p> 10 11 <p>To compile it, one needs Go installed, plus a few other things for various other 12 builtin tools. On Linux we primarily support Ubuntu; it should work pretty readily on 13 most distros though.<br/> 14 See <a href="https://github.com/thought-machine/please/blob/master/tools/images/ubuntu">tools/images/ubuntu</a> 15 for information and a Dockerfile for setting up a recommended environment.</p> 16 17 <p>To build on OSX, you will similarly need to add some extra packages; we recommend using 18 <a href="https://brew.sh">Homebrew</a> to add at least <code>go</code> and <code>python3</code>.</p> 19 20 <p>For building on FreeBSD, you will need to install Bash as well as (obviously) Go and Git.<br/> 21 Currently binary downloads aren't available, we hope to make them available in future.</p> 22 23 <p>Windows is unfortunately not supported natively, since it's just too different from the 24 Unix environment Please is designed for. It might well be possible to make it work using 25 Cygwin or MinGW / MSYS, or the recent Ubuntu on Windows development though. We aren't 26 doing this work ourselves because we don't have any Windows machines, but we're 27 happy to accept PRs in that direction.</p> 28 29 30 <h3>What's the licence?</h3> 31 32 <p><a href="http://www.apache.org/licenses/">Apache 2.0</a></p> 33 34 35 <h3>Why use Please instead of go build / Maven / Gradle?</h3> 36 37 <p>Cross-language support is a big advantage; we have four main languages in use at Thought Machine 38 (Javascript, Python, Java and Go) plus several smaller pieces (some C++ and Thrax grammars) and 39 having to invoke different compilers and/or test tools for each one would be extremely tiresome.</p> 40 41 <p>Please can also integrate many different kinds of build steps; for example a code generation 42 step using <code>go generate</code> or <code>protoc</code> can be invoked dynamically without 43 having to check the resulting code into the repository.</p> 44 45 <p>We've tried other tools (notably Gradle and Buck) internally and ultimately decided that 46 we could build something that would either better fit our needs, be considerably faster, 47 or both.</p> 48 49 50 <h3>Why use Please instead of Bazel, Buck or Pants?</h3> 51 52 <p>All four of these systems are quite closely related in the scheme of things, being inspired by 53 (or in Bazel's case, a direct open sourcing of) Google's Blaze.</p> 54 55 <p>Several of us had worked at Google and used Blaze extensively there; we were excited about it being 56 open sourced as Bazel but by then we were already using Please internally. It's a great system but 57 we have slightly different goals, specifically we're aiming Please at being lighter weight and 58 pushing the boundaries of what can be done within the BUILD language. Since Please is written in 59 Go there's no runtime dependency on the JVM. 60 </p> 61 62 <p>We actually used Buck for some months internally before deciding to write Please and before it 63 was capable of building our repo. We preferred it to other options available, but again we're 64 focused on different goals; Please is easier to extend to new languages, has a bunch of features 65 that we specifically wanted (e.g. test containerisation) and has a stronger focus on BUILD 66 language correctness. Conversely we have much less support for mobile development.</p> 67 68 <p>We're least familiar with Pants; one of our developers briefly tried it and while we liked 69 many aspects we didn't think it was the ideal fit for us at the time.</p> 70 71 72 <h3>What inspired the design of Please?</h3> 73 74 <p>Originally Blaze, since a number of us had used it at Google. More recently we'd used Buck 75 internally so many things superficially resemble that for compatibility reasons 76 (e.g. <code>python_binary</code> instead of <code>py_binary</code> etc).</p> 77 78 <p>Some of the advanced features are based on things we would have liked to do with Blaze, for example 79 being able to defer creation of some build rules until they actually need to be built. This is 80 only really of interest for spectacularly large trees of targets or especially esoteric use 81 cases though.</p> 82 83 <p>Mostly, of course, it was inspired by our fearless leader Paul, specifically the point when 84 he told us "you absolutely cannot write your own build system". After that it was 85 really inevitable...</p> 86 87 88 <h3>Why is it so fast?</h3> 89 90 <p>Firstly, all the rules explicitly declare their dependencies, so Please can aggressively 91 parallelise build rules wherever possible. It can also cache & reuse previous outputs when 92 they haven't changed, and it hashes all input files to make sure it's correct.</p> 93 94 <p>Also BUILD files encourage you to break projects into smaller components, which can then 95 be compiled in parallel. It's still possible to define a project with a single BUILD file 96 in the traditional Java way that one would use in Gradle etc, and this works fine for 97 smaller projects, but for larger ones parallelising the compilation can be a big advantage.</p> 98 99 <p>There are no separate steps inside Please; parsing BUILD files, building targets and running 100 tests can all happen simultaneously, so there's no down time waiting for the last thing to 101 compile before the tests begin. The parsing process is also very fast due to having an 102 in-process Python interpreter.</p> 103 104 <p>It being written in Go and being an entirely native binary means great performance and fast 105 startup times; internally it's also highly parallelised and can take full advantage of the 106 underlying hardware.</p> 107 108 <p>Finally, the rules themselves are optimised in various ways; for example, the construction of 109 the final .jar from a <code>java_binary</code> is an efficient concatenation of other .jar 110 files without any recompression. Similarly the output .pex from a <code>python_binary</code> 111 is built up piecemeal throughout the <code>python_library</code> rules and assembled at the end 112 so we don't have to recompress an entire zip file every time you change one .py file.</p> 113 114 115 <h3>How do you parse the BUILD files? What format are they?</h3> 116 117 <p>The currently-unnamed BUILD language is a restricted subset of Python; see 118 <a href="language.html">here</a> for more details, documentation and a formal grammar.</p> 119 120 <p>This provides a nice balance between an elegant and powerful language, but also one that can 121 be interpreted more easily than Python itself, and that is reasonably familiar to many developers.</p> 122 123 <p>One downside to this is that the BUILD files are a little hard to automatically edit or 124 update compared to a data format like XML, Yaml or JSON. We think this is worth the tradeoff 125 for giving the developer more power and (in our opinion) a significantly nicer format.<br/> 126 A couple of Please features can help with updating BUILD files; see <a href="commands.html#gc">plz gc</a> 127 and <a href="commands.html#hash">plz hash --update</a> for more info.</p> 128 129 <p>We suggest investigating <a href="https://github.com/bazelbuild/buildifier">buildifier</a> 130 if you'd like a pretty-printer / autoformatter for them.</p> 131 132 133 <h3>Okay, but what exactly are you using to parse the files?</h3> 134 135 <p>The built-in parser is an internal pure Go implementation. It's evolved through several implementations 136 over time; ultimately this provides maximum control and performance (because we are not subject to 137 Python's GIL, or cgo calling overhead).</p> 138 139 140 <h3>How does Please build itself? Do I need Please to build Please?</h3> 141 142 <p>Please bootstraps itself using <code>go build</code> to build a temporary version of itself, 143 which is then used to rebuild itself using its own BUILD rules. This requires a little 144 duplication between the initial bootstrap script and the BUILD rules but obviously we 145 can't rely on anyone building it already having a version of it installed.</p> 146 147 <p>Fortunately the process is pretty fast since Go is fast to compile.</p> 148 149 150 <h3>Why write it in Go?</h3> 151 152 <p>We excluded most other languages that any of us were familiar with through a process 153 of elimination; JVM languages were ruled out from a concern about startup overhead, 154 we were concerned about Python's threading performance for an inherently parallel system 155 and felt C++ was too fiddly and lacked a strong standard library. Rust was still pre-1.0 156 at the time (although that didn't take long, as it turned out) so we felt it was a bit 157 early to leap into that.</p> 158 159 <p>It also turned out to be a really useful way of learning the language; the project is 160 about the right size to explore it properly and sufficiently self-contained not to 161 affect other parts of our repo until we were sure Go was a language we wanted to do more of.</p> 162 163 <p>We're very happy with the results; the performance of native binaries is excellent, 164 the language was easy to become productive with and has great support for all the things 165 we needed to do with it. Our early concerns (e.g. the classic "no generics!") 166 turned out to be a lot less problematic than we expected.</p> 167 168 <p>An alternative explanation is that the original high-level design meeting for Please was 169 an impromptu discussion in a pub one Friday evening, where we thought it would be a neat 170 language to try despite none of us having any real experience with it.</p> 171 172 173 <h3>Is this the primary repo, or do you have a secret internal version too?</h3> 174 175 <p>This is the only repository; all development is done here. Initially we had an internally 176 hosted repo but transferred the project to Github in preparation for open sourcing it. 177 178 <p>We've got some build rules in our internal repo that aren't built into Please yet. 179 We intend to open source as we can, but the ones left aren't easy to genericise 180 for various reasons.</p> 181 182 <p>There are some additional rules available at 183 <a href="https://github.com/thought-machine/pleasings">https://github.com/thought-machine/pleasings</a>, 184 which we either do not want to guarantee compatibility for, are still experimental, or are 185 sufficiently esoteric that we don't want the build process for Please to require them.</p> 186 187 188 <h3>How does the versioning scheme work? What are the compatibility guarantees?</h3> 189 190 <p>We are using <a href="http://semver.org">semantic versioning</a> so essentially: 191 <ul> 192 <li>Changes to the major version number mean you might have to make an active change 193 to your BUILD files or project config.</li> 194 <li>Changes to the minor version number indicate additional features that shouldn't 195 require any changes on your part.</li> 196 <li>Changes to the patch version number are bugfixes.</li> 197 </ul> 198 </p> 199 200 <p>These rules apply to the "public parts" of the project; specifically the command-line interface and flags, 201 the config file format and the BUILD file format and builtins are essentially the API 202 and so we take significantly more care about compatibility around those.<br/> 203 The interface to the various sub-tools invoked by Please we consider an implementation 204 detail and those might change more aggressively (although in practice they rarely do).</p> 205 206 <p>Things whose behaviour is not explicitly specified might change with less notice, 207 because of course you shouldn't have been relying on it anyway. This includes the exact 208 hash generation method - if it becomes necessary to change that for a bugfix it may force 209 apparently unnecessary rebuilds after an update. We try to avoid that as much as possible 210 since it's aggravating (for us too!) but since it doesn't affect eventual correctness 211 it can change in minor releases.</p> 212 213 <p>The versions don't apply to the code interfaces themselves, since we don't expect 214 this to see wide use as a library. If some part of it becomes popular in that way we'll 215 likely split it out to a separate repository and version it separately.</p> 216 217 218 <h3>What does it look like when I'm running it?</h3> 219 220 <p>Like this:</p> 221 222 <asciinema-player src="https://please.build/plz-recording.json"></asciinema-player> 223 224 <p>The appearance is somewhat inspired by Buck, although we have put some of our own 225 spin on it as well.</p> 226 227 <h3>What do the colours in the console output mean?</h3> 228 229 <p>They change based on the type of rule that's being built:</p> 230 231 <ul> 232 <li>Yellow: Go</li> 233 <li>Green: Python</li> 234 <li>Red: Java</li> 235 <li>Blue: Javascript</li> 236 <li>Cyan: Parsing a BUILD file</li> 237 <li>Magenta: Third party dependencies</li> 238 <li>White: Anything else.</li> 239 </ul> 240 241 <p>Libraries are normal weight, binaries (including tests) are bold.</p> 242 243 <p>There is absolutely no significance to the choice of colours beyond arbitrary choice 244 when that code was originally written.</p> 245 246 247 <h3>Why's it called Please?</h3> 248 249 <p>Because we liked the idea of sounding polite when typing "plz build", "plz test", etc.<br/> 250 Also we chose the domain name before almost anything else (priorities!).</p>