* Re: What if pandoc were rewritten today?
[not found] ` <1784a254-0585-4f1f-a3b9-e8331fdcac1fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-10-01 16:16 ` John MacFarlane
0 siblings, 0 replies; 2+ messages in thread
From: John MacFarlane @ 2021-10-01 16:16 UTC (permalink / raw)
To: Alex Shaw, pandoc-discuss
You have to remember that I started writing pandoc solely to play
with Haskell. (In fact, I only knew the bare basics of Haskell
when I started.) So, my goal was to have fun writing a lot of
Haskell, and that goal is hard to achieve using another language.
(Also, because this was my goal, I wasn't bothered by the fact
that when I started, Haskell didn't have much of a library
ecosystem. I just wrote the libraries I needed: zip-archive,
skylighting, texmath, unicode-collation, doclayout, doctemplates,
ipynb...)
That said, Haskell has proven to be an excellent choice for this
project. The strong type system makes refactoring easy, and
helps me avoid whole classes of fiddly bugs that would torment
me in languages like C or JavaScript. The ability to guarantee
that functions have no side effects is also extremely helpful.
And the parsec parser combinator library makes it easy to create
flexible parsers for even the most irregular syntaxes.
There are lots of things I'd probably do differently if I were
starting from scratch. I probably would have built the AST
around sequences rather than lists. (Currently we can work
with sequences in the Builder abstraction, but why not just
make the AST work that way?) I would have set things up so
that every AST element can have attributes (#684). I would have
used types more heavily (e.g. in Format and Attributes).
Probably I would have done without a Space constructor on
Inline (#7579). I would have added a Figure type (#3177). I
would have separated some core functionality into a separate
package (#6215). Ideally, support for different syntaxes could
also be split into separate packages so that people could take
what they need (however, this has to be balanced against the
convenience for the developer of having everything in the same
package). As you can see, most of these things are still planned
changes. Fortunately, Haskell's strong type system makes it
possible to make changes like this across a large code base
without going crazy.
Alex Shaw <alex.shaw.as-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> Hello. This is my first post, so I apologize if I'm doing anything wrong.
>
> I have a question/topic for conversation for John MacFarlane and any other
> long-time pandoc contributors:
>
> *If you were to start over from scratch today, what would you do
> differently?*
>
> If pandoc were never invented back in 2006, what are some different choices
> you would make today?
> Would you use a different language (C++, Rust, Python)?
> Different Haskell features (prefer Functors over Monads)?
> Internal design architecture (completely re-written AST)?
> Source-code structure (merge readers and writers so that each file format
> is specified in a single module instead of each file format being partially
> duplicated in a reader and a writer implementation)?
>
> Those are all just examples. Feel free to share whatever you like.
>
> --
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1784a254-0585-4f1f-a3b9-e8331fdcac1fn%40googlegroups.com.
^ permalink raw reply [flat|nested] 2+ messages in thread