17 ms·
Lessons learned after working one year as a Common Lisp Developer (2018)
- isoprophlex 5y agoSo... I want to like Lisp, and every time I read stories like these I understand why people enjoy it. But then I see a code snippet, something like this manual datetime string parser. Apparently the programmer needed to roll their own, and I wonder: how on earth am I going to convince my corpo overlords that this language belongs anywhere near a production system? (let ((year (parse-integer string :start 0 :end 4)) (month (parse-integer string :start 6 :end 7)) (day (parse-integer string :start 9 :end 10))) (- (+ (\* year 31556926) ;; no. of seconds in a year (\* month 2629743) ;; no. of seconds in a month (\* day 86400)) ;; no. of seconds in a day (\* 1900 31556926)))) ;; lisp timestamps start at 1900
- taeric 5y agoPretending that something like that doesn't already exist in production, feels like a lie. As a fun example, I was looking to store durations in iso format, and saw how our analysts would have to parse that out in our data warehouse.
- kqr 5y agoWell, yes, the Common Lisp standard library is showing its age in some respects. I think if you're aiming to use CL in production, you have to plan to paper over some of the standard library deficiencies with third party libraries or custom implementations. And then your concern is already accounted for. (This goes for many other languages too. C, JavaScript, Java, Haskell, R, Perl -- they all have their "holes" in the standard library that need to be filled in.)
- simongray 5y ago> how on earth am I going to convince my corpo overlords that this language belongs anywhere near a production system? This is part of the rationale behind Clojure, being able to lean on established platforms (Java and later JS): https://clojure.org/about/rationale https://clojure.org/about/rationale With that said, though, that parsing function doesn't seem all that complicated?
- darrenf 5y agoThe idea that “a month” has a constant number of seconds (edit: exactly 1/12th of a year) seems peculiar, so I’d argue the function needs to be more complicated.
- dm3 5y agoIt's using a standard-year/month/day convention which might be what's required in that particular case. It's definitely not a generic solution.
- hiptobecubic 5y agoThe point is that it's wrong.
- iostream23 5y agoExcept we just brought the JVM onboard, with its own headaches. The JVM is arguably as much of an obstacle to developing solutions as boilerplate in Java. You end up having to debug obscure JVM errors in production instead of sticking to Clojure. It’s also not doing any of the compiler tricks CL and schemes are noted for.
- simongray 5y agoThere is no silver bullet. Clojure is a great set of trade-offs.
- kaba0 5y agoWhat obscure JVM errors do you talk about? I’ve never ever had a JVM bug and while I don’t have decades of experience, I didn’t start today either. The JVM is hands down the easiest to debug platform, where you can connect to a prod instance remotely and see basically everything. Clojure does have a few not too readable errors, but I think that’s on Clojure’s semantics, has nothing to do with the JVM.
- bitwize 5y agoCL and Scheme can lean on Java as well (ABCL and Kawa). So why tolerate the dirt that Clojure pours in my boot?
- reikonomusha 5y agoCommon Lisp has a decent (but not amazing) number of well supported libraries. It's usually not a problem, except for perhaps really enterprise-y stuff. But Common Lisp is not the language to use in production (at least in a larger commercial context!) if your primary need is CRUD or glue. It does fine at those things, but Lisp is better wielded at problems that require "power in the large", like building a new compiler, solver, simulator, or "engine" of some sort, for instance. For those, the programming language matters a lot more than the libraries, in my opinion. I've had no issue using Common Lisp in production and employing teams to write and maintain it.
- jackdaniel 5y agoPerhaps they didn't know about a library local-time[1]? You can't blame the programming language for the programmer shortcomings. [1] https://common-lisp.net/project/local-time/manual.html https://common-lisp.net/project/local-time/manual.html
- pjmlp 5y agoI once saw someone had implemented the Calendar class from Java (when Java 6 was the latest version). Apparently reading javadoc wasn't his thing.
- bidivia 5y ago>how on earth am I going to convince my corpo overlords that this language belongs anywhere near a production system? Well, I don't see any difference with any other language you could use, from SQL, to C ,CSS or JSON. The fact is that the higher your corpo overlord, the less is he going to understand your scrawl. Instead of them understanding your language, it is you who need to speak theirs. You will need to understand MBA talk in order to communicate in simple terms(elevator pitch) why you using this weird language is important for the company. Then they will leave you alone if what you promised is true, or just fire you if it is not.
- reikonomusha 5y agoThis is true. Usually you have to convince your own colleagues, not management. (Obviously everywhere is different though.) Your senior software engineering colleague who is a huge "Python is the second best at everything" fan will be more of a hindrance than your boss, typically. It's not wholly invalid, but it can easily become a social/political issue rather than a technical one. If someone else is proposing a popular approach (like building a backend in Python), and you're proposing an oddball one (like using Lisp), be prepared for their solution to start off with 50 points of consensus and yours zero.
- hiptobecubic 5y agoGiven that so much of building anything new and delivering it in a timeframe that is useful is risk management, I think that's the right place to start. Especially at a company where the risks of Python are mostly known and the risks of lisp are mostly not.
- hyperman1 5y agoI inherited an enterprise-critical application in, I kid you not, Autohotkey. 5000 actual lines of it, none of them containing any sanity whatsoever. Apparently, some random end user decided to automate a job, other people liked, and it grew all kinds of unholy features. So after one very visible crash too many, the corporate overlords decided it was critical enough for IT to take over. By the time I got it, most of it was calls to Win32 functions, and almost nothing was using any functionality Autohotkey was any good at. I didn't even dare talk about it on the Autohotkey fora at the time, because I was sure the developers themselves would consider me an insane idiot and/or hit me with an axe. I migrated it to another language the day I understood it well enough. One of the great truths of ICT is: Anything can survive production if someone decides to bless it with insane amounts of time and money.
- seanw444 5y ago100% to that last paragraph.
- progmetaldev 5y agoOne of my first jobs was converting this crazy web-first language (HTML/OS) into PHP and/or ASP.NET. The language was like BASIC for the web, and there was so much superstition based on how things actually worked (things like having an empty ELSE on an IF statement because one time something broke and that might be why). I also drastically reduced memory and CPU usage, even taking some multi-hour jobs down to seconds. Luckily this was around 2007 and I have since intentionally forgotten most of that language.
- pjmlp 5y agoBy adopting either Allegro or LispWorks, the Common Lisp environments for big corps, survivors of the Lisp Machine IDE like tooling. Not only they are the survivors, they also come with additional libraries for all kind of stuff not covered by the standard.
- Decabytes 5y agoYea it’s tough. No matter how many times people say, you get the parenthesis eventually, it still is off putting for people when they see it the first time. I'm a big Lisp fan and the parenthesis don't bother me at all. But it's always going to be a sticking point with some people. This is a big reason for the Rhombus project in Racket[1] one of it’s main goals is to be a Lisp like language which combines the extensibility of a parens based language, with infix notation and a different surface syntax 1. https://github.com/racket/rhombus-prototype https://github.com/racket/rhombus-prototype
- martinflack 5y agoWell, let's clarify something - is it the syntax or the self-algorithm? To compare, this is what a psuedo-popular-lang might look like: let year = parse-integer(string, start=0, end=4) let month = parse-integer(string, start=7, end=7) let day = parse-integer(string, start=9, end=10) return ((year * 31556926 + ;; no. of seconds in a year month * 2629743 + ;; no. of seconds in a month day * 86400) - ;; no. of seconds in a day 1900 * 31556926) ;; lisp timestamps start at 1900 Honestly that looks pretty run-of-the-mill to me. Having said that, rolling your own date logic is insanity, as the problem is difficult[1] yet solved[2]. [1] https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b923ca https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b... [2] https://common-lisp.net/project/local-time/manual.html https://common-lisp.net/project/local-time/manual.html
- NoGravitas 5y agoThere's certainly a widely-used library for this (local-time). But there's also a widespread practice in CL to avoid unnecessary dependencies, partly because it's often so easy to write just the functionality you need. That's probably the case here.
- gleenn 5y agoI find it fascinating that the author was forced to learn CL because there were no jobs in Haskell. I believe him, but as a Clojure developer, I find it very hard to find a lot of jobs in any functional language, especially lisps. They exist, but I just don't see a lot of good ones. Someone tell me I'm crazy.
- taeric 5y agoCommon lisp is surprising not functional. It embraces that all things can be first class things. But mutable code is very very easy in common lisp.
- pjmlp 5y agoUntil everyone and their dog decided to turn functional as a synonym for as Haskell does it, Lisp was quite functional.
- bradrn 5y agoMy understanding is that Scheme is quite functional. So were the very first versions of Lisp. Common Lisp, on the other hand, strikes me as not very functional at all (from what limited experience I have of the language). It does have first-class functions, and functions like ‘map’ and ‘reduce’, but that isn’t enough to make it truly functional — it seems to lack the characteristic approach of building functions from smaller functions that is so common in functional languages. (Also, functionality is more of a continuum than a binary category. CL certainly is more functional than Python, but less functional than Scheme or SML. It all depends on where you draw the dividing line, though I’d argue that classifying CL as ‘non-functional’ makes for more meaningful categories.)
- lispm 5y agoThe very first versions of Lisp were less functional than Common Lisp: imperative, mutable data, mostly only dynamic scoping for variables, no lexical scope, first class data type of functions unclear, ... Common Lisp at least has lexical scope and first class functions.
- taeric 5y agoI'm doing this year's advent of code with literate org-mode buffers using common lisp. Been a surprising amount of fun. And I'm coming around to the idea that the loop macro is where most languages are ultimately converging. That and format. Which is remarkable. Certainly dense, but in a "this code is clearly responsible for making a string of that list, serves no other purpose." Something lacking in basically every other language, where a depressing amount of coffee exists simply to make a string of a list of objects. (Amusing, as Java finally got streams, which can look like LOOP, but with more periods. And probably more parens...)
- reikonomusha 5y agoMany folks are doing AoC in Common Lisp and Coalton (a statically typed DSL embedded in Lisp, so you can mix and match static and dynamic code). Many are hanging out on Discord [0] if you're interested in dropping by! [0] https://discord.gg/MCWrVfnJ https://discord.gg/MCWrVfnJ
- medo-bear 5y agoim having a lot of fun using common lisp for aoc too. for fun, my approach is to only use lists and standard lib operations on them. i am really amazed at how elegant and powerful the loop, map*, and reduce operations are. one thing i found that i needed to be mindful of are the different quality operators [0]. [0] http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node74.html http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node74.html
- taeric 5y agoYeah, I'm not using any libraries. Hardest part, typically, is parsing the input in. Mainly because I don't know how. Found some fun dangerous ways that work for me
- Jtsummers 5y agoI just straight used `read` for several of the days. It worked very well, even if it lacked all safety checks you might normally want.
- xept 5y agoThis is "The Good" part of the lessons. There's also "The Bad" one: https://cdagostino.io/posts/2018-03-28-one-year-common-lisp-developer-part-2-the-bad.html https://cdagostino.io/posts/2018-03-28-one-year-common-lisp-...
- nyir 5y agoGreat points on the list too, even though I still think they're more the acceptable trade-offs kind of bad. I.e., yes, of course `caddddr` will be unreadable, probably, so just don't. `declaim` has a sharp edge for a reason, but you can also make things better by increasing the debug and safety level, that's a great idea I really haven't seen repeated elsewhere. The JSON library makes sense, there are several ones and they're all making different decisions wrt. representing the JSON types. I wonder if anyone made a comparison of them with https://news.ycombinator.com/item?id=20724672 https://news.ycombinator.com/item?id=20724672, that would be useful. Lastly, I'd always add "be wary of pathnames", even though I was (am) a big fan of the concept in general, it's just sometimes a bit fiddly with regards to physical filenames that can appear on various systems (that's e.g. why SBCL's `native-namestring` can be necessary, http://www.sbcl.org/manual/#Pathnames http://www.sbcl.org/manual/#Pathnames).
- time_to_smile 5y ago> yes, of course `caddddr` will be unreadable, probably, so just don't I've found in general, while cute that they exist, the ca*d*r family of functions are certainly a code-smell in any lisp/scheme. They're typically a sign you really want a rather different data structure than a list, and if not they can almost always be replaced with `drop`/`take`.
- hajile 5y agohttps://sabracrolleton.github.io/json-review.html https://sabracrolleton.github.io/json-review.html The differences are pretty big. Some use associated lists, some use hash tables, some convert to CLOS, etc
- ir193 5y agoI've seen a lot posts saying condition system in common lisp is unmatched. is there similar thing in scheme?
- medo-bear 5y agonot really. i think out of all the schemes Guile might have the most developed condition system https://www.gnu.org/software/guile/manual/html_node/index.html#SEC_Contents https://www.gnu.org/software/guile/manual/html_node/index.ht...
- deleted 5y ago[deleted]
- klibertp 5y agoYou can roll your own with call/cc, but I'm not aware of any out-of-the-box implementation in Schemes. Racket has an exception-handling mechanism, but it's similar to ones from other languages and it doesn't offer restarts. It does also have a more powerful notion of delimited continuations and continuation marks, which would make rolling your own condition system a bit easier (well, discounting the initial research as to what the heck they are in the first place :))
- TheGrkIntrprtr 5y agoThis book containing interviews with Common Lisp hackers is pretty interesting. https://leanpub.com/lisphackers https://leanpub.com/lisphackers I believe the author worked at grammarly, using CL. Would be nice if he wrote an updated version!