Hacker News new | ask | show | jobs
by LandR 2496 days ago
I think if all you are doing is reading files line by line, reading a database dataset etc, then your choice of language is probably irrelevant. Choose whatever you prefer typing.

But here's CLojres read a file line by line and print it out:

    C:\\foo.txt
    "THis is line 1
     This is line 2
     This is line 3"

     (with-open [rdr (io/reader "C:\\foo.txt")]
        (doall (map println (line-seq rdr))))
      =>THis is line 1
        This is line 2
        This is line 3
A simple function to read a specified file line by line

   (defn read-file-line-by-line [file-path]
      (with-open [rdr (io/reader file-path)]
         (doall (line-seq rdr))))

   (read-file-line-by-line "C:\\foo.txt")
   => ("THis is line 1" "This is line 2" "This is line 3")
To read the line by line and convert them to upper case

     (map clojure.string/upper-case (read-file-line-by-line "C:\\foo.txt"))
     => ("THIS IS LINE 1" "THIS IS LINE 2" "THIS IS LINE 3")
1 comments

I don't think this is remotely true. Compare doing file parsing in Python, Perl, C#, Java, Common Lisp, OCaml, Ada, Fortran, C++...etc.

Doing it in Python is easy...it is a bigger pain in several of the other ones. Even your Clojure examples are definitely more work than in Python. You even defined a helper function (something I've never needed to do in Python) as the default is so easy. Mind you, the Clojure isn't too bad and definitely better than some of the others I've mentioned.

To your average developer...this is indeed probably irrelevant as IO might be a small part of your codebase. I do a lot of process automation though and do a lot of IO.