Live data from Hacker News

Beautiful mini language for outputing HTML in Python

shpaml.webfactional.com

61–70 of 74 posts

Re: Beautiful mini language for outputing HTML in Python

#61
post #8

There's just something wrong about creating a language with a language to produce about in a third language. As Brian Kernighan told Dustin Hoffman one time, "Learn to code!".

While your language^3 comment is technically true, this seems to be simply shifting one markup syntax to another, using a language to perform the translation. In addition, using something like SHPAML requires knowledge of the final output syntax, so the person using it must already know how to code. Edit: In reading my response, it seems too curt. I definitely see your point, but more so in contexts other than this.

It is not a promise, or even a goal, of SHPAML that it will relieve you the burden of understand the final output syntax, whether that is HTML or HTML combined with some template language.

SHPAML users are expected to be literate in both HTML semantics and syntax. The semantics of HTML are not abstracted away at all. The syntax is only abstracted away where it is redundant.

As a couple folks have pointed out, HTML is a pretty simple language. The problem with HTML is not its lack of simplicity; it is its verbosity.

So, if you use SHPAML, you undeniably get the terseness of SHPAML and the powerful semantics of HTML. So the question then comes down to simplicity. Does SHPAML eliminate too much of the simplicity of HTML syntax in trying to achieve terseness?

Re: Beautiful mini language for outputing HTML in Python

#62
post #54

this could almost be embedded, which would be much cooler i think. you'd have to define objects with names from html tokens and do some ugly hacking with python's operators. you'd also have to add something other than space between strings (a "+" might be ok). but once you've done that, this could be very neat. no processors - just constructing html in python. (i don't know if this sounds crazy or not, but you can se…

Other folks have tried to solve the problem of cleanly creating HTML from within Python itself, which I think is what you are alluding to. It's not a goal for me. To the extent that my markup is pretty static, but the content is dynamic, I try to use a templating language beneath SHPAML. If the structure of the page itself needs to be dynamic, then I probably want to serve up JSON to the browser, not HTML, and then l…

so, if i understand right, you think it's better to implement it as a separate language to stop people doing things that you don't think they should do, or think they don't need?

apart from stopping people from doing things, are there any what you might call "positive" reasons - advantages - to doing it your way?

Re: Beautiful mini language for outputing HTML in Python

#64
post #30
post #29

Earlier quoted context omitted.

The difficulty of programming isn't from having to type too much, it's from solving problems.

The difficulty of writing HTML is mostly having to type too much. Writing HTML isn't programming.

HTML isn't meant to be written directly. It's an output form, like Postscript or PDF.

Re: Beautiful mini language for outputing HTML in Python

#65
post #60

Earlier quoted context omitted.

Markdown is different, though. Rather than trying to cram HTML into a yet another pseudo-programming syntax, it tries to generate HTML that matches common plaintext-formatting conventions. You might not guess Markdown-formatted text was written with a formal markup language in mind. FWIW, there's a C implementation of Markdown called "discount" ( http://www.pell.portland.or.us/~orc/Code/discount/ ) which is crazy fas…

First of all, sorry about the name. SHPAML is not a pseudo-programming syntax. It is purely a markup language, so there are no programming constructs. SHPAML very deliberately tries to be a lightweight abstraction on top of HTML, unlike wikis and Markdown, which operate at a higher level abstraction. I am a huge fan of wikis, so I value the higher level abstraction at times, but I also see the need for an in-between…

That came off more harsh than intended. It sucks to post something you're excited about and have lots of people digging into it.

I'm not being critical of your tool in particular so much as wary of the flock of thin syntax transformers that have come out lately. They're fun projects, but adding yet another mutually incompatible data format is probably only a net gain under relatively specific circumstances (small teams, for starters). I like Markdown in this regard because it's downwardly compatible with how people would write anyway. You're right that it's at a different level of abstraction, though.

And about the name - I'm really tired of hearing the same Monty Python jokes all the time, but that's my problem.

Re: Beautiful mini language for outputing HTML in Python

#66

I no longer fall for languages that only change the syntax for something the author thinks it's cuter...

Right. I don't see any use case for this syntax especially that modern IDEs offer auto completion .

While it's less significant for HTML than code, verbose languages are problematic during reading as well as writing.

While generating stub code for class declarations, getters, setters, etc., can help with writing boilerplate-y OO code quickly, anyone trying to read it to decipher its intent will still have to deal with all the clutter. That's more likely to cause problems in the long run.

Re: Beautiful mini language for outputing HTML in Python

#67
post #54

Earlier quoted context omitted.

Other folks have tried to solve the problem of cleanly creating HTML from within Python itself, which I think is what you are alluding to. It's not a goal for me. To the extent that my markup is pretty static, but the content is dynamic, I try to use a templating language beneath SHPAML. If the structure of the page itself needs to be dynamic, then I probably want to serve up JSON to the browser, not HTML, and then l…

so, if i understand right, you think it's better to implement it as a separate language to stop people doing things that you don't think they should do, or think they don't need? apart from stopping people from doing things, are there any what you might call "positive" reasons - advantages - to doing it your way?

If my post made it sound like I am trying to stop people from doing anything, then it just came out wrong. I do think there are legitimate reasons to mostly build documents within a full-featured programming language, and I wouldn't stop people from doing that. I prefer to build the markup itself in a markup language with lightweight syntax, because documents should be readable, and markup languages have syntax specifically tailored for document readability. Then I supply dynamic content via the templating language.

Re: Beautiful mini language for outputing HTML in Python

#68
post #60

Earlier quoted context omitted.

First of all, sorry about the name. SHPAML is not a pseudo-programming syntax. It is purely a markup language, so there are no programming constructs. SHPAML very deliberately tries to be a lightweight abstraction on top of HTML, unlike wikis and Markdown, which operate at a higher level abstraction. I am a huge fan of wikis, so I value the higher level abstraction at times, but I also see the need for an in-between…

That came off more harsh than intended. It sucks to post something you're excited about and have lots of people digging into it. I'm not being critical of your tool in particular so much as wary of the flock of thin syntax transformers that have come out lately. They're fun projects, but adding yet another mutually incompatible data format is probably only a net gain under relatively specific circumstances (small tea…

I understand the objection to having too many mutually incompatible data formats, but I don't understand how Markdown is exempt from that concern. It achieves the goal of looking like what "people would write anyway," but at a higher cost in terms of departing from HTML semantics. For example, how do you indicate semantic structure via Markdown to allow for CSS styling or Javascript manipulation of the DOM?

Re: Beautiful mini language for outputing HTML in Python

#69
post #43
post #19

Earlier quoted context omitted.

The problem is that this is a trivial problem. Why add an abstraction on top of something that is already so simple?

My problem with HTML is not its lack of simplicity; it is its verbosity. SHPAML solves the (fairly) trivial problem of making HTML less verbose. The abstraction pays off for me insofar as I expect to use SHPAML for the next decade or so, and it's easy to remember the syntax, easy to share the output, etc.

Yeah, but how many other people will be using it? You may be planning on using it for a decade, but you will be in a very small minority. And so to share the output (the very common and portable HTML), you need to add another step to your workflow to convert things. This just seems like too much effort for very little gain.

Re: Beautiful mini language for outputing HTML in Python

#70
post #69
post #43

Earlier quoted context omitted.

My problem with HTML is not its lack of simplicity; it is its verbosity. SHPAML solves the (fairly) trivial problem of making HTML less verbose. The abstraction pays off for me insofar as I expect to use SHPAML for the next decade or so, and it's easy to remember the syntax, easy to share the output, etc.

Yeah, but how many other people will be using it? You may be planning on using it for a decade, but you will be in a very small minority. And so to share the output (the very common and portable HTML), you need to add another step to your workflow to convert things. This just seems like too much effort for very little gain.

If 0.001% of the world's population uses it, I think that comes out to something like 60,000 people.

You can see here that I've already solved the problem of sharing SHPAML output using HTML:

http://shpaml.webfactional.com/

You are right about it adding a step to my workflow. If only there was some kind of machine that could automate things for me...

Post reply on HN