Live data from Hacker News

Ask HN: How to rediscover the joy of programming?

news.ycombinator.com

301–310 of 337 posts

Re: Ask HN: How to rediscover the joy of programming?

#301
post #158
post #18

I had the same issue. Then I went back to the roots: Lisp And learned Clojure. You will feel like you know nothing. You will feel handicapped. You will be confused. Then, one day, you will understand what simplicity means and how Clojure's design embraces that more than in any other language I know. By then you will have embraced the flying-by-your-pants-exploratory style of programming at the REPL. And don't want to…

What is the best way to get started with Clojure these days? So much has changed since the early days.

The language itself is very stable. There were no breaking changes. You can pick up just any Clojure book (even old one), and probably 98% of it still be very relevant.

Re: Ask HN: How to rediscover the joy of programming?

#302
post #178
post #18

I had the same issue. Then I went back to the roots: Lisp And learned Clojure. You will feel like you know nothing. You will feel handicapped. You will be confused. Then, one day, you will understand what simplicity means and how Clojure's design embraces that more than in any other language I know. By then you will have embraced the flying-by-your-pants-exploratory style of programming at the REPL. And don't want to…

Yeah, then you won't be able to get a job anywhere and will puke at the sight of OOP code. Seriously, Clojure is by far my favourite language but with mouths to feed I had to put it down and get serious with JS, Python and Kotlin.

Clojure is still massively helpful to learn, even if it is not the primary language of use. It is guaranteed to make a better programmer from anyone who has never done Lisp or FP before. It is my go-to tool for prototyping - whenever I am not allowed to use Clojure, I still first write an initial prototype in it and then translate it to the target language. Even though that sounds counter-intuitive - I am far much faster compared to if I had to write directly in the target language.

Re: Ask HN: How to rediscover the joy of programming?

#303
post #18

I had the same issue. Then I went back to the roots: Lisp And learned Clojure. You will feel like you know nothing. You will feel handicapped. You will be confused. Then, one day, you will understand what simplicity means and how Clojure's design embraces that more than in any other language I know. By then you will have embraced the flying-by-your-pants-exploratory style of programming at the REPL. And don't want to…

> You will feel handicapped. You will be confused.

For anyone who wants to learn Clojure (or any Lisp) from scratch, here's my advice:

Don't try to learn it by reading books. What I mean: don't try to mentally parse and analyze printed code written in Clojure. For uninitiated Clojure code may look like unreadable gibberish. If you try to understand Clojure code by merely staring at it, it may feel very exhausting.

Remember: Unlike most other languages where the code is "dead" until you compile it an run it, Clojure code is a "living thing," analyzing its "static" properties without evaluating that code makes little sense.

Get an editor/IDE that supports "structural editing." Learn basic structural editing commands - slurp, barf, transpose. Learn/set a keybinding that allows you to evaluate the expression at the cursor.

And then eval your expressions and sub-expressions. That would make it much easier to learn. And would bring joy to the experience.

Re: Ask HN: How to rediscover the joy of programming?

#305

Earlier quoted context omitted.

I really like your comment. > switched to a language that built and ran faster Which one did you switch to?

Go, probably.

yep! but it's not really about Go, it's about finding something that suits my groove. I don't for a moment think Go is the best language (I suspect Rust would be more my thing), but as an ex-Java dev, I'm tired of fighting the tools, and that's something you hear quite often with Rust.

So I compromised by trying Go, and my productivity has been really great. And productivity seems to me to be the thing that is most important about making me happy.

(actually I suspect most people would say they love productivity, but not everyone seems to know how to achieve it).

Re: Ask HN: How to rediscover the joy of programming?

#306
post #178

Earlier quoted context omitted.

Yeah, then you won't be able to get a job anywhere and will puke at the sight of OOP code. Seriously, Clojure is by far my favourite language but with mouths to feed I had to put it down and get serious with JS, Python and Kotlin.

Clojure is still massively helpful to learn, even if it is not the primary language of use. It is guaranteed to make a better programmer from anyone who has never done Lisp or FP before. It is my go-to tool for prototyping - whenever I am not allowed to use Clojure, I still first write an initial prototype in it and then translate it to the target language. Even though that sounds counter-intuitive - I am far much fa…

I don't really get this. If you're working in the usual OOP environment (JS, Ruby, Python, Java) what use is it modelling your solution in a functional language based on immutable data structures? Isn't that like running around naked before putting on your straight-jacket ready for work?

Re: Ask HN: How to rediscover the joy of programming?

#307

Earlier quoted context omitted.

That's a fair point about the Perl example, but Scheme and Common Lisp (including both Chicken and SBCL, last I checked) support (if not outright require) full numeric towers with rational number types, so these are indeed exact representations (unless you explicitly request binary floats for e.g. performance reasons) and not just rounding during printing. There are lots of other examples of doing it "right" (using m…

Yeah, in CL the 0.1 is read syntax for a float (IEEE-754ish on most modern implementations.) If you want exactly 0.1, you’d have to say 1/10. The printer is probably cheating and rounding to the output you expect (I think Python 3 may do this now?) Aside from financial applications, there’s very little reason to care about the trailing remainder.

> The printer is probably cheating and rounding to the output you expect

    northrup@Topaz:~$ sbcl
    This is SBCL 1.5.8, an implementation of ANSI Common Lisp.
    More information about SBCL is available at .
    
    SBCL is free software, provided as is, with absolutely no warranty.
    It is mostly in the public domain; some portions are provided under
    BSD-style licenses.  See the CREDITS and COPYING files in the
    distribution for more information.
    * (= (+ 0.1 0.2) 0.3)
    T
    * (= (- (+ 0.1 0.2) 0.3) 0)
    T
> Aside from financial applications

"Financial applications" happen to be pretty common reasons for number crunching :)

Re: Ask HN: How to rediscover the joy of programming?

#308

Earlier quoted context omitted.

That's a fair point about the Perl example, but Scheme and Common Lisp (including both Chicken and SBCL, last I checked) support (if not outright require) full numeric towers with rational number types, so these are indeed exact representations (unless you explicitly request binary floats for e.g. performance reasons) and not just rounding during printing. There are lots of other examples of doing it "right" (using m…

I am aware of numeric towers and actually checked whether that was going on. sbcl 1.4.16 uses single floats: https://ideone.com/ruw5qi I don't know enough about Scheme to dig under the covers to see how it's being represented internally.

Per my other comment, SBCL's defaults still cause (= (- (+ 0.1 0.2) 0.3) 0) → T. I guess they're technically floats (or at the very least not rationals) given that (= 0.3 3/10) → NIL.

Re: Ask HN: How to rediscover the joy of programming?

#309
post #306

Earlier quoted context omitted.

Clojure is still massively helpful to learn, even if it is not the primary language of use. It is guaranteed to make a better programmer from anyone who has never done Lisp or FP before. It is my go-to tool for prototyping - whenever I am not allowed to use Clojure, I still first write an initial prototype in it and then translate it to the target language. Even though that sounds counter-intuitive - I am far much fa…

I don't really get this. If you're working in the usual OOP environment (JS, Ruby, Python, Java) what use is it modelling your solution in a functional language based on immutable data structures? Isn't that like running around naked before putting on your straight-jacket ready for work?

First of all: every modern version of languages you mentioned has some basic FP primitives; second: most of the time, it's all about the logic (algorithm) and data transformations. Yes, sometimes, it feels weird, like trying to glue every single hair back onto your chin after you shaved your beard off. And of course, the approach has certain limitations - you can't use macros, you have to be careful with recursion and lazy evaluations, etc. And it only works for small problems, and I'm not talking about maintaining big projects that way.

Re: Ask HN: How to rediscover the joy of programming?

#310

Earlier quoted context omitted.

Yeah, in CL the 0.1 is read syntax for a float (IEEE-754ish on most modern implementations.) If you want exactly 0.1, you’d have to say 1/10. The printer is probably cheating and rounding to the output you expect (I think Python 3 may do this now?) Aside from financial applications, there’s very little reason to care about the trailing remainder.

> The printer is probably cheating and rounding to the output you expect northrup@Topaz:~$ sbcl This is SBCL 1.5.8, an implementation of ANSI Common Lisp. More information about SBCL is available at . SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more…

This just means that 0.3 has the same internal representation as the result of (0.1 + 0.2).

Internally, they're probably both 0.30000000000000004 (depending on precision), so an equality check returns true.

It could also be that they're both 3/10 rational numbers, but given other tests in this thread that's likely not the case out the box.

Post reply on HN