3 ms·
A big problem with visual debuggers is that they are too blunt of an instrument. Often I wish to examine specific things under specific conditions and thus use
by tabtab 8y ago
A big problem with visual debuggers is that they are too blunt of an instrument. Often I wish to examine specific things under specific conditions and thus use conditionals to narrow down what's being explored instead of bajillion breakpoints and/or log records. Debuggers could add conditional expressions, but then they'd be re-inventing WRITE statements anyhow.
As far as the nearby statement that maybe I didn't learn dissection correctly, that may indeed be the case, but was also my original point: perhaps the real problem is that nobody knows how to TEACH functional/logical programming right, and that's why they have not caught on in the mainstream despite being around several decades. I'd love to "get" the benefits, but it just won't click. Sometimes you have to teach programmers how to think, not just what to think.
- tom_mellior 8y ago> Debuggers could add conditional expressions, but then they'd be re-inventing WRITE statements anyhow. SWI-Prolog's debugger can be invoked conditionally whenever you want from inside your running application. I've used it many times, and the code is simply: (Condition -> gtrace ; true) It's true that you could stick a write there, but you would have to think about what pieces of data you will need. Your mileage may vary. I've found this style a lot more useful than "traditional" debuggers where you set breakpoints beforehand and hope you hit them, as you say. > As far as the nearby statement that maybe I didn't learn dissection correctly, that may indeed be the case The point was more specifically that you didn't learn Prolog properly (or at all) and don't realize that it forces you to dissect your code. As I said, in Prolog you cannot nest loops. You cannot nest loops. It's hard to write a big non-dissected piece of code if you cannot nest loops. > perhaps the real problem is that nobody knows how to TEACH functional/logical programming right I agree with regards to logic programming. We need better free tutorials. I don't particularly like the linked one, it feels like it doesn't start at a beginner's level. I would be interested if anyone who didn't know any Prolog before has managed to learn Prolog from it.
- pjmlp 8y agoI learned logic programming before learning Prolog. We got our introduction to it via the Tarkis' World book (90's edition). https://ggweb.gradegrinder.net/tarskisworld https://ggweb.gradegrinder.net/tarskisworld
- tabtab 8y agoRe: "but you would have to think about what pieces of data you will need." -- But with procedural you don't have to think much; the parts are right there to selectively examine. Re: "in Prolog you cannot nest loops...It's hard to write a big non-dissected piece of code if you cannot nest loops." -- But nesting is good for modularity. It's sometimes called "step-wise refinement", which is a brilliant abstraction that is usually easy and natural to comprehend. Nesting is how we have been splitting up society since the dawn of civilization: countries, states, counties, cities, etc. (or equiv.) Similar for big militaries. (Maybe this is a meta form of Conway's law? Either way Conway was on to something.)
- triska 8y agoRegarding your last sentence: Yes, I can confirm that this has happened, to a reasonable extent of "learned" in the sense that people went on to write programs using this material. However, I do not know how common this is, since I almost exclusively get feedback from those who found the material suitable. There were definitely complete beginners among them. For instance, here is a discussion that happened a few months ago, where it appears that also beginners comment positively: https://www.reddit.com/r/programming/comments/7pbkfv/great_free_book_on_modern_prolog_with_indepth/ https://www.reddit.com/r/programming/comments/7pbkfv/great_f... More recently, two university instructors started to use this book in courses that assume no previous knowledge about the language: Andrej Bauer in his specialist elective course Principles of Programming Languages at the University of Ljubljana: https://ucilnica.fri.uni-lj.si/course/view.php?id=67 https://ucilnica.fri.uni-lj.si/course/view.php?id=67 Norbert Zeh in his Principles of Programming Languages lectures at Dalhousie University in Canada: https://web.cs.dal.ca/~nzeh/Teaching/3136/index.html https://web.cs.dal.ca/~nzeh/Teaching/3136/index.html Much of my current work is aimed towards making the teleteaching environment GUPU available in a free Prolog system: https://www.complang.tuwien.ac.at/ulrich/gupu/ https://www.complang.tuwien.ac.at/ulrich/gupu/ This will help a lot to teach Prolog to beginners in a scalable way. On a rather personal, and maybe controversial, note: I regard the self-taught Prolog master as prevalent as for example the self-taught piano, chess or Zen master. In my experience, learning Prolog properly requires dedicated guidance, and it would be highly unusual to achieve mastery without it.
- zephyrfalcon 8y ago> In my experience, learning Prolog properly requires dedicated guidance, and it would be highly unusual to achieve mastery without it. Where would you find such a master, though... If you are not studying at a university where Prolog is taught, you're pretty much out of luck, I think. (I am assuming that asking questions in newsgroups/IRC/etc is not a substitute for it.)
- triska 8y agoYes, I agree. I was lucky enough to study where the current convenor of the Prolog ISO working group teaches, using a Prolog- and Elisp-based teleteaching environment that he has built over several decades. As in other disciplines, if you are elsewhere, you may have to move to get close to a master. This is not so unusual, is it? Vienna is a nice city for studying logic, and does attract students from all over the world!
- YeGoblynQueenne 8y ago>> As I said, in Prolog you cannot nest loops. You cannot nest loops. What do you mean here? My earlier comment was jokular, but you can definitely nest loops in Prolog: ... deconstruct([L|Ls],Acc1,Bind):- deconstruct(L,Acc1,Acc2) ,deconstruct(LS,Acc2,Bind). ... etc. That's a nested loop, right there. Do you mean it in the sense that it's still the same predicate rather than a consecutive change of scopes?
- tom_mellior 8y agoMost concretely I mean it in the context of the common auxiliary-predicate-with-an-accumulator pattern: foo_bar(Foo, Bar) :- foo_bar_aux(Foo, Bar, 0). foo_bar_aux(Foo, Bar, N) :- ... Which in a language like OCaml would be hiding the loop in a recursive function defined inside the main one: let foo_bar foo = let rec foo_bar_aux n = ... in foo_bar_aux 0 So yes, I think this is what you mean by being the same predicate rather than a "change of scopes". Of course there are many loop-like things that you can nest. If the arguments align just right, you can also use `maplist(maplist(maplist(baz)), ...)` instead of three auxiliary predicates, but I don't encounter many cases where this is possible or desirable.
- YeGoblynQueenne 8y agoI see what you mean, thanks. I think we're talking about the same thing then.
- simion314 8y agoYour Console.log will not help you in a recursive function
- tabtab 8y agoIf you have the right tracking variables, it's great for the job: "console.write(currentNodeID, parentNodeID, depthLevel, nodeVisitCount);" And one can wrap that into a conditional if they don't want to echo the entire journey. It's usually good to create such tracking variables in non-trivial systems anyhow. Bleep happens.
- tabtab 8y agoCorrection: should be "nodesVisitedCount". Also note that output formatting was sacrificed for brevity of the example.