12 ms·
Why Language-Oriented Programming? Why Racket?
- jhorsager 8y agoI hear this alot about Racket as if this is the value proposition and Racket stands alone with these features. Languages like Ruby are routinely used to build DSLs (RSpec, Rails, ServerSpec, Chef...etc). I would like to hear somebody address why Racket is superior to languages like Ruby for creating DSLs, because it for sure doesn't stand alone. Metaprogramming is a feature in a LOT of languages. I'm not arguing for those languages, I'm arguing Lisp languages aren't the only ones capable of creating other languages and a comparison would be more useful than repeated emphasis on unique ability for the task which I don't think is necessarily true.
- xrayspec 8y agoThe author acknowledges that other languages can be used for DSLs. He claims that Racket's hygienic macro system is the special feature that makes it superior for the task.
- creatornator 8y agoIn practice most Ruby "DSL"s are just regular libraries that you happen to be able to use without the familiar foo(bar) function call syntax. It's the difference between "Domain Specific Language" and "A Domain Specific Language", or embedded vs. hosted/standalone DSL's [0]. The value that Racket provides is facility in developing standalone languages, as opposed to the embedded DSL's that people make in Ruby. To address the examples you gave, RSpec, Chef, etc., those literally ARE just using Ruby, no new syntax, no new semantics. [0] https://www.quora.com/What-is-an-embedded-domain-specific-language https://www.quora.com/What-is-an-embedded-domain-specific-la...
- wildermuthn 8y agoIf I’m understanding the article correctly, it should be possible to create a Racket language that compiles to any other language. A quick google does reveal work has been done on C and Python, although it appears there are bugs and various work-arounds that precludes a full and clean integration. The Javascript integration appears dead (in terms of using the latest version of Racket) Although using Racket for this wholesale integration appears impractical, it does suggests a killer-app: extending general programming languages. In other words, using Racket as a transpiler. I.e., a better Babel.js, but for any language. I routinely use Python for machine learning tasks, but frequently am frustrated by the inflexibility of the language. Instead of solving the problem itself I have to first solve how to make the language do what I want (usually resulting in code that lacks expressiveness and brevity, and thus extensibility). I’d love to use lisp to leverage ML work that can only be done effectively in Python (Tensorflow, PyTorch, etc). Can Racket be an effective transpiler?
- xrayspec 8y agoIIUC Babel.js is essentially a fancy preprocessor for JS. So if by that analogy, you mean "can I use Racket to design my own notation that compiles to Python", yes of course.
- hardwaregeek 8y agoI was thinking recently about why I find programming languages so interesting. The answer I came up with was that programming languages allow you to create your own reality. You get to define how things work in this reality. Want functions to be values that can be arguments and return values? Sure! Want a lot of crazy symbols to do complicated math? Go for it! Want everything to be dynamic? Why not. The caveat that comes with this description is that sometimes people shouldn't create their own reality. Whether it's making decisions that ultimately lead to really screwy universes or just not being prepared to deal with the power that comes with changing the very fabric of reality, some people will not mesh well with LOP. And there's nothing wrong with that.
- nikki93 8y agoA pretty great example of "microworlds" from Seymour Papert'a "Mindstorms," which you would enjoy!
- black-tea 8y agoYeah, that's what I like about languages like Lisp and to a lesser extent Python and, conversely, why I dislike languages like Go.
- elizabeth_olu 8y agohttps://www.elizabethblog.com.ng/2019/02/rkelly-arrested-and-charged-with-10.html https://www.elizabethblog.com.ng/2019/02/rkelly-arrested-and...
- yesenadam 8y agouh..What is? (what you like about them)
- k__ 8y agoGo has quite its own reality. Structural typing, no generics, interface oriented. Sure, Java has interfaces, C doesn't have generics and TypeScript is also structurally typed, but I guess nominal typing, generics, and OOP is what most people who like static typing in the first place prefer.
- mpweiher 8y agoAbout a decade ago, I would have agreed with this 100%, and I still am fascinated and, quite frankly, awed by Racket and LOP (and looking forward to Racket Fest 2019 here in Berlin[1]). But. (You knew there was a "but"). While I don't quite agree with the assertion that with the right tooling (so: this tooling), creating a language is as easy as creating a library, I don't think it would solve our problems even if it were true. Language design is much harder than library design, even if the tooling is perfect and transparent. In the extreme we're going to end up with what Alan Kay calls inverse vandalism[2] aka the Mount Everest Effect: making things because we can, not because we should or they're good. In essence, designing a (domain specific) language should be your last resort, not your first resort. At least one that requires a parser or macro system to implement. After all, when we create a library, we are in fact creating a domain specific language, or at least a domain specific vocabulary. A framework goes a little further towards the idea of language. In fact, the first version of Simula was a simulation DSL. It was the second version that made the language into an OO language and the simulation "DSL" into a framework. The advantage being that you can use the same language with different frameworks for other domains. If we look at natural language, it is very much the same: we use the same language to talk about any number of domains, the most we tend to add is some domain-specific vocabulary. Imagine the tower of babel we would suffer under if every domain had a completely new and different language! That effect was very much encountered and later described by the LRG at PARC when they started using Smalltalk 72, which allowed every object to defined its own language[3]. It was chaos! Turns out we are not very good language designers in the heat of the programming battle. So they very consciously made the language more restrictive later. However, the Smalltalk message syntax is specifically designed to give you something akin to DSL, but without most of the problems[4]. A similar effect was documented by Bonnie Nardi for end users. Here as well, the expectation was that users would prefer domain-specific tools that were tailored exactly to their needs. This, surprisingly, turned out not to be the case. End users apparently vastly prefer general tools, even if the effort to adapt them to specific tasks is greater (see also: people writing documents in Excel...) That said, current general purpose programming languages are probably not quite flexible enough. I think there is a sweet spot to be found somewhere between Smalltalk-80 and something like Racket. [1] https://racketfest.com https://racketfest.com [2] http://worrydream.com/EarlyHistoryOfSmalltalk/ http://worrydream.com/EarlyHistoryOfSmalltalk/ [3] http://stephane.ducasse.free.fr/FreeBooks/BitsOfHistory/BitsOfHistory.pdf http://stephane.ducasse.free.fr/FreeBooks/BitsOfHistory/Bits... [4] https://youtu.be/Ao9W93OxQ7U?t=627 https://youtu.be/Ao9W93OxQ7U?t=627
- deleted 8y ago[deleted]
- quelltext 8y agoIf you create whole new languages, i.e. external languages, not really embedded DSLs, with their own syntax, how is Racket better than other languages at implementing those? Neither the sntax object, nor hygiene are of concern when you build external DSLs, which the author's examples seem to be. I have not yet seen a compelling argument for Racket there vs. for instance a parser generator framework. I might just be missing the point. Either way the author's convincing seemed to have failed for me.
- choeger 8y agoI think racket makes it simple to compose your language implementation modules. So e.g., hygiene could be imported (with minimal adaptions to your syntax/binders).
- quelltext 8y agoYeah, that's true. I would love to read an article about that with practical examples, i.e. showing that language composition is really a common and needed pattern (not just a theoretic concern, ... are LOP users really composing several language modules often?), and how Racket enables it.
- elizabeth_olu 8y agohttps://www.elizabethblog.com.ng/2019/02/maduguri-in-explosion-as-boko-haram.html https://www.elizabethblog.com.ng/2019/02/maduguri-in-explosi...
- Rasyidsugar 8y agoBy the way I wrote an article about an English grammar. maybe it could be useful for you .. https://www.tolongtangtugas.web.id/2019/02/master-present-perfect.html https://www.tolongtangtugas.web.id/2019/02/master-present-pe...
- pge 8y agoIn LISP-like languages like Racket, the code is a list. That is, a program is just a list of tokens (a b c), the same data structure one would use for storing any other kind of data (the equivalent of Python’s [a b c]). When programs are themselves just lists, they are easy to manipulate with code. So, in LISP-like languages, it is easy to write code that writes code. That makes them especially suitable for domain-specific languages or LOP. You can write functions that write code, making a new language. I think PG has some writings on this topic, but I don’t remember if it is online or in his LISP textbooks. His company Viaweb did this, IIRC, using a DSL written in LISP to generate HTML.
- findingbuzz 8y agoso many programming languages... i wonder if there is someone that knows them all
- bling0bling0 8y agoI find it a pretty amazing feat that the author has created a programming language (Racket), then used it to create another language called Pollen[1] for book publishing, then went ahead and used Pollen to publish three books. Oh and the fonts are designed by him too[2]. [1] https://docs.racket-lang.org/pollen/ https://docs.racket-lang.org/pollen/ [2] https://mbtype.com/ https://mbtype.com/
- seotut2 8y agoNo, the author hasn't created Racket. The author is the lawyer https://en.wikipedia.org/wiki/Matthew_Butterick https://en.wikipedia.org/wiki/Matthew_Butterick. Racket was developed by PLT Inc.
- DonaldPShimoda 8y ago> Racket was developed by PLT Inc. There's not a lot of information on PLT Inc. these days, so: Racket was developed under direction of Matthias Felleisen, with his students Matthew Flatt, Shriram Krishnamurthi, and Robby Findler serving as the core development team. They also published the book "How to Design Programs" [0], and Krishnamurthi published "Programming Languages: Application and Interpretation" [1], which are both books that rely on Racket. (PLAI actually uses its own language which is developed in Racket, called plai-typed, but which relies on the DrRacket environment.) [0] https://htdp.org https://htdp.org [1] http://www.plai.org http://www.plai.org
- deleted 8y ago[deleted]
- zzless 8y agoAs the comment below points out the author did not create Racket. However there is an author (Donald Knuth or DEK as he is known) who did just that: create a new language (two of them: TeX and METAFONT) for typesetting and making fonts, created new fonts (Computer Modern), published a series of books about the languages and the fonts, AND the programs that implement these languages. Then he used his creations to typeset his 'The Art of Computer Programming' (or TAOCP) books.
- mark_l_watson 8y agoI bought two of the author’s books and also enjoy his newsletter. That said, I still have not drank the LOP coolaid, yet. I almost always start Lisp development projects in a repl, getting low level things I need working. Initially I don’t worry at all about making things tidy. I keep this process going until I have something that works. Then I start cleaning up code, perhaps factoring out common code, etc. If I see enough value in the new code and if it makes sense, then I move parts out to a separate library. It is at this point, after experimenting with a problem and having good code, that I think in some cases it would be good to step back and decide whether to design a new language for the type of problem you just solved.
- komalkshp 8y agoAmazing girl
- cubano 8y ago"Before you leave, please know: I’m hedged either way. LOP and Racket have been an incredible force multiplier on my programming productivity" Well, wouldn't we expect that the author of a particular programming language to be mad productive in it because, you know, they designed all the mental models and assumptions that are baked into it? You would never once stumble on syntactic ambuigity because, to you, there is no ambuigity...or perhaps there is but you slyly added that bit just to fuck with programmers heads...or who knows the reason. I'm just postulating that for an author to boast about their productivity with the language they designed is somewhat self-serving.
- kasey_junk 8y agoThe author of this article is not the author of Racket. Racket is built by a team and has been around a long time.
- deleted 8y ago[deleted]
- bsaul 8y agoI'm currently browsing the list of languages made with racket (here http://docs.racket-lang.org/search/index.html?q=H%3A http://docs.racket-lang.org/search/index.html?q=H%3A) and it seems like most languages are just lisp variants. I suppose they were made for educational or fun purposes, but i wonder if i haven't missed something more deep as to why someone would want to reimplement a lisp in a lisp language.
- cat199 8y agosemantics != syntax
- darkpuma 8y agoIt's not that those languages are "lisps", they just mostly use s-expressions. That's because the syntax isn't what they're trying to innovate on, or what they're trying to stand out with. And also because once you understand s-expressions, it becomes kind of hard to justify not using s-expressions. Honestly, why bother with novel syntax when your PL semantics can be expressed in terms of s-expressions?
- spdegabrielle 8y agoA sampler of languages is at https://docs.google.com/spreadsheets/d/1K4IbX0OH8pz1qebG5lIaQynFIFAO2vqBA8EuCClRSSI https://docs.google.com/spreadsheets/d/1K4IbX0OH8pz1qebG5lIa...
- jellybellys 8y ago2 reasons: 1. Lispers often find s-expression syntax easier to edit for many applications. So it's not surprising that a lot of the folks who design languages in Racket also might choose an s-expression syntax for their language design. 2. By using the same (or similar, in the case of Pollen/Scribble/...) syntax as the main racket language, it's easy to give access to the full power of racket in a DSL.
- e12e 8y agoI'd say most are racket variants - and that makes sense - the scribble lang (for documentation/documents) is a prime example of that kind of "tool" DSL, and "lazy" (as mentioned by another commenter) is another. https://docs.racket-lang.org/scribble/getting-started.html https://docs.racket-lang.org/scribble/getting-started.html But there's also stuff like: http://docs.racket-lang.org/sweet/index.html http://docs.racket-lang.org/sweet/index.html And after a quick Google I found: https://github.com/soegaard/minipascal https://github.com/soegaard/minipascal And there are of course things like: https://docs.racket-lang.org/datalog/datalog.html https://docs.racket-lang.org/datalog/datalog.html But I suppose that qualifiés as "lisp like"... [ed: and the article mentions "brag" which I think would be odd to call "lisp like" : https://docs.racket-lang.org/datalog/datalog.html https://docs.racket-lang.org/datalog/datalog.html ]
- platz 8y ago> maximum precision Sometimes maximum precision means having a first-class typechecker & type inference. (You could build some of that too in Racket if you really need to. Of course, that code itself will not be verified or typechecked.) > Why aren’t these languages DSLs? They aren't DSL's because they need statically-linked binaries, and good error messages, and then your task is not as easy as desugaring to a LISP/dynlang.
- adjkant 8y ago> Of course, that code itself will not be verified or typechecked. Easy, just used typed Racket :)
- platz 8y agoOk, so now you have Typed Racket (that last point was a relatively minor comment on the larger argument). Does implementing the above then correspond to the strengths as described in LOP?
- adjkant 8y agoI'm not sure I'm fully following what you're getting at due to the terseness and my first comment was more of a fun note that you can always build on language features, but generally speaking you could inherit and use the types and checking of Typed Racket in your DSL and still add the syntax you want for increased precision.
- adjkant 8y agoAn interesting tangent I think about sometimes: I think when people think about "programmers/developers" vs "computer scientists", this is where the difference could really show up in the future. A developer who knows how to code and hack may not have the skill/design knowledge to properly create a language/DSL, perhaps making a monster in the process. A well trained computer scientist (academic, self taught, doesn't matter) should have those tools and more importantly the design know how. A lot of teaching (again in both academia and not) really lacks on teaching good design for programming generally. I think we're already starting to see this difference show up with libraries and frameworks (somewhat already DSL's themselves), and if we keep moving towards the direction of DSL's I think you will find many of the bright programmers of tomorrow going away from writing code to make things but instead code to make languages to make things. The final step of code to thing (from a technical perspective) seems to become increasingly boilerplate more than ever before as tooling keeps expanding. You still need to know the deep internals for large scale things, but it's never been easier to spin up a quick project that "just works" and does quite a lot. If library/framework/language creators do their job, this should only get easier. At a certain point I wonder if the actual programming ever becomes a "lower tier" of the software world.
- maxhallinan 8y ago> A developer who knows how to code and hack may not have the skill/design knowledge to properly create a language/DSL, perhaps making a monster in the process. A well trained computer scientist (academic, self taught, doesn't matter) should have those tools and more importantly the design know how. The author of Beautiful Racket, Matthew Butterick, is a lawyer and a typographer. He is not a computer scientist. And yet, he designed a DSL called Pollen for creating web-based books. Pollen has been quite successful within the Racket community. My understanding is that Racket is predicated on the idea that people like Matthew, as much as people like your computer scientists, are the best authors of DSLs. They are the ones who understand the domains they're working in. If the division you predict ever does exist, it is because the tools have failed to make people who are not computer scientists capable of creating the DSLs they need to solve their problems. It's not because languages are inherently better designed by experts in the domain of programming languages.
- Rasyidsugar 8y agoLanguage is an interesting thing to be discussed .. The fact, there are many people here discuss it .. In addition, I try to maintain my English by writing some articles, such as 1. https://www.tolongtangtugas.web.id/2019/02/master-present-perfect.html https://www.tolongtangtugas.web.id/2019/02/master-present-pe... 2. https://www.tolongtangtugas.web.id/2019/02/belajar-asyik-simple-present-tense.html https://www.tolongtangtugas.web.id/2019/02/belajar-asyik-sim... See that, if you like .. thanks ..
- DyslexicAtheist 8y agoI like his style of writing and how elegant and powerful LOP is. The jsonic snippet is insane (in a good way). In the wrong hands or for the wrong job it could lead to a security disaster though. Still pretty cool to be able to think out of the box like this. Makes me rethink totally the way we do things and why. #lang jsonic // a line comment [ @$ 'null $@, @$ (* 6 7) $@, @$ (= 2 (+ 1 1)) $@, @$ (list "array" "of" "strings") $@, @$ (hash 'key-1 'null 'key-2 (even? 3) 'key-3 (hash 'subkey 21)) $@ ]
- agumonkey 8y agomethinks a lot of the programming world at the interface (semantics/syntactic/ergonomic) is .. implicit tree processing. see html encoding through functions, or kotlin builders, or json dsl ..
- GorgeRonde 8y agoAs a Clojure programmer I find Racket's "#lang" feature fascinating, all the more so it seems to be doing exactly the opposite of what's recommended in Clojure: favor data over functions over macros. Personally most of the DSLs I write in Clojure are "private" (i.e. I write them for myself to help me develop a library or an app) and thus they tend to be small. This is why I favor functions over data: it allows me to reuse common function combinators (e.g (fn or-fn [f g] (fn [& args] (or (apply f args) (apply g args))))) so that I do not have to reimplement them which is something you have to do if you approach the problem with a data-first mindset. Instead, if I really want to prettify such function-based DSLs by bringing forth the use of data to express the problem at hand, I write a DSL-as-data parser and implement it as one or multiple DSL-fns. More @ https://gist.github.com/TristeFigure/20dd01b0d3415f34075cfc02a1918106 https://gist.github.com/TristeFigure/20dd01b0d3415f34075cfc0... How does this compare to Racket DSLs ?
- juliangamble 8y agoSome notes on Data > Functions > Macros in Clojure: https://lispcast.com/data-functions-macros-why/ https://lispcast.com/data-functions-macros-why/
- wool_gather 8y agoThis is tangential to the article, but. Scheme was one of my first languages and I would love to pick it/Racket up again. But the Racket IDE (like DrScheme before it) is painful to use. Especially compared to a more "native" Mac editor. Has anyone used Racket with success in another IDE or programmer's editor?
- soegaard 8y agoTry `racket-mode` for Emacs. It has many of the features that DrRacket has. https://github.com/greghendershott/racket-mode/blob/master/Reference.md https://github.com/greghendershott/racket-mode/blob/master/R...
- wool_gather 8y agoI'll give it a go, thanks!
- dangom 8y agoDefinitely interesting, and the examples look nice, but biased in that absolutely no evidence is given to support that LOP makes anyone more productive.
- dullcrisp 8y agoI’m sorry to nitpick on a good article, but this article lost me when it proved that HTML is a programming language by showing that it can be output by a Python program. This seems to be a case of proving too much [0]. [0] https://en.wikipedia.org/wiki/Proving_too_much https://en.wikipedia.org/wiki/Proving_too_much
- Retra 8y agoIt may be proving too much, but it is also arguing the general point. Your objection would be that this example would prove that all strings are programs, which might seem absurd. But in fact, all strings are programs if you haven't specify which interpreter they are supposed to be programs for. Either way, that seems like a silly approach, IMO.