Good morning. A small think piece. Would Clojure be more popular language if it was written in M-expressions https://lucidglitch.com/posts/clojure-with-m/
I lov this article! I was about to mention YAMLScript, but see that @henrik beat me to it. 😃
I think you should post the article to #news-and-articles too, btw. And for future articles, that channel is a better fit.
Thanks @pez . You are always kind, especially In moments like this, when the world glitches and I, kind of in frustration, write things like this article. Yes, news-and-articles sounds like a nice place. I'll try calva some day 😂
Yes, it's the repl that's printing. Who's printing when we call println? ;)
@andersmurphy but we don't use XML to describe logic. Not in general programming as such. The popularity aspect is limited to describing data whether it is web service or a user interface. JSON too. If we start writing code in JSON we will at some start representing code as arrays and then would have to drop those commas 😄
@stefanvstein I feel lisp with S expressions is the most concise way to use the same syntax for data and code. It is effort sure. But I don't think that gets in the way of Clojure as much as FP and immutable and recursion puts off someone who has never used it much for years. There's also these languages with batteries included web frameworks and rich library ecosystem. I feel those things are also a major issue. As far as syntax goes, one thought for revisiting macros. Is there a lot of value in using the same syntax for code and data. I kind of like the direction Elixir took. Introduced special syntax for AST representation of code which itself otherwise is in more appealing ruby-like syntax. Also, quote, unquote and splice is kind of special already. You've to only deal with it when you write macros. Something we anyway don't write a lot.
@amogh.talpallikar I think I like Clojure better. But I have far more experience with Clojure than Elixir, so it wouldn't be fair for me to compare. I find reading Erlang too difficult. I'm total novice each time. Elixir is far simpler for me to understand. I read F# pretty well. But well formed Clojure is the easiest syntax I know. But sure, I have failed to understand that a macro is a macro many times. I shouldn't judge the Elixir AST representation just yet, I have only toyed with it
@stefanvstein I haven't looked at Elixir AST in depth either. But first glance felt like it tries to make written code friendlier for folks that don't like lisp syntax but still manage a macro system. I agree that Clojure code is as minimal as it can get to express logic! I'll spend some time reading upon M expressions!
@amogh.talpallikar Oh, I think M expressions was paper product by John McCarthy. I guess it was later implemented in mocklisp. I think James Gosling used it when initially porting emacs to unix. Very weird. But an attempt to make lisp more algolish. And Apple tried this too, with Dylan for the Newton, kind of. For me it's just getting harder to read, but I'm curious what the problem really is
Just an observation but JSON and HTML/XML are both very close to S-expressions and are popular.
Yes. Wouldn't we replace JSON and XML with some edn, any day :-)
... and posting the same thing i two groups was a mistake, sorry for that inconvenience.
You can find something of this in Ys, eg. https://github.com/BetterThanTomorrow/calva/blob/published/.circleci/config.ys#L70
Via a completely different, or at least indirect, heritage, but nevertheless.
I don't know the answer to your question, but just wanted to point out that Hello World in Clojure is much simpler that what you wrote in your code.
It's simply "Hello World"
Sure, parametrization and everything, but (str "Hello " a) would also work. As well as many other subtle variations with no need for println.
Even with println, (defn hello [a] (println "Hello " a))
Good morning @blueberry. Each language example in the post uses some sort of string formatting or interpolation. Just to give an somewhat fair view in comparison. I guess String concatenation, like with a StringBuilder on JVM, (str "Hello " a), would work in any of these languages. I did also left out System.out.println in the java example, and assumed that every java programmer do have a static function that they statically refer when they want to print something 😂. I don't agree that a sole string is a hello world function, as it's not a fn? that represents the value, like e.g. (constantly "hello world"). It's the repl that's printing.
(defmacro Loop [& body] `(loop [] ~@body (recur)))
(defmacro Eval [& body] `(try (eval ~@body) (catch Exception e# e#)))
(let [print println]
(-> (read) (Eval) (print) (Loop)))
https://lucidglitch.com/posts/tiny-clojure-repl/New version of https://github.com/mpenet/legba/ is out. It includes a few bugfixes and new/simpler router implementation Legba is a library for building OpenAPI native services in clojure.