back to article 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 …

  1. WolfFan Silver badge

    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.

    1. mythicalduck

      comparing a variable to itself isn't a problem?

      Sure it is, but it's not "2 errors" like that screenshot suggests. The first is an error, the "second" is a suggested solution.

      I don't know if it's intentional, but it certainly makes the "error count" ambiguous IMO

      1. Ian Bush
        Boffin

        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.

        1. Brewster's Angle Grinder Silver badge

          "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.

      2. 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.

        1. hellwig Silver badge

          re: Assembly

          Did you mean:

          AND R3,R3

          JEQ <blah>

          ?

          Because CMP R3, R3 always sets the zero flag, whether R3 is zero or anything else.

          I believe AND is more efficient than CMP (for x86 at least), which is why it's a faster way to check for zero.

        2. Dagg

          >> CMP R3,R3

          Ahh, the joys of MACRO-11

          You could also do

          CMP R3,R3

          JZ somewhere

          or

          JNZ

          There was also TST R3 which did the same as CMP

      3. Edward Benson

        @mythicalduck : The 2 errors means there were 2 errors of this category found ("Same Code is Written to the Left and Right"), and the screen shot shows one example.

    2. Whitter
      Boffin

      NaN

      A bit of pedantry which has nothing to do with the error in the article: comparing a variable to itself isn't always madness, as it is a specific property of floating point NaN values:

      x= NaN

      y = x

      x != y

      1. 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.

        1. 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.

    3. 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.

  2. Jonimus
    WTF?

    Reminds me of the reports I've heard of EFL's code quality as seen in one of the more famous Daily WTF posts https://what.thedailywtf.com/topic/15001/enlightened/2

    1. Dan 55 Silver badge

      This link is obligatory Samsung/Tizen reading. If you have a Samsung smart TV and you haven't disconnected it from the Internet after reading that, then you deserve whatever it that happens to you.

    2. 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++)

      1. Dan 55 Silver badge

        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.

  3. John Smith 19 Gold badge
    Unhappy

    I had not heard of Tizen before

    And it does not look like I'll be hearing about it again.

    1. a_yank_lurker Silver badge

      Re: I had not heard of Tizen before

      If the bugginess is as bad as stated you will be hearing of Tizen at least indirectly as Samsung uses it in many different devices.

      1. Steve Davies 3 Silver badge

        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.

        1. Charlie Clark Silver badge

          Re: I had not heard of Tizen before

          If they are serious about ditching Android

          They're not. They found that Android's requirements were too much for some devices and wanted something with a smaller footprint and already had a homegrown OS.

          1. 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.

            1. Aladdin Sane Silver badge

              Re: Google's become much more prescriptive about Android's look/behaviour

              Because Touchwiz is fucking awful.

        2. Avyerino

          Re: I had not heard of Tizen before

          Translate it: http://samtizen.blogspot.ru/2017/06/samsung-tizen-os.html

    2. I ain't Spartacus Gold badge
      Happy

      Re: I had not heard of Tizen before

      You can tell it's Tizen when your eyes are shut!

  4. Stuart Halliday

    Still living in the 20th Century where they think they can dish out as much shite as they want.

    But nowadays there's educated customers who know when a company is pulling a fast one.

    We'll just need to inform our clients what we think of their devices.

  5. Herby Silver badge

    40 zero-days??

    Looks a bit excessive if you ask me. Similarities to Swiss cheese come to mind.

    1. Brenda McViking
      Trollface

      Re: 40 zero-days??

      Come now, 40 zero days isn't that excessive - Let's not forget that a 7 year old kid could find that many in an hour in Flash, and they've been fixing that for over 20 years!

  6. MNGrrrl
    Trollface

    Translation

    "We don't have a problem and we're working to fix it as quickly as possible." -- Samsung, Creator of the Self-Immolating Phone

  7. Sgt_Oddball Silver badge

    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.

    1. Voland's right hand Silver badge

      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.

      1. Sgt_Oddball Silver badge

        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.

  8. Anonymous Coward
    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???

    1. Anonymous Coward
      Anonymous Coward

      Re: extremist well.

      An AC talking about hidden agendas? Like it!

      (It is a joke, right?)

      1. Voland's right hand Silver badge

        Re: extremist well.

        An AC talking about hidden agendas? Like it!

        An AC commenting on it should qualify as a double entendre.

  9. Anonymous South African Coward Silver badge

    Good to know, will make sure to avoid all Sagsmug Tizen products in future.

    Rather stick with Android for now, until they sort out the fun and games in the Tizen code.

  10. Anonymous Coward
    FAIL

    Samsung didn't really care about security and tried to rush Tizen to the market ASAP

    Shouldn't be surprising: this is what Samsung does with every product it makes.

  11. Anonymous Coward
    Anonymous Coward

    So, worst code ever?

    I reckon Windows 10. All of it.

    1. werdsmith Silver badge

      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.

    2. 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.

  12. tony2heads
    Megaphone

    What Would Linus Say!

    They need a leader like Linus Torvalds who will take no crap code, and will let then know it VERY LOUD

  13. Anonymous Coward
    Anonymous Coward

    I've seen worse:

    10 GOTO 10

  14. JimmyPage Silver badge
    Boffin

    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

    1. 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.

  15. Anonymous Coward
    Anonymous Coward

    Just stop

    Sammy, you have been writing shitty software for years, 99.999999% if which nobody wanted or used or liked (think TouchWiz, Samsung Store, Bixby). Please just stop writing software. You are no good at it.

    1. stephanh

      Re: Just stop

      Special mention for "Samsung Kies".

  16. Anonymous Coward
    Anonymous Coward

    'Worst codebase he's ever seen'? He should work where I do (posted anonymously for obvious reasons)

  17. 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...

    1. WolfFan Silver badge

      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?

  18. 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/

  19. weetechsolution

    My qouestion:- How to take a screenshot Programmatically and download it in png format?

    I have an Tizen app in which i put one background image and one text view on that backgroung. So, i want to merge both view and make png image which user can download.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2019