215
LISP is ugly (lemmy.ml)
submitted 2 years ago by [email protected] to c/[email protected]
all 42 comments
sorted by: hot top new old
[-] [email protected] 57 points 2 years ago

If your code is that deeply nested, surely something has gone horribly wrong, yes?

[-] [email protected] 14 points 2 years ago

Problem is that Js kind of encourages this being single threaded and using callbacks for anything blocking. To be fair, the new async syntax sugar helps in modern Js, but nesting a bunch of callbacks or promises was basically the way you did stuff for the longest time.

[-] [email protected] 15 points 2 years ago

Yes and no. Any programming language encourages nesting as in the end the computer does nest your code. So it is only normal and predictable that languages would reflect that. BUT! Nest logic can often be inverted and by doing so, reduce how much nesting you need to do.

If (data is not null) {
    If (data has field x) {
         Return data x
    } else return null
} else return null

Can be

If (data is null) return null
If (data hasn't field x) return null
Return data x
[-] [email protected] 0 points 2 years ago

I'm not arguing that avoiding deep nesting is a good idea, or that techniques foe doing that don't exist. I'm just pointing out that Js style programming naturally leads you to nesting things because of the nature of callbacks. Notice how your example isn't using callbacks.

[-] [email protected] 5 points 2 years ago

Yeah and you can void nesting there just as easily and you have the same issues in any other programming language. You just need to create functions. Also JavaScript is not single threaded... you only have access to the dom on one thread, for obvious reasons.

Please explain to me how you do e.g. file downloads without a callback in your favorite language. If you solution involves having the main thread being stuck in a while loop, I am not sure if your complain about nested code can be taken seriously.

[-] [email protected] 10 points 2 years ago

Code aesthetic: If your code looks like a triangle, you're seriously doing something wrong.

[-] [email protected] 5 points 2 years ago

I prefer a bunch of

if (fucked_up) {return(error_code);}

for checking common errors.

[-] [email protected] 2 points 2 years ago

Yup, never nest.

All the conditions should be checked and returned if they failed as you go through the function with the successful response being the last line.

[-] [email protected] 36 points 2 years ago
[-] bdonvr 18 points 2 years ago

Directly linking the file of an XKCD should be illegal

https://xkcd.com/297/

[-] [email protected] 10 points 2 years ago

Linking to images should be illegal

[-] [email protected] 6 points 2 years ago* (last edited 2 years ago)

I'll let Randall Munroe decide that himself, considering the fact that he provides URLs for hotlinking below the comics

[-] bdonvr 7 points 2 years ago

I don't mean the act of embedding or direct linking in general, but in link aggregators these comics are well known for their alt text, which cannot be seen from the direct link.

I think a good practice might be embedding the comic directly in your comment along with a "source" link.

[-] [email protected] 2 points 2 years ago* (last edited 2 years ago)

these comics are well known for their alt text

It's title text, or in web comic circles, hover text. The linked comic's alt is simply Lisp Cycles.

[-] [email protected] 12 points 2 years ago

Back when I was still in school, I ran a few tests on real world LISP and Java (the then dominant language, this was in the late days of Sun Microsystems succes).

Turns out most LISP programs had fewer parentheses then Java had braces, parens and brackets.

[-] [email protected] 0 points 2 years ago

Java follows the paradigm of boilerplate oriented programming.

[-] [email protected] 8 points 2 years ago

If your code looks like this, you seriously need to reconsider your code

[-] [email protected] 6 points 2 years ago

are there any JS fans who argue that it's elegant? i thought the supposed advantage was that it's flexible and universal.

[-] [email protected] 10 points 2 years ago* (last edited 2 years ago)

It's a stockholm syndrome kind of thing.

[-] [email protected] 2 points 2 years ago

Well, universal, anyway.

[-] [email protected] 2 points 2 years ago

Well my Js isn't looking like that and it is really easy not too. But bad people write bad code.

[-] [email protected] -1 points 2 years ago

Weirdly, I've seen plenty of people who appear to genuinely like Js and Ts.

[-] [email protected] 1 points 2 years ago

I learned Lisp at uni and hated it. Thankfully that was long enough ago that I’ve forgotten everything I learned about it.

[-] [email protected] 30 points 2 years ago

I’m sorry to hear you learned nothing.

[-] [email protected] 14 points 2 years ago

Yeah - pure functions and immutable data aren't always the right answer, but appreciating that they're damn good most of the time is a good first step. Writing obvious code that does exactly what it appears to do at first glance and not one thing more? Your colleagues will thank you when they have to work with your stuff.

[-] [email protected] 9 points 2 years ago

And metaprogramming and tail call optimization and and…. At least other languages are starting to catch up with this 60 year old language, by for instance implementing lambda expressions.

this post was submitted on 24 Sep 2023
215 points (93.2% liked)

Programmer Humor

38328 readers
5 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS