comparing a variable to itself isn't a problem? O-kay. I didn't make that kind of error back when I was first learning to code <mumble> years ago. Hint: I was using the then spanking new FORTRAN77 super language, though the school used punch cards as it didn't have a computer with terminals the year I started. It acquired a Prime shortly thereafter, with real terminals, and we stopped using the punch card machine. I used old cards as bookmarks for years (okay, for decades, I had a lot of the things) afterwards.
Good news: Samsung's Tizen no longer worst code ever. Bad news: It's still pretty awful
Samsung's Tizen appears to have more holes than a screen door, but the mobile operating system, which powers Samsung watches, TVs, and a few phones, may not be as disastrous as it seems. It does look bad. According to Andrey Karpov, founder and CTO of Program Verification Systems, the Russia-based maker of static code analyzer …
COMMENTS
-
-
-
Thursday 13th July 2017 08:41 GMT Ian Bush
There have been legitimate uses for comparing a variable to itself - in particular under IEEE754 all comparisons that have a NaN as one of the operands return false, so checking for equality of a variable with itself was a way of detecting whether the variable held a NaN. Unfortunately optimising compilers used to think "what is this idiocy" and throw it away, hence many languages contain a isNaN function or similar.
-
Thursday 13th July 2017 12:18 GMT Brewster's Angle Grinder
"Unfortunately optimising compilers used to think "what is this idiocy" and throw it away, hence many languages contain a isNaN function or similar."
When I was a much younger programmer, I, *ahem*, deleted a bunch of NaN checks. For that reason, I always add a comment when writing expressions like
if ( !( x >= 0) ) etc;
.That said, you probably don't want infinity either, so doing a check for non-finite numbers is easier and less prone to destruction by compilers and novice programmers.
-
-
Thursday 13th July 2017 09:36 GMT ForthIsNotDead
In assembly language we compare registers to themselves all the time to see if they're zero or non-zero, as it sets the flags in the status register...
CMP R3,R3
JEQ somewhere \ if r3=0 then jump
Just sayin...
Aint gonna help the poor guy who wrote that code, though. Yes, it's just a typo, or, possibly the result of pressing enter too quickly with a code-completion type editor.
-
-
-
Thursday 13th July 2017 10:37 GMT PVS-Studio
Re: NaN
PVS-Studio analyzer knows about these situations and doesn't issue the warnings for some float/double comparision. Its logic is quite complicated. The names of variables, functions, comments are taken into account. This is the attempt to guess if the check is performed on NaN or it's just a typo.
-
Thursday 13th July 2017 13:20 GMT Kristian Walsh
Re: NaN
Just to state it clearly, the NaN test exemption doesn't apply to the code fragment shown in the article, as the expression shown in that code, "(x>x)", is never true for any type or value of x, NaN or otherwise*
* unless you overload operator>() to do something unrelated to testing for greater magnitude... In whcih case, I will find you and I will do bad things to you.
-
-
-
Thursday 13th July 2017 12:26 GMT Wensleydale Cheese
"the school used punch cards as it didn't have a computer with terminals the year I started.
...
I used old cards as bookmarks for years (okay, for decades, I had a lot of the things) afterwards."
Punch cards were also excellent for shopping lists.
Unfortunately I never managed to snaffle as many as you did.
-
-
-
Thursday 13th July 2017 20:00 GMT patrickstar
To be fair, a lot of the main complaints about Enlightenment there can basically be summed up as "I don't like this GUI toolkit and it doesn't do stuff the way I'm used to. Also, I want it to be in C++!".
You could write something substantially similar about any GUI toolkit... they're pretty much all horrible. Just that if you're lucky you can learn to live with the horrors of one of them, and possibly even begin to like it (known as Stockholm syndrome).
Samsung seems to have some cultural issues though. As well as issues with their Tizen codebase (the example in this article most definitely isn't from Enlightenment - one of the posters complaints is that they refuse to use C++)
-
Friday 14th July 2017 18:48 GMT Dan 55
Not only do they not use C++, but they insist on an object orientated-like toolkit in C.
This is possible, but they decided not to use types, only void *s. This makes development slow and bug prone. It's pretty much the worst way you could choose to implement a toolkit.
You might complain about Qt but it's lightyears ahead of ETL.
Other posts on the same site say that Samsung management ignore non-Koreans and they use Excel spreadsheets to diff source code. Their working culture is pretty bad.
-
-
-
-
Thursday 13th July 2017 05:41 GMT Steve Davies 3
Re: I had not heard of Tizen before
If they do insist on using then the hackers will find a nice fat juicy target waiting for them.
If they are serious about ditching Android and going with Tizen in the competition with iOS (in all its guises) then Samsung need to spend all that mega profit that they are making on it before it can be considered a serious contender. Unfortunately, we'll probably see more devices using Tizen before it is ready.
Yes, the same can be said for both iOS and Android at the start but I think the gadget buying public have moved on a bit since then. If these devices turn out to be crap then Samsung will have to take the hit.
For me it is just another reason to avoid Samsung when considering a purchase.
-
-
Thursday 13th July 2017 11:03 GMT fuzzie
Re: I had not heard of Tizen before
Full Android is too heavy for "feature" phones and getting increasingly bloated for even entry-level handsets. Google's Mobile Services ODM agreement prevents them from using AOSP for those. In addition, Google's become much more prescriptive about Android's look/behaviour, diluting Samsung's look'n'feel and attempts to build their own services infrastructure.
Tizen's trying to pull off the consortium development model of Symbian, but from that I can tell it's only seen real action in Samsung wearables, TVs and a handful of phones.
I strongly believe we need competition for Android, but it's a long and tiring road, as Jolla with SailfishOS also discovered.
-
-
-
-
-
Thursday 13th July 2017 06:43 GMT Sgt_Oddball
and this is why...
I'd generally much prefer a dumb device if I'm going to hang onto it for a while. Like a tv for example (though I've found a way to solve that. Large monitor with hdmi but I digress). Putting a poorly supported OS into anything then giving it internet access is asking for trouble.
-
Thursday 13th July 2017 07:19 GMT Voland's right hand
Re: and this is why...
Then dumbify it.
My smart TV is hooked up as a monitor to a small HP microserver upgraded with a decent video card (35-40W power consumption). All the smarts are in the server. So is half (5TB) of the content.
All the "smart" devices in the house sit on a subnet hanging off the server and are firewalled off the Internet. They get cut-down DNS, NTP addresses and that is it. Nothing more without approval.
I like it this way and it will stay this way until the consume electronic manufacturers relent on their idea of "socializing" all of my media via their smart TV interface. My media ideas are distinctly antisocial and I would like them to stay that way.
-
Thursday 13th July 2017 12:00 GMT Sgt_Oddball
Re: and this is why...
I've got a similar system set up at home (hacked nowTV box running plex client which is served by my test/dev/pissing around with server running esxi). I also did the same to said microserver for my parents (though only 3TB of storage plus it runs backups for them, though it does have the borg cube sticker set on it because they're slightly bigger geeks than me).
But as for the average punter' this is probably beyond them or their comprehension (since it's a TV it should just work no?) so not everyone has this option.
-
-
-
Thursday 13th July 2017 07:04 GMT Anonymous Coward
Hmmmmm
"Tizen at least matches Google's mobile operating system in terms of disorganization"
How so? Android project seems to be run extremist well. Meeting all its release goals, and delivering a stable and robust operating system.
Are those hidden agendas starting to show through again???
-
-
Thursday 13th July 2017 12:47 GMT werdsmith
Re: So, worst code ever?
I've never managed to get a look at the WIn10 source, so I can't comment.
However, when I see the claim "worst code ever" I am always sceptical because I know that there is still plenty of my own code out there working away in various places. It was definitely the worst ever.
-
Thursday 13th July 2017 21:37 GMT patrickstar
Re: So, worst code ever?
Like I always write here when people go all "MS code must be so ugly herp derp I eat paste!!11": I have read a lot of MS code. It's certainly not worse than anything else. Certainly mixed quality like any big codebase with a long history, but OTOH some parts (like the kernel) are really, really good to compensate for the eyesores.
-
-
Thursday 13th July 2017 10:50 GMT JimmyPage
Is it my age ?
First off, the example shown is *not* "comparing a variable with itself", it's returning the result of comparing a variable with itself.
Second off, that's not as crazy as it seems ... I have memories of such tricks being used to stand in for "return 1;" or "return true;" - particularly if you want to obfuscate assembler.
Thirdly (although it is BAAAAAD) practice, bear in mind that in some situations/languages, referencing a variable can actually run code (which could change the value of something somewhere).
All of that said, part of writing good code is it should make intuitive sense, which doesn't really apply in those 3 situations
-
Thursday 13th July 2017 12:51 GMT stephanh
Re: Is it my age ?
In assembler this makes sometimes sense, "cmp eax, eax" sets some flags to a known state. However, in a higher-level language "x==x" just gets optimized away to 1 (unless it is a floating-point type, in which case as already mentioned "x != x" is equivalent to (but less obvious than) "isnan(x)").
In assembler, we also had tricks like "xor eax, eax" as the shortest and fastest way to set register eax to 0. But in C, it makes little sense to write "x ^= x"; the compiler knows all these tricks and then some.
-
-
Friday 14th July 2017 09:41 GMT Cursorkeys
A good thread about this on TheDailyWTF
There is a wonderful thread by a Sammy programmer on The Daily WTF Forums about EFL (the software framework under Tizen), if you know even the basics of programming it's hours of entertainment:
https://what.thedailywtf.com/topic/15001/enlightened
As a wonderful bonus Carsten Haitzler himself appears on page 5 to defend his baby. He promptly goes full pants-on-head; shortly afterwards the forum is banned on the Samsung Intranet.
We also find out that "BITCH" and "NAUGHTY PROGRAMMER!!! SPANK SPANK SPANK!!!" are totally normal messages for professional software to produce...
-
Friday 14th July 2017 18:42 GMT WolfFan
Re: A good thread about this on TheDailyWTF
Oh. My. God.
I just sampled that (very long!) thread. The only place I've seen crap on the level of that perpetuated by Carsten Haitzler (and that just has to be a nym...) is deep, deep, DEEP in the bowels of talk.origins, when the creationist cretins get caught lying their behinds off (again) and tie themselves into (bigger) knots trying (and failing) to justify their idiocy, and even they can't quite match this. This boy can't actually be a professional coder... can he? Please tell me that he was only joking... Even Ray (No True Scotsman) Martinez isn't as bad as Haitzler, and Ray thinks that Pope Francis is an atheist 'cause El Papa's version of Christianity isn't an exact match to Ray's. (Yes, I'm serious. Ray thinks that Pope Francis is an atheist. Really. Actually, all Popes, possibly reaching as far back as Peter, are/were atheists 'cause they disagree(d) with the One True Authority on All Things Christian. Kinda like anyone who disagrees with Carsten Haitzler is a naughty programmer who should be spanked.)
How is it that Tizen just doesn't collapse of its own weight?
-
-
Wednesday 26th July 2017 18:44 GMT PVS-Studio
Our team wrote three articles related to the code analysis of Tizen operating system. The operating system contains a lot of code, so this is the reason why it is a fertile ground for writing different articles. I think that we will go back again to Tizen in future, but right now other interesting projects are waiting for us. So, I will sum up some results of the work done and answer a number of questions that have arisen after the previously published articles. Tizen: Summing Up - https://www.viva64.com/en/b/0522/
-
Thursday 13th February 2020 06:33 GMT jswitte3416
Tizen in 2020?
Now that it's 2020 - have things changed in the past 3 years? I see one article that opined that Tinzen was dead in 2018 ("Samsung Gear S4 with Wear OS: Tizen is dead" (2018) ; https://www.slashgear.com/samsung-gear-s4-with-wear-os-tizen-is-dead-24531830/). Then I see another that it dominates the Smart TV space with 21% in 2019 ("Samsung’s Tizen OS dominates global smart TV market" (2019); https://www.fiercevideo.com/video/samsung-s-tizen-os-dominates-global-smart-tv-market).
Has the culture at least with regards to "testing is irrelevant" changed?