diff --git a/.gitignore b/.gitignore index a3b42dd..a3c9ad4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ adminmailer/config.go adminmailer/adminmailer local/backups /tmp +*.exe diff --git a/public/fishbowl-dark.css b/public/fishbowl-dark.css new file mode 100644 index 0000000..ccca84f --- /dev/null +++ b/public/fishbowl-dark.css @@ -0,0 +1,618 @@ +.fishbowl { + background-color: #36393e; + color: #dcddde; +} + +.fishbowl a { + color: #00aff4; + text-decoration: none; +} + +.fishbowl a:hover { + text-decoration: underline; +} + +.fishbowl img { + object-fit: contain; + image-rendering: high-quality; + image-rendering: -webkit-optimize-contrast; +} + +.fishbowl .preamble { + display: grid; + grid-template-columns: auto 1fr; + max-width: 100%; + padding: 1rem; +} + +.fishbowl .preamble__guild-icon-container { + grid-column: 1; +} + +.fishbowl .preamble__guild-icon { + max-width: 88px; + max-height: 88px; +} + +.fishbowl .preamble__entries-container { + grid-column: 2; + margin-left: 1rem; +} + +.fishbowl .preamble__entry { + margin-bottom: 0.15rem; + color: #ffffff; + font-size: 1.4rem; +} + +.fishbowl .preamble__entry--small { + font-size: 1rem; +} + +.fishbowl .chatlog { + padding: 1rem 0; + width: 100%; +} + +.fishbowl .chatlog__message-group { + margin-bottom: 1rem; +} + +.fishbowl .chatlog__message-container { + background-color: transparent; + transition: background-color 1s ease; +} + +.fishbowl .chatlog__message-container--highlighted { + background-color: rgba(114, 137, 218, 0.2); +} + +.fishbowl .chatlog__message-container--pinned { + background-color: rgba(249, 168, 37, 0.05); +} + +.fishbowl .chatlog__message { + display: grid; + grid-template-columns: auto 1fr; + padding: 0.15rem 0; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__message:hover { + background-color: #32353b; +} + +.fishbowl .chatlog__message:hover .chatlog__short-timestamp { + display: block; +} + +.fishbowl .chatlog__message-aside { + grid-column: 1; + width: 72px; + padding: 0.15rem 0.15rem 0 0.15rem; + text-align: center; +} + +.fishbowl .chatlog__reference-symbol { + height: 10px; + margin: 6px 4px 4px 36px; + border-left: 2px solid #4f545c; + border-top: 2px solid #4f545c; + border-radius: 8px 0 0 0; +} + +.fishbowl .chatlog__avatar { + width: 40px; + height: 40px; + border-radius: 50%; +} + +.fishbowl .chatlog__short-timestamp { + display: none; + color: #a3a6aa; + font-size: 0.7em; + line-height: 1.4em; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__message-primary { + grid-column: 2; + min-width: 0; +} + +.fishbowl .chatlog__reference { + display: flex; + margin-bottom: 0.15rem; + align-items: center; + color: #b5b6b8; + font-size: 0.85em; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.fishbowl .chatlog__reference-avatar { + width: 16px; + height: 16px; + margin-right: 0.25rem; + border-radius: 50%; +} + +.fishbowl .chatlog__reference-author { + margin-right: 0.3rem; + font-weight: 600; +} + +.fishbowl .chatlog__reference-content { + overflow: hidden; + text-overflow: ellipsis; +} + +.fishbowl .chatlog__reference-link { + cursor: pointer; +} + +.fishbowl .chatlog__reference-link * { + display: inline; + pointer-events: none; +} + +.fishbowl .chatlog__reference-link .hljs { + display: inline; +} + +.fishbowl .chatlog__reference-link:hover { + color: #ffffff; +} + +.fishbowl .chatlog__reference-link:hover *:not(.chatlog__markdown-spoiler) { + color: inherit; +} + +.fishbowl .chatlog__reference-edited-timestamp { + margin-left: 0.25rem; + color: #a3a6aa; + font-size: 0.75rem; + font-weight: 500; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__header { + margin-bottom: 0.1rem; +} + +.fishbowl .chatlog__author { + font-weight: 500; + color: #ffffff; +} + +.fishbowl .chatlog__bot-label { + position: relative; + top: -0.1rem; + margin-left: 0.3rem; + padding: 0.05rem 0.3rem; + border-radius: 3px; + background-color: #5865F2; + color: #ffffff; + font-size: 0.625rem; + font-weight: 500; + line-height: 1.3; +} + +.fishbowl .chatlog__timestamp { + margin-left: 0.3rem; + color: #a3a6aa; + font-size: 0.75rem; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__content { + padding-right: 1rem; + word-wrap: break-word; +} + +.fishbowl .chatlog__edited-timestamp { + margin-left: 0.15rem; + color: #a3a6aa; + font-size: 0.7em; +} + +.fishbowl .chatlog__attachment { + position: relative; + width: fit-content; + margin-top: 0.3rem; + border-radius: 3px; + overflow: hidden; +} + +.fishbowl .chatlog__attachment--hidden { + cursor: pointer; + box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.1); +} + +.fishbowl .chatlog__attachment--hidden * { + pointer-events: none; +} + +.fishbowl .chatlog__attachment-spoiler-caption { + display: none; + position: absolute; + left: 50%; + top: 50%; + z-index: 999; + padding: 0.4rem 0.8rem; + border-radius: 20px; + transform: translate(-50%, -50%); + background-color: rgba(0, 0, 0, 0.9); + color: #dcddde; + font-size: 0.9rem; + font-weight: 600; + letter-spacing: 0.05rem; +} + +.fishbowl .chatlog__attachment--hidden .chatlog__attachment-spoiler-caption { + display: block; +} + +.fishbowl .chatlog__attachment--hidden:hover .chatlog__attachment-spoiler-caption { + color: #fff; +} + +.fishbowl .chatlog__attachment-media { + max-width: 45vw; + max-height: 500px; + vertical-align: top; + border-radius: 3px; +} + +.fishbowl .chatlog__attachment--hidden .chatlog__attachment-media { + filter: blur(44px); +} + +.fishbowl .chatlog__attachment-generic { + max-width: 520px; + width: 100%; + height: 40px; + padding: 10px; + border: 1px solid #292b2f; + border-radius: 3px; + background-color: #2f3136; + overflow: hidden; +} + +.fishbowl .chatlog__attachment--hidden .chatlog__attachment-generic { + filter: blur(44px); +} + +.fishbowl .chatlog__attachment-generic-icon { + float: left; + width: 30px; + height: 100%; + margin-right: 10px; +} + +.fishbowl .chatlog__attachment-generic-size { + color: #72767d; + font-size: 12px; +} + +.fishbowl .chatlog__attachment-generic-name { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.fishbowl .chatlog__embed { + display: flex; + margin-top: 0.3rem; + max-width: 520px; +} + +.fishbowl .chatlog__embed-color-pill { + flex-shrink: 0; + width: 0.25rem; + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; +} + +.fishbowl .chatlog__embed-color-pill--default { + background-color: #202225; +} + +.fishbowl .chatlog__embed-content-container { + display: flex; + flex-direction: column; + padding: 0.5rem 0.6rem; + border: 1px solid rgba(46, 48, 54, 0.6); + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + background-color: rgba(46, 48, 54, 0.3); +} + +.fishbowl .chatlog__embed-content { + display: flex; + width: 100%; +} + +.fishbowl .chatlog__embed-text { + flex: 1; +} + +.fishbowl .chatlog__embed-author-container { + display: flex; + margin-bottom: 0.5rem; + align-items: center; +} + +.fishbowl .chatlog__embed-author-icon { + width: 20px; + height: 20px; + margin-right: 0.5rem; + border-radius: 50%; +} + +.fishbowl .chatlog__embed-author { + color: #ffffff; + font-size: 0.875rem; + font-weight: 600; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__embed-author-link { + color: #ffffff; +} + +.fishbowl .chatlog__embed-title { + margin-bottom: 0.5rem; + color: #ffffff; + font-size: 0.875rem; + font-weight: 600; +} + +.fishbowl .chatlog__embed-description { + color: #dcddde; + font-weight: 500; + font-size: 0.85rem; +} + +.fishbowl .chatlog__embed-fields { + display: flex; + flex-wrap: wrap; + gap: 0 0.5rem; +} + +.fishbowl .chatlog__embed-field { + flex: 0; + min-width: 100%; + max-width: 506px; + padding-top: 0.6rem; + font-size: 0.875rem; +} + +.fishbowl .chatlog__embed-field--inline { + flex: 1; + flex-basis: auto; + min-width: 50px; +} + +.fishbowl .chatlog__embed-field-name { + margin-bottom: 0.2rem; + color: #ffffff; + font-weight: 600; +} + +.fishbowl .chatlog__embed-field-value { + color: #dcddde; + font-weight: 500; +} + +.fishbowl .chatlog__embed-thumbnail { + flex: 0; + max-width: 80px; + max-height: 80px; + margin-left: 1.2rem; + border-radius: 3px; +} + +.fishbowl .chatlog__embed-image-container { + margin-top: 0.6rem; +} + +.fishbowl .chatlog__embed-image { + max-width: 500px; + max-height: 400px; + border-radius: 3px; +} + +.fishbowl .chatlog__embed-footer { + margin-top: 0.6rem; + color: #dcddde; +} + +.fishbowl .chatlog__embed-footer-icon { + width: 20px; + height: 20px; + margin-right: 0.2rem; + border-radius: 50%; + vertical-align: middle; +} + +.fishbowl .chatlog__embed-footer-text { + vertical-align: middle; + font-size: 0.75rem; + font-weight: 500; +} + +.fishbowl .chatlog__embed-plainimage { + max-width: 45vw; + max-height: 500px; + vertical-align: top; + border-radius: 3px; +} + +.fishbowl .chatlog__embed-spotify { + border: 0; +} + +.fishbowl .chatlog__embed-youtube-container { + margin-top: 0.6rem; +} + +.fishbowl .chatlog__embed-youtube { + border: 0; + border-radius: 3px; +} + +.fishbowl .chatlog__sticker { + width: 180px; + height: 180px; +} + +.fishbowl .chatlog__sticker--media { + max-width: 100%; + max-height: 100%; +} + +.fishbowl .chatlog__reactions { + display: flex; +} + +.fishbowl .chatlog__reaction { + display: flex; + margin: 0.35rem 0.1rem 0.1rem 0; + padding: 0.125rem 0.375rem; + border: 1px solid transparent; + border-radius: 8px; + background-color: #2f3136; + align-items: center; +} + +.fishbowl .chatlog__reaction:hover { + border: 1px solid hsla(0,0%,100%,.2); + background-color: transparent; +} + +.fishbowl .chatlog__reaction-count { + min-width: 9px; + margin-left: 0.35rem; + color: #b9bbbe; + font-size: 0.875rem; +} + +.fishbowl .chatlog__reaction:hover .chatlog__reaction-count { + color: #dcddde; +} + +.fishbowl .chatlog__markdown { + max-width: 100%; + line-height: 1.3; + overflow-wrap: break-word; +} + +.fishbowl .chatlog__markdown-preserve { + white-space: pre-wrap; +} + +.fishbowl .chatlog__markdown-spoiler { + background-color: rgba(255, 255, 255, 0.1); + border-radius: 3px; +} + +.fishbowl .chatlog__markdown-spoiler--hidden { + cursor: pointer; + background-color: #202225; + color: rgba(0, 0, 0, 0); +} + +.fishbowl .chatlog__markdown-spoiler--hidden:hover { + background-color: rgba(32, 34, 37, 0.8); +} + +.fishbowl .chatlog__markdown-spoiler--hidden::selection { + color: rgba(0, 0, 0, 0); +} + +.fishbowl .chatlog__markdown-quote { + display: flex; + margin: 0.05rem 0; +} + +.fishbowl .chatlog__markdown-quote-border { + margin-right: 0.5rem; + border: 2px solid #4f545c; + border-radius: 3px; + background-color: #4f545c; +} + +.fishbowl .chatlog__markdown-pre { + background-color: #2f3136; + font-family: "Consolas", "Courier New", Courier, monospace; +} + +.fishbowl .chatlog__markdown-pre--multiline { + margin-top: 0.25rem; + padding: 0.5rem; + border: 2px solid #282b30; + border-radius: 5px; + color: #b9bbbe; +} + +.fishbowl .chatlog__markdown-pre--multiline.hljs { + background-color: inherit; + color: inherit; +} + +.fishbowl .chatlog__markdown-pre--inline { + padding: 2px; + border-radius: 3px; + font-size: 0.85rem; +} + +.fishbowl .chatlog__markdown-mention { + border-radius: 3px; + padding: 0 2px; + background-color: rgba(88, 101, 242, .3); + color: #dee0fc; + font-weight: 500; +} + +.fishbowl .chatlog__markdown-mention:hover { + background-color: #5865f2; + color: #ffffff +} + +.fishbowl .chatlog__markdown-timestamp { + border-radius: 3px; + padding: 0 2px; + color: #a3a6aa; +} + +.fishbowl .chatlog__emoji { + width: 1.325rem; + height: 1.325rem; + margin: 0 0.06rem; + vertical-align: -0.4rem; +} + +.fishbowl .chatlog__emoji--small { + width: 1rem; + height: 1rem; +} + +.fishbowl .chatlog__emoji--large { + width: 2.8rem; + height: 2.8rem; +} + +.fishbowl .postamble { + padding: 1.25rem; +} + +.fishbowl .postamble__entry { + color: #ffffff; +} diff --git a/public/fishbowl-light.css b/public/fishbowl-light.css new file mode 100644 index 0000000..1839f7d --- /dev/null +++ b/public/fishbowl-light.css @@ -0,0 +1,619 @@ +.fishbowl { + background-color: #ffffff; + color: #23262a; + border: 1px solid #ddd; +} + +.fishbowl a { + color: #0068e0; + text-decoration: none; +} + +.fishbowl a:hover { + text-decoration: underline; +} + +.fishbowl img { + object-fit: contain; + image-rendering: high-quality; + image-rendering: -webkit-optimize-contrast; +} + +.fishbowl .preamble { + display: grid; + grid-template-columns: auto 1fr; + max-width: 100%; + padding: 1rem; +} + +.fishbowl .preamble__guild-icon-container { + grid-column: 1; +} + +.fishbowl .preamble__guild-icon { + max-width: 88px; + max-height: 88px; +} + +.fishbowl .preamble__entries-container { + grid-column: 2; + margin-left: 1rem; +} + +.fishbowl .preamble__entry { + margin-bottom: 0.15rem; + color: #2f3136; + font-size: 1.4rem; +} + +.fishbowl .preamble__entry--small { + font-size: 1rem; +} + +.fishbowl .chatlog { + padding: 1rem 0; + width: 100%; +} + +.fishbowl .chatlog__message-group { + margin-bottom: 1rem; +} + +.fishbowl .chatlog__message-container { + background-color: transparent; + transition: background-color 1s ease; +} + +.fishbowl .chatlog__message-container--highlighted { + background-color: rgba(114, 137, 218, 0.2); +} + +.fishbowl .chatlog__message-container--pinned { + background-color: rgba(249, 168, 37, 0.05); +} + +.fishbowl .chatlog__message { + display: grid; + grid-template-columns: auto 1fr; + padding: 0.15rem 0; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__message:hover { + background-color: #fafafa; +} + +.fishbowl .chatlog__message:hover .chatlog__short-timestamp { + display: block; +} + +.fishbowl .chatlog__message-aside { + grid-column: 1; + width: 72px; + padding: 0.15rem 0.15rem 0 0.15rem; + text-align: center; +} + +.fishbowl .chatlog__reference-symbol { + height: 10px; + margin: 6px 4px 4px 36px; + border-left: 2px solid #c7ccd1; + border-top: 2px solid #c7ccd1; + border-radius: 8px 0 0 0; +} + +.fishbowl .chatlog__avatar { + width: 40px; + height: 40px; + border-radius: 50%; +} + +.fishbowl .chatlog__short-timestamp { + display: none; + color: #5e6772; + font-size: 0.7em; + line-height: 1.4em; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__message-primary { + grid-column: 2; + min-width: 0; +} + +.fishbowl .chatlog__reference { + display: flex; + margin-bottom: 0.15rem; + align-items: center; + color: #5f5f60; + font-size: 0.85em; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.fishbowl .chatlog__reference-avatar { + width: 16px; + height: 16px; + margin-right: 0.25rem; + border-radius: 50%; +} + +.fishbowl .chatlog__reference-author { + margin-right: 0.3rem; + font-weight: 600; +} + +.fishbowl .chatlog__reference-content { + overflow: hidden; + text-overflow: ellipsis; +} + +.fishbowl .chatlog__reference-link { + cursor: pointer; +} + +.fishbowl .chatlog__reference-link * { + display: inline; + pointer-events: none; +} + +.fishbowl .chatlog__reference-link .hljs { + display: inline; +} + +.fishbowl .chatlog__reference-link:hover { + color: #2f3136; +} + +.fishbowl .chatlog__reference-link:hover *:not(.chatlog__markdown-spoiler) { + color: inherit; +} + +.fishbowl .chatlog__reference-edited-timestamp { + margin-left: 0.25rem; + color: #5e6772; + font-size: 0.75rem; + font-weight: 500; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__header { + margin-bottom: 0.1rem; +} + +.fishbowl .chatlog__author { + font-weight: 600; + color: #2f3136; +} + +.fishbowl .chatlog__bot-label { + position: relative; + top: -0.1rem; + margin-left: 0.3rem; + padding: 0.05rem 0.3rem; + border-radius: 3px; + background-color: #5865F2; + color: #ffffff; + font-size: 0.625rem; + font-weight: 500; + line-height: 1.3; +} + +.fishbowl .chatlog__timestamp { + margin-left: 0.3rem; + color: #5e6772; + font-size: 0.75rem; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__content { + padding-right: 1rem; + word-wrap: break-word; +} + +.fishbowl .chatlog__edited-timestamp { + margin-left: 0.15rem; + color: #5e6772; + font-size: 0.7em; +} + +.fishbowl .chatlog__attachment { + position: relative; + width: fit-content; + margin-top: 0.3rem; + border-radius: 3px; + overflow: hidden; +} + +.fishbowl .chatlog__attachment--hidden { + cursor: pointer; + box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.1); +} + +.fishbowl .chatlog__attachment--hidden * { + pointer-events: none; +} + +.fishbowl .chatlog__attachment-spoiler-caption { + display: none; + position: absolute; + left: 50%; + top: 50%; + z-index: 999; + padding: 0.4rem 0.8rem; + border-radius: 20px; + transform: translate(-50%, -50%); + background-color: rgba(0, 0, 0, 0.9); + color: #dcddde; + font-size: 0.9rem; + font-weight: 600; + letter-spacing: 0.05rem; +} + +.fishbowl .chatlog__attachment--hidden .chatlog__attachment-spoiler-caption { + display: block; +} + +.fishbowl .chatlog__attachment--hidden:hover .chatlog__attachment-spoiler-caption { + color: #fff; +} + +.fishbowl .chatlog__attachment-media { + max-width: 45vw; + max-height: 500px; + vertical-align: top; + border-radius: 3px; +} + +.fishbowl .chatlog__attachment--hidden .chatlog__attachment-media { + filter: blur(44px); +} + +.fishbowl .chatlog__attachment-generic { + max-width: 520px; + width: 100%; + height: 40px; + padding: 10px; + border: 1px solid #ebedef; + border-radius: 3px; + background-color: #f2f3f5; + overflow: hidden; +} + +.fishbowl .chatlog__attachment--hidden .chatlog__attachment-generic { + filter: blur(44px); +} + +.fishbowl .chatlog__attachment-generic-icon { + float: left; + width: 30px; + height: 100%; + margin-right: 10px; +} + +.fishbowl .chatlog__attachment-generic-size { + color: #72767d; + font-size: 12px; +} + +.fishbowl .chatlog__attachment-generic-name { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.fishbowl .chatlog__embed { + display: flex; + margin-top: 0.3rem; + max-width: 520px; +} + +.fishbowl .chatlog__embed-color-pill { + flex-shrink: 0; + width: 0.25rem; + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; +} + +.fishbowl .chatlog__embed-color-pill--default { + background-color: rgba(227, 229, 232, 1); +} + +.fishbowl .chatlog__embed-content-container { + display: flex; + flex-direction: column; + padding: 0.5rem 0.6rem; + border: 1px solid rgba(204, 204, 204, 0.3); + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + background-color: rgba(249, 249, 249, 0.3); +} + +.fishbowl .chatlog__embed-content { + display: flex; + width: 100%; +} + +.fishbowl .chatlog__embed-text { + flex: 1; +} + +.fishbowl .chatlog__embed-author-container { + display: flex; + margin-bottom: 0.5rem; + align-items: center; +} + +.fishbowl .chatlog__embed-author-icon { + width: 20px; + height: 20px; + margin-right: 0.5rem; + border-radius: 50%; +} + +.fishbowl .chatlog__embed-author { + color: #4f545c; + font-size: 0.875rem; + font-weight: 600; + direction: ltr; + unicode-bidi: bidi-override; +} + +.fishbowl .chatlog__embed-author-link { + color: #4f545c; +} + +.fishbowl .chatlog__embed-title { + margin-bottom: 0.5rem; + color: #4f545c; + font-size: 0.875rem; + font-weight: 600; +} + +.fishbowl .chatlog__embed-description { + color: #2e3338; + font-weight: 500; + font-size: 0.85rem; +} + +.fishbowl .chatlog__embed-fields { + display: flex; + flex-wrap: wrap; + gap: 0 0.5rem; +} + +.fishbowl .chatlog__embed-field { + flex: 0; + min-width: 100%; + max-width: 506px; + padding-top: 0.6rem; + font-size: 0.875rem; +} + +.fishbowl .chatlog__embed-field--inline { + flex: 1; + flex-basis: auto; + min-width: 50px; +} + +.fishbowl .chatlog__embed-field-name { + margin-bottom: 0.2rem; + color: #36393e; + font-weight: 600; +} + +.fishbowl .chatlog__embed-field-value { + color: #2e3338; + font-weight: 500; +} + +.fishbowl .chatlog__embed-thumbnail { + flex: 0; + max-width: 80px; + max-height: 80px; + margin-left: 1.2rem; + border-radius: 3px; +} + +.fishbowl .chatlog__embed-image-container { + margin-top: 0.6rem; +} + +.fishbowl .chatlog__embed-image { + max-width: 500px; + max-height: 400px; + border-radius: 3px; +} + +.fishbowl .chatlog__embed-footer { + margin-top: 0.6rem; + color: #2e3338; +} + +.fishbowl .chatlog__embed-footer-icon { + width: 20px; + height: 20px; + margin-right: 0.2rem; + border-radius: 50%; + vertical-align: middle; +} + +.fishbowl .chatlog__embed-footer-text { + vertical-align: middle; + font-size: 0.75rem; + font-weight: 500; +} + +.fishbowl .chatlog__embed-plainimage { + max-width: 45vw; + max-height: 500px; + vertical-align: top; + border-radius: 3px; +} + +.fishbowl .chatlog__embed-spotify { + border: 0; +} + +.fishbowl .chatlog__embed-youtube-container { + margin-top: 0.6rem; +} + +.fishbowl .chatlog__embed-youtube { + border: 0; + border-radius: 3px; +} + +.fishbowl .chatlog__sticker { + width: 180px; + height: 180px; +} + +.fishbowl .chatlog__sticker--media { + max-width: 100%; + max-height: 100%; +} + +.fishbowl .chatlog__reactions { + display: flex; +} + +.fishbowl .chatlog__reaction { + display: flex; + margin: 0.35rem 0.1rem 0.1rem 0; + padding: 0.125rem 0.375rem; + border: 1px solid transparent; + border-radius: 8px; + background-color: #f2f3f5; + align-items: center; +} + +.fishbowl .chatlog__reaction:hover { + border: 1px solid rgba(0, 0, 0, 0.2); + background-color: white; +} + +.fishbowl .chatlog__reaction-count { + min-width: 9px; + margin-left: 0.35rem; + color: #4f5660; + font-size: 0.875rem; +} + +.fishbowl .chatlog__reaction:hover .chatlog__reaction-count { + color: #2e3338; +} + +.fishbowl .chatlog__markdown { + max-width: 100%; + line-height: 1.3; + overflow-wrap: break-word; +} + +.fishbowl .chatlog__markdown-preserve { + white-space: pre-wrap; +} + +.fishbowl .chatlog__markdown-spoiler { + background-color: rgba(0, 0, 0, 0.1); + border-radius: 3px; +} + +.fishbowl .chatlog__markdown-spoiler--hidden { + cursor: pointer; + background-color: #b9bbbe; + color: rgba(0, 0, 0, 0); +} + +.fishbowl .chatlog__markdown-spoiler--hidden:hover { + background-color: rgba(185, 187, 190, 0.8); +} + +.fishbowl .chatlog__markdown-spoiler--hidden::selection { + color: rgba(0, 0, 0, 0); +} + +.fishbowl .chatlog__markdown-quote { + display: flex; + margin: 0.05rem 0; +} + +.fishbowl .chatlog__markdown-quote-border { + margin-right: 0.5rem; + border: 2px solid #c7ccd1; + border-radius: 3px; + background-color: #c7ccd1; +} + +.fishbowl .chatlog__markdown-pre { + background-color: #f9f9f9; + font-family: "Consolas", "Courier New", Courier, monospace; +} + +.fishbowl .chatlog__markdown-pre--multiline { + margin-top: 0.25rem; + padding: 0.5rem; + border: 2px solid #f3f3f3; + border-radius: 5px; + color: #657b83; +} + +.fishbowl .chatlog__markdown-pre--multiline.hljs { + background-color: inherit; + color: inherit; +} + +.fishbowl .chatlog__markdown-pre--inline { + padding: 2px; + border-radius: 3px; + font-size: 0.85rem; +} + +.fishbowl .chatlog__markdown-mention { + border-radius: 3px; + padding: 0 2px; + background-color: rgba(88, 101, 242, .15); + color: #505cdc; + font-weight: 500; +} + +.fishbowl .chatlog__markdown-mention:hover { + background-color: #5865f2; + color: #ffffff +} + +.fishbowl .chatlog__markdown-timestamp { + border-radius: 3px; + padding: 0 2px; + color: #5e6772; +} + +.fishbowl .chatlog__emoji { + width: 1.325rem; + height: 1.325rem; + margin: 0 0.06rem; + vertical-align: -0.4rem; +} + +.fishbowl .chatlog__emoji--small { + width: 1rem; + height: 1rem; +} + +.fishbowl .chatlog__emoji--large { + width: 2.8rem; + height: 2.8rem; +} + +.fishbowl .postamble { + padding: 1.25rem; +} + +.fishbowl .postamble__entry { + color: #2f3136; +} \ No newline at end of file diff --git a/public/waterline.svg b/public/waterline.svg new file mode 100644 index 0000000..8b98936 --- /dev/null +++ b/public/waterline.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ansicolor/ansicolor.go b/src/ansicolor/ansicolor.go index b0e218d..94dd443 100644 --- a/src/ansicolor/ansicolor.go +++ b/src/ansicolor/ansicolor.go @@ -36,14 +36,6 @@ var BgWhite = "\033[47m" func init() { if runtime.GOOS == "windows" { - Reset = "" - Red = "" - Green = "" - Yellow = "" - Blue = "" - Purple = "" - Cyan = "" - Gray = "" - White = "" + Reset = BgBlack + Reset } } diff --git a/src/hmndata/user_helper.go b/src/hmndata/user_helper.go index 4e8d6cb..ccf098d 100644 --- a/src/hmndata/user_helper.go +++ b/src/hmndata/user_helper.go @@ -12,8 +12,9 @@ import ( type UsersQuery struct { // Ignored when using FetchUser - UserIDs []int // if empty, all users - Usernames []string // if empty, all users + UserIDs []int // if empty, all users + Usernames []string // if empty, all users + DiscordUserIDs []string // if empty, no Discord filtering // Flags to modify behavior AnyStatus bool // Bypasses shadowban system @@ -44,8 +45,9 @@ func FetchUsers( } type userRow struct { - User models.User `db:"hmn_user"` - AvatarAsset *models.Asset `db:"avatar"` + User models.User `db:"hmn_user"` + AvatarAsset *models.Asset `db:"avatar"` + DiscordUser *models.DiscordUser `db:"discord_user"` } var qb db.QueryBuilder @@ -54,6 +56,7 @@ func FetchUsers( FROM hmn_user LEFT JOIN asset AS avatar ON avatar.id = hmn_user.avatar_asset_id + LEFT JOIN discord_user ON discord_user.hmn_user_id = hmn_user.id WHERE TRUE `) @@ -63,6 +66,9 @@ func FetchUsers( if len(q.Usernames) > 0 { qb.Add(`AND LOWER(hmn_user.username) = ANY($?)`, q.Usernames) } + if len(q.DiscordUserIDs) > 0 { + qb.Add(`AND discord_user.userid = ANY($?)`, q.DiscordUserIDs) + } if !q.AnyStatus { if currentUser == nil { qb.Add(`AND hmn_user.status = $?`, models.UserStatusApproved) @@ -89,6 +95,7 @@ func FetchUsers( for i, row := range userRows { user := row.User user.AvatarAsset = row.AvatarAsset + user.DiscordUser = row.DiscordUser result[i] = &user } diff --git a/src/hmnurl/hmnurl_test.go b/src/hmnurl/hmnurl_test.go index ee861d6..eedc40a 100644 --- a/src/hmnurl/hmnurl_test.go +++ b/src/hmnurl/hmnurl_test.go @@ -172,6 +172,15 @@ func TestPodcastRSS(t *testing.T) { AssertRegexMatch(t, BuildPodcastRSS(), RegexPodcastRSS, nil) } +func TestFishbowlIndex(t *testing.T) { + AssertRegexMatch(t, BuildFishbowlIndex(), RegexFishbowlIndex, nil) +} + +func TestFishbowl(t *testing.T) { + AssertRegexMatch(t, BuildFishbowl("oop"), RegexFishbowl, map[string]string{"slug": "oop"}) + AssertRegexNoMatch(t, BuildFishbowl("oop")+"/otherfiles/whatever", RegexFishbowl) +} + func TestForum(t *testing.T) { AssertRegexMatch(t, hmn.BuildForum(nil, 1), RegexForum, nil) AssertRegexMatch(t, hmn.BuildForum([]string{"wip"}, 2), RegexForum, map[string]string{"subforums": "wip", "page": "2"}) diff --git a/src/hmnurl/urls.go b/src/hmnurl/urls.go index 337c0c0..460ba3f 100644 --- a/src/hmnurl/urls.go +++ b/src/hmnurl/urls.go @@ -365,6 +365,26 @@ func BuildPodcastEpisodeFile(filename string) string { return BuildUserFile(fmt.Sprintf("podcast/%s/%s", models.HMNProjectSlug, filename)) } +/* + * Fishbowls + */ + +var RegexFishbowlIndex = regexp.MustCompile(`^/fishbowl$`) + +func BuildFishbowlIndex() string { + defer CatchPanic() + return Url("/fishbowl", nil) +} + +var RegexFishbowl = regexp.MustCompile(`^/fishbowl/(?P[^/]+)/?$`) + +func BuildFishbowl(slug string) string { + defer CatchPanic() + return Url(fmt.Sprintf("/fishbowl/%s/", slug), nil) +} + +var RegexFishbowlFiles = regexp.MustCompile(`^/fishbowl/(?P[^/]+)(?P/.+)$`) + /* * Forums */ diff --git a/src/models/user.go b/src/models/user.go index 874fbe6..758f346 100644 --- a/src/models/user.go +++ b/src/models/user.go @@ -50,6 +50,7 @@ type User struct { // Non-db fields, to be filled in by fetch helpers AvatarAsset *Asset + DiscordUser *DiscordUser } func (u *User) BestName() string { diff --git a/src/templates/src/fishbowl.html b/src/templates/src/fishbowl.html new file mode 100644 index 0000000..797bdd6 --- /dev/null +++ b/src/templates/src/fishbowl.html @@ -0,0 +1,89 @@ +{{ template "base.html" . }} + +{{ define "extrahead" }} + + + + + +{{ end }} + +{{ define "content" }} +
+

{{ .Info.Title }}

+

{{ .Info.Description }}

+ +
+
+ This is a fishbowl: a panel conversation held on the Handmade Network Discord where a select few participants discuss a topic with depth and nuance. We host them every two months, so if you want to catch the next one, join the Discord! +
+
+ +
+ {{- .Contents -}} +
+
+{{ end }} diff --git a/src/templates/src/fishbowl_index.html b/src/templates/src/fishbowl_index.html new file mode 100644 index 0000000..6035cc0 --- /dev/null +++ b/src/templates/src/fishbowl_index.html @@ -0,0 +1,33 @@ +{{ template "base.html" . }} + +{{ define "content" }} +
+

Fishbowls

+ +

Every two months on the Discord, we host a fishbowl: a panel conversation where a select few community members can discuss a topic in detail. Fishbowls give us the opportunity to discuss difficult subjects with more nuance and detail than you can find anywhere else on the Internet. In many ways, they're a distillation of everything the network is about.

+ +

This is an archive of those conversations. If you would like to catch one live, join the Discord!

+ +

We're still working through our backlog of fishbowls, so not all of these are available yet. We'll publish them as we finish them.

+ +
+ {{ range .Fishbowls }} +
+ {{ if .Valid }} +

{{ .Fishbowl.Title }}

+ {{ else }} +

{{ .Fishbowl.Title }}

+ {{ end }} +
+ {{ .Fishbowl.Month }} {{ .Fishbowl.Year }} +
+ {{ with .Fishbowl.Description }} +
{{ . }}
+ {{ end }} +
+ {{ end }} +
+ +

If you'd like to help us plan more fishbowls, join the discussion over on GitHub.

+
+{{ end }} diff --git a/src/templates/src/fishbowls/README.md b/src/templates/src/fishbowls/README.md new file mode 100644 index 0000000..7e22d74 --- /dev/null +++ b/src/templates/src/fishbowls/README.md @@ -0,0 +1 @@ +Make sure to name these folders according to the URL slugs of the fishbowls. Otherwise, static files for fishbowls will not work. diff --git a/src/templates/src/fishbowls/oop/OOP.html b/src/templates/src/fishbowls/oop/OOP.html new file mode 100644 index 0000000..acb3bb1 --- /dev/null +++ b/src/templates/src/fishbowls/oop/OOP.html @@ -0,0 +1,12127 @@ +
+ + + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +Topic: What, if anything, is OOP? + +
+
+
+ bvisness + + + May 28, 2022 09:58 AM +
+ +
+ Welcome to yet another fishbowl, everyone! Just setting things up here. The main conversation is here in this thread, and the #fishbowl-audience conversation starts here: https://discord.com/channels/239737791225790464/708458209131757598/980155512412864552 + +The pinned messages are some "checkpoints" in the discussion; chapter markers of sorts. Check them out if there's a specific aspect of the discussion you'd like to see. + + (edited) +
+ + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 09:59 AM +
+ +
+ Welcome, everyone! + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:00 AM +
+ +
+ Hi! + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:01 AM +
+ +
+ So, this fishbowl is a long time coming. Since the dawn of the network, many people have asked the question: Is object-oriented programming bad, or what? + +
+ + + + + +
+
+
+
+
+
+
10:02
+
+ +
+ +
+ That is, unfortunately, not a very nuanced question. ๐Ÿ™‚ + +
+ + + + +
+
+
+
+
+
+
10:02
+
+ +
+ +
+ Our conversations about OOP often veer in a lot of different directions, and the subject is hard to discuss productively because it means so many different things to different people. + +
+ + + + +
+
+
+
+
+
+
10:04
+
+ +
+ +
+ There are many different ideas that are bundled into the modern concept of "object-oriented programming". There are also many languages that have taken on these ideas with different decisions and tradeoffs. Our goal in this fishbowl is to break this subject down and discuss these different concepts with more nuance. + +
+ + + + +
+
+
+
+
+
+
10:04
+
+ +
+ +
+ To that end, we're doing things just a little bit differently for this one. Each of our esteemed participants have picked a particular aspect of "OOP" to present, and we'll be working through those over the course of the conversation here. + +
+ + + + +
+
+
+
+
+
+
10:04
+
+ +
+ +
+ On that note, let me introduce our participants: + +
+ + + + +
+
+
+
+
+
+
10:05
+
+ +
+ +
+ - me (hi) + +
+ + + + +
+
+
+
+
+
+
10:05
+
+ +
+ +
+ - @demetrispanos, general wise elder of the community with particular expertise in machine learning and artificial intelligence + +
+ + + + +
+
+
+
+
+
+
10:06
+
+ +
+ +
+ - @gingerBill, creator of the Odin programming language + +
+ + + + +
+
+
+
+
+
+
10:07
+
+ +
+ +
+ - @Kartik Agaram, creator of creative and very low-level programming systems / operating systems such as Mu and Teliva (look them up!) + +
+ + + + +
+
+
+
+
+
+
10:08
+
+ +
+ +
+ - @SirWhinesalot, a community member whose comments were instrumental to the planning process for this fishbowl (if there are projects you've worked on that I'm not aware of, let me know and I'll update this introduction ๐Ÿ˜…) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:08 AM +
+ +
+ none public ๐Ÿ™‚ + +
+ + + + +
+
+
+
+
+
+
10:08
+
+ +
+ +
+ but my expertise is in Domain-Specific Languages and Constraint Solving + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:08 AM +
+ +
+ ๐Ÿ‘ + +
+ + + + +
+
+
+
+
+
+
10:09
+
+ +
+ +
+ Before we get into the various modern conceptions of OOP, I think it would be good to take a look back at the history of object-oriented programming, and the path that we took to get to where we are today. @Kartik Agaram has graciously volunteered to walk us through that history, so - take it away, Kartik! + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 10:10 AM +
+ +
+ Is this thing on? Ok, let me paste in some prepared remarks. A quick, opinionated timeline of the major ideas that make up OO. + +
+ + + + +
+
+
+
+
+
+
10:10
+
+ +
+ +
+ 1958-1966: A few different people gradually come up with the notion of structured data. Conventions for managing compound data made of multiple words in memory. If you have two points, you want their x and y coordinates close together and in the same relative order. Seems obvious, but wasn't! See http://akkartik.name/sketchpad-oo.png from the Sketchpad thesis [1]. + +1960-1962: Ivan Sutherland works on Sketchpad. It presages many OO ideas, but they're all in the programmer's mind and prose (thesis) because the code is all machine code. + +1961-1962: Simula provides language support for many OO ideas: objects, classes, inheritance, dispatch based on the precise class of an object (virtual methods).[2] + +1960-1975: Data first. This was mostly a mindset thing, but led eventually to notation like obj.method. Had spread fairly wide by around 1975, when Fred Brooks said, "show me your code and I'll be mystified. Show me your data structures and the code will be obvious." [3] + +1973-1975: Abstract data types by Barbara Liskov. Ignore internal details of how objects are laid out in memory. Focus instead on a small vocabulary of operations that can be performed using them. Interfaces, basically.[4] + +1966-1975: Alan Kay coins OO after working on Smalltalk. (The first chapter of http://gagne.homedns.org/~tgagne/contrib/EarlyHistoryST.html is better than my history above.) "Did not have C++ in mind." However, we're only halfway done. + + (edited) +
+ + + + + +
+
+
+
+
+
+
10:11
+
+ +
+ +
+ 1970-1975: Lexical scope comes into its own, and leads naturally to closures.[5] + +1980-1994: Lisp has been evolving largely in parallel, but now starts to cross-pollinate with OO. MIT Flavors (1982), CommonLOOPS (1986), CLOS (1994). OO is big on late binding. Lisp takes late binding to 11, with before/after advice and dispatch based on the types of multiple arguments. In 1994, Common Lisp decides to adopt lexical scope by default. + +1992: It becomes clear that there's a yin-yang duality between objects and closures.[6] Though objects have the benefit of putting data first. + +1994: The "gang of four" writes the Design Patterns book, based on ideas by the architect Christopher Alexander. Kicks off the field of OO design. + +2001: Joel Spolsky coins "architecture astronauts,"[7] peak of hype cycle for design patterns. (OO design remains in vogue to this day, though.) + +2007: Clojure arrives. Built on an OO foundation (the JVM) but determinedly anti-OO. Peak of the hype cycle for OO? Functional programming is now ascendant, impelled by the value of immutability. + +2008-2014: Growing anti-OO sentiment[8], anti-design-patterns sentiment[9], awareness that composition is superior to inheritance[10]. + +2020: Richard Feldman crystallizes the case against OO[11]: OO wants to make every object a little computer. But why do we want to make all programs distributed? + +
+ + + + +
+
+
+ +
+
+
+
10:12
+
+ +
+ +
+ Ok I'm done ๐Ÿ™‚ Summary: there's a lot of ideas baked into "OO". Most of them are great. Some of them are showing their age. And unbundling them all feels more useful than treating them monolithically. End prepared remarks ๐Ÿ™‚ + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:14 AM +
+ +
+ Excellent, this is a wonderful place to start. I appreciate that you included a lot of the recent takes on OO; I think we'll especially be revisiting a lot of the 2001-present takes as we go along. + +
+ + + + +
+
+
+
+
+
+
10:16
+
+ +
+ +
+ For some more context, what languages were in use around the 60s-70s when Brooks said that quote about data structures, and when Liskov was pioneering abstract data types? + +
+ + + + +
+
+
+
+
+
+
10:16
+
+ +
+ +
+ In general I'm curious how some of these early ideas manifested in the tools that we now use today. (I know Java was a big one along the way, and we'll have a nice long section dedicated just to that...) + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:18 AM +
+ +
+ I know CLU (Barbara Liskov's language) came out in 1973 + +
+ + + + +
+
+
+
+
+
+
10:18
+
+ +
+ +
+ Interestingly it was the first language with built-in Tagged Unions as far as I know + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 10:19 AM +
+ +
+ Oh gosh. I wasn't around then ๐Ÿ™‚ but my weak sense is that while there were a few different programming languages being researched, the vast majority of people were programming in machine code and Assembly back then. Big ones: Fortran, COBOL, Algol (still getting refined), Lisp 1.5. + +
+ + + + +
+
+
+
+
+
+
10:20
+
+ +
+ +
+ @SirWhinesalot Yes, I think so! Too bad it took so long for them to go "mainstream". + +
+ + + + +
+
+
+
+
+
+
10:21
+
+ +
+ +
+ Going back to that Brooks quote. I think he was mostly talking about how programmers communicate. Languages and compilers weren't really the dominant gatekeepers of notation back then. + +
+ + + + +
+
+
+
+
+
+
10:21
+
+ +
+ +
+ It was paper, in some form. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:21 AM +
+ +
+ That makes sense, I suppose that would be the case + +
+ + + + +
+
+
+
+
+
+
10:22
+
+ +
+ +
+ The sense that I get (which may not be very accurate) is that in the 60s and 70s, there was a lot of pioneering work in the field happening mostly in parallel, but that the ideas hadn't really taken hold in "industry" yet. At what point would you say that began to occur? + + (edited) +
+ + + + +
+
+
+
+
+
+
10:22
+
+ +
+ +
+ Certainly from what I've seen of e.g. FORTRAN, the "practical tools" of the day didn't have any such concepts. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 10:25 AM +
+ +
+ That's a good question. I have a hard time thinking of descriptions of production systems and languages used by industry. Even though Bell Labs and PARC came from industry, I think a lot of their work was fed by govt. grants and so tightly coupled with govt. rather than commercial considerations. + +The software industry took off around late 70s? And then it took a while to rediscover the value of programming languages as the PC revolution took off and computers got fast enough to manage HLLs. + +
+ + + + +
+
+
+
+
+
+
10:25
+
+ +
+ +
+ Turbo Pascal was 1983. That was really my introduction to high-level languages. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:26 AM +
+ +
+ I know @gingerBill is quite a Pascal fan; I don't know if he would know any more about the history there + +
+ + + + +
+
+
+
+
+
+
10:26
+
+ +
+ +
+ or at least a Wirth fan ๐Ÿ™‚ + +
+ + + + +
+
+ โค๏ธ + 3 +
+
+
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 10:27 AM +
+ +
+ The first Pascal was created by Niklaus Wirth in 1970 as a teaching tool. + +
+ + + + +
+
+
+
+
+
+
10:27
+
+ +
+ +
+ It mostly became popular because of its simplicity and that it was easy to learn, especially amongst many of the minicomputer buyers in the 1970s. + +
+ + + + +
+
+
+
+
+
+
10:28
+
+ +
+ +
+ Pascal (along with C) are part of a language family called ALGOL, specifically ALGOL 60. + +
+ + + + +
+
+
+
+
+
+
10:28
+
+ +
+ +
+ ALGOL is the basis of pretty much every imperative (procedural) programming language to date. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:30 AM +
+ +
+ It's honestly pretty crazy to me to look at the timeline here and see that nearly all these fundamental OOP-y designs were all developed independently at around the same time. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 10:31 AM +
+ +
+ ALGOL 60 was created by many designers with many famous names too: +John Backus, Peter Naur (yes, those two of Backus-Naur Form), Friedrich Bauer (discovered the stack data structure), Charles Katz (you'll see his name in many papers), John McCarthy (AI, Lisp, etc), Alan Perlis (APL), and many many more. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 10:31 AM +
+ +
+ And then the whole academic side runs out of steam in the 2000s, in my mind.. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 10:32 AM +
+ +
+ There's the basic history lesson for the roots of all imperative programming languages, as well as some others like Lisp and APL. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:33 AM +
+ +
+ The 1980s to early 1990s is when OOP really starts picking up steam, Object Pascal, Objective-C, C++, COM, all culminating in Java in 1995 + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:33 AM +
+ +
+ I think I can see traces of all these historical ideas in the languages we use today, and perhaps we can refer back to this list as we go + +
+ + + + +
+
+
+
+
+
+
10:33
+
+ +
+ +
+ What Bill is saying about imperative programming languages may accidentally be a good segue into the first major concept of OOP that I have on my list... + +
+ + + + +
+
+
+
+
+
+
10:34
+
+ +
+ +
+ Which is that OOP is when you associate behavior with data, in a sense just the idea of a "method". (I am not saying this is a completely correct concept, but it is one that I see frequently discussed.) + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 10:34 AM +
+ +
+ One really important thing that I would love to bring up before we dive deep into the philosophy questions is the distinction between Object-Oriented Programming (OOP) and Methods, and why I think this is at the heart of the discussion. + + (edited) +
+ + + + +
+
+
+
+
+
+
10:35
+
+ +
+ +
+ I'd argue that 99% of the reasons people want methods (and what many mean by "OOP" in a weird sense) are for the following reasons: + + (1) Organizing procedures under a data type + + (2) Allowing methods as a form syntactic sugar for writing calls in a subject verb object manner, e.g. do_thing(x, y) vs x.do_thing(y) + + (3) Searching for procedures/methods by a data type, especially with the aid of tools such as an IDE + +Regarding (1), I personally believe this is much better solved with a well designed package/module/library system as part of the language. Most OOP languages do not have such a system and usually use classes as a means to organize code. For my programming language Odin, packages have really aided us in terms of organization a lot better than + +Regarding (2), this is a weird linguistic typology thing which I doubt most people will even know unless they speak multiple languages. If you want to learn more about word orders in different languages, I recommend reading the following: + + * https://en.wikipedia.org/wiki/Subject%E2%80%93verb%E2%80%93object_word_order + * https://en.wikipedia.org/wiki/Verb%E2%80%93subject%E2%80%93object_word_order + + +Regarding (3), this is purely a tooling issue. It comes down to two main aspects: + + * Many people just want to use the tools that they have and how they currently work (there is nothing wrong with that, per se) + * Many people cannot think outside of the current paradigm and think what is being asked for is not possible + + +Doing foo. and waiting for the IDE to autocomplete what is available for that value of a specific data type is extremely useful to many people, but there is not reason it could not work for something that was purely procedural, it is that many languages nowadays do support some form of methods and thus the general need has not arisen. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 10:36 AM +
+ +
+ Like Common Lisp's generic methods. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:36 AM +
+ +
+ So in your opinion, is it not correct to say that "associating behavior with data" is essential to OOP, because all functions are associated with some form of data? (Regardless of syntax?) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 10:37 AM +
+ +
+ "mere methods" (Lua is a good example of this, where they're just sugar for passing in the "subject" pointer) are IMO roughly analogous to for-loops or if-blocks, i.e. a syntactic standardization of a widespread common practice + +
+ + + + +
+
+
+
+
+
+
10:37
+
+ +
+ +
+ "procedural programming" could be seen as just standardizing a handful of assembly language idioms into language constructs + +
+ + + + +
+
+
+
+
+
+
10:37
+
+ +
+ +
+ "mere methods" are, for me, just more of this + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 10:38 AM +
+ +
+ they standardize the pattern
struct mything { + // whatever +} + +void mything_do_cool_stuff (struct mything *m, int x) { + // whatever +}
+ +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:38 AM +
+ +
+ I would agree with @demetrispanos and @gingerBill , methods as in the little . notation and OOP are independent concerns + +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
demetrispanos
+
+ +they standardize the pattern
struct mything { + // whatever +} + +void mything_do_cool_stuff (struct mything *m, int x) { + // whatever +}
+ +
+
+
+ SirWhinesalot + + + May 28, 2022 10:39 AM +
+ +
+ importantly, note how in the pattern above the function is not tied to struct, you can keep adding as many functions as you want + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:39 AM +
+ +
+ in OOP, classes have a fixed set of methods, usually + +
+ + + + +
+
+
+
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
SirWhinesalot
+
+ +importantly, note how in the pattern above the function is not tied to struct, you can keep adding as many functions as you want + +
+
+
+ demetrispanos + + + May 28, 2022 10:40 AM +
+ +
+ yes exactly, that's part of what I mean by "mere" (i.e. they're not wound up in some other concept like a class) + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 10:39 AM +
+ +
+ Lua is an example of something I'd like to call an Emergent OO Programming Language , but I'll leave that for a little later to reduce confusion. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 10:40 AM +
+ +
+ Lua after all is a table oriented language. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 10:39 AM +
+ +
+ There's a few of those ๐Ÿ˜„ + +
+ + + + +
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
SirWhinesalot
+
+ +in OOP, classes have a fixed set of methods, usually + +
+
+
+ Kartik Agaram + + + May 28, 2022 10:40 AM +
+ +
+ "open to extension" is another wonderful idea we should discuss at some point. โค๏ธ Ruby + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:40 AM +
+ +
+ Smalltalk as well + +
+ + + + +
+
+ ๐Ÿ’ก + 1 +
+
+
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
demetrispanos
+
+ +yes exactly, that's part of what I mean by "mere" (i.e. they're not wound up in some other concept like a class) + +
+
+
+ bvisness + + + May 28, 2022 10:40 AM +
+ +
+ Would you elaborate on what extra ideas a "class" adds to the picture? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 10:42 AM +
+ +
+ I'd say a "mere class" is a struct with a fixed set of "mere methods" (echoing some comments from above) + +
+ + + + +
+
+
+
+
+
+
10:42
+
+ +
+ +
+ but classes as practiced add more ideas like visibility, inheritance, etc. + +
+ + + + +
+
+
+
+
+
+
10:43
+
+ +
+ +
+ I'd note that while "mere methods" are IMO definitely useful, it's not clear to me what you get from a "mere class" + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:43 AM +
+ +
+ I think a mere class only becomes useful when subtype polymorphism is involved (i.e., a vtable of some sort) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 10:43 AM +
+ +
+ ah yes, good point + +
+ + + + +
+
+
+
+
+
+
10:43
+
+ +
+ +
+ I agree + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 10:44 AM +
+ +
+ The evolution I tend to see is: +* Putting the primary data type first is a nice way to organize vocabularies in people's minds. (I think this is what y'all mean by "mere methods") +* Once you do that, you can also generalize and allow different types to do different things. That pulls in inheritance and static dispatch. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:45 AM +
+ +
+
* Putting the primary data type first is a nice way to organize vocabularies in people's minds. (I think this is what y'all mean by "mere methods") +
yes
+ +
+ + + + +
+
+
+
+
+
+
10:46
+
+ +
+ +
+ but importantly, the generalization of mere methods has consequences + +
+ + + + +
+
+
+
+
+
+
10:47
+
+ +
+ +
+ because the set of methods is usually fixed + +
+ + + + +
+
+
+
+
+
+
10:47
+
+ +
+ +
+ the moment you do so + +
+ + + + +
+
+
+
+
+
+
10:47
+
+ +
+ +
+ for implementation reasons + +
+ + + + +
+
+
+
+
+
+
10:47
+
+ +
+ +
+ there are alternative formulations but they tend to have severe performance penalties + +
+ + + + +
+
+
+
+
+
+
10:48
+
+ +
+ +
+ this is why I think mere methods and OOP are separate concerns. Having a nice . notation is one thing, introducing the extra machinery is another (and OOP only starts manifesting when the extra machinery comes into play) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 10:50 AM +
+ +
+ I guess re: methods and subtypes, we should also mention prototype-style ideas because that gives a related view on what "mere classes" would do + +
+ + + + +
+
+
+
+
+
+
10:50
+
+ +
+ +
+ in self (https://en.wikipedia.org/wiki/Self_(programming_language)) you have the idea of a prototype as the unit of implementation delegation + +
+ + + + +
+
+
+
+
+
+
10:51
+
+ +
+ +
+ (and of course this carried over into the original version of Javascript OO) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 10:52 AM +
+ +
+ Yeah. There's definitely class- and prototype-based OO out there. Also extensible vs closed to extension. + +Trying to demarcate precisely the boundaries of "OOP" might be a time sink. I'd much rather chop OOP up into its component pieces, and then we can discuss each separately. And then the question of, "is there anything we missed?" becomes fruitful. + +
+ + + + +
+
+
+
+
+
+
10:52
+
+ +
+ +
+ In a game you can have a performance-focused substrate that is closed to extension, and a command language like Lua that is open to extension. Both use OO ideas. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 10:52 AM +
+ +
+ I think it's important to address how people think about OO though + +
+ + + + +
+
+
+
+
+
+
10:53
+
+ +
+ +
+ because just chopping up the pieces leads to talking about various pieces in isolation and that's not what gets people confused (or irate) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:53 AM +
+ +
+ Let's talk about some of those pieces though, because getting a more nuanced idea of them will allow us to come back to what does get people confused and irate + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
SirWhinesalot
+
+ +this is why I think mere methods and OOP are separate concerns. Having a nice . notation is one thing, introducing the extra machinery is another (and OOP only starts manifesting when the extra machinery comes into play) + +
+
+
+ bvisness + + + May 28, 2022 10:54 AM +
+ +
+ I think we should start discussing this "extra machinery". I'm not sure what angle to discuss first; there's the more nuts-and-bolts ideas such as inheritance and polymorphism, but there's also the very hairy subject of object-oriented design. @SirWhinesalot is our point person for that, but I'd like to make sure we feel we've covered our bases first. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:55 AM +
+ +
+ Right, might be worth posting that meme making fun of GeeksForGeeks here ๐Ÿ˜„ + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:56 AM +
+ +
+ heh + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:56 AM +
+ +
+ So what we're talking about here is the idea that "OOP models the real world". + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 10:56 AM +
+ +
+ that's indeed the most important meme to address IMO + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:56 AM +
+ +
+ Should we tackle that now? or after we split OOP up first? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 10:57 AM +
+ +
+ and it links up to almost everything else + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 10:57 AM +
+ +
+ Let's just get into it. + +
+ + + + +
+
+
+
+
+
+
10:57
+
+ +
+ +
+ We can branch from there into everything else, like Demetri says + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 10:57 AM +
+ +
+ What does it mean for OOP to model the real world? Here's what Wikipedia has to say (technically from the Domain-Driven Design page, but the two are intimately related): + +
In terms of object-oriented programming it means that the structure and language of software code (class names, class methods, class variables) should match the business domain. For example, if a software processes loan applications, it might have classes like LoanApplication and Customer, and methods such as AcceptOffer and Withdraw.
+ +
+ + + + +
+
+
+
+
+
+
10:57
+
+ +
+ +
+ I would like to focus on that Customer class. Think of a website like Amazon, what does a Customer do? They can login/logout, purchase items, review items, contact customer support, etc. They also have a lot of data about them like their user-info, preferences, purchases, support tickets, etc. + +
+ + + + +
+
+
+
+
+
+
10:58
+
+ +
+ +
+ What data and methods should the Customer class have? + +
+ + + + +
+
+
+
+
+
+
10:58
+
+ +
+ +
+ Really think about this and the consequences it has on the structure of the codebase. All of the above? Classes should have a "single-responsibility" (supposedly). What should the single responsibility of the Customer class be? + +
+ + + + +
+
+
+
+
+
+
10:58
+
+ +
+ +
+ You see how we immediatelly start getting into trouble? + +
+ + + + +
+
+ ๐Ÿ˜„ + 1 +
+
+
+
+
+
+
+
+
10:58
+
+ +
+ +
+ Then there's the issue of structuring your code into class hierarchies based on real-world concepts, e.g. Customer : Person, Seller : Person, Employee : Person. + +
+ + + + +
+
+
+
+
+
+
10:58
+
+ +
+ +
+ The problem of course is that the same person can not only be all three, they can be different subsets at different times! Even real-world taxonomies need to be updated from time to time, and this modeling style is imposing that kind of rigid structure, with far less certainty, on your data and behavior. + +
+ + + + +
+
+
+
+
+
+
10:59
+
+ +
+ +
+ This style is considered bad practice these days, but even without the taxonomy nonsense the core issue remains, which is trying to model real-world concepts as bundles of encapsulated data + behavior. It just doesn't work well in practice, that idea is the fundamental mistake. + +
+ + + + +
+
+
+
+
+
+
10:59
+
+ +
+ +
+ IMO of course + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:00 AM +
+ +
+ One wonderful book that made the rounds last year: https://buttondown.email/hillelwayne/archive/why-you-should-read-data-and-reality + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 11:01 AM +
+ +
+ My personal view that thinking "OOP models the real world" is wrong because it is a category error. You cannot treat [programming objects] as "real objects" since "real objects" and "programming objects" have little connection to each other ontologically. This is why I've previously called OOP a form of misinterpreted and misapplied Aristotelian Metaphysics applied to a domain it was never meant to model[2]. + +By this statement, I mean that artificially conforming to any/all relations between data and types to an artificial hierarchy of agency is a form of naรฏve-Aristotelian metaphysics. Since there is no actual agency in the programming objects, it is a partial fallacy (and as previously stated, category error). When trying to conform a program to have a particular structure when it does not naturally, the absence of a structure in a program in more useful than a bad structure. + +[1] https://en.wikipedia.org/wiki/Category_mistake +[2] https://www.gingerbill.org/article/2020/05/31/progamming-pragmatist-proverbs/ + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:02 AM +
+ +
+ Map vs territory confusion, right? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 11:02 AM +
+ +
+ There is also the other aspect that in an actual Aristotelian metaphysics, an object can belong to an infinite amount of "classes" in any moment and even change depending on the situation. + +
+ + + + +
+
+
+
+
+
+
11:02
+
+ +
+ +
+ In a way, yes. + +
+ + + + +
+
+
+
+
+
+
11:03
+
+ +
+ +
+ When we discuss of an object, we are speaking of it about what is relevant to us in that situation. + +
+ + + + +
+
+
+
+
+
+
11:03
+
+ +
+ +
+ Let's take a random object off my table right now: a lens cap. + +
+ + + + +
+
+
+
+
+
+
11:03
+
+ +
+ +
+ A lens cap could be in the class of objects that cover a lens. + +
+ + + + +
+
+
+
+
+
+
11:03
+
+ +
+ +
+ But it could also be used a coaster for my drink. + +
+ + + + +
+
+
+
+
+
+
11:04
+
+ +
+ +
+ It could also be used as an eye patch. + +
+ + + + +
+
+ ๐Ÿด‍โ˜ ๏ธ + 1 +
+
+
+
+
+
+
+
+
11:04
+
+ +
+ +
+ Or a weird weapon. + +
+ + + + +
+
+ ๐Ÿ—ก๏ธ + 1 +
+
+ โšซ + 1 +
+
+ ๐Ÿ“ท + 1 +
+
+
+
+
+
+
+
+
11:04
+
+ +
+ +
+ Or a one of an infinite number of things with infinite uses. + +
+ + + + +
+
+
+
+
+
+
11:04
+
+ +
+ +
+ The question is realizing what is relevant for the situation. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:05 AM +
+ +
+ Now you've got me thinking about what a computer that can fluidly move between ontologies would look like.. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 11:06 AM +
+ +
+ This is why, in my personal opinion, a huge issue with force something to an "object"/"class"/etc has issues with. Things belong to more than just one class and trying to force it into one category can be very bad, especially when there is no "object" to speak of in the first place, only algorithms and data structures. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 11:06 AM +
+ +
+ The relational/logical model tends to be much better at this, since you can add/retract facts about an object + +
+ + + + +
+
+
+
+
+
+
11:06
+
+ +
+ +
+ Entity-Component Systems are a form of relational model btw + +
+ + + + +
+
+
+
+
+
+
11:06
+
+ +
+ +
+ Some people think they are a form of OO, that's incorrect + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:08 AM +
+ +
+ I think whether or not it is wrong, "OO solves problem by modeling the real world" is both believed and practiced, and indeed it is widely used to advertise and teach OO + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 11:08 AM +
+ +
+ Indeed, that's how I was taught in university + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:08 AM +
+ +
+ this is what I mean about talking about how people think about it + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:08 AM +
+ +
+ The best defense I've heard for OO design is to limit your ambitions to modeling solutions, not problems. That avoids the issues@gingerBill raises, but it's also a much more modest goal. OO design books seem to pay this idea lip service, but quickly go back to thinking symbols are the thing they represent. It's a very easy mental trap to fall into. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 11:09 AM +
+ +
+ modeling solutions is antithetical to OO-best practices (as taught), because the right solution often involves some sort of "Manager" class that handles the data, and these are "frowned upon" because they don't bundle the data and behavior + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
Kartik Agaram
+
+ +The best defense I've heard for OO design is to limit your ambitions to modeling solutions, not problems. That avoids the issues@gingerBill raises, but it's also a much more modest goal. OO design books seem to pay this idea lip service, but quickly go back to thinking symbols are the thing they represent. It's a very easy mental trap to fall into. + +
+
+
+ gingerBill + + + May 28, 2022 11:10 AM +
+ +
+ The irony of that statement is that is kind of the opposite of the point. Programming is a form of problem solving. If you have already solved the problem, then redesigning it to be OOP is really weird, and borderline masturbation. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:10 AM +
+ +
+
limit your ambitions to modeling solutions, not problems. +
I would phrase this as "[90s style C++/Java] OO offers the ability to form hierarchies of data structures and functions but that this is usually misinterpreted to mean that it will be useful to model hierarchies of concepts in the world outside the program"
+ +
+ + + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
gingerBill
+
+ +The irony of that statement is that is kind of the opposite of the point. Programming is a form of problem solving. If you have already solved the problem, then redesigning it to be OOP is really weird, and borderline masturbation. + +
+
+
+ Kartik Agaram + + + May 28, 2022 11:11 AM +
+ +
+ The idea is that once you've solved a problem, OO Design is a good way to continue to maintain the solution without forgetting why you did what you did. Software systems can last a long time! + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 11:12 AM +
+ +
+ I've found no advantage to an OO design vs any other form of design with a clear structure, unless the features provided by OO (like subtype polymorphism) were necessary + +
+ + + + +
+
+
+
+
+
+
11:12
+
+ +
+ +
+ In fact quite the opposite, since OO design can impose a lot of rigidity that is hard to get rid off + +
+ + + + +
+
+
+
+
+
+
11:13
+
+ +
+ +
+ See weird workaround like C# extension methods for an example + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
Kartik Agaram
+
+ +The idea is that once you've solved a problem, OO Design is a good way to continue to maintain the solution without forgetting why you did what you did. Software systems can last a long time! + +
+
+
+ gingerBill + + + May 28, 2022 11:13 AM +
+ +
+ See the trick? If it needs to be continuously improved, it's not a solution, yet. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:13 AM +
+ +
+ I would say I almost never use inheritance, but I almost always use methods + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:13 AM +
+ +
+ and if someone told me I could never use inheritance again I would not consider it a big loss + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:13 AM +
+ +
+ I'm actually not familiar with any non-OO design methodology ๐Ÿ˜„ They kinda sucked the oxygen out of the room, didn't they? + +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
Kartik Agaram
+
+ +I'm actually not familiar with any non-OO design methodology ๐Ÿ˜„ They kinda sucked the oxygen out of the room, didn't they? + +
+
+
+ SirWhinesalot + + + May 28, 2022 11:14 AM +
+ +
+ there are many architectures you can use. Things like publish/subscribe, model-view-update, etc. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 11:14 AM +
+ +
+ Certainly though the term "design patterns" has come to exclusively mean "object-oriented design patterns", and really the gang of four stuff + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
Kartik Agaram
+
+ +I'm actually not familiar with any non-OO design methodology ๐Ÿ˜„ They kinda sucked the oxygen out of the room, didn't they? + +
+
+
+ gingerBill + + + May 28, 2022 11:14 AM +
+ +
+ "JUST SOLVE THE PROBLEM YOU HAVE" is my preferred one. + +
+ + + + +
+
+ ๐Ÿ’ฏ + 7 +
+
+
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +Certainly though the term "design patterns" has come to exclusively mean "object-oriented design patterns", and really the gang of four stuff + +
+
+
+ bvisness + + + May 28, 2022 11:15 AM +
+ +
+ and that persists to this day, thanks probably to universities? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:15 AM +
+ +
+ yes I think the fact that OO has the superficial appearance of a "theory of programming" is important here + +
+ + + + +
+
+
+
+
+
+
11:15
+
+ +
+ +
+ (re: universities) + +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:15 AM +
+ +
+ universities had rapidly increasing needs to "produce programmers" but universities loathe doing anything that might look like vocational school + +
+ + + + +
+
+
+
+
+
+
11:16
+
+ +
+ +
+ OOP looked like it had some ideas from type theory, had some kind of taxonomy scheme, had some claims to provable properties + +
+ + + + +
+
+
+
+
+
+
11:16
+
+ +
+ +
+ and so it was compatible with what a university might be persuaded to adopt + +
+ + + + +
+
+
+
+
+
+
11:17
+
+ +
+ +
+ and it also had the claim of "intuitively models the real world, so businesses like it" + +
+ + + + +
+
+ ๐Ÿ’ก + 1 +
+
+
+
+
+
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:15 AM +
+ +
+ https://en.wikipedia.org/wiki/Software_design does have a list. I guess I'm not aware of it because I don't do design ๐Ÿ˜… + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 11:18 AM +
+ +
+ My university thankfully presented all paradigms (procedural, oo, functional, logical) + +
+ + + + +
+
+
+
+
+
+
11:19
+
+ +
+ +
+ a good question there is if OO is an actual paradigm + + (edited) +
+ + + + +
+
+
+
+
+
+
11:19
+
+ +
+ +
+ Alan Kay certainly thought so, but Smalltalk OO is a very different beast from C++ or Java or whatever + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:20 AM +
+ +
+ I think Kay has sufficiently lost that battle that there's not much point talking about it as a peer + +
+ + + + +
+
+
+
+
+
+
11:20
+
+ +
+ +
+ when I want to talk about his stuff I say "Kay style OO" or "message passing OO" + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 11:22 AM +
+ +
+ I personally think Kay-style OO could be seen as a unique programming paradigm (when you include the full reflexivity and the IDE as the OS sort of programming style Smalltalk has), but regular OO is not, it's just procedural programming with a pointless structure on top + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:22 AM +
+ +
+ the folk understanding of OO, which IMO is like 90+% of people, is something like +- your program is a collection of classes +- one class per file +- each class represents some concept from the real world +- each class has a single responsibility (this is at odds with above but whatever :P) +- there are "good patterns" of assembling classes into programs to solve problems + + (edited) +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 11:23 AM +
+ +
+ I (luckily?) don't have any programming education, let alone academic, so I cannot comment on what is or what is not taught commonly in Universities beyond what I have heard. From what I can tell, they seem to vary extremely widely compared to say harder science such as Physics or Chemistry. If you go to one University for Physics, it'll be similar enough to another. But for Computer Science (Infomatics), it will be very very different + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:23 AM +
+ +
+ Among other critiques, this approach causes some blind spots because you get trained to think in terms of nouns and deemphasize verbs: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:24 AM +
+ +
+ yes, a very important essay in this history + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
Kartik Agaram
+
+ +Among other critiques, this approach causes some blind spots because you get trained to think in terms of nouns and deemphasize verbs: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html + +
+
+
+ bvisness + + + May 28, 2022 11:24 AM +
+ +
+ I love that post. When Demetri showed it to me for the first time years ago, I was shocked by how much it resonated with me + +
+ + + + +
+
+
+
+
+
+
11:25
+
+ +
+ +
+ This seems like as good a time as any for Demetri to talk about Java and what it did to the world of software + +
+ + + + +
+
+
+
+
+
+
11:25
+
+ +
+ +
+ which he volunteered to do as someone who lived through the Great Javafication + +
+ + + + +
+
+
+
+
+
+
11:31
+
+ +
+ +
+ To give some context for that, though, my understanding is that Java really took over the software industry in the mid-90s for a variety of reasons I'm not entirely familiar with + +
+ + + + +
+
+
+
+
+
+
11:31
+
+ +
+ +
+ He talked about it some on our podcast episode about programming education, as I recall (https://handmade.network/podcast/ep/eeac46c9-5e90-4b1c-9104-cff49734764d) + +
+ + + + +
+
+
+
+
+
+
11:32
+
+ +
+ +
+ And much of what he laid out in his "folk understanding of OO" above is, as far as I know, a direct line from Java + +
+ + + + +
+
+
+
+
+
+
11:32
+
+ +
+ +
+ for example, one class per file + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:34 AM +
+ +
+ Java uses classes for everything. Namespacing, modeling the solution, modeling the world, file system organization... + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 11:34 AM +
+ +
+ Yes I believe other languages aren't as restrictive, but the pattern is visible in a lot of C# codebases for example + + (edited) +
+ + + + +
+
+
+
+
+
+
11:34
+
+ +
+ +
+ one file per class + +
+ + + + +
+
+
+
+
+
+
11:34
+
+ +
+ +
+ because they sort of act like modules as well, specially when it's a "static" class with "static" methods + +
+ + + + +
+
+
+
+
+
+
11:35
+
+ +
+ +
+ (read: a bog standard procedural thing with extra keywords) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 11:36 AM +
+ +
+ Java was the first "real" programming language I learned, and it took me a long time to broaden my understanding enough to unlearn a lot of the decisions it made. static is certainly an example of that; a great way to obscure a very obvious concept. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 11:37 AM +
+ +
+ It was the first question I asked my teacher: "What does static mean?" + +
+ + + + +
+
+
+
+
+
+
11:37
+
+ +
+ +
+ I had been exposed to Pascal before, but not in an educational setting + +
+ + + + +
+
+
+
+
+
+
11:37
+
+ +
+ +
+ So public static void main() inside a class was very confusing + +
+ + + + +
+
+
+
+
+
+
11:38
+
+ +
+ +
+ Btw his answer was "I'll explain that by the end" + +
+ + + + +
+
+
+
+
+
+
11:38
+
+ +
+ +
+ "Ignore it for now, just know it needs to be there" + +
+ + + + +
+
+
+
+
+
+
11:38
+
+ +
+ +
+ never a good start + +
+ + + + +
+
+
+
+
+
+
11:40
+
+ +
+ +
+ it was much worse for my partner, her teacher decided explaining the difference between static and non-static was a great discussion topic for class 2 of newbie bioinformatics learning to program + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 11:40 AM +
+ +
+ static is a great scapegoat example for the problems with Java's design decisions, but I suspect there is a lot more to it than that + +
+ + + + +
+
+
+
+
+
+
11:41
+
+ +
+ +
+ For example, I'm curious if from @demetrispanos's perspective, the design of Java's standard library had an impact here (or if that was just an outflow of the language design) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:42 AM +
+ +
+ the standard library specifically, I'm not sure ... though Java definitely pioneered the idea that the standard library would have a canned solution for almost everything + +
+ + + + +
+
+
+
+
+
+
11:42
+
+ +
+ +
+ I remember buying "Java in a Nutshell" in the late 90s and being genuinely shocked at its size + +
+ + + + +
+
+
+
+
+
+
11:42
+
+ +
+ +
+ I think the large standard library overlapped with the idea of programs as "connecting objects to each other" + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 11:43 AM +
+ +
+ Well perhaps it would be best to just step back then and talk about the shift you saw in the industry when Java hit the scene + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:44 AM +
+ +
+ Java was the front runner but C++ in the 90s was also a major participant (indeed Design Patterns came from the C++ community) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:45 AM +
+ +
+ Also Smalltalk! + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:45 AM +
+ +
+ I think the biggest change was just how much marketing effort was behind "90s OOP", led primarily by Java (in terms of marketing) + +
+ + + + +
+
+
+
+
+
+
11:46
+
+ +
+ +
+ Java promised everybody a pony + +
+ + + + +
+
+
+
+
+
+
11:46
+
+ +
+ +
+ universities got to teach a thing that looked like a theory of programming + +
+ + + + +
+
+
+
+
+
+
11:46
+
+ +
+ +
+ businesses got programmers that could program in "intuitive real world concepts" + +
+ + + + +
+
+
+
+
+
+
11:46
+
+ +
+ +
+ new programmers were told they didn't have to worry about details their predecessors used to sweat over, and could just draw object/class hierarchy diagrams + +
+ + + + +
+
+
+
+
+
+
11:47
+
+ +
+ +
+ (there were also other Java promises re: security and portability that aren't relevant here) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:48 AM +
+ +
+ I wonder how much of Java being OO was because of the marketing efforts predating it.. ๐Ÿค” + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 11:48 AM +
+ +
+ well, to ask a question I think I know the answer to...how did Java live up to the hype :) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:48 AM +
+ +
+ I think Gosling definitely saw himself as successor to Bjarne who was successor to Ritchie etc. + +
+ + + + +
+
+
+
+
+
+
11:49
+
+ +
+ +
+ and indeed Java was conceptualized as a kind of "C++, the good parts" + +
+ + + + +
+
+
+
+
+
+
11:49
+
+ +
+ +
+ and it's telling what they thought were "the good parts" + +
+ + + + +
+
+
+
+
+
+
11:49
+
+ +
+ +
+ class hierarchies + +
+ + + + +
+
+
+
+
+
+
11:49
+
+ +
+ +
+ you don't just have the option of classes, everything is a class (even your program itself) + +
+ + + + +
+
+
+
+
+
+
11:50
+
+ +
+ +
+ I would say that by the end of the 90s the thing we now know as "Java/C++ OOP" was cemented as the responsible way to write software + +
+ + + + +
+
+
+
+
+
+
11:51
+
+ +
+ +
+ or rather, cemented the reputation as such + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:51 AM +
+ +
+ One reason it took so long to notice that OO didn't always work well, was that it worked best in the lower levels where people designed and implemented languages like Java. After they put in all the effort to build the language over a decade, it took a decade of using OO methodologies in anger to crystallize its limitations. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:51 AM +
+ +
+ well also it genuinely did work reasonably well with widget hierarchies in GUIs + +
+ + + + + +
+
+
+
+
+
+
11:52
+
+ +
+ +
+ but that was IMO an accident of overlap between problem and solution domain + +
+ + + + +
+
+
+
+
+
+
11:52
+
+ +
+ +
+ the widgets are code objects, and having hierarchies of code objects is something that OOP delivers as it says on the tin + +
+ + + + +
+
+
+
+
+
+
11:52
+
+ +
+ +
+ and indeed "textbox with a slider" is a reasonable conceptual descendant of "plain textbox" + +
+ + + + +
+
+
+
+
+
+
11:53
+
+ +
+ +
+ so I think many people saw that there was a good solution for an ascendant problem (the 90s saw the rise of GUIs to dominance) + +
+ + + + +
+
+
+
+
+
+
11:53
+
+ +
+ +
+ and they figured this would just be the first major success of many + +
+ + + + +
+
+
+
+
+
+
11:54
+
+ +
+ +
+ but widget hierarchies are much more usefully modeled by OOP than, say, customer/person hierarchies + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 11:55 AM +
+ +
+ That might be an interesting example to break down further + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:55 AM +
+ +
+ (Except when widgets used inner classes. That was a whole other can of worms..) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
demetrispanos
+
+ +but widget hierarchies are much more usefully modeled by OOP than, say, customer/person hierarchies + +
+
+
+ SirWhinesalot + + + May 28, 2022 11:56 AM +
+ +
+ Important to note here that UI frameworks moved away from "Split button inherits from Button" to "Split button is a button with a nested dropdown and a vertical line", you see that shift with the introduction of WPF at least + +
+ + + + +
+
+
+
+
+
+
11:57
+
+ +
+ +
+ so the move away from inheritance to composition was definitely ongoing in the 2000s + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 11:57 AM +
+ +
+ yeah this is what I meant by "reasonably well", i.e. it was better than no organization at all but didn't end up being the one abstraction to rule all of GUI + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 11:58 AM +
+ +
+ I do think it's interesting though that it was still a more effective model than what you tend to see elsewhere. @Kartik Agaram and @SirWhinesalot talked in the planning doc about objects needing to belong to the "solution domain", not the "problem domain", and this feels like a similar situation to me + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 11:59 AM +
+ +
+ One thing I still grapple with is that it's easier to use computers to talk about computers than it is to do something useful. That leads to all our yak shaving and abstraction-tower-building tendencies. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:01 PM +
+ +
+ Yeah, OO is a rather natural way to model GUIs (not necessarily the only way, nor the best), but it works. A button has some internal state, it responds to some events, those events are shared between all kinds of GUI entities. A "Widget" interface that gets implemented by many different Widget classes is a rather obvious way to model this + +
+ + + + +
+
+
+
+
+
+
12:02
+
+ +
+ +
+ even in languages without native OO support + +
+ + + + +
+
+
+
+
+
+
12:02
+
+ +
+ +
+ See COM or GTK in C for examples + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +I do think it's interesting though that it was still a more effective model than what you tend to see elsewhere. @Kartik Agaram and @SirWhinesalot talked in the planning doc about objects needing to belong to the "solution domain", not the "problem domain", and this feels like a similar situation to me + +
+
+
+ Kartik Agaram + + + May 28, 2022 12:02 PM +
+ +
+ That HN comment (https://news.ycombinator.com/item?id=785601#785833) actually hit me like a pile of bricks. Until then I'd only heard that you used inheritance to model is-a relationships, then wandered off because that seemed to suck. + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:02 PM +
+ +
+ yes how many times has a junior programmer agonized over "is-a" vs "has-a" + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
demetrispanos
+
+ +yes how many times has a junior programmer agonized over "is-a" vs "has-a" + +
+
+
+ bvisness + + + May 28, 2022 12:03 PM +
+ +
+ I did this for years + +
+ + + + +
+
+
+
+
+
+
12:03
+
+ +
+ +
+ and it was a meaningless question + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:03 PM +
+ +
+ yeah and the memeplex around 90s OOP invites that activity + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:03 PM +
+ +
+ it very strongly implies that this is what you should do + +
+ + + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:03 PM +
+ +
+ interface vs implementation inheritance. And then I find that in practice, all inheritance is good for is sharing code. + + (edited) +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +and it was a meaningless question + +
+
+
+ SirWhinesalot + + + May 28, 2022 12:04 PM +
+ +
+ meaningless but unfortunately very critical if you're in an OO language + +
+ + + + +
+
+
+
+
+
+
12:04
+
+ +
+ +
+ because the decision is one you're mostly stuck with + +
+ + + + +
+
+
+
+
+
+
12:04
+
+ +
+ +
+ without a major rewrite + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
SirWhinesalot
+
+ +meaningless but unfortunately very critical if you're in an OO language + +
+
+
+ bvisness + + + May 28, 2022 12:04 PM +
+ +
+ this I would say is a strong Java-ism + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:05 PM +
+ +
+ In practice, why is a relationship between two concepts being model as a language feature? + +
+ + + + +
+
+
+
+
+
+
12:05
+
+ +
+ +
+ There's absolutely no reason for this + + (edited) +
+ + + + +
+
+
+
+
+
+
12:05
+
+ +
+ +
+ I can model that A is a B in 1000 ways + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:05 PM +
+ +
+ well, the dirty secret is that it's not + +
+ + + + +
+
+
+
+
+
+
12:05
+
+ +
+ +
+ there is not even an attempt at it + +
+ + + + +
+
+
+
+
+
+
12:05
+
+ +
+ +
+ all that is attempted is sharing implementation details with ancestors + +
+ + + + +
+
+
+
+
+
+
12:06
+
+ +
+ +
+ the language never engages with whether the alleged is-a relationship is valid + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:06 PM +
+ +
+ true, you actually have to be careful to ensure an A is actually a B + +
+ + + + +
+
+
+
+
+
+
12:06
+
+ +
+ +
+ in fact traps like that are typical exam questions + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:06 PM +
+ +
+ the is-a aspect is entirely in people's minds + +
+ + + + +
+
+ โ˜๏ธ + 2 +
+
+
+
+
+
+
+
+
12:06
+
+ +
+ +
+ the thing that exists in the material world is sharing code + +
+ + + + +
+
+ ๐Ÿ’ฏ + 2 +
+
+
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:06 PM +
+ +
+ which is much better done with before/after advice or hooks that receive anonymous functions + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:08 PM +
+ +
+ When teaching my FIRST robotics students, I've struggled in the past with better examples to illustrate how inheritance works in Java than the classic "Cat is-a Animal" thing, and I suppose that's largely because inheritance isn't actually very good at modeling anything practical + +
+ + + + +
+
+
+
+
+
+
12:08
+
+ +
+ +
+ but the concept must be taught if we are to use the language + +
+ + + + +
+
+
+
+
+
+
12:08
+
+ +
+ +
+ (we no longer use the language) + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
demetrispanos
+
+ +yes how many times has a junior programmer agonized over "is-a" vs "has-a" + +
+
+
+ bvisness + + + May 28, 2022 12:09 PM +
+ +
+ One other aspect of OOP I think might be worth exploring is the idea of "agency" of objects, which "has-a" gets into + +
+ + + + +
+
+
+
+
+
+
12:09
+
+ +
+ +
+ I'm not sure if we've really touched on that yet + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:09 PM +
+ +
+ perhaps in passing but we haven't deep dived on it + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:10 PM +
+ +
+ This also relates in my mind to the actor model and perhaps the talk @Kartik Agaram mentioned by Richard Feldman about how OOP design makes each object a "small computer" on its own + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:11 PM +
+ +
+ I might say "small machine" but yes, and indeed this is the origin in Simula + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:11 PM +
+ +
+ This is to me different from the taxonomy issue + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:11 PM +
+ +
+ indeed, separate concern + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:11 PM +
+ +
+ the execution of the program is a simulation of many independent machines doing things to each other + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:12 PM +
+ +
+ this is "OOP as a model of computation" + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:13 PM +
+ +
+ With hindsight, the question I'm left with is, why did anyone ever consider this a good thing. Alan Kay made the analogy with biological cells in http://gagne.homedns.org/~tgagne/contrib/EarlyHistoryST.html#4, but back then (i.e. until the 90s when I started programming) we all assumed that was a good thing. + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:14 PM +
+ +
+ I think it became popular because of the idea that you'd use "code objects" the same way you use, say, screws from Home Depot + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:14 PM +
+ +
+ ah yes, software components. The ubiquitous siren of lego blocks. + +
+ + + + +
+
+ legobrick + 1 +
+
+
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:14 PM +
+ +
+ starting a new blog engine? go get some XYZ database screws and some PQR rendering bolts and you're 90% done + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:14 PM +
+ +
+ one important distinction between the smalltalk view (that affects how "good" it is) is the fact that objects are "live". You're not describing a simulation in terms of a software description of communicating objects (as in Java or C++), but actually witnessing the objects interact and changing their behavior as appropriate + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:15 PM +
+ +
+ this always felt like Alan Kay marketing speak to me + +
+ + + + +
+
+
+
+
+
+
12:15
+
+ +
+ +
+ databases are similarly "alive" in that the tables change with each insert + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:16 PM +
+ +
+ live editing is also not dependent on any sort of "object" ๐Ÿ™‚ + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:16 PM +
+ +
+ Kay is a very creative guy, but he is also easily tempted by marketing language + +
+ + + + +
+
+
+
+
+
+
12:16
+
+ +
+ +
+ (this is fine, good ideas need marketing) + +
+ + + + +
+
+
+
+
+
+
12:16
+
+ +
+ +
+ anyway, it is indeed important to address OOP and the subject of software components/reuse + +
+ + + + +
+
+
+
+
+
+
12:17
+
+ +
+ +
+ because it definitely was perceived as the way to achieve the latter + +
+ + + + +
+
+
+
+
+
+
12:17
+
+ +
+ +
+ you no longer would do the "unimportant" "tedious" work of writing a string formatting function, you'd just use a java.util.StringFormatter + +
+ + + + +
+
+
+
+
+
+
12:17
+
+ +
+ +
+ (I don't know if that exists, it probably doesn't) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:18 PM +
+ + + + + + +
+
+
+
+
+
+
12:18
+
+ +
+ +
+ so close ๐Ÿ™‚ + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:18 PM +
+ +
+ and this overlaps with Java's enormous standard library, because it was meant to be analogous to walking into Home Depot and getting the screws you need + +
+ + + + +
+
+
+
+
+
+
12:18
+
+ +
+ +
+ haha closer than I thought + +
+ + + + +
+
+
+
+
+
+
12:18
+
+ +
+ +
+ importantly, I never saw any kind of argument for why an "object" would be more reusable than a function + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:18 PM +
+ +
+ but it was widely believed to be the case + +
+ + + + +
+
+
+
+
+
+
12:19
+
+ +
+ +
+ and that was a big part of the Java marketing agenda + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:18 PM +
+ +
+ but again, this has nothing to do with objects, a module will do just fine for this purpose + +
+ + + + +
+
+
+
+
+
+
12:18
+
+ +
+ +
+ yup + +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:19 PM +
+ +
+ the only case I can see for it is when the object is "live", meaning you acquire the object already in the state you want, but that's a big stretch + +
+ + + + +
+
+
+
+
+
+
12:19
+
+ +
+ +
+ why not just... configure the thing? + +
+ + + + +
+
+
+
+
+
+
12:19
+
+ +
+ +
+ was never clear either + +
+ + + + +
+
+
+
+
+
+
12:20
+
+ +
+ +
+ specially not in a Java like language where Classes may as well be modules with extra steps + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:20 PM +
+ +
+ yes and actually you can see some of this in how Python played out, because it was very oriented toward modules + +
+ + + + +
+
+
+
+
+
+
12:20
+
+ +
+ +
+ but then got a large influx of what I'll uncharitably call "java refugees" in the mid 00s + +
+ + + + +
+
+
+
+
+
+
12:21
+
+ +
+ +
+ and suddenly you started seeing a lot of python that looked like java + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:21 PM +
+ +
+ Reuse does feel like an idea important enough to be worth trying for a couple of decades. I'm glad we're past it now. At least for some people today, a library you can reuse registers as more liability than asset. Now you gotta wire it into your supply chain and watch out for vulnerabilities. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
Kartik Agaram
+
+ +Reuse does feel like an idea important enough to be worth trying for a couple of decades. I'm glad we're past it now. At least for some people today, a library you can reuse registers as more liability than asset. Now you gotta wire it into your supply chain and watch out for vulnerabilities. + +
+
+
+ bvisness + + + May 28, 2022 12:22 PM +
+ +
+ It does feel like that's the trend, thankfully, but I suspect the dream of perfect reuse will never die out + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:22 PM +
+ +
+ I think the reuse concern is largely mercenary + +
+ + + + +
+
+
+
+
+
+
12:22
+
+ +
+ +
+ I mean it's mainly something businesses care about to reduce costs + +
+ + + + +
+
+
+
+
+
+
12:22
+
+ +
+ +
+ this is fine, keeping costs low is a reasonable concern + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:23 PM +
+ +
+ The key for me is to minimize zones of ownership. Reuse makes most sense when a vocabulary of components was coherently designed to compose well. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:23 PM +
+ +
+ but I don't think it's ultimately a deep concern about quality of code (even if it overlaps with quality concerns like single-point-of-truth) + +
+ + + + +
+
+
+
+
+
+
12:24
+
+ +
+ +
+ I want to distinguish between "reuse" and just "use by someone else" + +
+ + + + +
+
+
+
+
+
+
12:24
+
+ +
+ +
+ because I think they're conflated, but really only the second thing matters in most cases + +
+ + + + +
+
+
+
+
+
+
12:24
+
+ +
+ +
+ if I write the postgres database engine, what's important is that many people can use it (and not write their own) + +
+ + + + +
+
+
+
+
+
+
12:24
+
+ +
+ +
+ what's not important is that it can be used to make a substantially different database engine + +
+ + + + +
+
+
+
+
+
+
12:24
+
+ +
+ +
+ but that's the "just like screws" idea + +
+ + + + +
+
+
+
+
+
+
12:25
+
+ +
+ +
+ the same screws can make a table or a bookshelf etc. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:26 PM +
+ +
+ Do you think object-oriented design is worse at providing reuse than other approaches, or just completely unrelated? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:26 PM +
+ +
+ one are where OOP matters for reuse is the idea of an interface that can be implemented in many different ways + +
+ + + + +
+
+
+
+
+
+
12:26
+
+ +
+ +
+ it sets a boundary between parts of the code + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:26 PM +
+ +
+ I think OOP tilted harder at that particular problem. Making it easier to build things that you can reuse with anything else. It failed, but that's ok. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:26 PM +
+ +
+ I would hesitate to attribute interfaces to any particular discipline + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +Do you think object-oriented design is worse at providing reuse than other approaches, or just completely unrelated? + +
+
+
+ demetrispanos + + + May 28, 2022 12:27 PM +
+ +
+ I think it is in practice worse because it forces you to buy into the author's specific set of branded lego pieces that don't quite fit anyone else's + +
+ + + + +
+
+
+
+
+
+
12:27
+
+ +
+ +
+ in my experience the things that are easiest to glue together have extremely simple and unopinionated representations + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:28 PM +
+ +
+ but if you have to instantiate an object from some complex hierarchy merely to get started, you have a lot of friction + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:28 PM +
+ +
+ It seems to me that easy reuse is in direct conflict with ideas of taxonomy and ownership and agency + + (edited) +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:28 PM +
+ +
+ the unix way is "almost everything is lines of text, and you have to parse them" + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:28 PM +
+ +
+ it's annoying, but easy to glue together + + (edited) +
+ + + + +
+
+
+
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +Do you think object-oriented design is worse at providing reuse than other approaches, or just completely unrelated? + +
+
+
+ gingerBill + + + May 28, 2022 12:28 PM +
+ +
+ So this depends. Most traditonal inheritance based OOP are worse than plain procedural, but something like Go's implicit interfaces (which some don't even call OOP) is a lot more reusable. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
gingerBill
+
+ +So this depends. Most traditonal inheritance based OOP are worse than plain procedural, but something like Go's implicit interfaces (which some don't even call OOP) is a lot more reusable. + +
+
+
+ gingerBill + + + May 28, 2022 12:28 PM +
+ +
+ The big issue is that Go's interfaces require GC and have many performance issues. + +
+ + + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:29 PM +
+ +
+ as @skejeton was getting at in #fishbowl-audience, a table doesn't own a screw, a table leg doesn't own a screw, they're just all there + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:29 PM +
+ +
+ the C way is "almost everything is arrays of a few machine-type primitives" + +
+ + + + +
+
+
+
+
+
+
12:29
+
+ +
+ +
+ and that too has proven to be a very productive way to glue things together, as it is the basis of almost every practical FFI design + +
+ + + + +
+
+
+
+
+
+
12:29
+
+ +
+ +
+ the web way is "almost everything is JSON" + +
+ + + + +
+
+
+
+
+
+
12:29
+
+ +
+ +
+ and again, that is easy to glue together + +
+ + + + +
+
+
+
+
+
+
12:30
+
+ +
+ +
+ Java attempted "amost everything is XML" but it rightfully went up in flames + +
+ + + + +
+
+
+
+
+
+
12:30
+
+ +
+ +
+ because XML has many of the same problems vs JSON as Java OOP vs procedural + +
+ + + + +
+
+
+
+
+
+
12:31
+
+ +
+ +
+ JSON makes no pretense of modeling the real world, it's just a record + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:32 PM +
+ +
+ rich hickey goes into this on why systems level concerns are different from application level concerns, and the data exchange between "processes" or "entities" in a system should be very "loose" + +
+ + + + +
+
+
+
+
+
+
12:32
+
+ +
+ +
+ it's why unix has just strings, or the web has json everywhere + +
+ + + + +
+
+
+
+
+
+
12:33
+
+ +
+ +
+ this is also why stuff like dependency injection frameworks exist, their job is to set up the "wiring" between various components, which gets more and more complicated the more detailed the interface specification they have to communicate is + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:35 PM +
+ +
+ Complexity feels like something worth talking about head on. A lot of our discussion has had it implicitly in the background. The promise of many languages/tools/paradigms is "treat complexity as an externality. Infinite scale!" This never bears out, and lately I consider it a bad direction. Why is it so important to be able to scale up in complexity? + +Oh wait, where am I, this is Handmade Network. I'm preaching to the choir ๐Ÿ˜… + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
Kartik Agaram
+
+ +Complexity feels like something worth talking about head on. A lot of our discussion has had it implicitly in the background. The promise of many languages/tools/paradigms is "treat complexity as an externality. Infinite scale!" This never bears out, and lately I consider it a bad direction. Why is it so important to be able to scale up in complexity? + +Oh wait, where am I, this is Handmade Network. I'm preaching to the choir ๐Ÿ˜… + +
+
+
+ bvisness + + + May 28, 2022 12:37 PM +
+ +
+ Well on that note, another thing that I had on my list was the idea that OOP allows you to scale up development and solve more complex problems. One of the links you posted during planning directly stated this exact idea. But...is there any merit to that idea at all? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:38 PM +
+ +
+ Was that perhaps just an accident of all the other things Java provided out of the box? + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:38 PM +
+ +
+ Namespacing does help. + +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:39 PM +
+ +
+ I think a lot of these ideas do help. Perhaps it's a matter of setting expectations. "This is awesome, rock out with it!" vs "You're trying to do something really hard, this thing will help mitigate the pain." + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:40 PM +
+ +
+ I now see that my prep notes actually say "OOP allows us to write larger programs" and that is definitely true troll + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:41 PM +
+ +
+ breaking down systems into components definitely helps with scaling things up, this is done all the time in hardware land, but components are not objects + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:41 PM +
+ +
+ I think the steelman version of this argument goes like this +1. OOP encourages you to assemble your program from many small objects, one per file +2. since each object has a single responsibility, individual changes that happen in the future usually belong in only one file +3. so even if you have 10k class files, only one matters at any given time +4. so you can scale your classes across your people + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:42 PM +
+ +
+ that's among the weaker steelmans I've seen + +
+ + + + +
+
+ ๐Ÿ˜‚ + 1 +
+
+
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:42 PM +
+ +
+ and this is mostly true for changes like "instead of saying Hello Newcomer, it should say Howdy Stranger when the player logs in" + +
+ + + + +
+
+ ๐Ÿ’ฏ + 1 +
+
+
+
+
+
+ + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:42 PM +
+ +
+ you look up the PlayerGreeter.java + +
+ + + + +
+
+
+
+
+
+
12:42
+
+ +
+ +
+ you change the greeting + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:42 PM +
+ +
+ I do often find myself needing to modify multiple classes/files in a single tiny commit. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:43 PM +
+ +
+ For a while I used to have my build script show me the average number of files modified in the last 10 commits. That did give an interesting sort of peripheral awareness. + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:44 PM +
+ +
+ one thing that's important to note is that OOP makes changing the architecture rather hard, i.e. since objects store their references to other objects, you have to jump around everywhere to change things + +
+ + + + +
+
+
+
+
+
+
12:44
+
+ +
+ +
+ if you try to avoid this by using some pattern where an "upper level" object sets everything up + +
+ + + + +
+
+
+
+
+
+
12:44
+
+ +
+ +
+ you end up with way too much argument passing to constructors + +
+ + + + +
+
+
+
+
+
+
12:44
+
+ +
+ +
+ which, in turn, leads to awful dependency injection frameworks + +
+ + + + +
+
+
+
+
+
+
12:45
+
+ +
+ +
+ in most component-based design systems for hardware, the connections between the components are a directly editable thing + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:45 PM +
+ +
+ ๐Ÿ’ฏ But then doesn't everything? I define architecture as "that which is hard to change." + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:45 PM +
+ +
+ That feels like it's mostly caused by the inheritance / taxonomy / hierarchy kinds of design problems we were talking about before + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 12:46 PM +
+ +
+ even with composition it's an issue, because of how communication between objects occurs + +
+ + + + +
+
+
+
+
+
+
12:46
+
+ +
+ +
+ i.e. For A to send messages to B, it needs to remember B + + (edited) +
+ + + + +
+
+
+
+
+
+
12:46
+
+ +
+ +
+ somehow, one way or another + +
+ + + + +
+
+
+
+
+
+
12:46
+
+ +
+ +
+ whereas in actual component-based systems, that "memory" is stored externally + +
+ + + + +
+
+
+
+
+
+
12:46
+
+ +
+ +
+ importantly, A does not own B here + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:46 PM +
+ +
+ sure, I guess I could see how it's a problem with "agency" ideas too + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:47 PM +
+ +
+ perhaps another thing worth noting here is that OOP overlapped with many general-good-practice "discoveries" and I think inherited some of their reputation, e.g. avoiding unnecessary globals + +
+ + + + +
+
+
+
+
+
+
12:47
+
+ +
+ +
+ (which OOP then undoes by inventing singletons :P) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:48 PM +
+ +
+ I suppose so, yeah + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
SirWhinesalot
+
+ +breaking down systems into components definitely helps with scaling things up, this is done all the time in hardware land, but components are not objects + +
+
+
+ bvisness + + + May 28, 2022 12:49 PM +
+ +
+ Going back to this, I would agree that breaking down systems into more-independent modules is certainly very important to solving larger problems; avoiding unnecessary globals is another example of a useful design tactic for tackling complexity + + (edited) +
+ + + + +
+
+
+
+
+
+
12:49
+
+ +
+ +
+ Was it really all that bad before OOP languages became popular though? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:49 PM +
+ +
+ All the fun there is in that word "unnecessary" ๐Ÿ™‚ + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:49 PM +
+ +
+ That might be too big a question ๐Ÿ˜› + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:50 PM +
+ +
+ well, OOP also largely coincided with the establishment of "programmer" as a known profession + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:50 PM +
+ +
+ Our programs did grow by several orders of magnitude in the period of the OO paradigm. I feel like it should take some of the credit/blame for that. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:50 PM +
+ +
+ indeed in the 80s it was common for people to conflate the "IT guy" with a programmer, and it was even riffed a bit in movies + +
+ + + + +
+
+
+
+
+
+
12:51
+
+ +
+ +
+ so I think it's hard to separate the professionalization of the field from the techniques that were popular at the time + +
+ + + + +
+
+
+
+
+
+
12:51
+
+ +
+ +
+ far fewer people were programming in the 80s + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:52 PM +
+ +
+ I suppose then that programming was just running into the very real problems of working with larger teams + + (edited) +
+ + + + +
+
+
+
+
+
+
12:52
+
+ +
+ +
+ "software engineering", to use Russ Cox's definition + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:52 PM +
+ +
+ yeah + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +I suppose then that programming was just running into the very real problems of working with larger teams + + (edited) +
+
+
+ Kartik Agaram + + + May 28, 2022 12:53 PM +
+ +
+ Oh very interesting, hadn't seen this before: https://research.swtch.com/vgo-eng + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:53 PM +
+ +
+ yep I was just gonna share the full quote: +
Software engineering is what happens to programming +when you add time and other programmers.
+ +
+ + + + +
+
+
+
+
+
+
12:54
+
+ +
+ +
+ Is it fair to say that OOP languages offered some useful tools for "software engineering", but that those tools were misused? + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:55 PM +
+ +
+ I'd say Java/C++ offered the versions of various things that became popular (e.g. modularity was a general useful idea, and the way it came to the market was classes) + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +Is it fair to say that OOP languages offered some useful tools for "software engineering", but that those tools were misused? + + (edited) +
+
+
+ Kartik Agaram + + + May 28, 2022 12:56 PM +
+ +
+ Yeah it feels like the nature of the world. You get some promises, you build something. You get some benefits, you get some problems you now have to live with. There's no going back. You can't enter a river twice. + +
+ + + + +
+
+
+
+
+
+
12:56
+
+ +
+ +
+ Even the bad parts, we had to explore them to understand why they're bad. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:56 PM +
+ +
+ it's worth trying to eliminate the "sturgeon contribution" (sturgeons law: 90% of everything is bad) + +
+ + + + +
+
+
+
+
+
+
12:57
+
+ +
+ +
+ a lot of bad stuff was done with OOP, but a lot of bad stuff would be done regardless + +
+ + + + +
+
+
+
+
+
+
12:57
+
+ +
+ +
+ so it's useful to think about what badness was imposed on top of the sturgeon fraction + +
+ + + + +
+
+
+
+
+
+
12:57
+
+ +
+ +
+ personally I think the "model the real world" thing is above-sturgeon badness + +
+ + + + +
+
+
+
+
+
+
12:58
+
+ +
+ +
+ it infected everything and everyone, it wasn't just the usual "most people do bad work" + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:58 PM +
+ +
+ you could argue that it's a sturgeon-multiplier + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:58 PM +
+ +
+ yes quite plausible + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 12:58 PM +
+ +
+ it makes the 90% even worse ๐Ÿ˜› + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 12:58 PM +
+ +
+ I tend to think all the above-sturgeon badness came from social context. Mostly incentives. Hard to blame a tech paradigm for it. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 12:59 PM +
+ +
+ but the paradigm clearly invites some forms of badness + +
+ + + + +
+
+
+
+
+
+
12:59
+
+ +
+ +
+ and deserves blame for something it invites + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:00 PM +
+ +
+ so for example, the problems with modeling + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:00 PM +
+ +
+ I can't blame OOP for people applying it lazily or in a way that it doesn't invite, but I can absolutely blame it for people using it the way it advertises itself + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:01 PM +
+ +
+ you yourself did talk though about the level of marketing behind Java - so both factors are certainly in play + +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:01 PM +
+ +
+ well ok but the thing that was marketed is not separable right? + +
+ + + + +
+
+
+
+
+
+
13:01
+
+ +
+ +
+ they didn't randomly choose something to promote, they chose that thing to promote + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:01 PM +
+ +
+ going from "I have this problem, how do I solve it with a combination of data structures and algorithms" to "how do I model these real-world concepts as agents with data + behavior" was one of the greatest mistakes we did as an industry + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 01:02 PM +
+ +
+ As an example, a nameless org I worked at was big on Design Patterns. But that was mostly caused by promotion incentives that reward complex-seeming work. I hate Design Patterns, but have a hard time blaming it for the ills created in its name. + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:02 PM +
+ +
+ ok but Design Patterns didn't say "you should base promotions on complex patterns" + +
+ + + + +
+
+
+
+
+
+
13:02
+
+ +
+ +
+ whereas OOP does say "you should have your program model concepts in the real world" + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:03 PM +
+ +
+ they (Design Patterns) were meant as a tool of communication, something to help explain what a certain structure in the code (that occurs often) is doing, but they turned into "best practices" somehow + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 01:03 PM +
+ +
+ True. I think I just give it some leeway as an honest mistake.. + +
+ + + + +
+
+
+
+
+
+
13:04
+
+ +
+ +
+ Design Patterns were also an honest mistake. They thought the problem they were solving was how to work in complex domains. The problem they turned out to solve was how to smuggle complexity and over-engineering into anything. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:05 PM +
+ +
+ I think they started from a very true and valuable observation, which is that code-as-characters-in-files reuse is [NOT] important compared to design reuse + + (edited) +
+ + + + +
+
+
+
+
+
+
13:05
+
+ +
+ +
+ that one insight was enough to persuade me to keep trying to find value in the book for years + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 01:05 PM +
+ +
+ this is Design Patterns, you mean? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:05 PM +
+ +
+ yeah + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 01:05 PM +
+ +
+ yeah that makes sense + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:06 PM +
+ +
+ if you already have a design of a solution you can reuse from the past, you're 80% done + +
+ + + + +
+
+
+
+
+
+
13:06
+
+ +
+ +
+ because most of programming is discovering a good-enough design + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:06 PM +
+ +
+ Design Patterns are certainly useful. I.e. "I need to model sum types in this language that doesn't have them, how do I do it?" -> "Visitor Pattern, here's how you set it up" + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:06 PM +
+ +
+ right well that's the Norvig argument, that design patterns are actually just papering over language deficiencies + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:07 PM +
+ +
+ they are ๐Ÿ™‚ + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:07 PM +
+ +
+ you don't need Command Pattern when you have first class functions + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:07 PM +
+ +
+ they're actually a great source of language design inspiration + +
+ + + + +
+
+
+
+
+
+
13:07
+
+ +
+ +
+ "how does your language avoid the need for this pattern" + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:08 PM +
+ +
+ yes and this would bring it back to the tried-and-true tradition of standardizing extant patterns of use + +
+ + + + +
+
+
+
+
+
+
13:08
+
+ +
+ +
+ just like the for-loop, or the mere method + +
+ + + + +
+
+
+
+
+
+
13:08
+
+ +
+ +
+ if you write an assembly program, you will at some point write what amounts to a for-loop + +
+ + + + +
+
+
+
+
+
+
13:08
+
+ +
+ +
+ so the language just makes that standard + +
+ + + + +
+
+
+
+
+
+
13:08
+
+ +
+ +
+ to the extent that can be done for design patterns I consider it useful + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:09 PM +
+ +
+ I think the problem was that "applying" design patterns somehow became a point of pride? which is silly? they're a shopping list of solutions to particular problems + +
+ + + + +
+
+
+
+
+
+
13:09
+
+ +
+ +
+ i.e. the more patterns in your code the better + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:09 PM +
+ +
+ yes, well ... this would be far afield but this is tied to bigtech interviewing/hiring practices in the late 90s + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:10 PM +
+ +
+ oh man + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:10 PM +
+ +
+ in the same way universities need a thing to teach as a theory of programming, tech companies needed a thing they could quiz + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:10 PM +
+ +
+ as much as I would love to crack the coding interview right now, we are past the three-hour mark and I think it would be a good idea to step back and summarize what we've discussed today + +
+ + + + +
+
+
+
+
+
+
13:11
+
+ +
+ +
+ although that would be a great subject for continued discussion afterward + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ demetrispanos + + + May 28, 2022 01:11 PM +
+ +
+ yes I agree it's too far a tangent + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:11 PM +
+ +
+ perhaps a future fishbowl, since it's not really OOP specific + +
+ + + + +
+
+
+
+
+
+
13:11
+
+ +
+ +
+ but also a problem + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:11 PM +
+ +
+ definitely + +
+ + + + +
+
+
+
+
+
+
13:12
+
+ +
+ +
+ So here's my summary of what we've covered: +- "OOP is when you associate behavior with data": This is present in OOP, but not really the heart of the issue. That is, just because you have methods doesn't necessarily mean you have anything more than simple procedural programming with some syntax sugar. +- "OOP models the real world": This is categorically not true or effective, no matter what language you use. The real world resists taxonomy, and doesn't have anything to do with the problems you are solving. +- "OOP is Java": Well, we didn't say it as such, but we did discuss many of the specific problems of Java, and the promises it failed to live up to, despite its takeover of industry. +- "OOP as a model of computation": This idea was appealing largely because of promises of independent components and easy reuse - but arguably OOP is worse at providing this than other programming paradigms (especially the Java flavor of OOP). +- "OOP tackles complexity": There are some good concepts, such as modularity and avoiding globals, that became popular along with OOP languages, but OOP itself makes things more complex. + + (edited) +
+ + + + +
+
+
+
+
+
+
13:13
+
+ +
+ +
+ Is this a fair representation or am I leaving things out? + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 01:13 PM +
+ +
+ I'd been writing a summary as well over the conversation, and it is much more instrumental, through the lens of "how to write better programs" + +- if you have lots of one kind of thing, give them a common template +- when building a program, take a moment to plan such schemas first +- as a schema proves valuable, rework it to be more timeless. This includes making it easy to change the memory layout, but much more. + +Some rules of thumb like these capture all that is valuable about OO, to my mind. And what programming languages can contribute here are late-binding capabilities that preserve optionality for the programmer. + +What they don't capture is the hardest problem of all: how you can preserve an executable, checkable model of the world that acts as a history of why your program is as it is. + +Tests are one way to do that. Formal models are another, though formal models can also be used for modeling solutions rather than contexts. Prose documents are a third. They have limitations, but they're better than nothing to a future code archeologist. + +A lot of the ills we see with OO dogma lie in the space between my rules of thumb. You have to wait until you understand a domain before you try to generalize. OO languages are particularly bad here, because you're forced to create classes literally on line 1. + +I think design as a general activity makes no sense. Good design comes from understanding a domain. It is by necessity domain-specific. + +And any design activity really has to have a certain level of humility. Pick a bounded problem. Interact with few peers (that themselves have humility in dependencies and goals). Keep things coherent rather than trying to optimize the whole ocean into paperclips. + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +Is this a fair representation or am I leaving things out? + +
+
+
+ SirWhinesalot + + + May 28, 2022 01:14 PM +
+ +
+ just that if we split interfaces/vtables from OO, and maybe the nice subject verb object syntax, there's nothing of use left + +
+ + + + +
+
+
+
+
+
+
13:16
+
+ +
+ +
+ I'm willing to leave interfaces/vtables as being "OO", as the one useful thing it has, because they are damn useful when you need them + +
+ + + + + +
+
+
+
+
+
+
13:17
+
+ +
+ +
+ but other people disagree that they're even "OO", since stuff like modules in SML have many similarities without the runtime dispatch for example, and there are many ways to do runtime dispatch that are not interface based + + (edited) +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:19 PM +
+ +
+ So in that case...I'd like to return to the original age-old question: "is OOP bad or what?" + +It sounds like the prevailing opinion here is that: +- Object-oriented programming is fundamentally an approach to modeling and design, not merely some nice syntax in your language +- Object-oriented design is fundamentally flawed, since the idea of solving problems by modeling the world is fundamentally flawed +- The flaws of object-oriented design also prevent OOP from being a useful model of computation, or from meaningfully tackling complexity + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:19 PM +
+ +
+ that's my view on the matter yes + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:19 PM +
+ +
+
A lot of the ills we see with OO dogma lie in the space between my rules of thumb. You have to wait until you understand a domain before you try to generalize. OO languages are particularly bad here, because you're forced to create classes literally on line 1. + +I think design as a general activity makes no sense. Good design comes from understanding a domain. It is by necessity domain-specific. +
And I appreciate these thoughts by @Kartik Agaram a lot.
+ +
+ + + + +
+
+
+
+
+
+
13:20
+
+ +
+ +
+ Not only does object-oriented design fail to model problems well, but the tools force you into bad designs immediately. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+
+ Avatar +
+ +
+
+ Avatar +
bvisness
+
+ +Not only does object-oriented design fail to model problems well, but the tools force you into bad designs immediately. + +
+
+
+ demetrispanos + + + May 28, 2022 01:21 PM +
+ +
+ yes in particular "in what class does this activity belong?" is a useless question that has wasted an enormous amount of time + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:20 PM +
+ +
+ btw, just to answer the question I posted when I did my design introduction + +
+ + + + +
+
+
+
+
+
+
13:21
+
+ +
+ +
+ What is the single responsibility of the Customer class? + + (edited) +
+ + + + +
+
+
+
+
+
+
13:21
+
+ +
+ +
+ it is to uniquely identify a customer, it's a primary key + +
+ + + + +
+
+
+
+
+
+
13:21
+
+ +
+ +
+ here's a Customer class in Odin + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:21 PM +
+ +
+
Customer :: distinct u64
+ +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:22 PM +
+ +
+ I think I can also reasonably conclude that, while OOP languages and practices may contain some good ideas, those are mostly unrelated to the core of object-oriented design. + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:24 PM +
+ +
+ I think "ownership" should maybe go in another fishbowl as well, since it has some similar issues with rigid tree-like structures and assigning "agency" to bits of data + +
+ + + + +
+
+
+
+
+
+
13:24
+
+ +
+ +
+ ownership is quite central to OOP + +
+ + + + +
+
+
+
+
+
+
13:24
+
+ +
+ +
+ even in GC languages + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:24 PM +
+ +
+ because there's a distinction between an object that "contains" another object within itself, and an object that "knows" about another object + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:25 PM +
+ +
+ in Rust there's a syntactical distinction, but in Java there isn't + +
+ + + + +
+
+
+
+
+
+
+ Avatar +
+ +
+
+ gingerBill + + + May 28, 2022 01:24 PM +
+ +
+ Ownership semantics is surprisingly related to OOP from an ontological perspective + +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:25 PM +
+ +
+ and there we have massive tangent #2 + +
+ + + + +
+
+
+
+ + + + + + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:25 PM +
+ +
+ But yeah I agree that it could be a valuable topic to fishbowl about someday. + +
+ + + + +
+
+
+
+
+
+
13:26
+
+ +
+ +
+ Thanks @Kartik Agaram for the summary thoughts - are there any other summary thoughts our other participants would like to provide before we close? + +
+ + + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:26 PM +
+ + + + + + +
+
+
+
+
+
+
13:26
+
+ +
+ +
+ so I'll shut up now ๐Ÿ˜› + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 01:27 PM +
+ +
+ Thanks everyone for this introduction to the fishbowl format. I'm a huge convert, to the extent that I think we should stop having in-person conferences. + +
+ + + + +
+
+ ๐Ÿ˜‚ + 3 +
+
+ AbnerHangry + 3 +
+
+
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:28 PM +
+ +
+ Thank you very much for participating! I am really glad we finally had the opportunity to discuss this topic thoroughly. + +
+ + + + +
+
+
+
+
+
+
13:29
+
+ +
+ +
+ Thank you all for helping me with my secret moderator agenda of being able to say "before you discuss OOP any further, read this conversation" ๐Ÿ˜ˆ + +
+ + + + +
+
+ brain + 6 +
+
+
+
+
+
+
+
+
13:30
+
+ +
+ +
+ I hope everyone found the conversation useful, that it helps you understand OOP better, and that it helps you understand how to write better programs. + +
+ + + + +
+
+
+
+
+
+
13:31
+
+ +
+ +
+ See you in a couple months for our next fishbowl! + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ Kartik Agaram + + + May 28, 2022 01:31 PM +
+ +
+ Thank you @bvisness for organizing! + +
+ + + + +
+
+ coolben + 2 +
+
+
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ SirWhinesalot + + + May 28, 2022 01:32 PM +
+ +
+ Indeed, thanks a lot @bvisness , and also thank you to all the participants + +
+ + + + +
+
+
+
+ + + +
+
+
+
+ Avatar +
+ +
+
+ bvisness + + + May 28, 2022 01:36 PM +
+ +
+ (For future readers, here is a link to the top! https://discord.com/channels/239737791225790464/980152876846428221/980153085320130630) + +
+ + + + +
+
+
+
+ + +
\ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1963eacbf364164efce1c597dc66aeab-E6901.png b/src/templates/src/fishbowls/oop/files/1963eacbf364164efce1c597dc66aeab-E6901.png new file mode 100644 index 0000000..ccf4824 Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/1963eacbf364164efce1c597dc66aeab-E6901.png differ diff --git a/src/templates/src/fishbowls/oop/files/1f3f4-200d-2620-6E400.svg b/src/templates/src/fishbowls/oop/files/1f3f4-200d-2620-6E400.svg new file mode 100644 index 0000000..ae0d531 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f3f4-200d-2620-6E400.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f44d-B3F5F.svg b/src/templates/src/fishbowls/oop/files/1f44d-B3F5F.svg new file mode 100644 index 0000000..595672d --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f44d-B3F5F.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f4a1-26401.svg b/src/templates/src/fishbowls/oop/files/1f4a1-26401.svg new file mode 100644 index 0000000..88b62e3 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f4a1-26401.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f4a5-61C11.svg b/src/templates/src/fishbowls/oop/files/1f4a5-61C11.svg new file mode 100644 index 0000000..36c50d6 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f4a5-61C11.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f4af-2188D.svg b/src/templates/src/fishbowls/oop/files/1f4af-2188D.svg new file mode 100644 index 0000000..3d565cc --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f4af-2188D.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f4f7-B9213.svg b/src/templates/src/fishbowls/oop/files/1f4f7-B9213.svg new file mode 100644 index 0000000..aa2d9c5 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f4f7-B9213.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f5e1-9D0D3.svg b/src/templates/src/fishbowls/oop/files/1f5e1-9D0D3.svg new file mode 100644 index 0000000..d1d7712 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f5e1-9D0D3.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f602-20224.svg b/src/templates/src/fishbowls/oop/files/1f602-20224.svg new file mode 100644 index 0000000..1ec7937 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f602-20224.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f604-6061B.svg b/src/templates/src/fishbowls/oop/files/1f604-6061B.svg new file mode 100644 index 0000000..99ac39c --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f604-6061B.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/1f914-54FF1.svg b/src/templates/src/fishbowls/oop/files/1f914-54FF1.svg new file mode 100644 index 0000000..4e8c4cc --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/1f914-54FF1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/261d-3A498.svg b/src/templates/src/fishbowls/oop/files/261d-3A498.svg new file mode 100644 index 0000000..95d8ddd --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/261d-3A498.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/26ab-FC554.svg b/src/templates/src/fishbowls/oop/files/26ab-FC554.svg new file mode 100644 index 0000000..169b72c --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/26ab-FC554.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/2757-5311E.svg b/src/templates/src/fishbowls/oop/files/2757-5311E.svg new file mode 100644 index 0000000..e730a08 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/2757-5311E.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/2764-02CD4.svg b/src/templates/src/fishbowls/oop/files/2764-02CD4.svg new file mode 100644 index 0000000..7eb5c59 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/2764-02CD4.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/3bf987dc7a33d0b2f989878615544d6a-D4B96.png b/src/templates/src/fishbowls/oop/files/3bf987dc7a33d0b2f989878615544d6a-D4B96.png new file mode 100644 index 0000000..833cb87 Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/3bf987dc7a33d0b2f989878615544d6a-D4B96.png differ diff --git a/src/templates/src/fishbowls/oop/files/418ec586b1074c5304d2bdfde2d725c9-F2143.png b/src/templates/src/fishbowls/oop/files/418ec586b1074c5304d2bdfde2d725c9-F2143.png new file mode 100644 index 0000000..fbb67b6 Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/418ec586b1074c5304d2bdfde2d725c9-F2143.png differ diff --git a/src/templates/src/fishbowls/oop/files/487994603568496650-3FA2C.png b/src/templates/src/fishbowls/oop/files/487994603568496650-3FA2C.png new file mode 100644 index 0000000..a57e0da Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/487994603568496650-3FA2C.png differ diff --git a/src/templates/src/fishbowls/oop/files/597863487032786944-538BB.png b/src/templates/src/fishbowls/oop/files/597863487032786944-538BB.png new file mode 100644 index 0000000..fc352f2 Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/597863487032786944-538BB.png differ diff --git a/src/templates/src/fishbowls/oop/files/62e486caf24d352ab938701a8d972730-5ADCF.png b/src/templates/src/fishbowls/oop/files/62e486caf24d352ab938701a8d972730-5ADCF.png new file mode 100644 index 0000000..8c3d6c9 Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/62e486caf24d352ab938701a8d972730-5ADCF.png differ diff --git a/src/templates/src/fishbowls/oop/files/777941313546092555-41FE8.png b/src/templates/src/fishbowls/oop/files/777941313546092555-41FE8.png new file mode 100644 index 0000000..8042e68 Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/777941313546092555-41FE8.png differ diff --git a/src/templates/src/fishbowls/oop/files/798990517714419714-A5156.png b/src/templates/src/fishbowls/oop/files/798990517714419714-A5156.png new file mode 100644 index 0000000..a14473a Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/798990517714419714-A5156.png differ diff --git a/src/templates/src/fishbowls/oop/files/851646609917476884-15D55.png b/src/templates/src/fishbowls/oop/files/851646609917476884-15D55.png new file mode 100644 index 0000000..f6d346b Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/851646609917476884-15D55.png differ diff --git a/src/templates/src/fishbowls/oop/files/89747c254631bcfd05c5c3e7141389aa-A1FB9.png b/src/templates/src/fishbowls/oop/files/89747c254631bcfd05c5c3e7141389aa-A1FB9.png new file mode 100644 index 0000000..6fe1dbd Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/89747c254631bcfd05c5c3e7141389aa-A1FB9.png differ diff --git a/src/templates/src/fishbowls/oop/files/db36a06d98bf0e98017ec3559150c05c-F4AEF.png b/src/templates/src/fishbowls/oop/files/db36a06d98bf0e98017ec3559150c05c-F4AEF.png new file mode 100644 index 0000000..fea5ea2 Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/db36a06d98bf0e98017ec3559150c05c-F4AEF.png differ diff --git a/src/templates/src/fishbowls/oop/files/twemoji_1f44d.svg b/src/templates/src/fishbowls/oop/files/twemoji_1f44d.svg new file mode 100644 index 0000000..595672d --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/twemoji_1f44d.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/twemoji_1f4af.svg b/src/templates/src/fishbowls/oop/files/twemoji_1f4af.svg new file mode 100644 index 0000000..3d565cc --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/twemoji_1f4af.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/twemoji_1f604.svg b/src/templates/src/fishbowls/oop/files/twemoji_1f604.svg new file mode 100644 index 0000000..99ac39c --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/twemoji_1f604.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/twemoji_1f605.svg b/src/templates/src/fishbowls/oop/files/twemoji_1f605.svg new file mode 100644 index 0000000..de6eb5d --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/twemoji_1f605.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/twemoji_1f608.svg b/src/templates/src/fishbowls/oop/files/twemoji_1f608.svg new file mode 100644 index 0000000..79c2480 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/twemoji_1f608.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/twemoji_1f61b.svg b/src/templates/src/fishbowls/oop/files/twemoji_1f61b.svg new file mode 100644 index 0000000..e249672 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/twemoji_1f61b.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/twemoji_1f642.svg b/src/templates/src/fishbowls/oop/files/twemoji_1f642.svg new file mode 100644 index 0000000..ff9f989 --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/twemoji_1f642.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/twemoji_1f914.svg b/src/templates/src/fishbowls/oop/files/twemoji_1f914.svg new file mode 100644 index 0000000..4e8c4cc --- /dev/null +++ b/src/templates/src/fishbowls/oop/files/twemoji_1f914.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/templates/src/fishbowls/oop/files/y18-27627.gif b/src/templates/src/fishbowls/oop/files/y18-27627.gif new file mode 100644 index 0000000..2f2daa8 Binary files /dev/null and b/src/templates/src/fishbowls/oop/files/y18-27627.gif differ diff --git a/src/templates/src/include/header.html b/src/templates/src/include/header.html index b124340..419bb36 100644 --- a/src/templates/src/include/header.html +++ b/src/templates/src/include/header.html @@ -73,6 +73,7 @@ Media
{{ svg "chevron-down-thick" }}
@@ -90,7 +91,7 @@ diff --git a/src/templates/src/landing.html b/src/templates/src/landing.html index 1d9b007..45c43a6 100644 --- a/src/templates/src/landing.html +++ b/src/templates/src/landing.html @@ -169,7 +169,7 @@ @@ -220,7 +220,7 @@

Community Showcase

- This is a selection of recent work done by community members. Want to participate? Join us on Discord. + This is a selection of recent work done by community members. Want to participate? Join us on Discord.
diff --git a/src/templates/src/wheeljam_index.html b/src/templates/src/wheeljam_index.html index 1ef17af..2ca44da 100644 --- a/src/templates/src/wheeljam_index.html +++ b/src/templates/src/wheeljam_index.html @@ -243,7 +243,7 @@
@@ -263,7 +263,7 @@

Showcase

- These screenshots and videos were shared in #jam-showcase on our Discord. Join us! + These screenshots and videos were shared in #jam-showcase on our Discord. Join us!

diff --git a/src/templates/templates.go b/src/templates/templates.go index ea07108..91a556f 100644 --- a/src/templates/templates.go +++ b/src/templates/templates.go @@ -10,6 +10,7 @@ import ( "git.handmade.network/hmn/hmn/src/auth" "git.handmade.network/hmn/hmn/src/hmnurl" "git.handmade.network/hmn/hmn/src/logging" + "git.handmade.network/hmn/hmn/src/utils" "github.com/Masterminds/sprig" "github.com/google/uuid" "github.com/teacat/noire" @@ -26,10 +27,13 @@ const ( var templateFs embed.FS var Templates map[string]*template.Template +//go:embed src/fishbowls +var FishbowlFS embed.FS + func Init() { Templates = make(map[string]*template.Template) - files, _ := templateFs.ReadDir("src") + files := utils.Must1(templateFs.ReadDir("src")) for _, f := range files { if hasSuffix(f.Name(), ".html") { t := template.New(f.Name()) diff --git a/src/templates/types.go b/src/templates/types.go index 5b766d2..33e9c6d 100644 --- a/src/templates/types.go +++ b/src/templates/types.go @@ -49,6 +49,7 @@ type Header struct { HMNHomepageUrl string ProjectIndexUrl string PodcastUrl string + FishbowlUrl string ForumsUrl string LibraryUrl string @@ -337,7 +338,6 @@ type ImageSelectorData struct { type Breadcrumb struct { Name, Url string - Current bool } type Pagination struct { diff --git a/src/website/base_data.go b/src/website/base_data.go index 377e877..eb41b11 100644 --- a/src/website/base_data.go +++ b/src/website/base_data.go @@ -72,6 +72,7 @@ func getBaseData(c *RequestContext, title string, breadcrumbs []templates.Breadc HMNHomepageUrl: hmnurl.BuildHomepage(), ProjectIndexUrl: hmnurl.BuildProjectIndex(1), PodcastUrl: hmnurl.BuildPodcast(), + FishbowlUrl: hmnurl.BuildFishbowlIndex(), ForumsUrl: hmnurl.HMNProjectContext.BuildForum(nil, 1), LibraryUrl: hmnurl.BuildLibrary(), }, diff --git a/src/website/fishbowl.go b/src/website/fishbowl.go new file mode 100644 index 0000000..03c605c --- /dev/null +++ b/src/website/fishbowl.go @@ -0,0 +1,247 @@ +package website + +import ( + "fmt" + "html/template" + "io" + "io/fs" + "net/http" + "regexp" + "sort" + "strings" + "time" + + "git.handmade.network/hmn/hmn/src/db" + "git.handmade.network/hmn/hmn/src/hmndata" + "git.handmade.network/hmn/hmn/src/hmnurl" + "git.handmade.network/hmn/hmn/src/models" + "git.handmade.network/hmn/hmn/src/oops" + "git.handmade.network/hmn/hmn/src/templates" + "git.handmade.network/hmn/hmn/src/utils" +) + +// This will skip the common path prefix for fishbowl files. +// We unfortunately need to do this because we want to use http.FileServer, +// but _that_ needs an http.FS, but _that_ needs an fs.FS... +var fishbowlFS = utils.Must1(fs.Sub(templates.FishbowlFS, "src/fishbowls")) +var fishbowlHTTPFS = http.StripPrefix("/fishbowl", http.FileServer(http.FS(fishbowlFS))) + +type fishbowlInfo struct { + Slug string + Title, Description string // The description is used for OpenGraph, so it must be plain text, no HTML. + Month time.Month + Year int + ContentsPath string +} + +var fishbowls = [...]fishbowlInfo{ + { + Slug: "internet-os", + Title: "The future of operating systems in an Internet world", + Description: `Despite the web's technical problems, it dominates software development today, largely due to its cross-platform support and ease of distribution. At the same time, our discussions about the future of programming tend to involve new "operating systems", but those discussions rarely take the Internet into account. What could future operating systems look like in a world defined by the Internet?`, + Month: time.May, Year: 2020, + }, + { + Slug: "metaprogramming", + Title: "Compile-time introspection and metaprogramming", + Description: `Thanks to new languages like Zig and Jai, compile-time execution and metaprogramming are a popular topic of discussion in the community. This fishbowl explores metaprogramming in more detail, and discusses to what extent it is actually necessary, or just a waste of time.`, + Month: time.June, Year: 2020, + }, + { + Slug: "lisp-jam", + Title: "Lessons from the Lisp Jam", + Description: `In the summer of 2020 we held a Lisp jam, where many community members made exploratory Lisp-inspired projects. We held this fishbowl as a recap, as a time for the participants to share what they learned and explore how those lessons relate to our day-to-day programming.`, + Month: time.August, Year: 2020, + }, + { + Slug: "parallel-programming", + Title: "Approaches to parallel programming", + Description: `A discussion of many aspects of parallelism and concurrency in programming, and the pros and cons of different programming methodologies.`, + Month: time.November, Year: 2020, + }, + { + Slug: "skimming", + Title: "Code skimmability as the root cause for bad code structure decisions", // real snappy, this one + Description: `Programmers tend to care a lot about "readability". This usually means having small classes, small functions, small files. This code might be "readable" at a glance, but this doesn't really help you understand the programโ€”it's just "skimmable". How can we think about "readability" in a more productive way?`, + Month: time.January, Year: 2021, + }, + { + Slug: "config", + Title: "How to design to avoid configuration", + Description: `Configuration sucks. How can we avoid it, while still making software that supports a wide range of behaviors? What is the essence of "configuration", and how can we identify it? How can we identify what is "bad config", and design our software to avoid it?`, + Month: time.March, Year: 2021, + }, + { + Slug: "simplicity-performance", + Title: "The relationship of simplicity and performance", + Description: "In the community, we talk a lot about performance. We also talk a lot about having simple codeโ€”and the two feel somewhat intertwined. What relationship is there between simplicity and performance? Are there better ways to reason about \"simplicity\" with this in mind?", + Month: time.May, Year: 2021, + }, + { + Slug: "teaching-software", + Title: "How software development is taught", + Description: "The Handmade Network exists because we are unhappy with the software status quo. To a large extent, this is because of how software development is taught. What are the good parts of software education today, what are the flaws, and how might we change things to improve the state of software?", + Month: time.June, Year: 2021, + }, + { + Slug: "flexible-software", + Title: "How to design flexible software", + Description: "We previously held a fishbowl about how to design to avoid configuration. But when you can't avoid configuration, how do you do it well? And if we want our software to be flexible, what other options do we have besides configuration? What other ways are there to make software flexible?", + Month: time.December, Year: 2021, + }, + { + Slug: "oop", + Title: "What, if anything, is OOP?", + Description: "Is object-oriented programming bad? Is it good? What even is it, anyway? This fishbowl explores OOP more carefullyโ€”what is the essence of it, what are the good parts, why did it take over the world, and why do we criticize it so much?", + Month: time.May, Year: 2022, + ContentsPath: "oop/OOP.html", + }, +} + +func FishbowlIndex(c *RequestContext) ResponseData { + type fishbowlTmpl struct { + Fishbowl fishbowlInfo + Url string + Valid bool + + date time.Time + } + type tmpl struct { + templates.BaseData + Fishbowls []fishbowlTmpl + } + + tmplData := tmpl{ + BaseData: getBaseData(c, "Fishbowls", []templates.Breadcrumb{ + {Name: "Fishbowls", Url: hmnurl.BuildFishbowlIndex()}, + }), + } + + var fishbowlTmpls []fishbowlTmpl + for _, f := range fishbowls { + fishbowlTmpls = append(fishbowlTmpls, fishbowlTmpl{ + Fishbowl: f, + Url: hmnurl.BuildFishbowl(f.Slug), + Valid: f.ContentsPath != "", + + date: time.Date(f.Year, f.Month, 0, 0, 0, 0, 0, time.UTC), + }) + } + sort.Slice(fishbowlTmpls, func(i, j int) bool { + return fishbowlTmpls[j].date.Before(fishbowlTmpls[i].date) // reverse + }) + tmplData.Fishbowls = fishbowlTmpls + + var res ResponseData + err := res.WriteTemplate("fishbowl_index.html", tmplData, c.Perf) + if err != nil { + return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to render fishbowl index page")) + } + return res +} + +func Fishbowl(c *RequestContext) ResponseData { + slug := c.PathParams["slug"] + var info fishbowlInfo + + // Only serve up valid fishbowls (with content) + exists := false + for _, fishbowl := range fishbowls { + if fishbowl.Slug == slug && fishbowl.ContentsPath != "" { + exists = true + info = fishbowl + } + } + if !exists { + return FourOhFour(c) + } + + // Ensure trailing slash (it matters for relative URLs in the HTML) + if !strings.HasSuffix(c.URL().Path, "/") { + return c.Redirect(c.URL().Path+"/", http.StatusFound) + } + + type FishbowlData struct { + templates.BaseData + Slug string + Info fishbowlInfo + Contents template.HTML + } + + contentsFile := utils.Must1(fishbowlFS.Open(info.ContentsPath)) + contents := string(utils.Must1(io.ReadAll(contentsFile))) + contents, err := linkifyDiscordContent(c, c.Conn, contents) + if err != nil { + return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to linkify fishbowl content")) + } + + tmpl := FishbowlData{ + BaseData: getBaseData(c, info.Title, []templates.Breadcrumb{ + {Name: "Fishbowls", Url: hmnurl.BuildFishbowlIndex()}, + {Name: info.Title, Url: hmnurl.BuildFishbowl(slug)}, + }), + Slug: slug, + Info: info, + Contents: template.HTML(contents), + } + tmpl.BaseData.OpenGraphItems = append(tmpl.BaseData.OpenGraphItems, templates.OpenGraphItem{ + Property: "og:description", + Value: info.Description, + }) + + var res ResponseData + err = res.WriteTemplate("fishbowl.html", tmpl, c.Perf) + if err != nil { + return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to render fishbowl index page")) + } + return res +} + +func FishbowlFiles(c *RequestContext) ResponseData { + var res ResponseData + fishbowlHTTPFS.ServeHTTP(&res, c.Req) + AddCORSHeaders(c, &res) + return res +} + +var reFishbowlDiscordUserId = regexp.MustCompile(`data-user-id="(\d+)"`) +var reFishbowlDiscordAuthorHeader = regexp.MustCompile(`(?s:(
.*?)()(.*?)(.*?)())`) + +func linkifyDiscordContent(c *RequestContext, dbConn db.ConnOrTx, content string) (string, error) { + discordUserIdSet := make(map[string]struct{}) + userIdMatches := reFishbowlDiscordUserId.FindAllStringSubmatch(content, -1) + for _, m := range userIdMatches { + discordUserIdSet[m[1]] = struct{}{} + } + discordUserIds := make([]string, 0, len(discordUserIdSet)) + for id := range discordUserIdSet { + discordUserIds = append(discordUserIds, id) + } + + hmnUsers, err := hmndata.FetchUsers(c.Context(), dbConn, c.CurrentUser, hmndata.UsersQuery{ + DiscordUserIDs: discordUserIds, + }) + if err != nil { + return "", err + } + + return reFishbowlDiscordAuthorHeader.ReplaceAllStringFunc(content, func(s string) string { + m := reFishbowlDiscordAuthorHeader.FindStringSubmatch(s) + discordUserID := m[4] + + var matchingUser *models.User + for _, u := range hmnUsers { + if u.DiscordUser.UserID == discordUserID { + matchingUser = u + break + } + } + + if matchingUser == nil { + return s + } else { + link := fmt.Sprintf(``, hmnurl.BuildUserProfile(matchingUser.Username)) + return m[1] + link + m[2] + "" + m[3] + link + m[5] + "" + m[6] + } + }), nil +} diff --git a/src/website/routes.go b/src/website/routes.go index 089dc14..2b64e96 100644 --- a/src/website/routes.go +++ b/src/website/routes.go @@ -222,6 +222,10 @@ func NewWebsiteRoutes(longRequestContext context.Context, conn *pgxpool.Pool) ht hmnOnly.GET(hmnurl.RegexPodcastEpisode, PodcastEpisode) hmnOnly.GET(hmnurl.RegexPodcastRSS, PodcastRSS) + hmnOnly.GET(hmnurl.RegexFishbowlIndex, FishbowlIndex) + hmnOnly.GET(hmnurl.RegexFishbowl, Fishbowl) + hmnOnly.GET(hmnurl.RegexFishbowlFiles, FishbowlFiles) + hmnOnly.POST(hmnurl.RegexAPICheckUsername, csrfMiddleware(APICheckUsername)) hmnOnly.GET(hmnurl.RegexLibraryAny, LibraryNotPortedYet)