7 ms·
This is great. Seriously. I cut my teeth in the early 2000s writing the type of PHP code that would make your eyes bleed. Global variables everywhere. HTML/
by nhashem 15y ago
This is great. Seriously. I cut my teeth in the early 2000s writing the type of PHP code that would make your eyes bleed. Global variables everywhere. HTML/PHP/MySQL in the same file. Career-wise I ended up going down a backend/database developer path, so if I do anything with consumer-facing web applications, it's on my free time.
I'm working on such an app now, and right now the fastest way I can get anything done is writing similar code to what I wrote in 2003. It's not quite as bad, but I continually succumb to doubt. Shouldn't I be using a framework? Wouldn't Python or Ruby be a better language to use now? Is it 'cheating' if I just throw these form elements in an HTML table? Shouldn't I be using something more scalable for the backend than a default installation of MySQL 5.1?
And yet, every time I try and address any of the above, it just gets frustrating to me. I have a limited of free time to work on this web application each week. So I want to spend that time actually DOING things with my web application, not just ramping up on learning some stuff so that I can maybe do some things a few weeks from now. This web application is getting a bit of traction with users. I always figured that I would eventually "code myself into a corner," and that making these suboptimal technology stack choices would result in me hitting some local maxima that would bite me in the ass and I'd have to basically rewrite everything.
But after reading this blog post, I feel a lot better about my choices. If this guy can make his web application work with the technology stack he prefers, then so can I.
- wynand 15y agoI have respect for people that can deliver, regardless of what they use. The allure of cool tech is strong but tech doesn't make products: people do. I cannot see what is wrong with your using plain PHP if you can get the job done faster (as long as you avoid things that make exploits easy, such as raw mysql db functions). When the time for a framework comes, you'll know. Stop worrying about what others think and good luck!
- JasPanesar 15y ago+1 to both of you!
- JasPanesar 15y agoOops, sorry, I didn't know this was not appropriate, first thread on HN, long time reader.
- radagaisus 15y agohere's how I learned Python without noticing it: (I had a background in PHP, JS, C++) 1. Off hours on 2-3 days with dive into python 3. 2. A month later - 'oh let's do this in python!' on google code jam 3. 'python challenge? that's cool' - one night hackathon a month later 4. 'I hate php, I'll do this new web app in django' 5. Two days messing with django 6. Five days and the app was done. I don't know if I write 'best practice' python or django but it's about x6 less code than in PHP. I can rewrite my app completely in 2 days. For me, the biggest problem in learning a new technology is finding the balance between cowboy hacking & analysis paralysis.
- joelhaasnoot 15y agoStory of my summer Except now I have couple hundred of lines of "legacy" PHP that's not being written in Python just yet and considering time constraints won't be. It makes crossover projects hard.
- antonp 15y ago>I don't know if I write 'best practice' python or django but it's about x6 less code than in PHP. Just curious... Surely you mean django vs php (not zend or some other framework - which _would_ have been the fair comparison.
- deleted 15y ago[deleted]
- gurraman 15y agoI think he compared before (plain php) and after (invested time in learning some new technology).
- radagaisus 15y agoNo, the weird thing is I'm comparing Django to Kohana. The app I worked on in PHP was more complex, but one API page was very similar in both apps: - Kohana: ~200 lines of code. - Django: 15. Seriously.
- gaius 15y agoDelivering version 1 is very different from delivering version 2, 3 4... That's when the real test of engineering is.
- auxbuss 15y agoNot just because this is what I do, mainly, but it's such an important point that it deserves highlighting. Working software is easy. Working maintainable software is harder.
- mnutt 15y agoI think the article is flawed in many ways, but if you define 'working' software as software that works for users in such a way that people actually want to use it, then working software isn't so easy. And getting from nothing to working software is harder than getting from working software to maintainable software. Or at least it's better understood.
- njharman 15y agoHa, I'd say non maintainable software isn't working. Just matter of time until it's broke or needs updating.
- drumdance 15y agoUse what works for you. For me, the main benefit of a framework is scalability of new developers. If you have to bring on someone else to extend & maintain your code, it's incredibly helpful to be able to point them to documentation.
- mechanical_fish 15y agoFor me, the main benefit of a framework is scalability of new developers. That's one, and it's a big one. The other, even bigger benefit is that other people will do things for you. They'll write plugins for you. They'll develop new versions of the framework for you. They'll do crazy experiments in corners of the framework design space ("Hey, can we make Drupal work with a CouchDB back end through a series of proxies?") and report the results in obscure Stack Overflow posts that will get indexed by Google. They'll find and fix bugs and security holes for you. When you ask one of them about some problem in your system, they'll have a fighting chance to give you useful advice -- even if they've never actually seen your system -- because, hey, all Rails apps are kind of alike, and all Drupal sites are kind of alike, and all node.js installations are kind of alike. The fact that this is the major benefit of using a common framework is also the reason why the poor OP feels so lonely. The whole point of a common framework is to have lots of meetings and rallies and beer bashes and hackathons and IRC channels so that everyone can swap ideas and recruit each other and basically work in a big team. They generate their own buzz, because the buzz is part of the value. But hand-rolled personal systems don't get that kind of buzz, because -- to paraphrase the ever-paraphrasable Tolstoy -- all standard web frameworks are alike, but all nonstandard web frameworks are nonstandard in their own way.
- infocaptor 15y agoMy web app mockuptiger is exactly what you say html/jquery/php/mysql look at wordpress, joomla, drupal
- andrewflnr 15y agoUm, what? For all practical purposes, those apps you mentioned are frameworks. Joomla actually has a pretty firm MVC structure inside, and IIRC Wordpress's codebase has a rep for being hard to work with. Drupal makes no bones about being a framework. These are not good examples to support a "just stick it together" philosophy, if that is indeed your philosophy. You have to stick the layers together at some point, but you'll still probably be better off keeping the glue out of your "business logic".
- jerf 15y ago"I'm working on such an app now, and right now the fastest way I can get anything done is writing similar code to what I wrote in 2003. It's not quite as bad, but I continually succumb to doubt." The biggest objective problem this style has is that it affords everything-injection; cross-site scripting attacks, SQL injection, command injection if you're using shell commands, etc. Every time you bash one string together with another one, you run the serious risk of introducing a security attack, and with this style of programming, you basically have to be thinking about every single string concatenation. Using a framework that will take some of the cognitive load off can be a net gain. It need not be a Glorious Framework, it just needs to be something that makes doing the right thing easier than doing the wrong thing. Otherwise, most of the rest of the pain will be felt by you, not your customers, so hey, whatever, go nuts. But this is a legitimate objection to this approach. (And a legitimate objection to every framework that fails to make the right thing easier than the wrong thing, which is still a great deal of them.)
- steve-howard 15y agoWhat I find interesting about PHP (among many laughably bad things about it) is that one of its key strengths for beginners is the easy mode-switch between scripted and verbatim mode (i.e. <?php and ?>), but all the large software projects whose code I've read used some kind of templating. I agree with the sentiments around here, though. If the goal is to write software that works and hopefully makes money, do what you know and ignore this year's hot new framework/language. Write readable code in case you need to refactor it later.
- dangrossman 15y agoWhat do these things have to do with a framework? PHP's built-in MySQL drivers (MySQLi, PDO, etc) support and encourage prepared statements and parameter binding. PHP's built-in string library supports HTML-encoding output. PHP's built-in filter library supports validating and sanitizing input. Writing apps without some kind of framework might lead to less organized, tighter coupled code, but it doesn't mean you're mashing together strings and ignoring security.
- mhansen 15y agoSmall nitpick: the customers will feel the pain if their username/password is leaked through SQL injection.
- dusklight 15y agoHave you heard of the term "confirmation bias" before?
- mootothemax 15y agoI'd really, really, really advise you at least check out a framework :) Spend 10 minutes reading the documentation behind CodeIgniter (http://codeigniter.com/ http://codeigniter.com/) and you'll see that you can have more time to spend developing, e.g., features, as the framework has taken care of the routine and mundane stuff. As a note, I would recommend Kohana (http://kohanaframework.org/ http://kohanaframework.org/) over CodeIgniter, but if you're pushed for time, you don't want to deal with a sparsely-documented framework ;)
- radagaisus 15y agoI've worked with Kohana a lot and I really don't like it, besides how skinny it is (oh, and the H in HMVC). Weird thing is the best programmer I know recommended it to me.
- eropple 15y agoKohana is a little brain-damaged. Good intentions, but it's essentially a PHP5 version of CodeIgniter in most ways that matter. The problem with this is that a PHP5 version of CodeIgniter doesn't leverage the constructs and concepts that make PHP5.3 (which in 2011 is the lowest version of PHP you should be considering) much more pleasant to work with than previous iterations. Kohana, and CI2, are both rather meat-axey frameworks, where the trend is toward elegance. I'd consider Symfony2 for most applications, or Silex (which is the Symfony2 app kernel, stripped of the majority of the Symfony2 framework) if you like writing the plumbing yourself. Yii is pretty nice, too.
- radagaisus 15y agoKohana 3 is not a rewrite of CI. it was written from scratch. Kohana also has the worst documentation in the world. Seriously. It has very clear comments in its source code, though.
- eropple 15y agoYes, it's written from scratch--which is why I said "essentially". It's a full rewrite into what is still not very idiomatic PHP5.1, and I can't really recommend using a non-5.3 framework given the improvements in expressivity and flexibility that came with 5.3.
- Hisoka 15y agoThat's not a bad strategy. I also believe in "Just get it out and done ASAP and brush it up like heck afterwards". Worry about injection attacks, efficiency issues, scaling after you gain some traction. You can always rewrite later when it becomes an issue.
- mark242 15y agoCan you please list out the applications you've created? I'd like to add them to my "never ever register on these sites" list. If you're only worrying about injection attacks "...after you gain some traction" or "...when it becomes an issue" you're already too late, and I don't ever want to trust any of my private data with you, ever. This is the 21st century. Scrubbing and validating user input is _trivial_ now, framework or no. Please, please, please, everyone who reads this, spend a day reading the OWASP guidelines, and _use_ their sample code. This isn't difficult, and it makes your applications a million times more secure _on_ _day_ _one_.
- Hisoka 15y agoOh please. I'm not building anything that requires a credit card, or anything sophisticated. When you have literally just a hundred users, YES I will skip paying lots of attention on injection attacks because the chances of that happening is very low. To you techies, it sounds like a huge deal, but the priority in any business to make profit first.
- eropple 15y agoSorry, but this is bull. If you take any information, even if it's an email and password, data security is either tops on your list or you're abusing your users (even "only a hundred"; one is too many!). There is literally zero middle ground on this: you do it or you shouldn't be building web applications. And given how utterly trivial it is to provide proof against injection attacks in any modern language and toolkit, choosing not to do so because it's "hard" as irresponsible as you can get. This sort of behavior is why the rest of us get a bad rap.
- 0x12 15y agoHave a look at the Yii framework.
- itrackmine 15y agonhashem, wow you really hit the nail on the head. So accurate it's scary. I too, thought I was the only one who put DOING before "ramping up and learning some stuff so that I can maybe do some things a few weeks from now." And of course Pud for the courage to be honest about how he's working. So many times in startups and new endeavors, getting things out is far more important than doing it "right". It's stinky, but it's a reality. If your checkbook, bills and time say one thing but your code says another, your checkbook/bills/time win - always. And the person who can pump out more working (working, not necessarily pretty/proper code-wise or stack-wise) apps wins (even if they lose, they win, based on odds - more attempts means more possible chances at winning).
- itrackmine 15y agoJust wanted to add: this is all imo. :)
- sanderjd 15y agoIt's interesting to me that you thought you were the only one who put doing before ...learning, for lack of a better word - from what I can tell, the trendy thing at the moment (besides all the trendy technologies) is to spurn design, best practices, and maintainability in favor of doing things in the stinky, realistic, checkbook and bills friendly manner. At least if you're judging solely based on articles and comments that get upvoted on HN. It's a constant pendulum between "right" and "quick", which makes me think the answer is almost certainly somewhere in the middle. Honestly, it makes me wary of being a customer of startups currently, if everyone is just trying to get to version 1 as quickly as possible without any consideration for the future, so I hope that attitude is not as widely spread as it appears to be.
- zachperret 15y agoReally you should only be worried if you're using version 1 apps. I'm a fan of quick prototyping and quick release (in alpha/beta, of course), as long as the team is committed to putting the time in on the back-end. Getting a product out is an important step 1...the real work (and money) is in steps 2-1000.
- dalore 15y agoI was like you back in the day, then I tried using one of the new frameworks (it was Django) and I was like why didn't I do this earlier, it would have saved me a bunch of time from all the stuff it does for me and the less writing I have to do.