git » homepage.git » master » tree

[master] / archive / forums / hacker-news / raw / items / 18775023.json

{"by":"wooby","id":18775023,"kids":[18775200,18775165],"parent":18774888,"text":"At a Clojure meetup I attended a couple years ago, a long-time Java programmer asked &quot;how do you manage huge projects without static types?&quot;<p>The best answer I could think of was, &quot;don&#x27;t manage huge projects.&quot; Instead, divide projects as early as possible in development into supporting libraries, each capable of being independently tested and maintained.<p>In my experience, applications developed with this attitude coalesce themselves into a small ecosystem of mostly generic library code with a domain-specific apex &quot;application&quot; entrypoint to bind them.<p>In an application factored like this, type checking isn&#x27;t something you want as much anymore, since the constituent libraries interface with one another at a level above. They present and consume &quot;public&quot; (intra-application) APIs, the behavior of which are defined not just by types but by at least documentation and tests. The thing that static types let you do -- have huge amounts of code, woven together with structural dependencies -- is no longer a thing you need or want. It would seem bad, actually, since what you&#x27;d have is an inscrutable mass only a machine can understand.<p>I haven&#x27;t worked enough with large non-Clojure codebases to say whether or not this approach is superior, but I can say that it scales. Another nice thing about it in a business setting is that supporting libraries lend themselves to open-sourcing, and a relationship with an open source community is a good thing for a company&#x27;s development efforts&#x2F;hiring&#x2F;contracting in my experience.<p>To answer your specific questions:<p>* I don&#x27;t think I write more unit tests (I should probably write more tests in every language I use)<p>* I don&#x27;t have any experience with clojure.spec<p>* All of the features of Lisp work together to make it awesome, including macros. In particular, in the context of an &quot;ecosystem of libraries&quot; approach, macros are a fantastic tool for exporting a DSL from a supporting library. They&#x27;re also use for DSLs in the apex code, where application-specific behavior can be defined in terms of a DSL.<p>* I don&#x27;t really wish I had static types - I love Lisp the way it is. But I have found various languages for structural checking useful with certain kinds of sub-program, like receiving data from the outside world, and for writing compilers. If you write a compiler as a series of transformations, it&#x27;s nice if the shape of the code between transformations is well-defined somehow.<p>You&#x27;re definitely smart enough to use Lisp. I think the key to success is not necessarily smarts, but attentiveness to modularity or cognizance of the difference between &quot;library&quot; and &quot;application&quot; types of code.<p>* There&#x27;s a Paul Graham essay related to this idea: <a href=\"http:&#x2F;&#x2F;www.paulgraham.com&#x2F;progbot.html\" rel=\"nofollow\">http:&#x2F;&#x2F;www.paulgraham.com&#x2F;progbot.html</a><p>* I think this approach is applicable not just to Lisp, but maybe to any dynamic language with a sufficiently rich set of generic collections and with the concepts of a &quot;module&quot; or &quot;package&quot;.","time":1545974273,"type":"comment"}