PHP is a decent language and ecosystem these days. Perhaps one of the minority of ecosystems that are actually on the rise rather than on the decline. It still has lots of warts, but whatever. Forget the idea that PHP is "taking what you can" or not a sane language -- you're in it now so might as well get up to speed with best practices and use it the best you can. I promise you can build compelling software in PHP.
Familiarize yourself with the ecosystem by poking at the most popular frameworks, at least skimming the docs to understand the types of things they provide and how they're structured: Zend, Symfony and Symfony Components, Laravel, Slim, Silex. Study WordPress, the "stereotypically bad" piece of software, for anti-patterns, but there's also a lot of good stuff in there and some improvements on the roadmap.
Composer is the npm of PHP. Check out packagist (horrible UI though) or browse github's PHP repos to find some of PHP's commonly used packages, like Monolog and phpunit. You can build a simple app in minutes in Laravel, and even put together a small product MVP using 90% boilerplate code within a matter of days on Laravel. Since there's a growing ecosystem for these tools now, it's getting easier and easier to write quality software in PHP, and it's actually a relatively pleasant experience.
Plus shipping and managing PHP in production is a breeze -- it's the most widely supported web platform, after all. We've got support on great CI systems like circleci and scrutinizer-ci.
There's only a couple of things that stood out to me as suboptimal:
- PHP ncurses is not well documented beyond just function signatures. Of course, curses itself is well documented, and ncurses functions map one to one with the PHP extension, so that wasn't really that bad.
- I should have separated my classes and built a PHAR (PHP archive), but I got lazy.
- There's the portability comment I've made a few times already
But other than all that, PHP did its job perfectly. Easy to write, read, and organize.
I upvoted this comment because I really like the idea of "I built this because I wanted to". I like the idea of Show HNs as an "I made this thing for me, and not for any other reason". Thanks for posting your project!
> But there are two reasons I didn't go that route:
My biggest issue is that Slack doesn't allow non-paying accounts (I forget what they call the tier - "guest" account or something) to use the IRC gateway.
There's one project I'm involved with that moved its support channel from Freenode to Slack. I used to idle in the channel 24/7 thanks to ZNC, and now I have to actually log in through the web interface every time I want to ask a question. It's their loss, too, because I'm also no longer as available to answer other users' questions.
If you run a software project, please, please, do not host your support channel on Slack. I don't want to have to request an invitation just to join the channel, and I don't want to have to either download and open the Slack app or use their web interface just to ask a question or answer other people's questions.
 Their web interface has really terrible performance, and last I checked, their Linux "app" was just a webview around said web interface, with equally terrible performance.
I actually intended to write a comment in the README about my choice of language, but as things go, I forgot.
I was actually surprised how well this worked in PHP. The only issue is that the ncurses PHP extension, not being compiled by default in most package managers' PHP distribution, does force you, the user, to take an extra step in installing it. That is unfortunate.
That would be a grave issue if I saw this as a product, but since it's a pet project, I see that as totally acceptable :) I actually never even intended to release this publicly!
That's not the issue here. You could have written that in shell script it wouldn't matter. Just that PHP(+ all the extensions required) makes it more difficult to deploy for someone who just want to try out your project.
Source: I have a master's degree in mechanical engineering in hybrid vehicle powertrains, and a big part of my research was battery technology. I spent some time working with the folks at National Semiconductor learning this, so I have several primary sources.
Disclaimer: my knowledge of the field is from ca 2010.
1) Lots of deep discharge cycles do negatively affect battery life. Try not to jump between 0% and 100% too much.
2) Li-ion batteries do not love being at 100% SOC (state of charge). As batteries become more dense, the membranes become thinner. High SOC equates to high chemical potential, which will break down membranes faster. As such, avoid leaving your battery at 100%. This wasn't as much of a problem with older batteries with thicker membranes, but is becoming more and more an issue as we try to squeeze every ounce of density out of batteries.
3) Roughly 70% SOC is where a battery is happiest, but the whole range of ~30-80% is pretty happy for a li ion cell. Try to keep your battery at ~70% or so overnight, at 50% or so for long sleeps.
A good usage pattern: plug in and let charge to 90%, unplug and use for a couple of hours, plug back in at 50% or so, rinse and repeat.
However, i'd rather buy a new battery after 5 years (if my laptop is still fit and the battery is dead), than having to complicate my life and think about when to unplug or charge my laptop multiple times each day for 5 years...
My Macbook air from mid 2011 is currently at 100/6700*5629 = 84% battery health.
(6700 = design capacity, gathered from "ioreg -l -n AppleSmartBattery -r".
I agree with you. Instead of optimizing for battery life by constantly checking & adjusting my charging, I'd rather live my life focusing on other things. What I do is super simple: plug it in whenever possible.
Same here. I have no reason to dispute the expert who says Lithium-ion batteries "don't love 100%". Fine, but they don't seem to dislike it too much, either. So far I haven't had any batteries that didn't perform well when they were mostly plugged in, occasionally discharged in mobile use.
I see some similarities to, e.g., medical pronouncements that some particular food increases risk of cancer. It's easy to get alarmed, but there's a big difference between it increasing my likelihood of getting cancer by 0.05% and making cancer, say, (just to illustrate the point) 100 times more likely. The former I would likely ignore and the latter would probably make me give up the food instantly.
Yosemite is a total mess, but it has gotten slightly better with 10.10.3 (if you are willing to ignore the Photos app, which launches constantly for no reason).
If you are willing to mess with drivers, you may want to try installing Linux. On a 2013 Air, battery life and performance (even graphics!) are surprisingly better with Debian Jessie than with OS X. Of course, it is a newer model than yours, but the drivers will only be more stable and mature with a 2011. Especially if you have 4 GB RAM and you're running into a memory barrier with OS X, you should see a significant improvement.
My iPhone and a couple flash drives do this, probably because it thinks my scanner is a camera. Unfortunately I can't stop it from launching (assuming I can disable it in Preferences) until it will actually launch—I have left it beachballing for a very long time and it still has not finished launching, so I just force quit it.
This used to be the only place to change the setting—which was ridiculous because virtually no one ever used Image Capture (especially because iPhoto opened by default). But to Apple's credit, you can now also change this preference in Photos. Of course, as the previous poster pointed out, you have to actually wait for Photos to finish launching. But at least it's there now!
Always 'Quit' open apps you don't use,
never, NEVER have 2 sessions open at the same time,
and try using lighter applications when you can (VLC instead of iTunes for music, Skim instead of Preview for PDFs, Preview instead of Photos for images, etc)
I have to use a 2012 MBP with Yosemite from time to time and if I follow these rules it is definitely bearable.
My 2011 11" Air (i7) runs 10.10 just fine. I haven't noticed any slowdown over the past 4 years, although I do disable all the unnecessary transparency and animations Apple keeps adding for seemingly no reason.
By the way, my battery health is also around 85% after 500 cycles and being plugged in and charged to 100% whenever possible.
Switch to OSX 10.9, problem solved. My 2012 rMBP with top end specs is also sluggish on 10.10.3. Not sure what Apple is thinking. On the other hand I am still using my 2003 Panasonic CF 73. It's not quick, but for the limited tasks of automating my DSLR it works perfect.
MacBook Pro (13-inch, Early 2011) 2.3Ghz i5, self-upgraded hardware to 16GB 1333MHz DDR3 RAM, Samsung SSD 120GB, caddy with 500GB HD, replaced battery with cheap Chinese, running 10.10.3 like a charm (only my SD-card slot never worked).
Yes, mine still runs smooth, that's why i always buy the fastest model (processor) available, it's more expensive when buying but usually saves money in the long run.
(i have the 1.8GHz Dual-Core Intel Core i7)
Agreed. I do avoid leaving my laptop plugged in overnight, but I'm also not too careful about leaving it plugged in during the day. I'll often pop the charger out when I notice the battery at 100%, but I'm not going to lose sleep if I forget about it or operate slightly sub-optimally.
I have a Lenovo Yoga Pro 2, it's got an app that manages this for me. I turn on "conservation mode" and it keeps the charge at 55%-60%. The only negative here (and it would be there with doing it yourself) is that if I run out without the charger I'm essentially at 1/2 capacity.
Could you clarify how you arrived at 84% battery health? After the command "ioreg -l -n AppleSmartBattery -r" I see DesignCapacity, but where does the other number (5629) come from? I'd like to compute battery health myself...
Just another data point: I'm at 77% (4431/5770) on an April 2010 MBP. I tend to leave it plugged in when possible, and often run it far down when not near an outlet. I take it that's about the worst I can do, but the convenience has seemed worth it.
Agreed. My mid-2012 Macbook Pro Retina has been plugged in @ 100% nearly all the time it's been in use. Pretty much the only time it's not plugged in is when traveling. Battery is at 7845/8460 CurrentCapacity/DesignCapacity or 93%.
That was just a personal estimate, obviously if the battery health is for example at 75% you also lose 25% of 'the time' to work without plugging it in... so if that becomes a problem when traveling i might want to buy a new one.
For others this might not be a problem of course.
Ok. I was wondering if the breakeven is set as 5 years but if the cycle of tilt to full makes the life shorter for the battery, then it may not be worth it. I agree that if I've to weigh battery life vs my time, I would go with the latter.
So what my laptop should do automatically is to stop charging once it hits ~90%, and start charging again when it hits ~40%. And the OS should give me an easy-to-reach option to "charge to 100%" for when I'm about to make a trip. Why hasn't anyone implemented this yet?
You're right. Someone should have done it in each OS. In linux it's just a matter of echo-ing a few numbers to the write "files". I just made a script to do it, see my other comments here if interested.
This assumes the battery percentage displayed is the SOC. This might be the case for laptops or small appliances where manufacturers are happy to trade long battery longevity for a small gain in time to empty, but the Model S for example has gap of a kWh+ and will simply not charge or discharge the battery fully, to avoid these cases where a very low of very high SOC damages the battery.
On ThinkPads this can be (or maybe used to be) configured in one of the preinstalled ThinkVantage utilities (Power Manager). But I believe that the whole charging logic itself is really in EC firmware and this application is only user interface for that.
As an aside: the mechanism works in slightly different way (at least on all of my 4 thinkpads of different generations). There are two thresholds, maximum battery capacity when charging can start and capacity when charging stops, the aforementioned application even seems to have some kind of logic to set these thresholds according to battery aging.
Also, trying to keep Li-ion cells charged to constant state of charge is not good for their lifespan. What is commonly known as trickle-charging (charging by infrequent, short but large pulses of current) is actively discouraged by most cell manufacturers, sometimes even citing safety reasons.
I don't know, but there seems to be not very much incentive to invest a lot of R&D dollars on this problem from a manufacturer standpoint:
* Devices marketed on how long they last on a single charge, but much less often on how quickly the battery degrades
* Batteries are a later upgrade upsell opportunity
* I would not be surprised to learn that a significant number of device upgrades start as simply wanting a better battery (but why not upgrade at the same time)
I'm not sure I'd want my battery to be "that" smart, safety measures coded into the power/battery drivers (which would be present on the battery itself, not main OS drivers) sounds about right. Optimizing and things like that I rather leave up to the OS, or even an APP (as long as it cannot do anything dangerous).
I mean it's one thing if my OS can control the charging cycle to some extend, whether Apple can install drivers (and bad guys bad stuff) on my Battery "smart" board.
It may seem like a big leap now, but I bet someday (or perhaps even now, why do people place tape on their webcams otherwise) it could become a problem.
But of course, to my knowledge so far Apple is doing a pretty good job in keeping Macs and OSX kind off secure (don't quote me on that), however than again I don't want OSX to become as restrictive as iOS or I'll have to switch to Linux t get my dev-tools working. (not a fan of that personally)
Granted device manufactures are pushing devices out every year or two, and it's in their best interest to offer the longest battery life possible, there is no incentive or evidence present that manufactures are limiting the maximum charge to prolong battery life.
Having read similar perspectives I was always annoyed that there was no way to essentially pause the charging and perhaps run via trickle charge at a set percentage, so if I'm tethered to a desk for a week I could keep the battery at 70% and then choose to bring it to 100% if I expect a long day away from an outlet. Perhaps this is not plausible for some reason? Would it be control required at the battery firmware level? (Referring to an Apple laptop for example)
The only concerns I have with this advice is the heat generated by constantly draining/charging the battery will degrade the life, plus constantly cycling will degrade the battery in other ways as well.
If a charger could be tweaked to charge the battery slowly and not overcharge it, that'd be the ultimate solution.
SOC is relative to the application, but it is possible many applications nowadays purposely operate within a specific SOC and not exactly 0-100%. We need an Apple battery engineer in here to confirm ;)
Temperature, temperature gradients, heat, membrane potential, charge/discharge speed, etc, are all variables in long term battery life, along with dozens of others.
So I'm reluctant to agree or confirm with any sweeping statement about a single variable (in this case, heat generated by charging), because it may be true in some cases but not in all. And it also depends on the specific battery.
Most likely, for most laptops, for most daily use-cases, and a charging pattern of 90-50-90 in 2-3 hours, I'd rather take the slightly increased temperature than keep the battery at 100% for that time period.
But again: it depends. On so many things.
Edit: also, either case (keeping at 100% for 3 hours vs 90-50-90 for 3 hours) is better than keeping at 100% 24/7. So no harm done if you can't decide which is better. Just A) don't plug in all day long and B) don't go crazy with the heat and you'll be fine.
The Thinkpad power manager mentions the issue and comes with different modes to maximize the battery lifespan.
Quote: "If you primarily use your computer with the AC adapter attached and only infrequently use battery power, battery deterioration may occur faster if the battery is constantly charged at 100%. Lowering the charge thresholds for your battery, periodically resetting the battery gauge, using Maximum Lifespan mode, or using Battery Health Mode will help increase its lifespan."
But how do I know the battery reports honest numbers? If all these years spent dealing with hard disks tought me anything, it's that what's being reported by the device could be totally different from the reality :)
Perhaps some brands charge a premium for a "long lasting" battery whose only actual difference from a regular one is a firmware hack that keeps it at %80 charge? Can I actually know this?
Long term battery degradation happens when its membranes degrade. There are hundreds of variables involved. Temperature IS a variable. But I'm reluctant to outright confirm what you're saying because it may be misleading. Avoiding plugging in when hot could help in some situations, but it won't help in all, so it's not a categorical rule.
Heat is a major cause of battery degradation, partially why I don't agree with constantly charging/discharging since it causes more heat.
Keep your laptop cool, perhaps even consider battery saving options while plugged in if you find it is generating too much heat.
Edit: A running laptop will cause heat, so shut it off when not using it. A plugged in laptop shouldn't create much more heat than a laptop running on battery power, if anything, the battery should be cooler when plugged in and fully charged (assumption made).
It'd be nice if the battery controller/charger had the intelligence to make these optimizations transparent to the end user. So present them with 100% or whatever, but in actuality, the battery is at 90%, most of the time it's plugged in, and so on.
I thought this was actually standard operating procedure for laptop batteries (or really, anything using lithium batteries). Similarly, 0% is actually more like 5 or 10%.
If you actually deep discharge a lithium battery to 0%, think they'll sometimes have problems taking a charge again. You see this occasionally when someone has taken to 0% on the meter, then let it self-discharge on the desk for a long time.
No. Leaving a battery at 100% is bad for the battery's life. Just as bad as deep cycling all the time. Even if your laptop is stationary, knock the charger out once a day and let it run on battery power for a bit.