|
"" posted:stuff about embedded system I forgot whats also funny Trying to optimize an embedded system dear god.. Running a profiler might show 70% of the time the program is in the "wait" function As in 70% of the time it was doing absolutely nothing Why you might say? Good question...
|
# ? May 17, 2011 12:39 |
|
|
# ? May 16, 2024 04:41 |
|
Melted_Igloo posted:Running a profiler might show 70% of the time the program is in the "wait" function Do you mean a function that just runs the processor at full blast doing nothing? Because there is nothing wrong with idling.
|
# ? May 17, 2011 13:01 |
|
Wheany posted:Do you mean a function that just runs the processor at full blast doing nothing? Because there is nothing wrong with idling. Well when you have data backed up in one processor and not getting sent to another processor (talking about an embedded system) then yes idling is sort of bad Actually - Any real-time system, idling is bad, because it should be doing something like making sure the system is still running and not crashing spectacularly although windows is pretty good at hiding all the background stuff going on I give it that, its actually pretty awesome how Windows works Melted_Igloo fucked around with this message at 17:06 on May 17, 2011 |
# ? May 17, 2011 16:28 |
|
Ryouga Inverse posted:This sounds great until you realize that it means you have to install Qt 3 and 4 side by side on any machine that you want to run Qt apps for an arbitrary amount of time, because there's always that one rear end in a top hat who wrote his poo poo for Qt 3 and then had the audacity to die or something. Qt is also good at not changing its API on a whim. Within a major version number, it remains forward compatible at a binary level (code compiled for Qt 4.2 will run with Qt 4.7). They only break things every few years with a new major version number. For open-source C++ libraries, that's pretty rare. I personally can't think of any Qt 3 apps still sitting around that I run, but I can imagine the scenario cropping up. That's life, basically, there's not a good alternative to having both sets of libraries sitting around.
|
# ? May 17, 2011 16:30 |
|
Jonnty posted:At the very worst, it's just old code that hasn't been taken out (I assume), but it doesn't sound like it's causing any active harm? I'd hardly call that a horror, just a bit overcautious. Unless it's checking for something that needn't be checked the first place. Well, unless Opera releases a version 50, at which point that code will enable the Opera 5 (now 80 years old) hacks. Doing stuff based on browser version strings is pretty much inexcusable.
|
# ? May 17, 2011 22:49 |
|
Unfortunately because the DOM is such a hosed up mess, trying to figure out what browser you're on is the best you're going to get in a lot of cases to see if the browser supports what you're trying to do. It would be great if the DOM had a 'supported' namespace so we could do 'if (browser.supported.elements.video)' but that's too much to handle for the W3C. So we have to do hosed up poo poo like if (document.createElement('video').canPlayType). Sometimes that doesn't even work (IE) so we have to do poo poo like Is it IE? Okay what version of IE?
|
# ? May 17, 2011 22:59 |
|
Even if there was a way to ask if the browser supports a feature, you'd still have to sniff the browser version to workaround the inevitable browser bugs.
|
# ? May 17, 2011 23:23 |
|
NotShadowStar posted:It would be great if the DOM had a 'supported' namespace so we could do 'if (browser.supported.elements.video)' but that's too much to handle for the W3C.
|
# ? May 18, 2011 00:14 |
|
OddObserver posted:It does. document.implementation.hasFeature. The actual feature granularity kinda sucks, though. This is actually really frustrating when looking online to find the best way to detect a certain kind of browser. "Best practice" has taken over the web and virtually every site you find says "oh don't do browser detection, do feature detection". Which is great if what you're trying to detect is whether a feature is supported or not. But despite the fact that we're in two-thousand-loving-eleven there are still behavioral differences between browsers that don't have anything to do with a DOM or script feature. It's obnoxious that web dev conventional wisdom has decided these cases no longer crop up anymore.
|
# ? May 18, 2011 01:48 |
|
NotShadowStar posted:Unfortunately because the DOM is such a hosed up mess, trying to figure out what browser you're on is the best you're going to get in a lot of cases to see if the browser supports what you're trying to do. http://www.modernizr.com/
|
# ? May 18, 2011 02:03 |
|
Monkeyseesaw posted:Which is great if what you're trying to detect is whether a feature is supported or not. But despite the fact that we're in two-thousand-loving-eleven there are still behavioral differences between browsers that don't have anything to do with a DOM or script feature. Sorry, I'm new to this: can you give an example? e: VVV Doc Hawkins fucked around with this message at 04:17 on May 18, 2011 |
# ? May 18, 2011 02:42 |
|
Because it is fresh in my mind, here's a discussion of keyboard input across the different browsers: http://unixpapa.com/js/key.html
|
# ? May 18, 2011 02:45 |
|
Doc Hawkins posted:Sorry, I'm new to this: can you give an example? Go try to implement the auto-expanding textboxes in Facebook, where the text can be round-tripped (typed->saved to disk->displayed all the same). You'll run into enough that you don't want to play anymore before you get one browser done. If you do manage to get one done, go paste a Word doc into it. WHAT THE gently caress (I know that's the way it's supposed to work ... now ... but man that poo poo was infuriating, because I was writing it for people who were going to do exactly that.
|
# ? May 18, 2011 04:08 |
|
Another input related one is Firefox notoriously caches input fields across multiple POSTs. This can be a huge pain in the rear end if, for example, dropdown selections determine a number of other JS-enhanced elements on the page and the drat events don't fire on reload in Firefox because the input fields are already "selected". The workaround isn't difficult but it's a case where no "if (window.blah)" can solve the problem. I've run into others involving subtleties in how some browsers fire off dependent HTTP requests when a user is navigating away from the current page; some browsers simply skip the request if it determines the response won't be useful. If you're trying to implement an internal JS analytics package that relies on sending that request it puts a rather sizable hole in your data aggregation and the only way to account for it is old-fashioned browser-sniffing Dr Monkeysee fucked around with this message at 05:54 on May 18, 2011 |
# ? May 18, 2011 05:49 |
|
Monkeyseesaw posted:Another input related one is Firefox notoriously caches input fields across multiple POSTs. This can be a huge pain in the rear end if, for example, dropdown selections determine a number of other JS-enhanced elements on the page and the drat events don't fire on reload in Firefox because the input fields are already "selected". This causes real issues in many places of Django's admin interface.
|
# ? May 18, 2011 06:38 |
|
A couple of points: Browser sniffing can help in doing workarounds for specific browsers for certain feaures. That is something we have to live with at the moment. What you should never use it for is blocking access to your site or placing a "gently caress you" banner on top of every page on your site (like Picasa does for Opera) My second point is: Opera has always been a marginal desktop browser, at least globally, meaning only "enthusiasts" (nerds) have installed it. So, from the 2% market share that all Opera versions have cumulatively, probably 80% are a reasonably current. (Numbers pulled out of my rear end, natch) So if you want to pretend that you support Opera, why would you check for Opera 5, and only Opera 5? It is literally over 10 years old and there are like 4 installations of it in existence on Windows 98 computers rotting on some attics somewhere. e: Opera's rendering engine has changed once since then (in 2003) and its JavaScript engine has changed twice. It's literally a different browser. So loving angry about Opera. Wheany fucked around with this message at 07:29 on May 18, 2011 |
# ? May 18, 2011 07:21 |
|
Monkeyseesaw posted:I've run into others involving subtleties in how some browsers fire off dependent HTTP requests when a user is navigating away from the current page; some browsers simply skip the request if it determines the response won't be useful. If you're trying to implement an internal JS analytics package that relies on sending that request it puts a rather sizable hole in your data aggregation and the only way to account for it is old-fashioned browser-sniffing I assume you've tried: code:
|
# ? May 18, 2011 10:34 |
|
Jonnty posted:So...the horror is that your app is too portable? In 2006 I had to make part of a web app work with IE 3. It only killed me a little on the inside.
|
# ? May 18, 2011 14:15 |
|
ColdPie posted:Well, unless Opera releases a version 50, at which point that code will enable the Opera 5 (now 80 years old) hacks. That Opera "fix" is the real coding horror here.
|
# ? May 18, 2011 15:38 |
|
Gotta submit my own horror of shamecode:
E: The real horror, however, is the web service receiving the import data having only a single method with a single string field as parameter. Containing an XML document, of course (But at least it wasn't me who designed this turd.) SirViver fucked around with this message at 16:28 on May 18, 2011 |
# ? May 18, 2011 16:12 |
|
HatfulOfHollow posted:That Opera "fix" is the real coding horror here. I prefer Opera's user agent to this: quote:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13 That is the user agent of Mozilla-AppleWebKit-KHTML-Gecko-Chrome-Safari. Just throw Internet Explorer and Trident in there for maximum compatibility.
|
# ? May 18, 2011 16:43 |
|
I found a home for you, date printer!code:
|
# ? May 18, 2011 17:09 |
|
I never liked January much, so I applaud that date printer for it's bold step.
|
# ? May 18, 2011 18:08 |
|
Fiend posted:
Why do people do this? What's wrong with: code:
|
# ? May 18, 2011 18:56 |
|
That has multiple exit points and everything must be SESE because structured programming will save us from the horrors of goto.
|
# ? May 18, 2011 20:04 |
|
I know nothing about Java so don't yell at me if the syntax is off, but surely this is better?code:
|
# ? May 18, 2011 21:15 |
|
It's usually hazardous to try to "Fix" horrors in these threads.
|
# ? May 18, 2011 21:25 |
|
Hammerite posted:I know nothing about Java so don't yell at me if the syntax is off, but surely this is better? The right thing to do is use your language's preferred date/calendar library for things like this, if possible, rather than do it yourself at all.
|
# ? May 18, 2011 21:53 |
|
Hammerite posted:I know nothing about Java so don't yell at me if the syntax is off, but surely this is better? Find/Replace 'printDay()' with 'DateTime.Now.ToString("dd.MMM.yyyy").ToUpper()'
|
# ? May 18, 2011 22:07 |
|
Wheany posted:I prefer Opera's user agent to this: And if you do navigator.appName, you'll get 'Netscape'.
|
# ? May 19, 2011 00:19 |
|
OddObserver posted:And if you do navigator.appName, you'll get 'Netscape'. Haha, that's like the cherry on top
|
# ? May 19, 2011 02:22 |
|
Fiend posted:Find/Replace 'printDay()' with 'DateTime.Now.ToString("dd.MMM.yyyy").ToUpper()' Well, "lines of code written per day" obviously isn't a performance metric where you work! That other guy is like 40x more productive than you.
|
# ? May 19, 2011 03:11 |
|
Hammerite posted:I know nothing about Java so don't yell at me if the syntax is off, but surely this is better? Replace every month with January and I think you've got it!
|
# ? May 19, 2011 03:20 |
|
Hammerite posted:I know nothing about Java so don't yell at me if the syntax is off, but surely this is better? If somebody wants to yell at me, I'm guessing it's C#. I don't know anything about it thought because my .NET frameworks always commit suicide.
|
# ? May 19, 2011 04:53 |
|
Zombywuf posted:I assume you've tried: We tried everything we could possibly think of. We also confirmed it was an issue in other analytics packages (including Google Analytics, who actually warn in their documentation not to rely on this specific kind of event). It's not standard HTTP behavior, the request just never fires. Given the edge-case nature of it my guess is it's some weird "optimization" in the request/response loop someone decided was a good idea at some point. Wheany posted:So if you want to pretend that you support Opera, why would you check for Opera 5, and only Opera 5? It is literally over 10 years old and there are like 4 installations of it in existence on Windows 98 computers rotting on some attics somewhere. What's particularly funny about this is Opera is literally the easiest browser to detect: if (window.opera). Though I don't know if this property was available 10 years ago. Dr Monkeysee fucked around with this message at 07:10 on May 19, 2011 |
# ? May 19, 2011 07:08 |
|
Monkeyseesaw posted:What's particularly funny about this is Opera is literally the easiest browser to detect: if (window.opera).
|
# ? May 19, 2011 09:08 |
|
Sedro posted:Why do people do this? What's wrong with: I'm only into my 3rd year of programming, but my college teaches us to not use multiple return statements and instead create a single variable at the top and return it at the end. Why exactly, I'm not sure, but I hear it's good form.
|
# ? May 19, 2011 09:25 |
|
enthe0s posted:I'm only into my 3rd year of programming, but my college teaches us to not use multiple return statements and instead create a single variable at the top and return it at the end. Why exactly, I'm not sure, but I hear it's good form.
|
# ? May 19, 2011 09:50 |
|
enthe0s posted:I'm only into my 3rd year of programming, but my college teaches us to not use multiple return statements and instead create a single variable at the top and return it at the end. Why exactly, I'm not sure, but I hear it's good form. It's only good form in cases where it improves readability. In cases like that, it's just stupid.
|
# ? May 19, 2011 09:50 |
|
|
# ? May 16, 2024 04:41 |
|
enthe0s posted:I'm only into my 3rd year of programming, but my college teaches us to not use multiple return statements and instead create a single variable at the top and return it at the end. Why exactly, I'm not sure, but I hear it's good form.
|
# ? May 19, 2011 09:50 |