Hi guys! Let me ask you about an issue I have for ...
# thinking-together
p
Hi guys! Let me ask you about an issue I have for a long time. The problem is that many times in “standard mainstream” languages a business term in the business logic is duplicated in different names and even IDEs can’t relate the dups, I have to rely on Good ol’ Search & Replace and/or regex - which does not help much really. What I’d like to see if I’d be able to assemble function names just as other piece of data in my program. I am wondering if that feature already exist somewhere (I’d suspect it’s in LISP if anywhere). Example: Instead having
setA(A a), setB(B b), setC(C c)
or
(setA a), (setB b), (setC c)
as different functions, I’d like to have
([set A] a), ([set B] b),([set C] c)
. So next time when I want to refactor/rename
A
, or even
set
to something else, I’d be able to do that easily. The reason I got there is that I am really into Refactoring and my belief is the easiest Refactoring method is(/must be) Renaming so its a shame not being able to Rename stuff in 0.1 sec. (just changing the characters, not even addressing the change in meaning!) Without easy, secure renaming (lol) my productivity can’t even start.
Please tell me it’s just a macro and can be done in Clojure! 😄 And the real question how to hack it onto Typescript not to ruin other IDE features 😄 @Prathyush @shalabh
l
Same! The concept I'm been thinking about is that all entities are identified by id under the hood, such that a rename really is just one rename, not a hundred changes. Furthermore, you may add "aliases" to entities (eg.
put book in bookshelf
might be nicer (as in help you solve your problem faster, in some cases) than
add object to container
). Then, you may switch between jargon and abstraction in the view layer as you go. Identifiers should strive to be non-entangled, eg.
setTemperature termostat 15deg
could instead be
set temperature of termostat to 15deg
. If we then also have
set volume of speaker to 20db
, the
set
identifier could be (auto) linked as the same "action type", and thus renamed to, eg. "adjust" (or only rename when used with a temperature (then, "adjust" will become an alias to "set" with a specific association to "temperature")).
❤️ 1
👍 1
p
Yep! I have some further ideas myself, but the main question is first: what is available today and what/how?
d
Go find Simonyi's work in the Intentional Domain Workbench.

https://youtu.be/4pT9tDmxjlg

💯 1
g
incidentally, Charles Simonyi might be interested in funding FoC @stevekrouse
p
@Dan Cook I’ve already checked it earlier, but it seemed too vague to me. What parts do you think relate the most?
d
I think it basically amounted to storing code as a reified structure, and referencing entities by I'd (GUID) rather than by name. Things still have names, but they are stored with the entity. So the names can change, but the IDs (and this the references to things) do not. So something like renaming becomes trivial. Even though the literal structure of code contains IDs, some editor would actually show you the names
p
Yeah, something like that. Are you aware of something like that implemented in VSCode / Jetbrains world?
b
My work on Tree Notation is attempting to solve this sort of problem. In Tree Languages, everything is "clean data". Every character is meaningful, and every word has types. Parsing is very easy (there are no parens or quotes or semicolons, etc). The end result is in the future, due to the reduction in tooling cost, it will be very easy to do all sorts of project-wise refactors through a variety of strategies more intelligent than Regex Search/Replaces or simply "Intelligent Renames". You should be able to do queries like "rename all 'A' item cell Types to 'X'" or "rename all 'set' method cellTypes to 'setFoo' "
👍 1
p
@Breck Yunits Yeah, I really like the query part, thought about the same. Can you give a pointer to your work? And can you maybe give me an insight why these things are not widespread yet? What prevents Jetbrains / Microsoft to use such tech? Is it the near future?
b
Here are some demo languages: https://jtree.treenotation.org/designer/ here is more info: https://treenotation.org/
And can you maybe give me an insight why these things are not widespread yet?
1. It was not theoretically obvious that visible syntax characters are not necessary. 2. Tree Languages are only substantially better than BNF languages when you have tools that leverage the advantages of Tree Languages. BNF Languages + BNF Languages Tools > Tree Languages. From what I've seen so far Tree Languages + Tree Languages Tools > BNF Languages + BNF Languages Tools
3. What prevents Jetbrains / Microsoft to use such tech? Nothing, but the usage numbers are still very small (in the thousands of weekly actives currently)
4. Is it the near future? I think so, once a killer app takes off
I'm very eager to launch Ohayo 14, which is the first fully open source advanced app that utilizes Tree Languages
should be any day now
perhaps someone else will end up creating a killer app that leverages Tree Notation (or another spatial notation—I have to admit for the possibility that I've made some key mistakes in TN)
but if not someone else, we should have a couple going by 2020
p
Ty!
s
(This is a favorite problem of mine, btw - the model and code duplication all over the place - not just in one language but in a system across many programs and languages - today we need to repeat way too much without adding value) I see two or three overlapping ideas here. The shared observation is that 'cross reference represented as strings' is the usual way. This has problems with renaming because we have to find all instances of the same string but only where it references the same entity. Using an
id
for the cross reference and the string name as metadata attached to the id kind of solves this (with tooling support, see unison). But the original post is talking about something else too. Specifically if I have a name
setA
and decide to rename A to B, I want the name to automatically become
setB
. Even with id references, this would have to be manual because
setA
is the metadata attached to id1 and
getA
is the metadata attached to
id2
etc. Unless we go a bit further and instead of attaching string metadata to the id, define multiple pieces of metadata to link to the entities
set
and
A
. The main requirement is you want only one place where the string
A
exists and it is referenced everywhere else by its id.
👍 2
d
Interesting! Yeah, that's totally a common place thing in programming: Foo, FooFactory, FooContainer, etc. I'll have to keep that in mind for my "Interact" project: rather than storing entities directly (e.g. any party of code or data), it stores the steps or actions that were taken to create it (and thus there's no distinction between user interaction, and "code"). So for example, even if you manually create something called "Foo" and something called "FooBar", you could edit the actions to be as if you associated the string "Foo" to a variable, and then used that variable to build the names of the other things. Then if you change what that value "was", the other things change too
👍 3
v
@Pezo - Zoltan Peto What you describing looks a lot like multidispatch methods in Common Lisp. You would have method 'set', that is dispatched over both 'a' and 'A'.
p
@Vladimir Gordeev Ah great! Thanks that is a great insight! Years before at collage I did not understand that feature, we did not learn lisp. Now I am! Do you have any other related insights?:)
v
@Pezo - Zoltan Peto You're welcome) I am not sure what insights are related. Actually I don't understand exactly why you want this feature in the first place. I got from your post, that it makes renaming of the terms easier. Any other reasons?
p
It's a huge one. I am fed up with search and replaces :) it prevents me to refactor other things easily which involves renaming.
v
I see
b
@Pezo - Zoltan Peto do you use strongly typed languages with good refactoring tools? TypeScript and C# in VS (and Sublime Text) have great project wide intelligent "Rename".
p
Yes sure, I use Webstorm which has the best such feature I think.
@Dan Cook yes exactly as you described. And its not done yet.... 🤯 Especially awful when I want to change a database table name because the software itself and the meanings evolve(!), but I don't have the courage, because god knows what breaks. But for that we have migration at least. But for Foo - FooFactory - SetFoo we have nothing :D
c
Unison language can do this AFAIK. This is more of a traditional AST-rewriting approach (not “function names = data”), but Mesh Spreadsheet also lets you just type over an existing name and have it update all places it’s referenced. See near the end of the video here: https://m.youtube.com/watch?v=_U6gE3cNgbI
👍 2
p
@shalabh Exactly: this happens across the whole system. I mentioned this a “program level” only because its simpler and because of this there is a higher chance its solved which I am interested in 🙂. Checking Unison! Thanks everyone who mentioned.
@shalabh As you mentioned: Unless we go a bit further and instead of attaching string metadata to the id, define multiple pieces of metadata to link to the entities
set
and
A
. The main requirement is you want only one place where the string
A
exists and it is referenced everywhere else by its id. ------- Yes exactly! I want this! And it is really interesting because it gets to a weird place, where every name must be unique across the system! And if we are working with multiple systems which merge (have interaction) any time in future (like web) we might need global unique names! Which seems is totally opposite of the standard view of “avoid global things”. (Okay, sure, it’s mainly against vars, not consts.) However, if we are able to rename things easily I am totally ok with using globally unique names.