Author Topic: Clojure in Cad - a taste of things to come  (Read 7212 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Clojure in Cad - a taste of things to come
« Reply #15 on: August 26, 2016, 07:32:02 PM »
Sory, it is not about Clojure, but it can be interesting for C# programmers: http://avalonedit.net/


Nice find, will take a look, thanks.

With all of these user controls, you need to do a fair bit of setup work to get the required functionality, especially if you are using a language that is not built into the control.
You need to handle keyboard shortcuts and things like syntax colouring and behaviour.
They do save a lot of work but I wouldn't mind building one from scratch one day just for shiggles. The repl side is hand built using a simple textbox control and has been fun so far and will need some major refactoring once the prototype is working.

It is interesting. Can you use the breakpoints and conditional breakpoints in this code editor?

No, and they are not really required. Clojure does come with some inspection tools but no debugger.

As Clojure is immutable by default a lot of the pain of setting state is removed, this is the main reason we even need a debugger in imperative languages, to check state.
Most functions are pure functions in that they only return an output given certain input and there are no side effects such as setting var's. These pure functions are very easy to test and plug together to form larger functions.

There are ways to have side effects and you need them as you will need to eventually to set/change say an entity's properties with your calculated data, but these can be isolated, tested and viewed with a simple print statement or similar inspection function with output to the repl.

The repl is key here, it allows you test and debug as you code. Enter your function in the repl and test it, if it has a problem you can fix it and retest all in the same session, you have instant feedback.

The current process in C# is:
write code -> build & deploy -> test/debug -> refactor/fix bugs -> repeat until done then final deploy

The process in Clojure will be:
write code -> test/debug -> refactor/fix bugs -> repeat until done then build & deploy

I still have to iron out a few things and finish some basic functionality like loading and saving files and make the repl remember past commands then I will post up a demo with an example of the workflow and how testing can be built in.

The goal of this tool is for 'live' development of code, this code can then be used to build a class library dll just like a C# one. I think I can even do this from the repl and at this point is the only way to have commands registered but while testing, calling from the repl is basically the same.



"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Clojure in Cad - a taste of things to come
« Reply #16 on: August 26, 2016, 08:12:29 PM »
Here's a contrived example of how I would go about testing, IOW I wouldn't double up on the functions like this :)
I would also have a 'tests' file to load and run all tests as a test suite as a separate process rather than include them in the source.
If there was an error such as using a string as an input the repl would catch this as well but these tests are logic tests and they work well, particularly for pure type functions.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Clojure in Cad - a taste of things to come
« Reply #17 on: August 27, 2016, 02:20:16 AM »
Thank you for the detailed response.