7 ms·
Does PHP modify code client side like Javascript? IMO this is the inherent difficulty with Javascript. I would prefer that you have the "source code" as two se
by mikorym 7y ago
Does PHP modify code client side like Javascript?
IMO this is the inherent difficulty with Javascript. I would prefer that you have the "source code" as two separate things: the hard details of the page and the code to manipulate behaviour.
This [1] current HN front page link would illustrate what I mean. You have a colour palette (hard details) and the behaviour (code to plot the colour palette). Of course this is a simplification, but it shows the way of thinking and the way of optimising use of code and space.
[1] https://news.ycombinator.com/item?id=21937607 https://news.ycombinator.com/item?id=21937607
- krapp 7y agoThat's not really a difficulty of javascript the language - you're supposed to have your javascript completely separate from the HTML and CSS, with everything in static files of that type. Separation of concerns was built into the web from the beginning. It just happens to be a popular architectural pattern at the moment to reimplement the DOM, HTML and CSS all in javascript and have one big mess of code.
- tchaffee 7y agoSeparation of concerns can be handled in one language. The popular MVC pattern does not require three separate languagues. And in fact that's rare in my experience. So web frameworks moving towards the norm and allowing it to all be handled in the same language should not be surprising or a mess.
- wongarsu 7y ago>The popular MVC pattern does not require three separate languagues. And in fact that's rare in my experience. ASP.NET MVC uses C#, (C)HTML and CSS for a total of three languages. WPF uses XAML and C# for a total of two. Android uses XML and Java for a total of two. I think Delphi only uses one, I vaguely remember the designer outputting plain Delphi instructions? I might be misremembering. React is not exactly encouraging separation of concerns, and in some ways this was better in the times of JQuery. But I don't think this is directly related to the number of languages involved.
- tchaffee 7y agoOf course when it comes to the web it's three languages underneath. Per the standard, you can't escape that. Now look at apps that are built to run on an OS using MVC. It's usually all in the same language. Why? Separation of concerns doesn't imply separate languages. There might be some merit to the idea of a DSL for each concern? But if the end result of that experiment includes CSS, I would call the experiment a failure.
- wongarsu 7y agoAndroid, WPF and Universal Windows all use XML to specify UI, and the programming language of choice to specify code. That's still two languages, even if it removes the need for a third language exclusively for styles. In each you could use pure code to build the UI but readability and maintainability would suffer a lot, so nobody does that. Once you have the view separated from the controller, writing the view in a language better suited for nested UI seems quite natural. What are examples of MVC using only one language?
- mumblemumble 7y agoPerhaps Cocoa development, though it typically used a GUI tool for the UI layout, so not really. Smalltalk, but Smalltalk MVC is different from what MVC typically means nowadays. FWIW, WPF uses MVVM, not MVC. The differences are as subtle and pedantic as they are important.
- rsynnott 7y agoI'm not sure how common vs not common Interface Builder usage really is. At any rate, I'd say "typically" is a stretch.
- mumblemumble 7y agoThat's fair. My experience on the subject is admittedly pretty ancient. When I was doing it, back in the early 2000s, IB was how everyone I knew did it.
- chrisweekly 7y agoYou're right that it's not javascript's fault per se. But the rest of your comment represents a narrow, dated and frankly ignorant viewpoint. Component-based front-end architecture has tremendous advantages. And if you want to see "one big mess", simply examine the CSS of virtually any moderately-sized website or web application. I've been doing web-related development since the late 90's, and I make a living as a UI Architect. Increasingly my clients are looking for my help to unfk their nightmarish, effectively unmaintainable legacy codebases -- which typically have followed this same cargo-cult "wisdom" to their detriment.
- krapp 7y agoI'll just vaguely gesture in the general direction of the multitudes of developers on HN who both work with front-end frameworks and complain ceaselessly about what a nightmare it is and stand by my statement. It can have both tremendous advantages and be a mess. Both can be, and are, true.
- airstrike 7y agoo/
- chrisweekly 7y agoFair point.
- mhd 7y agoComponent-based architecture doesn't imply JS-based versions of HTML and/or CSS, though. React does it that way, e.g. web components don't. Not that I'm averse to "reinventing" HTML or CSS in the first place, although doing that in JS would be somewhat ironic.
- chrisweekly 7y agoHuh? How do you think web components are implemented? Hint: they're JS APIs.