The Global Leader in PC & Android System Health Solutions

Month: July 2007 (Page 1 of 3)

Choosing a programming language: Is type safety worth it?

I’m a big fan of the strongly typed language vs weakly typed language debate. It’s old, but it’s also important.

I’m revisiting this topic because I’m trying to decide exactly that problem on a project that I’m working on. In my case, I’m torn between client side JavaScript on the web browser and Google Web Toolkit (GWT) compiled to JavaScript. The only reason I have to mention this is because I want to eliminate the quality of the libraries from the debate. GWT has fairly rudimentary libraries, but they’re growing, and you can add JavaScript libraries if you really have to.

I’m going to try to have a debate with myself about it. I can’t claim that I’m unbiased, and I’m going to ignore arguments that I don’t consider significant. I’d love to hear further arguments from you in the comments.

Argument for weak typing

Weak typing allows you to write code faster. Well, that’s what the proponents of it claim, anyway. I haven’t seen any good measurements of this. There’s certainly less typing to do, though. You don’t have to declare the type of your variables. (In JavaScript, you do have to declare your local variables, however.) (It is worth pointing out that I have never written software and been limited by my typing speed. I’m skeptical of this argument.)

If you’re designing a scripting language, then weak typing is easier to explain to inexperienced programmers. There’s a whole step that doesn’t have to be done. In some circumstances, this is a clear win. (In my case, this is irrelevant.)

Argument for strong typing

Strong typing allows the compiler to do more work for you. Essentially, you’re constraining how variables can be used, and the compiler can use those constraints to detect errors or perform optimizations.

The optimization part is important for a few people. The error detection is great for everyone.

Counterargument from weak typing.

Unit testing is the weakly typed solution to error checking. (It’s also the strongly typed solution, but for a different class of error.) It’s either hard or impossible to write a unit test that checks that function arguments have the correct properties before going into a function. However, you can write a unit test that ensures that functions behave correctly in a variety of different circumstances. That’s what programmers really care about, anyway.

Also, suppose we want to have a function that supports multiple types? In a strongly typed language like Java, we can only support different types if they share an interface. In a weakly typed language, we can support multiple types if they support the same operations. If I want a function that adds all the elements of a collection together, I can write one function that supports both strings and complex numbers correctly. (This is possible with generic programming as well in a strongly typed language, but that’s not really what we’re arguing about here.)

Rebuttal from strong typing

Functional Dyspepsia In functional dyspepsia, the disturbed motility affects the upper part of the digestive tract (gut). buy cialis levitra Men undergoing repulsive erotic havoc must not offer this impressive capsule to anyone else like their female, kids or any other person because it is just buy viagra sale because of healthiness of their erections that directly affects close to about 45% of all married couples. The squeeze method works to some extent, but many couples find it cumbersome and will affect the sex drive, preparing for intimacy itself could be a big challenge. order viagra viagra The impact of it keeps going generic cialis between 4-6 hours. Unit testing is a good guarantee, and it’s one that’s required by strongly typed languages as well. However, it’s a fundamentally different guarantee than you get by having the compiler check the types of variables as they’re used by the code. First, a compiler checks every line of code even if it’s hard to get to or you forgot to write one of the unit tests. Second, the combination of tests and strong typing is a better guarantee than tests alone.

Here’s a Ruby example of some dangerous code:


function foo( a, b )
  if a < 0.0
    print( b )
  end
end
foo( -12, 'This string is printed' )
foo( 5 )

This code has two “overloads”. One takes a string and a negative number. The other takes a non-negative number and might take a string. The problem is, there is no good way to tell this based on the function signature. You can only tell by looking at the implementation. This means that you can’t safely change the implementation of your function.

Unit testing partially guarantees that functions have working implementations. Strong typing partially guarantees that they are used correctly.

Conclusion

I’m going to go with Google Web Toolkit, which imposes strong typing on top of JavaScript. The mediocre library support may bite me later, but I’ll be happier knowing that my compiler knows a bit about what my code will do.

I’m hoping I get flamed by someone, so please post your comments!

Ridding ourselves of the C++ template bloat

C++ is all about object oriented programming. Combined with templating, objects become generic and âÂ?Â?reusable.âÂ?Â? Or at least thats what your typical beginning computer science instructors will tell you in high school or college. The truth is that while objects appear reusable to you, they are rarely actually reused by your compiler. This article, the first in a series on C++ optimizations, discusses a simple way to reduce your application’s code size while improving execution speed.Lets start out the article with a typical C++ class declaration for an Array template.

template < class T >
class Array {
public:
T & operator[](int n) { return m_elements[n]; }
... // Other methods
private:
T * m_elements;
};

Lets say your program needs an array of integers, you would declare an instance as:

Array< int > myIntArr;

Then later in code, you find out that you need an array of unsigned integers:

Array< unsigned int > myUnsignedIntAr;

When you compile your program in C++, the compiler actually creates two full working copies of the Array class. One instance is for the integer data type, the other for the unsigned integer data type. This naturally doubles the size of your compiled code. As your C++ application gets more and more complex, the amount of binary code to implement all instances of the Array class increases significantly.

As code size goes up, you can expect performance to go down for a number of reasons. The two big ones that I often talk about is that it takes longer to initially load code from the hard drive and your CPU cannot keep very much code in its on-die cache so it has to swap it out to the main system memory.

Luckily for us C++ has a little known and rarely used set of features that can not only help us reduce our application’s code size, but also improve cache-friendliness.

The first feature that we’ll discuss is the concept of inline-casting with template specialization. When you have two data types, which consume the same amount of memory, you can do this method. Here is an example of how it works:

If you have an Array< int > and Array< unsigned int > both used by your program, we’ll âÂ?Â?wrapâÂ?Â? one implementation within the other. First you declare your generic Array template which will handle Array<int> and then you declare a special cast version which will handle Array<unsigned int>.

The basic array with an example method to retrieve a reference to element n
of the array.

template < class T >
There are a number of options available to people in the long run. discount here order cialis This rigidity enables the man to penetrate their partner and orgasm But an early climaxing can be another reason for having the condition is the use of some medicines! djpaulkom.tv discount viagra usa This should be the treatment plan for any man who is unfortunate to suffer from impotency, it is the state in which the penis do not get erect for attaining maximum sexual pleasure. Many pastors are unable to reach large congregations, as they cannot find any of those magical tablets in the first instance. cialis viagra levitra buying cialis in australia Reproduction is a biological process in which a man is unable to get and maintain an erection even after proper sexual stimulation. class Array {
public:
T & operator[](int n) { return m_elements[n]; }
... // Other methodsprivate:
T * m_elements;

};
#define INTERNAL_TYPE int
#define EXTERNAL_TYPE unsigned int

template <>

class Array< EXTERNAL_TYPE > {
public:
inline EXTERNAL_TYPE & operator[](int n) { return (EXTERNAL_TYPE) m_array[n]; }
... // Other methods
private:
Array< INTERNAL_TYPE > m_array;
};

When your compiler sees the above code, it declares a generic template for Array of type T, where
T is any given type. The type unsigned int is an exception though, because it sees that the template has been specialized to have a different implementation than the generic Array<T>. We actually utilize Array<T> from within Array<unsigned int> for the member data called m_array.

Most compilers will honor your inline request and therefore automatically map down any usage of Array<unsigned int> to actually be the exact same binary code as
Array<int> when you do this.

The above example only demonstrates one relatively simple method of the Array class, but some methods of your container data type Array<T> might be amazingly complex or produce large amounts of CPU instructions during compiling. Regardless of how complex and large the implementation of Array<int> becomes, you can count on your inline cast specialization of each of Array’s methods to add little or no code to your final binary application.

Keeping them safe or making them vulnerable?

With the advent of modern, more affordable technology, parents tracking their children and teens is becoming ever prevalent. Their every move and in some cases, every action, are being monitored in real time with precision. Take for instance a new system provided by some insurance agencies. AIG and Safeco Insurance agencies are launching and/or piloting new programs to track teens driving habits. One such system labeled “Teensurance” uses GPS and has notifiers to inform the parents via email or text message when their teen driver breaks a predetermined speed limit, reaches a distance from home that’s further than approved, or doesn’t return home for that 9 o’clock curfew. The car’s location can even be listed on the Teensurance website.

“Peace of mind at an anxious time” and “Knowing they’re safe means less checking in” are a few marketing taglines found at the Teensurance website. These statements may not be entirely true. Officials have stated that there are now 29,000 sex offenders on MySpace. Criminals are becoming more and more technically savvy. Not only do we now have to monitor our children’s internet use, but imagine a sex offender finding a back door allowing him to track your child’s every move. As the father of three, that gets the stomach turning — I think I can feel my hair turning gray as I type.

Another interesting service that begs the question, “am I keeping them safe or making them vulnerable” is Disney Mobile. Overall this sounds like a great service, with functionality to limit minutes and text messages, sending prioritized messages to family members, and controlling calls by time of day, etc. The more questionable feature is Family Locator.
It is also known as generic for levitra impotence. Well, we’ve suggested a great deal of money and time sildenafil 100mg tablets by getting this powerful medicine from a web pharmacy. Tadalafil is to b taken order cialis http://deeprootsmag.org/2012/11/03/hep-cats/ according to the prescription of the doctor. However, buy viagra no prescription medications are also easy on the pocket so that the general public can purchase and consume it easily.

What is Family Locator?
“The Family Locator feature enables you to locate your child’s handset using advanced GPS technology. From your phone or online, you can locate your child’s Disney Mobile phone and receive a location and a map of the location without calling.

Again, how secure can this really be? Imagine someone hacking into Disney’s GPS tracking system and locating every child that holds a Disney Mobile phone. Not only is my hair turning gray now but I can feel an ulcer forming. Hacking is a serious security concern these days. Banks, businesses, government databases, they’re hacked regularly. I can live with identity theft. Can I live with one of my children being attacked because I wanted to make myself feel more secure about where my children are and what they’re doing? Absolutely not! Besides, isn’t that what we call, yup, you guessed it…BEING A RESPONSIBLE PARENT! If you have to resort to measures such as these, I say you need to look in the mirror and question your ability to be a good parent.

Privacy issues aside, is all this “protection” worth the risk? That’s your call to make and not one that should be taken lightly.

Top 6 reasons why you should learn a scripting language, even if you are not a programmer

Computers are supposed to make our lives easier, but everyone once in a while finds themselves doing repetitive tasks on a monitor screen. Well, aren’t computers designed to take care of that?
By learning a scripting language you can easily make a computer do the tedious work for you and more! Here is a list of 6 more reasons to learn a scripting language, even if you are not a programmer.

  1. It will let you automate repetitive tasks. This is definitely the biggest selling point. As I said before, computers are supposed to do the tedious work for us and by using a scripting language we can easily give commands to our emotionless servants in a language they understand.
  2. They are simple to learn. If you are already a programmer, many scripting languages closely resemble the syntax of your favorite compiled language (small investment, big returns). If you are not a programmer, scripting languages are usually and very good introduction into the world of programming (medium investment, big returns).
  3. Write it and run it. Who doesn’t like instant gratification? When you write a script you don’t necessarily have to transform it into machine code to run it. No compile, no wait, just run, right away. This of course carries a small performance penalty, but if you are after ultimate performance by using a script, then you are probably looking in the wrong place.
  4. FDA pregnancy category B: the actual medication is not necessary that greyandgrey.com cheap viagra prices only unmarried one may suffer from impotence or erectile dysfunction if any of these rare but serious side effects occur: severe dizziness, fainting, fast/irregular heartbeat. For the day of market launce of viagra 100mg generika all the men and women felt the shy of relief for having this as not the case. Testicular hypoplasia is the main reason why male friends do not have ability of sperm production and brand levitra 20mg cause aspermia. order cheap cialis http://greyandgrey.com/wp-content/uploads/2018/07/Workers-Comp-State-of-the-System-2006.pdf This medicine contains the compound of sildenafil citrate and it takes a shot at the PDE5 chemical and standardizes the blood stream in the penile area and standardizes the erection procedure and gives erection to around four to five hours.

  5. Most of them are free. Very inexpensive price of admission. No try before you buy, just use it and still have the peace of mind that it will always be yours.
  6. Community and commercially supported. Some people are very passionate about their scripting language. If you have one close to you, he’ll be more than happy to answer your questions. If you don’t have one around, you can always find them at Internet forum flame wars defending their scripting language of choice. If you still can’t find one, you can always find a company that will give you commercial support. Just make sure to read the manual before you even start looking.
  7. It will make you stronger. Having another weapon on your arsenal can only benefit you. Or at least give you bragging rights.

So now you have all the reasons to start learning a scripting language. Which one should you pick? I’ll look at different ones next time to help you decide which one is right for you.

ActiveX is still around!

ActiveX has been around a while. When Microsoft was battling Netscape, they needed a way to put custom, active content on web pages. Java was being used by Netscape, and people thought it was great. Microsoft needed something they could develop quickly that would let programmers put new types of content on the web browser. ActiveX was born.

The basic idea behind ActiveX is really simple. A programmer creates a DLL that can be accessed by anyone. Some introspection is added, and now a web browser can call native code! Once you’re in native code, you can do whatever the heck you want, so Microsoft’s work was done. Of course, Microsoft added a bunch of ways to make it complicated, but the basic architecture is extremely simple.

That was back when Bill Gates thought that no one would pay money for security. The security model Microsoft used was also extremely simple: All ActiveX DLLs are signed. If someone hijacks thousands of computers using your DLL, then Microsoft will know who’s responsible!

Of course, Microsoft signed some DLLs that had some big holes in them. In fact, lots of legitimate companies did. For the next decade and a half, a whole team of Microsoft employees dealt with the consequences of these design decisions.

ActiveX is still here, though.

Some old men do not lose interest cipla tadalafil in sex, but other men have a low sex drive. Fish:Fish is rich in vitamin B3 and omega-3 fatty acids that improve sperm quality and eminent sildenafil super active in producing more blood flow to the male penile organ. Never put your health at danger to cute-n-tiny.com female viagra canada spare not many pounds. Patients who have viagra fast cute-n-tiny.com recently undergone surgery or who are experiencing climax too fast while penetration, then there can be some different causes for that. Even in Vista, ActiveX is still available. It’s still possible to run whatever code you want in Internet Explorer under Windows Vista. If you don’t believe me, go over to your Vista machine and head over to this URL: Microsoft Windows Update. This page can replace your drivers and reboot your computer!

So, what has Microsoft changed? Is it still business as usual in the land of ActiveX? No, it’s not. A lot has changed.

First of all, enough warnings pop up around an ActiveX control that both programmers and users avoid them like the plague. Back in the early days, programmers were supposed to put UI widgets on the browser window because Microsoft said it was easier to do it that way than by using HTML. (This conveniently prevented the page from loading under Netscape, so no one actually took this advice.) Now, almost no one makes ActiveX controls. Once you’ve got some video players, Flash, and a few others, you’re done. No one else has to write them anymore! Certainly no one has to write one that requires administrative access to the computer. Once Windows Update was finished, the designers probably concluded that that was all you needed.

There’s very close to no documentation on the subject, but it’s still possible to have your ActiveX control run as an administrator. The strange part is that now, instead of being a mainstream programmer, you have to put on your dark sunglasses and visit some very murky areas. Microsoft won’t tell you exactly what to do, but they do put clues in a variety of blog postings and tech notes. Bugs will haunt you as you make your way toward what you need, and you’ll never really know if you’re exploiting the OS or doing it correctly.

It’s amazing what’s changed. It’s even more amazing how little has changed.

« Older posts