4 ms·
Taking the gist of what he's saying ('Other languages are a lot more concise than Java') I tend to have the same feeling even with HTML when using CSS. For exa
by FuzzyDunlop 15y ago
Taking the gist of what he's saying ('Other languages are a lot more concise than Java') I tend to have the same feeling even with HTML when using CSS.
For example, CSS has its own syntax for classes and IDs, and once you're used to that, you can go back to HTML and it can get a little bit frustrating having to do it more verbosely.
// CSS
div.example, div#example {}
// HTML
<div class='example' id='example'>
// What I sometimes end up doing by accident
<div.example> / <div#example>
And the same with PHP vs JS
// Empty object in JS
var obj = {}
// Empty object in PHP
$obj = new stdClass();
Or coffee-script, Erlang, etc. vs plenty other languages
// defining a function in the former
func() -> ...
// and the latter
function() { ... }
And the languages that rely on indentation to identify code blocks vs. those that use curly braces or parentheses. The latter is a nightmare when code is nested several blocks deep and you've a sequence of:
}
}
}
}); ...
By the same token there's probably a blog post out there about how confusing concise syntax is and how it's hard to figure out what the hell '{}' or '[]' or '?:' means compared to their more verbose counterparts.
- bl 15y agoIf you are used to CoffeScript and python and feel like you're trudging through syrup when you work on HTML, you might check out SHPAML (http://shpaml.webfactional.com/ http://shpaml.webfactional.com/). I found SHPAML to be more closely related to those two than HAML and friends: indented syntax, minimal angle brackets, etc. And per your wish: div.example_class Content here... p#id_example More content... From the previous discussions here on HN there were many skeptics, but I have found that it has greatly reduced mental friction when I have to wrestle with HTML: the markup is fast to write, a joy to read, and I get warm, fuzzy feelings knowing that my HTML source is not drowning in markup soup. Caveats: 1. It doesn't appear to be actively maintained. (But it is distributed as a single, readable python script that one can easily modify to taste. It spits out plain HTML, so if you ever want to ditch SHPAML, you will never be left high and dry.) 2. Doesn't include a round-trip translator. (Not terribly important to me.) 3. Like CoffeeScript and their ilk, the output line numbers don't line up with the source. 4. There are a few bits of gymnastics one has to do to conform to the grammar. For example, a link anchor must appear isolated on a new line to use the most absolutely tersest syntax. Since SHPAML passes HTML straight through, you can avoid this by added the standard markup. 5. SHPAML may not be automatically included in your workflow if you are using something like Rails or Django, but I believe there are a set of github projects that address this.
- jpadvo 15y agoGood old fashioned HAML is regularly maintained, and appears to have been the inspiration for SHPAML: http://haml-lang.com/ http://haml-lang.com/ It also comes with SASS/SCSS which similarly cleans up stylesheets, and adds things like variables and mixins.
- arethuza 15y ago"The latter is a nightmare when code is nested several blocks deep" It isn't if you have a decent editor.