Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  In the second example how does a live programming
  system synthesize a "Person" object?
Most data types should have `example` methods. They're too useful not to have, for documentation generation as well as live programming. `Person` in this case should definitely have one.

  What if there are multiple constructors?
  What if it depends on ten other objects
  when being created?
Each of those other objects should also have `example` methods. Person's example method should use those, possibly modifying them after they're called so that they make more sense in the context of a `Person`.

  What if this object only originates from
  a database? Should the user constantly create
  these objects by hand when they want to edit
  any function in their program?
Zomg no. Make `example` methods. The idea of having beginners program without static types and immutability seems misguided to me, because it makes them keep the whole program in their head instead of just the function they're working on. The idea of making them keep the whole program in their head _while also not having an example of what they're operating on_ is just silly.

PS As to the "generating unit tests" point, the place to start looking for inspiration is QuickCheck: http://www.stuartgunter.org/intro-to-quickcheck/

EDIT: PPS: If any lispers are reading this, I'd be curious to hear how you generate example objects at the REPL. Since the lisp community places such a high priority on REPL programming maybe it's already explored this area in depth.



If any lispers are reading this, I'd be curious to hear how you generate example objects at the REPL. Since the lisp community places such a high priority on REPL programming maybe it's already explored this area in depth.

Clojure is my language of choice. What I've been doing so far is keep sample data in my unit test files. I then use a mixture of running code direct from my editor [0], importing the sample data from my (non-editor) REPL [1] and actually running the unit tests.

Its worth noting that this usually happens in reverse: I construct the data in the REPL while experimenting and then copy it to the unit tests after for reuse.

    how does a live programming system synthesize a "Person" object?
That just got me thinking. In Clojure, we generally use raw data (primitives, maps, lists, sets, vectors) rather than hiding behind objects, so synthesizing them is the same as any other data.

Realistically, there would generally be a constructor function, but most functions are deterministic pure functions. I feel like OO languages may be harder to make play nice with live programming because OO hides a lot of stuff and encourages impurity.

[0] I can eval the entire file, the form that the cursor is on, or I can eval code I type into a REPL.

[1] (require '[my-test-namespace.my-test-file :as alias]) Then access alias/sample-data


Very slick, thanks for sharing:)


>Zomg no. Make `example` methods.

So we sort of run into an issue here with "What people should do" vs. "What people actually do".

The creator of such a tool needs to design their tool around the reality of "What people actually do". And in our current target language C#, there is not an existing culture around building example methods. (And often people don't even have unit tests).

The biggest challenges we've faced when building Alive are running into problems like this one, where there isn't a clear, nice solution.


That makes a ton of sense. I'm definitely familiar with the difference between "where we could be" and "where the ecosystem is right now":)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: