• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Massa

Member
"Numerical Computing with IEEE Floating Point Arithmetic" is a fantastic book on the topic, quite short and easy to read. I highly recommend it to all programmers.
 

Koren

Member
I see. But the issue is that Windows will forbid you to remove the file as long as there's someone "using" it. It can be an unclosed file descriptor somewhere, or something like this. There's no easy way around it, the first task would be to

Actually in this case, i think the issue is you need to use shutil.rmtree to remove a directory tree. os.remove doesn't work for directories, and os.rmdir only works for empty directories
 

komplanen

Member
Programming is about encountering difficult problems and solving them. You can have something explained to you 100 times, but until you've encountered it yourself it doesn't really sink in.

Presumably your teacher has explained about imprecise represntation of floating point. Now you have an actual experience to back that up

Very insightful thought and I agree with you 100%. This isn't that though. This course I'm taking is practically Baby's First Programming course. I've done this with C# and Java and now I'm doing it with C. There's no computer science theory at all. Just syntax. No teacher either as this is a text only summer course. No explanations like what's the difference between floats and doubles or even basic stuff like unsigned versus signed values. It's literally just the absolute basics.

That's what really threw me off here. I'm 99% there's a mistake in the task's expected output either by design or their compiler does something different now than it used to.

I am now of course reading about the float accuracy stuff because I actually want to know :)
 

Koren

Member
Actually in this case, i think the issue is you need to use shutil.rmtree to remove a directory tree. os.remove doesn't work for directories, and os.rmdir only works for empty directories
Good catch, but what had me is that os.remove on a directory return "Access denied", if I'm not mistaken, and not "File being used". There may be two issues there?

It's literally just the absolute basics.
Want to take chances he thinks %.1f display the truncated value and not the rounded one? ^_^

I am now of course reading about the float accuracy stuff because I actually want to know :)
Good luck ^_^ That's an interesting subject (and things a programmer should know if he deals with fp values) although sometimes it's insanely complicated.

I don't even think there's an obvious benefit of using the "ties to even" rule on decimal values...
 

Kansoku

Member
The math discussion was interesting, because I'm having problems with something similar right now. I asked here before about Python image processing libraries, and I'm having a hard time understanding some parts of the article I'm trying to replicate. This in particular:

Nncdwap.png


The problem is less what a symbol means (though I still don't know what "i_1, i_2 ... i_k" are, and they haven't appeared before in the article), and more understanding what the fuck is happening, like what c and I\c are in relation to the image and/or hue circle, or why they are getting the hue h() of c, or the use of i in max i ∈ c h_i(c).

I imagine it would be easier to everyone if, at least in addition to the math definition, people write stuff in plain english, or maybe pseudo code for more algorithmic stuff.
 

Koren

Member
I imagine it would be easier to everyone if, at least in addition to the math definition, people write stuff in plain english, or maybe pseudo code for more algorithmic stuff.
Anyone can write awful an unreadable formulas, unfortunately (and I grant you that this set is complex... there's even mess with indexes and exponents).

That being said, I'm not sure using an english sentence instead of "argmax" is better. And at the end, the thing that bothered me most is actually a sentence, the "adjacent groups" (OK, that's also because the "formula" that explain the idea is awful).

I think that the main problem here is that
- it doesn't explain what the hue histogram on a neighborhood of the pixel is
- the fact that they factorized two things into a single formula (hue AND gradient)
doesn't help.

Most of those issues come from the fact that articles like this are length-constrained, it's often awful to put a whole method in 4, 8 or 10 pages, including state of art, tests, bibliography, etc :/

Do you want pseudo-code for this?
 

Koren

Member
Wittgenstein helped us understand that language is imprecise and the only hope is precise, artificial languages. That's what math is!
Math can be imprecise, too (and in this case, it is... at the very least, the double usage of index k in the definition of adjacent groups is awful, I think)
 

Kansoku

Member
Anyone can write awful an unreadable formulas, unfortunately (and I grant you that this set is complex... there's even mess with indexes and exponents).

That being said, I'm not sure using an english sentence instead of "argmax" is better. And at the end, the thing that bothered me most is actually a sentence, the "adjacent groups" (OK, that's also because the "formula" that explain the idea is awful).

I think that the main problem here is that
- it doesn't explain what the hue histogram on a neighborhood of the pixel is
- the fact that they factorized two things into a single formula (hue AND gradient)
doesn't help.

Most of those issues come from the fact that articles like this are length-constrained, it's often awful to put a whole method in 4, 8 or 10 pages, including state of art, tests, bibliography, etc :/

Do you want pseudo-code for this?

I think the end is a good exemple of the use of both. It "explains" that it's a sum and show it trough the formula. Ideally this would happen with everything. There stuff that's kinda harder to explain, such as formula (2), but that itself doesn't need much explanation. What bothered me the most was the definition of c and I\c and formulas (3).

But yeah, it is something common in articles. I don't understand why constrain the length of an article. To me an article is supposed to show what lead the person to try X, a quick contextualization of what already has been done in the area and then explain X. If I can't understand X, what value the article has to me? I imagine if I already worked in the area, and been following progress on the problem, understanding this wouldn't be a problem. But for someone who is starting in the area, it is really frustrating.

Anyway, yeah a pseudo-code would help immensely.
 
Good catch, but what had me is that os.remove on a directory return "Access denied", if I'm not mistaken, and not "File being used". There may be two issues there?.

os.remove is probably implemented with the DeleteFile win32 api. It doesn't say on the documentation what error code it returns if you try to delete a directory, but ERROR_ACCESS_DENIED wouldn't suprise me one bit, it gets used more than it should
 

Koren

Member
What bothered me the most was the definition of c and I\c and formulas (3).
I agree... that's what I was talking about "adjacent groups", and the " i_{k+1} = i_k +1 mod 8 ". It's really misleading.

If I'm not mistaken, the idea is easier to understand with a picture:
3_8ths_circ_gr_sm.gif


If you have a circular table with 8 cell, the idea is to split it into two differents non-empty parts, with adjacent parts. There's 28 possible splits if I'm not mistaken.

c refer to the green part of the pie, I to the entire pie, I \ c to the entire pie minus the green part, so the white part.

I don't understand why constrain the length of an article.
Depends... More pages are more expensive. Often, you CAN add pages, but you'll pay for them (when the normal number of pages is "free" if your article is selected).

There's conferences where you can choose the number of pages, but the number of pages is included in the reviewing process: you have to be short.

Usually, I'd say that articles are not the best place to give all the details for an algorithm. There's better places for this: webpages (with code), "magazines", books, thesis... The idea of an article is to convey the ideas with enough details to be able to redo the experiments if you have enough time to think about it.

If I can't understand X, what value the article has to me?
Pretty sure you can, but you may need to have some experience in the field. Should you really not understand something, the mail of the authors is there for a reason...

But for someone who is starting in the area, it is really frustrating.
I know, I went through this, but I found installing libraries and dependancies like Boost far, far more bothering than any research paper ^_^

Anyway, yeah a pseudo-code would help immensely.
With a grain of salt, I may have misunderstood:

In case you're working with gradients:
Code:
for each (x, y) pixel
  create a table T of size 8, initialized with 0
  
  for each (x', y') pixel close to (x, y)
    Compute the direction of gradient at (x', y')
    Add 1 to the table in the cell corresponding to the
     direction (N, NE, E, SE, S, SW, W, NW) of the gradient
  
  for a in 0..6
    for b in (a+1)..7          (<- for all partitions of the table)

      find the highest value *h1* in T[a:b)
        and the index *i1* of the corresponding cell 
  
      find the highest value *h2* in T but not in T[a:b)
        and the index *i2* of the corresponding cell 
  
      compute v[a,b] = exp(-abs(h2-h1)) * abs(i2-i1)
  
  return the minimum among all values v[a,b]

If you're working with hue, it's the same, except that N, NE, E... is the direction in a hue circle (not sure I'm clear?)


Edit: an image would probably be useful:
color_wheel.gif

each cell correspond to one of the eight colors, you just count the pixels in the neighborhood that fall into each of those colors to build the table T.


________________________

A quick'n dirty Python:

Code:
from operator import itemgetter

def DualIndexAndMax(table, rng) :
    return ( max( (e for e in enumerate(table) if e[0] in rng), key=itemgetter(1)),
             max( (e for e in enumerate(table) if e[0] not in rng), key=itemgetter(1)) )
Take a table and a range, and return (i1, h1), (i2, h2)
where h1 is the highest value of table among indexes in the range, and i1 the corresponding index
and h2 is the highest value of table among indexes NOT in the range, and i2 the corresponding index

Code:
def GenRanges() :
    for a in range(7) :
        for b in range(a+1, 8) :
            yield range(a, b)
A generator that will give all ranges corresponding to the 28 partitions of the circular 8-cell table

Code:
from math import exp

def GenValues(table) :
    for rng in GenRanges() :
        ((i1, h1), (i2, h2)) = DualIndexAndMax(table, rng)
        yield exp(-abs(h2-h1))*abs(i2-i1)
A generator that yield all the values of formula (2) for all partitions of the circular 8-cell table

Code:
def DealWithTable(table) :
    return min(GenValues(table))
A fonction that return the minimum

So, you have to:
- check everything is correct
- check again!
- fill the blanks, which is :
Code:
for each pixel (x, y) :
    compute T for the pixel (x, y)
    call DealWithTable(T)
    add the result to an accumulator
(you have to choose a neighborhood, compute gradients or hue on each pixel in it, and fill T)


Then probably rewrite this so that it's more efficient. It'll be very slow for a big image, but at least, you can check if it's working. I'm see some possible optimization for the computation part, but they're not trivial.

The first thing to do, obviously, is to compute hue/gradient only ONCE for each pixel.
 

Koren

Member
os.remove is probably implemented with the DeleteFile win32 api. It doesn't say on the documentation what error code it returns if you try to delete a directory, but ERROR_ACCESS_DENIED wouldn't suprise me one bit, it gets used more than it should
I just checked, os.remove on an empty directory indeed return winerror 5 (access denied) and not winerror 32 (file in use).

So if he gets winerror 32, I'd say there can be another issue than just the improper use of os.remove?

It's a precise language imprecisely used :)
I'll grant you that, but you can get the same precision with natural language since you can always describe precisely the mathematical notation in natural language ^_^ (although it's tricky... I've had a blind student in my math class when I was a student, we had to precisely describe every equation, that was difficult and exhausting, but also a great exercise, in fact).
 

NetMapel

Guilty White Male Mods Gave Me This Tag
Actually in this case, i think the issue is you need to use shutil.rmtree to remove a directory tree. os.remove doesn't work for directories, and os.rmdir only works for empty directories
Alright thanks guys. I will see if shutil.rmtree works and report back when I can :) let's say in directory /test/ there are multiple folders all with files contained within. Call them folder A, B... Etc and I want to get rid of /test/B. So shutil.rmtree('/test/B/') should hopefully work then?
 

Koren

Member
Alright thanks guys. I will see if shutil.rmtree works and report back when I can :) let's say in directory /test/ there are multiple folders all with files contained within. Call them folder A, B... Etc and I want to get rid of /test/B. So shutil.rmtree('/test/B/') should hopefully work then?
I'd rather use shutil.rmtree('test/B/') after being sure you're in the correct directory... Why an absolute path?

Especially on Windows where absolute path are not completely absolute if you omit the drive.

And be really, really, really careful, you work without safety net, you won't see "Are you sure you want to delete everything on the disk Y/N?"...
 

Koren

Member
Dude thank you so much. This is super helpful. I actually understand now.
I hope I'm not wrong, but if It can help, I'm happy...

Just one more thing that wasn't super clear, the gradient direction and the part of the hue circle are interchangeable?
They give different estimation of "harmony" in the picture... harmony of color and harmony of "directions". I haven't read the full paper, but I think they use both.

But yes, you can use anyone you want, depending on what you're after. In fact, you can probably compute several gradients (one for each color channel, at least).


Edit: now that I think about it, I'm wondering what you do when the neighborhood of a pixel only have white/gray/black pixels, for which the hue is undefined, or when the gradient norm is null... There's some holes in the algorithm you'll have to fill :/
 

Koren

Member
Transition from Java to C++, how difficult is it?
Depends on you, and which parts of C++ you'll want to use (it's quite huge).

I'd say "not that difficult", but you may not like the changes if you're fond of Java (it's the opposite for me), and when you don't like something, everything seems more tedious.

I reckon the pointers and the lack of auto garbage collection will be tough.
Not really, if you jump directly into C++X11 (or 14) and intelligent pointers.

Pointers will behave correctly, and you'll get the equivalent of "garbage collecting". Any data that isn't referenced anymore will be freed without anything from you... it's not garbage collecting per se, because the freeing is done AS SOON AS the pointer is "destroyed", not later when the language see it fit (I actually prefer it this way, myself).
 

Kansoku

Member
Edit: now that I think about it, I'm wondering what you do when the neighborhood of a pixel only have white/gray/black pixels, for which the hue is undefined, or when the gradient norm is null... There's some holes in the algorithm you'll have to fill :/

They convert the image to HSV before, so I would guess they would divide the values, as in divide the values from 0 to 255 (or however many bytes is used to represent HSV) in 8 groups.
 

Koren

Member
They convert the image to HSV before, so I would guess they would divide the values, as in divide the values from 0 to 255 (or however many bytes is used to represent HSV) in 8 groups.
But the H value has no meaning if S=0 or V=0... It works, but I don't like the bias it add...
 
If anyone could help me understand a couple questions about this code it would be greatly appreciated. Thanks.

1) Why isn't largest_area set to -1.0 the second time the function is called?
2) When you run the program a second time, will it remember the largest area from the previous run? Why or why not?


Code:
   #include <stdio.h>
    #define PI 3.141592654
 
    double area_of_circle( double radius )
    {
            static double largest_area = -1.0;
            double area;
 
            area = PI*radius*radius;
            printf("The area is %lf\n",area);
 
            if( area > largest_area )
            {
                  printf("This is the largest area so far!\n");
                  largest_area = area;
            }
            else if( largest_area > -1.0 )
            {
                  printf("I've seen bigger circles\n");
            }
            return( area );
    }
 
    int main()
    {
            area_of_circle(1.0);   
            area_of_circle(5.0);
            area_of_circle(2.0);
            return 0;
    }
 

Koren

Member
1) Why isn't largest_area set to -1.0 the second time the function is called?
If the question is about the reason, it's because the idea is to remember the largest area ever encountered by the program.

It is set to -1.0 so that the first circle is always the largest ever seen (area is always >=0)

If the question is about the "how", id est why the initialization is done only at the first call, see below...

2) When you run the program a second time, will it remember the largest area from the previous run? Why or why not?
In one run of the program, it'll remember the value from the last call.

When you use the "static" keyword before a variable declaration in a function, the variable isn't destroyed at the end of the function, but lives till the end of the program. The initialization is only done when the variable is created, so during the FIRST call of the function.

In a sense, it's a bit like a global variable defined outside of the function, but which can only be seen inside the function...

But if you run the program several times, the whole memory is cleared, including the static variables, so no, it won't remember the largest circle of a previous run.

BTW, the
Code:
else if( largest_area > -1.0 )
could simply be
Code:
else
since during the first call the area WILL be > largest_area (= -1.0) so the "then" clause will be used, and after that, largest area will always be > -1.0

Also,
Code:
#define PI 3.141592654
is a bad idea that will bring issues, you'd better use
Code:
const double PI=3.141592654;
 
I'm guessing some people here has seen that Quora post where somebody asks how to print:



and a lot of people give him really inane answers that are technically right. Well I recently figured out that my Organization of Programming Languages professor is the top comment.

https://www.quora.com/Homework-Ques...-program-that-produces-the-following-output-1

Some of these responses are really great.


A lot of those answers seem... way more complicated than need be?
 

Two Words

Member
What's a good simple program I can do that will help me apply what I'm learning in Linear Algebra? I don't know if doing some sort of 3D stuff would be simple enough because I've never done anything like that before, but maybe it is simpler than I'd expect. I guess I'm looking for an example where I could solve a certain problem using the stuff in Linear Algebra that maps to a context outside of Linear Algebra. Like, not just mapping one vector subspace to another through a linear transformation. But something that will allow me to use that skill to answer something useful.
 

Makai

Member
What's a good simple program I can do that will help me apply what I'm learning in Linear Algebra? I don't know if doing some sort of 3D stuff would be simple enough because I've never done anything like that before, but maybe it is simpler than I'd expect. I guess I'm looking for an example where I could solve a certain problem using the stuff in Linear Algebra that maps to a context outside of Linear Algebra. Like, not just mapping one vector subspace to another through a linear transformation. But something that will allow me to use that skill to answer something useful.
Rotate a sphere by dragging with the mouse. Have it not freak out when you go over a pole.
 

Two Words

Member
Rotate a sphere by dragging with the mouse. Have it not freak out when you go over a pole.
I'm not entirely opposed to it, but that would require me to learn how to create 3D objects and have them interactable with a mouse. I've never done that. What is a good platform to do something like this?
 

Makai

Member
I'm not entirely opposed to it, but that would require me to learn how to create 3D objects and have them interactable with a mouse. I've never done that. What is a good platform to do something like this?
Unity would be trivial

https://docs.unity3d.com/ScriptReference/GameObject.CreatePrimitive.html
https://docs.unity3d.com/ScriptReference/Transform.html
https://docs.unity3d.com/ScriptReference/Input.GetMouseButton.html
https://docs.unity3d.com/ScriptReference/Input-mousePosition.html
 

Jokab

Member
Anyone have experience setting up Coverity for an internal build system? I'm having trouble with it not finding any source code even though the logs look like it's capturing the compile commands.

Figured I'd throw the question out before writing up something longer.
 

Ambitious

Member
*snip*

Last week, I applied at company B. And B is simply amazing.
In terms of employee count, it's way bigger than A, but they nonetheless have some kind of startup vibe. Young, dynamic/agile, enthusiastic, skilled people full of bright ideas. Again, a very personal culture. Truckloads of perks. Many, many learning opportunities. Flexible work times. Many team events (barbecues, cinema, sports, ...).
In fact, in the last three years, they won a prestigious "Most Popular Employer [of the country]" award.

In terms of technology, they too are focused on Java, but they also use a lot of other extremely interesting stuff. I'd love to learn so much of it. Their set of preferred tools and technologies is seriously attractive. And their project portfolio is very diverse, too.

I want that job so badly. However, as you might expect, they're looking for seriously talented people. And I don't think I qualify. The company is also known for holding popular programming contests, and finishing one of their tests is part of the application process. They have a bunch of example tests of varying lengths and difficulties on their site. I tried some of them. They're really tricky.

*snip*

Alright. Today's the big day. The test will be unlocked in 40 minutes. I've got four hours to complete it.
 

NetMapel

Guilty White Male Mods Gave Me This Tag
I'd rather use shutil.rmtree('test/B/') after being sure you're in the correct directory... Why an absolute path?

Especially on Windows where absolute path are not completely absolute if you omit the drive.

And be really, really, really careful, you work without safety net, you won't see "Are you sure you want to delete everything on the disk Y/N?"...
Oh yeah I just put that path in as an example. I got the exact path stored in a variable. However, I just tried shutil.rmtree and no dice. Still the same issue :( Process is being used by the software I'm launching the Python script from. I have to close the software to release thr Windows permission. I can actually individually delete the files contained within the destination folder though, but just not the folder itself. Really scratching my head on this haha.
 

Pinewood

Member
So Im starting at a new place and it seems knowing Excel macros and VBA are recommended. Ive done a bit of VBA at school but that was 2-3 years ago and I dont remember anything. Im doin this simple macro that takes accounting data and then rewrites it into a format that is usable for our database, getting rid of unnecessary details while it does that. I have a pretty good idea of what Im going to do, but I need some syntax help...

Code:
Sub populate()
Dim i As Integer
i = 2
Dim wrks As Worksheet
Set wrks = Sheets("result")
While IsEmpty(Sheets(wrks).Cells(i, 2)) <> True
    Worksheets(wrks).Cells(i, 1).Value = "AAA"
    Worksheets(wrks).Cells(i, 3).Value = "BB0"
    Worksheets(wrks).Cells(i, 5).Value = "CC0"
    Worksheets(wrks).Cells(i, 7).Value = "AD_MAN"
    If Worksheets(wrks).Cells(i, 6).Value = "DDDD" Then
        Worksheets(wrks).Cells(i, 4).Value = "TT.74"
    Else
        Worksheets("Tulemus").Cells(i, 4).Value = "TT.0"
    End If
    i = i + 1
    Wend
End sub
So this actually worked until I went and added the wrks variable (had worksheets("result") there before that). Im not even sure I need that there, but it seemed like a great idea since Im working with multiple sheets. This is just a simple subprogram that will populate the table with data that is pretty much static. Not the prettiest way but alas...

Code:
Function datamine(i As Integer)
i = 1
While Worksheets("Data").Cells(2, i).String <> "Total Actual Cost"
i = i + 1
Wend
End function
Here the while clause gives me a syntax error, I know I need to find this specific string but not sure how the proper syntax is.
 

Koren

Member
Oh yeah I just put that path in as an example. I got the exact path stored in a variable. However, I just tried shutil.rmtree and no dice. Still the same issue :(
That's what I expected, seeing the error you reported...

It seems that the software has a handle on the directory (you can check it with sysinternals process explorer, for example), and in this case, there's unfortunately no really safe things to do on the script side as far as I know. :/

If you can change the software itself, you can try to discard the handle on the directory when you don't need it anymore...
 

NetMapel

Guilty White Male Mods Gave Me This Tag
That's what I expected, seeing the error you reported...

It seems that the software has a handle on the directory (you can check it with sysinternals process explorer, for example), and in this case, there's unfortunately no really safe things to do on the script side as far as I know. :/

If you can change the software itself, you can try to discard the handle on the directory when you don't need it anymore...
Hmmm ok if I were to just execute a .py file from the software instead, would that bypass the whole process thing? Like, in the software, I'll just have it execute a separate .py file instead of running the full script from within. That might work, right?
 

Ambitious

Member
Alright. Today's the big day. The test will be unlocked in 40 minutes. I've got four hours to complete it.

Just finished it. The task was to develop a Picross solver, and it was split into seven stages. Unfortunately, I managed to complete only five of them. I made a few stupid mistakes which cost me some time, and the difficulty spike from stage 5 to 6 was huge. Ran out of time.

Finishing all seven stages is not required to be hired, though. It's just to get an idea of the skills of the applicant.
 

Koren

Member
A picross solver? That's interesting... I'd be curious to hear about the details. Are they public?

Hmmm ok if I were to just execute a .py file from the software instead, would that bypass the whole process thing? Like, in the software, I'll just have it execute a separate .py file instead of running the full script from within. That might work, right?
Unfortunately, I'm 99% sure it won't. You really have to find the handle and release it. :/
 

NetMapel

Guilty White Male Mods Gave Me This Tag
A picross solver? That's interesting... I'd be curious to hear about the details. Are they public?


Unfortunately, I'm 99% sure it won't. You really have to find the handle and release it. :/
Yeah I just tested it earlier and no dice. Oh well. I will just create a big pop up message box to tell the user that you cannot overwrite. Technically you're not supposed to anyways... Thanks for all your help
 
Just finished it. The task was to develop a Picross solver, and it was split into seven stages. Unfortunately, I managed to complete only five of them. I made a few stupid mistakes which cost me some time, and the difficulty spike from stage 5 to 6 was huge. Ran out of time.

Finishing all seven stages is not required to be hired, though. It's just to get an idea of the skills of the applicant.

What sort of algorithm did you use?
 

Somnid

Member
Hmm then perhaps I need to ask my instructor something, because we're supposed to be building webpages in PHP/HTML and not using javascript.

What you're being asked to do is called a post-back. Basically the button should have a value and should be placed in a form with method=POST

Code:
<div></div>
<form method="POST">
    <button name="hidediv" value="true">Hide Div</button>
</form>

Then in the PHP code you would read the value from the global post object and then conditionally render the div.

D4Danger is right that you wouldn't do it like this in real-life, it's an extremely antiquated way to do dynamic HTML before Javascript was common and is a bad user experience because it requires reloading the entire page from the server for a tiny change.
 

Koren

Member
it's an extremely antiquated way to do dynamic HTML before Javascript was common and is a bad user experience because it requires reloading the entire page from the server for a tiny change.
I wish they were non-convoluted and clever ways to do this in pure CSS. I'm still reluctant to use javascript, is only because as a user, I don't like to give so much leeway to webpages in term of processing (I still often have javascript disabled).
 

Somnid

Member
I wish they were non-convoluted and clever ways to do this in pure CSS. I'm still reluctant to use javascript, is only because as a user, I don't like to give so much leeway to webpages in term of processing (I still often have javascript disabled).

I don't think you should be scared of js, more than any other thing you run on your computer wep apps are well-sandboxed and safe. A well constructed site with javascript can work completely offline and have high performance making for a good UI experience, saving you bandwidth and battery life in the process. There is still a bit of dependency on the site owner doing the right thing, managing Content Security Policy and other such things to defend against XSS but even the defaults are pretty good. There's also current proposals for features that sites better manage the resources 3rd party scripts use and so it'll continue to get better with time. Plus you can still burn through CPU cycles on expensive animations.

There are some drafts I've seen for toggleable states via CSS, I imagine it won't be terribly long before one picks up some traction.
 
Top Bottom