tag:blogger.com,1999:blog-2447174102813539049.post6183408182308465326..comments2024-03-29T00:46:13.051-07:00Comments on Room 101: Reflecting on Functional ProgrammingGilad Brachahttp://www.blogger.com/profile/17934280339206214042noreply@blogger.comBlogger23125tag:blogger.com,1999:blog-2447174102813539049.post-60676381841794566982023-10-12T05:18:50.293-07:002023-10-12T05:18:50.293-07:00In the dynamic world of enterprise software develo...In the dynamic world of enterprise software development, mastering SAP Web Dynpro is an indispensable skill that can catapult your career to new heights. If you're in Noida and looking for top-notch <a href="https://arnavdigital0.wixsite.com/my-site/post/sap-web-dynpro-training-in-noida" rel="nofollow">SAP Web Dynpro Training in Noida</a>, look no further than ERP NOIDA. Our comprehensive training program is tailored to equip you with the knowledge and skills necessary to excel in the ever-evolving field of SAP Web Dynpro.<br />arnav digitalhttps://www.blogger.com/profile/08137760346894839687noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-68270559055289326012022-02-17T02:39:47.019-08:002022-02-17T02:39:47.019-08:00SAP Web DynPro Training In Noida<a href="https://emaze.me/sap-webdyn-pro-course-in-noida" rel="nofollow">SAP Web DynPro Training In Noida</a>ERP Training Noidahttps://www.blogger.com/profile/16035514502876470407noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-30908377257900761992011-06-05T14:23:01.612-07:002011-06-05T14:23:01.612-07:00As an example in a more practical setting, code ge...As an example in a more practical setting, code generation is commonly used as a substitute for reflection in GWT, which lacks reflection due to the runtime overhead when generating JavaScript.<br /><br />It's not a general substitute and tends to be limited to people writing advanced libraries. But it's sufficient to port most of Guice (which relies heavily on reflection) to GWT.Brian Slesinskyhttps://www.blogger.com/profile/06578159790743176316noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-25173400712897957552011-01-19T07:29:53.589-08:002011-01-19T07:29:53.589-08:00Perhaps you say staged execution can be built as a...Perhaps you say staged execution can be built as a tool because, for example, one can always print out some code to a file and run it with something like system(). But by the same token, reflection can also be built as a tool because, for example, one can always read (even the running program's own) code from a file and react accordingly - generate boilerplate code, invoke methods by name, etc. Would you please give an example of something that can be done only if reflection facilities are provided by the language system core?單中杰https://www.blogger.com/profile/14754929367418830739noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-4446040332123477882011-01-19T07:11:48.788-08:002011-01-19T07:11:48.788-08:00Hi John,
Thanks for the comment - it's always...Hi John,<br /><br />Thanks for the comment - it's always nice when someone agrees with me :-) .<br /><br />Staged execution has its uses, I'm sure. One can build up staged execution environments as tools. Reflection, on the other hand, has to be part of the system core. That is one reason why I see it as more fundamental.Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-1965447679567425612011-01-18T12:04:18.577-08:002011-01-18T12:04:18.577-08:00Hi Gilad,
I've recently done some work on var...Hi Gilad,<br /><br />I've recently done some work on various mini-EDSLs in Haskell, using a variety of techniques (final-tagless, GADT, and quasi-quoted) and I ran into exactly these same problems. Currently I resort to dynamic recompilation at runtime via the plugins package.<br /><br />I'm particularly dis-satisfied with the Template Haskell solution as all TH splices must be resolved at compile-time.<br /><br />In Haskell at least it may be possible to hack something together by using the Data class (I'm thinking of something like the impure interface to cmdargs), but I would consider that both incredibly ugly and unstable.<br /><br />I do think that metaprogramming would be part of a viable solution, but only in a good multi-stage environment (MetaML comes closest to what I'm thinking of).Anonymoushttps://www.blogger.com/profile/14086288462709102194noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-91311684331362098482011-01-12T03:13:34.158-08:002011-01-12T03:13:34.158-08:00The problem you have found lies in inventing usele...The problem you have found lies in inventing useless terms with broad meaning like "separation of grammar and semantic action", "create datatypes dynamically", "generic datatype", "executable grammars" and so on. The problem is imaginable, as those words. Just get rid of them.beroalhttps://www.blogger.com/profile/13229768366613602827noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-30226169522817668662011-01-01T12:24:21.974-08:002011-01-01T12:24:21.974-08:00The boundaries between functional and non-function...The boundaries between functional and non-functional can be blurry. Consider <a href="http://paste.lisp.org/+2J76" rel="nofollow">a version of your example in ContextL/Common Lisp</a>.<br /><br />No classes were harmed in the production of this code. There are also no unsurmountable amounts of side effects involved. The syntax can always be made look neater by way of macros. It is relatively straightforward to imagine a context-oriented extension of a pure functional language that can express this example in a similar way, except maybe for static typing issues.<br /><br />The gist of why this separation between syntax and semantics is possible both in your and my version is because of the restricted form of dynamic scoping you get with super calls (or call-next-method in Common LIsp). This allows intercepting methods/functions at well-defined points. In object-oriented programming, objects and the class hierarchies in which they are involved are the 'drivers' for this limited form of dynamic scoping; in context-oriented programming, it is the layer activation.Pascal Costanzahttps://www.blogger.com/profile/04512975624438301971noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-5754387809690282932011-01-01T07:43:02.851-08:002011-01-01T07:43:02.851-08:00I confess I never heard of Bla. It's a neat id...I confess I never heard of Bla. It's a neat idea - though a quick perusal shows no sign of reflection, so perhaps it's a tad off-topic. It does seem like a nice and novel integration of OO and FP. Thanks for the pointer!Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-42840687785027066402011-01-01T04:02:36.609-08:002011-01-01T04:02:36.609-08:00Have you looked at Bla?
http://strlen.com/bla-lan...Have you looked at Bla?<br /> http://strlen.com/bla-languagepizzaeaterhttps://www.blogger.com/profile/01249161455443529453noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-65320484089844767522010-12-15T08:59:11.198-08:002010-12-15T08:59:11.198-08:00I'm not sure what "academic tradition&quo...I'm not sure what "academic tradition" you have in mind that includes Haskell but not Lisp/Scheme, but one pure language with reflection is <a href="http://www.daimi.au.dk/~danvy/Papers/danvy-malmkjaer-LFP88.ps.gz" rel="nofollow">Blond</a>.單中杰https://www.blogger.com/profile/14754929367418830739noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-2204117511734211602010-12-13T20:40:06.886-08:002010-12-13T20:40:06.886-08:00單中杰 :
I'm not talking about Lisp/Scheme etc. O...單中杰 :<br />I'm not talking about Lisp/Scheme etc. Or even Erlang. I'm talking about pure functional programming languages in the academic tradition (like Haskell).Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-79879413405156347572010-12-13T20:06:29.658-08:002010-12-13T20:06:29.658-08:00What about the line of work on reflection started ...What about <a href="http://library.readscheme.org/page11.html" rel="nofollow">the line of work on reflection started by Brian Smith</a>?單中杰https://www.blogger.com/profile/14754929367418830739noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-76744143763201127052010-12-13T07:18:07.743-08:002010-12-13T07:18:07.743-08:00Hi Dominique,
I've always seen dependent type...Hi Dominique,<br /><br />I've always seen dependent types as too heavy. I'll take a look a the reference you provided and see how it works for grammars. <br /><br />In any case, type safety isn't really very high on my list of priorities. The goal is to avoid redundancy and boiler plate and just express the grammar. I'll gladly trade type safety guarantees away if they get in the way of that goal.Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-7697918872258395262010-12-13T01:13:35.985-08:002010-12-13T01:13:35.985-08:00Gilad,
Thanks for posting my previous comment, I&...Gilad,<br /><br />Thanks for posting my previous comment, I'm not sure what went wrong and if it was my fault or blogger.com's.<br /><br />First of all, I agree with you that parser combinator libraries in pure functional languages have previously not paid enough attention to separation between grammar and semantics, however my <a href="http://projects.haskell.org/grammar-combinators/" rel="nofollow">grammar-combinators</a> work at least shows that it is possible with a modest annotation burden, even without compile-time meta-programming (but meta-programming does help to avoid certain boilerplate code).<br /><br />Regarding the reflection vs compile-time meta-programming question, my personal view is that both are non-ideal, because errors in meta-programs will be detected at run-time (by the program user) or at library user's compile time (by the application developer), whereas they should ideally be detected by the library author. I think the one programming language technology showing long-term promise here are dependently typed languages like Agda, Epigram or Coq where arbitrary correctness properties of meta-programs can be proven by library authors (I'm very impressed by Brink, Holdermans and Löh's <a href="http://people.cs.uu.nl/andres/DependentlyTypedGrammars/DependentlyTypedGrammars.pdf" rel="nofollow">dependently typed grammars</a>).<br /><br />By the way, if you're interested in compile-time meta-programming in a dependently typed programming language, I think the badly-documented and experimental quoteGoal stuff in Agda is extremely novel and interesting.Unknownhttps://www.blogger.com/profile/10482246694886071621noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-57069913064606701832010-12-12T15:27:17.748-08:002010-12-12T15:27:17.748-08:00And now I'll respond to Dominique.
First of a...And now I'll respond to Dominique.<br /><br />First of all, thanks for the pointers to your work. In early 2007, I asked several well known researchers in the Haskell/FP world about any work on separating grammar and semantic actions in parser combinators and no one could point at anything. Some even asked why it mattered! So I'm glad that you understand that it is important, and are working in this area.<br /><br />Substantively, I disagree with you. I did explicitly note that one could do this via meta-programming and that didn't cut it from my perspective. So Template Haskell based stuff does not undermine my claims in the least. Mteaprogramming and reflection are different. Claiming that metaprogramming is a substitute for reflection is a position that only those without reflection are likely to embrace.Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-43006214432330274752010-12-12T15:21:48.058-08:002010-12-12T15:21:48.058-08:00Oddly, One comment that blogger notified me of has...Oddly, One comment that blogger notified me of hasn't shown up here, so I'll post it by hand:<br /><br />I'm sorry, but in my opinion, your account does not do justice to pure<br />functional languages, especially those with advanced type systems such<br />as Haskell + GHC extensions. As an example, take a look at my grammar-combinators<br />library. I believe that it clearly invalidates some of your<br />assertions.<br /><br />First of all, the library features complete separation between<br />grammar and semantic actions, which you seem to claim is<br />impossible in a pure programming language.<br /><br />Secondly, the need to define data types is limited to types for the<br />non-terminals (possibly empty, but typically represented by the AST<br />types) and a pattern functor representing the relations between the<br />non-terminals. Note that the Abstract Syntax Tree (contrary to the<br />Concrete Syntax Tree) is not something that you can derive from<br />the grammar, as it abstracts from the details of the syntax. There is<br />some duplication here, but most of it can be eliminated using (not yet<br />implemented) Template Haskell functions. In return, a lot more<br />correctness of user code can be guaranteed at compile time.<br /><br />Finally, I want to point out that none of the arguments you provide<br />(including the HUnit example by the way, see e.g. here)<br />actually indicate any need for run-time reflection, but rather a<br />compile-time meta-programming facility such as Template<br />Haskell, which is readily available in the de facto standard<br />implementation (GHC) of maybe the most widely used pure functional<br />programming language (Haskell). <br /><br /><br /><br />Posted by Dominique to Room 101 at 12/12/2010 12:17 PMGilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-31957875890696017242010-12-12T15:10:37.610-08:002010-12-12T15:10:37.610-08:00I guess that a sort of dependent-type system could...I guess that a sort of dependent-type system could help for this cases. Just as you could define the type of the lists of size 10, you could define the type of the "if" token, and statically type check all the places where you use it.<br />OTOH, it will make the type checking very hard, at best. (http://en.wikipedia.org/wiki/Dependent_type)c43nghttps://www.blogger.com/profile/02100927857356825585noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-40314847959128771072010-12-12T12:17:07.818-08:002010-12-12T12:17:07.818-08:00I'm sorry, but in my opinion, your account doe...I'm sorry, but in my opinion, your account does not do justice to pure<br />functional languages, especially those with advanced type systems such<br />as Haskell + GHC extensions. As an example, take a look at my <a href="http://projects.haskell.org/grammar-combinators/" rel="nofollow">grammar-combinators</a><br />library. I believe that it clearly invalidates some of your<br />assertions.<br /><br />First of all, the library features complete separation between<br />grammar and semantic actions, which you seem to claim is<br />impossible in a pure programming language.<br /><br />Secondly, the need to define data types is limited to types for the<br />non-terminals (possibly empty, but typically represented by the AST<br />types) and a pattern functor representing the relations between the<br />non-terminals. Note that the Abstract Syntax Tree (contrary to the<br />Concrete Syntax Tree) is <b>not</b> something that you can derive from<br />the grammar, as it abstracts from the details of the syntax. There is<br />some duplication here, but most of it can be eliminated using (not yet<br />implemented) Template Haskell functions. In return, a lot more<br />correctness of user code can be guaranteed at compile time.<br /><br />Finally, I want to point out that none of the arguments you provide<br />(including the HUnit example by the way, see e.g. <a href="http://hackage.haskell.org/package/test-framework-th" rel="nofollow">here</a>)<br />actually indicate any need for run-time reflection, but rather a<br />compile-time meta-programming facility such as <a href="http://www.haskell.org/haskellwiki/Template_Haskell" rel="nofollow">Template<br />Haskell</a>, which is readily available in the de facto standard<br />implementation (GHC) of maybe the most widely used pure functional<br />programming language (Haskell).Unknownhttps://www.blogger.com/profile/10482246694886071621noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-91374599349501045362010-12-12T07:25:35.949-08:002010-12-12T07:25:35.949-08:00Damien,
Thanks for the example illustrating the s...Damien,<br /><br />Thanks for the example illustrating the same issue.<br /><br />Mark H. : Thanks for the pointer.<br /><br />Mark LS: ALways nice to hear from you.Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-86932807407987572342010-12-12T04:09:48.201-08:002010-12-12T04:09:48.201-08:00Good to see you again Gilad, I was starting to wor...Good to see you again Gilad, I was starting to worry :).<br /><br />As for the article, I completely agree, but I am bias.Mark Lee Smithhttps://www.blogger.com/profile/12819093371910833234noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-75778984998191531632010-12-12T02:41:46.131-08:002010-12-12T02:41:46.131-08:00There is a few interesting things in Kiselyov'...There is a few interesting things in Kiselyov's and Shan's implicit configurations paper -- http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf. <br /><br />I think there is a haskell implementation floating around for the reflection components discussed in the paper.Unknownhttps://www.blogger.com/profile/01048328517086006295noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-85048826561167213412010-12-12T01:44:40.271-08:002010-12-12T01:44:40.271-08:00Here is how to define HUnit test suites in Haskell...Here is how to define HUnit test suites in Haskell:<br /><br />combTests :: Test<br />combTests = TestList [<br /> TestLabel "testHasOnePair" testHasOnePair<br /> , TestLabel "testHasTwoPairs" testHasTwoPairs<br />]<br /><br />as you can see, the test name is duplicated: once as a string for the error message and once as a function to execute the test.Damien Cassouhttps://www.blogger.com/profile/03691760086661227601noreply@blogger.com