4 ms·
I am that person. Coming from an electrical engineering/Low Level programming background HTML is a Markup language. I get those. CSS is stylesheets and in my
by wojcech 10y ago
I am that person. Coming from an electrical engineering/Low Level programming background
HTML is a Markup language. I get those.
CSS is stylesheets and in my opinion very straightforward. The hard part is making designs that are functional and beautiful and making it cross browser compatible, but CSS has very few warts if the "wtf" variety
JavaScript and it's ecosystem is disgusting for me. It's not hard, I can write stuff in it, it's ugly. I just don't want to touch it if I can avoid it. Pure personal preference. Typescript and elm help me to minimise the work I have to do in that mindspace. Maybe vue aims at similar clientele with less taste for statically typed/functional programming
- pluma 10y agoYou admit you understand it and it's just a personal preference. Therefore you're not that person. The stated goal of making templating accessible to programmers isn't to shield people who don't like JS, it's to shield non-programmers who don't understand programming languages. This is the absurdity I'm arguing against. If it was just about making JS look different, there would be no need to use Vue in the first place.
- goatlover 10y agoI thought the point also was not to mix the programming language in with the display logic, which was done a lot with PHP in the past, resulting in messy applications.
- matt4077 10y agoYeah, and that idea was always pretty stupid. They'd create some some new, terribly ugly, syntax. Maybe at first functions were limited, nut inevitably, they'd add connectors for every function in the "host" language (php/js/...). Or just something generic, allowing you to do something like <this-is-definately-not-a-programming-language native="Kernel.exec('sudo rm -rf /'"/>. OF course it meant you had to learn a new language, even though you were perfectly capable of perfectly suitable language already. But at least designers didn't have to learn "programming". There's no way around this. Templates need logic, mostly for loops (or maps, same difference), or dynamic formatting.
- dpcx 10y agoTemplates need some level of logic, yes. Putting the entirety of the business logic in your templates is not only bad, but dangerous. Because unless you're replicating your business logic in your non-template code, I can change things in the DOM, and potentially corrupt the system. Unless I completely miss the boat about how Angular/React/Vue/etc are supposed to be used. I only know from my previous years of seeing it done in the way I mentioned above, and every time, the work always ended up duplicated in the non-template code.
- simplify 10y agoWhat's your definition of business logic?
- combatentropy 10y ago> "make it easy for non-programmers to write templates" > I feel like that has been an illusory strawman from the start. You're right, the nonprogramming web designer may be a rare bird. Even if they exist, they don't exist long. I have always believed that someone can pick up the rudiments of programming in a couple of weeks. Someone who starts out writing HTML and CSS will eventually rub up against JavaScript. In time they will incorporate a snippet of JavaScript here and there. First it will be mindlessly pasted from the Internet. But after reading enough blogs, they will be bundling React and adhering to the functional programming paradigm to load their own blogs. Come to think of it, I wish there were more people who knew just HTML and CSS. More seriously, I myself know HTML, CSS, and a few programming languages, but unless the page is very simple I still like to separate things into template files. I prefer Handlebars, but often I just use PHP's alternative syntax. > apparently suffer from a nervous breakdown if they have to look at > an if-block or understand a for-loop Well, if-blocks and for-loops are the two main pieces of logic I think every template syntax must have. Mustache said it wrong. Templates should not be "logicless." Templates should be "processingless": they should not have side effects or further manipulate the data. This is okay: {{#if items}} <ul> {{#each items}} <li><a href="{{url}}">{{name}}</a>: {{description}}</li> {{/each}} </ul> {{else}} <p>none</p> {{/if}} This is less nice: <p>Any items you have will be listed below:</p> <? $q = pg_query('select * from items') ?> <? if (0 !== pg_num_rows($q): ?> <ul> <? while ($item = pg_fetch_assoc($q)): ?> <? if (userCanSeeItem($_SESSION['username'], $item['id'])): ?> <li> <a href="<?= h($item['url']) ?>"><?= h($item['name']) ?></a>: <?= h(ucfirst($item['description'])) ?> </li> <? endif ?> <? endwhile ?> </ul> <? else: ?> <p>none</p> <? endif ?> The problem is not ifs and loops nor the use of raw PHP, with its alternative syntax. The problem is the database calls (pg_query), controller-esque function calls (userCanSeeItem) and text clean-up (ucfirst). This kind of stuff should be hidden inside a model-esque function (getItemsOfUser($username)) which returns a ready-to-print associative array. I use templates not because I'm scared of all that. Instead it's sort of like the recently re-loved functional programming paradigm. Template files should have no side effects. I know that once I stuff the data into a template, then nothing else will happen besides output to the user's screen.
- mataug 10y agoYou're not the only one who finds JS and its ecosystem disgusting.
- subpixel 10y agoVue's single-file components (html, js, and scoped css) are super-appealing to me. The message is something like: "These concepts you understand and use all the time? We aren't going to make you abstract them away. We're going to use them as the foundation for a new way to build apps."