📜 ⬆️ ⬇️

End of an era of dynamic languages

The last few months I have been programming mostly on Scala (for work) and on Haskell (for the soul). This week, I, however, a little more pee on Ruby (for work) and Clojure (for the soul).

Ruby took me off balance almost immediately. No, well, still in terms of "add a small feature to the existing code" you can write on it. You simply add a unit test, run it on the old code, edit it, run the test again - voila, ready, take it. But to threaten something more becomes too difficult.

But as for my new, spick and span, project-favorite on Clojure ... Oh, Clojure! Breath of fresh air! Fertile land of well-composed functions, immiable data structures and all that. How beautiful is your syntax and how wise your sensitivity! All your essence in the functions accepting and returning. Both your SQL generator, the database access layer, the HTML parser, and the URL router are one and the same fascinating picture of mappings, driven back and forth by processor ticks, excellent with its rhythm of well-assembled Swiss watches.
')
Returning to Clojure after a long time is like being at home. It just inspires the programmer. But for some reason this time I felt another feeling unexpected for me: uncertainty.

My dialogue with Clojure looked something like this:

- Oh, my light, Clojure! Thank you for this amazing immutable data structure with a query map. May I ask what is inside?
- Isn't it obvious? There is an HTTP request.
- Yes, yes, of course. But in what kind exactly? What are the keys and what are the values?
- Isn't it obvious? There is an HTTP request.
- Yes, yes, of course. I read the source code and documentation in search of an answer.
- Yes, read it and figure it out.
- I read. And what are the variables attr and f? And when I call the function wrap-params - what keys are added to the map?
- Isn't it obvious?
- Forget. I'll just add a debug output here and here.

All this beats on productivity. Each call to a library function, if you have not learned it by heart, requires you to rummage through the source code trying to figure out how to use it. Each map received after the call requires a debugging output in order to understand what to do with it.

Yes, Clojure is a powerful thing. But this power is uncontrollable, it does not have a vector, and without someone who can give advice, it can only destroy. And now I’m not talking about philosophical concepts, only about code. Which of us did not suffer from Ruby metaprogramming or Clojure mappings? We ourselves and the victims and the perpetrators of our suffering.

Here's an example: is domain-oriented languages ​​(DSL) a way to solve problems, or another way to create them? Let's talk about DSL's destructive power in Clojure. Clojure programmers love DSL, and the language structure predisposes them to use. But I think that something is wrong here. Let's, for example, imagine such an HTML generator. Here you are instead

<span class="foo">bar</span>


:

[:span {:class "foo"} "bar"]


, DSL HTML? : HTML. , , DSL, ( ) , HTML , ?

enlive yesql , .

DSL, , , DSL , . bidi, URL-. , «». , GET /notes. bidi :

(def my-routes
  ["/notes" :index-handler])


:

(bidi/match-route my-routes "/notes")
;; {:handler :index-handler}
;; Success!

. , :

GET /
GET /notes
GET /notes/:id
POST /notes
POST /notes/:id

! - Ctrl+F , , , , , :

(def my-routes
  ["" {"/" :home-page-handler
       "/notes"
         {:get  {"" :index-handler}
          :post {"" :create-handler}
          ["/" :id] {:get  {"" :show-handler}
                     :post {"" :update-handler}}}}])

, , ? , ?


: . , , . . « ». ? . , , ?



(Gradual typing)
: Typed Racket, Typed Clojure, TypeScript, Typed Lua. Python "type hints"

, . , , - .

, , . -, , . Clojure , ? ? .

, , , - «, », . ?

, — . , , , . .


, , , , ? ! - !

, . , , - . - , , . — .

, , . , , ?

hlint Haskell ( ) . , . , :



, . , , - ? , ?


, , , .

Scala , , Solr. , Solr null . , , , Clojure. . . , , , . -. : , isItPorn() null?

: . , , null .

2 Scala. . , . .

. . , . !

Ruby , , Clojure . . .

: , Ruby - . , , , . — - . .


: . . . , ( -), , . , .

. — , Clojure, . , , .

, , , . . , . , Elm Crystal , Haskell Scala. .

, , , . — -, . , , «, !». , , — , ? , ? .

«, ». , . , , . , , . , - . , .

Source: https://habr.com/ru/post/271705/


All Articles