New Apps

Articles

Tips

Events

Improve Soft Skills

Latest Post


C# on the left, Java on the right:


1. Properties: You will immediately notice, that in java you have to write get/set methods instead of properties.

2. Virtual/Final:  Very important difference is, that all methods and properties in java are implicitly virtual. In C# you have to explicitly tell that the property or method is virtual. On the other side, in java, you have to implicitly tell that a method is final (resp, sealed).

3. In C# you can also write properties and method using Lambda syntax (see Test property);

4. In C# you can write optional method parameters. In Java you can achieve the same by method overloading:

Related : To Learn C# fromSratch

5. implicit typing:

  1. //C#:
  2. var person = new Person();
  3. //variable person is of type Person, obviosly
  4.  
  5. //Java
  6. Person person = new Person(); //variable type must be expressed explicitelly


6. Linq:
given that I have following collection of people:

  1. var people = new[]
  2. {
  3. new Person { FirstName = "Daniel", LastName = "Turan" },
  4. new Person { FirstName = "John", LastName = "Smith" },
  5. new Person { FirstName = "John", LastName = "Brown" }
  6. }


in C# i can query against the collection like:

  1. var me = people .Where(p => p.FirstName == "Daniel").First();
  2.  
  3. var numberOfJohns = people.Count(p => p.FirstName == "John");
  4.  
  5. var mostFrequestNames = people
  6. .GroupBy(p => p.FirstName)
  7. .OrderByDescenting(group => group.Count())
  8. .Select(group => new
  9. {
  10. Name = group.Key,
  11. Occurences = group.Count()
  12. });


Linq has fundamentally changes the way we write C# code. In java there is still no alternative that is good enough.

There is much more syntactic sweetness in C#, like async/await, which greatly improves readability and maintainability of asynchronous code, string interpolation, extension method and a lot more.

References :



C# learnt from many mistakes that Java had.

  • C# has decimal fixed point.
  • C# has var (local variable type inference) since 3.0.
  • C# has real generics ("reified generics") since 2.0. Java has fake generics ("erasure generics") since Java 5.
  • C# has real properties.
  • C# has value types.
  • C# has attributes since the very beginning. Java only has annotations (the Java equivalent to attributes) since Java 5.
  • Ditto for for-each loops.
  • Ditto for auto-boxing and auto-unboxing.
  • Ditto for varargs.
  • C# has using (and the dispose pattern, via IDisposable) since the very beginning. Java only has try-with-resources (the Java equivalent to using) since Java 7.
  • Ditto for string switches. Also note that C# switches are more versatile than Java's ones; you can use goto case and goto default to jump to other cases.
  • C# has lambdas since 3.0, long before Java did (Java 8).
  • Ditto for extension methods. (The closest thing Java has to extension methods are interface default methods, and those are introduced in Java 8.)
  • C# has static classes (non-instantiable classes where all methods have to be static) since 2.0. In Java, you can hack around it by making a class with only private constructors, but you can still define non-static methods in such a class.
  • C# methods are non-virtual by default. In Java you can only make a method non-virtual by making it private or final.
  • C# requires using override when overriding, and forbids using override when not overriding. This makes it easier to detect when a refactor is breaking other code.
  • C# has operator overloading.
  • C# has compile-time constants using const. In Java, you can only have compile-time constants for numbers, booleans, characters, and strings.
  • C# does not have checked exceptions. Many programmers consider checked exceptions a broken concept.
  • C# has named and optional arguments since 4.0.
  • C# has ref and out parameters. In Java, everything is pass-by-value; it's not possible to have pass-by-reference.
  • C# has enumerator generators via yield since 2.0.

Having said that, there are things that actually appeared in Java first, that C# either doesn't have or has caught up to later:

  • Covariant and contravariant generic type parameters have been around since Java 5, but were introduced in C# 4.0.
  • Java enumerations (which are full-fledged classes) are much more advanced than C# enumerations (which are basically just integers). For example, you can use it to implement a simple state machine.
  • Java has BigDecimal which provides decimal floating point, as opposed to C#'s builtin decimal fixed point.
Yes. C# lacks some stuff java has but events with deleagetes, async/await or LINQ have advantage over type variance (covariance and contravariance) in java.




  • If you are developing applications for Windows desktops, or for Windows servers (e.g. ASPdotNET), or for Windows phone, then C#.
  • If you are developing a PC game or writing an OS, then C or C++.
  • If you are writing server applications (e.g. web or mobile), or targeting Android phones, then Java.
  • If you are targeting iPhones/iPads, then ObjectiveC or Swift.
  • If you are building the browser side of an application, or if using node.js, then Javascript.
  • Since the comments I keep getting are pointing out how non-universal my original answer to this silly question was, I should point out that there are many other computer languages that are great for various uses. Python, PHP, Perl, Ruby, assembly, whatever.

Simply using the "best" language related to the domain still doesn't mean it's going to give you the "best" results in the "quickest" / "easiest" manner. Just that it's more possible than with others. It's still very much up to what the programmer knows and implements. None of them (any language ever invented - not just those you've listed) are anything close to a "magic-bullet".

Therefore "best" is not just an irrelevant term (especially if no specialization in domain is stated), it's also subjective and individual- / group dependent. I.e. before stating the "best", first state "what" you want to do as well as what you know and how well you can use it (unless you're willing / able to spend a lot of time trying to become an expert in something you don't know). Only then could you even attempt at rating a language's suitability.


Frankly speaking, every programming language is Best, if you can master it. For example, A person with sound knowledge over only C is a valuable key resource compared with a person having 'basic knowledge' on many languages.

The interesting thing is that, once you master a single language, conquering others will not be that tough!

So, suggestion for the beginners: Be the master of a modern language(whatever suits you) & after that try to gather basic knowledge of others, eventually if you have time, master those as well.




The Evolution of the C# Language

An interesting part of our conversation revolved around the concept that developers are often divided into two different camps when it comes to the evolution of programming languages. In one camp, you've got those who believe that the evolution of software languages will provide improvements that ultimately make software better. In the other camp, you've got others who believe that these programming languages should stay the way they are because they're too complex as is. Furthermore, this second camp also believes that the lack of new functionalities lets developers concentrate on learning and understanding the intricacies of the language.
When Anders Hejlsberg led the initiative to develop the C# language nearly 12 years ago, the language was developed with the intention to be a simple object-orientated language that would be familiar to C, C++, and Java users. There's been a lot of innovation that's transpired over the past 12 years, such as adding a general type system, query comprehension, interoperability with dynamic languages, and a myriad of features that have been added to the language over time.
With that said, the evolution of C# has brought new complexities to the table.
"Simple is no longer accurate. It's now a very complicated language," Lippert said.
Lippert went on to describe a tension that exists for most developers.
"Sometimes it's not even two camps, per se. I often get this from the same person in a conversation, where they say, 'I really want this new feature, and I would make really good use of that feature, but I worry I will have to train my coworkers on how to use it correctly,'" Lippert said.
This train of thought is something that's on the minds of many C# developers. Lippert elaborated by saying that future developments made to the language really need to balance how new and useful features can be included in the language without being overly complex.
Lippert also outlined several questions that should be asked when considering to implement new features into a language:
Is this new feature easy to use?
Does this new feature add enough benefit to include in the language?
Does this new feature do a good job of not introducing strange interactions with existing features?
Does this new feature make it susceptible for developers to introduce errors into their code?


Writing Quality Code with C#: Common Gotchas

Related: "Future of C# Apps"
"One of the architects on the .NET Framework, Rico Mariani, used to say that he wanted C# to be a pit of quality language. You throw users into the pit of quality, and everything they do is quality," Lippert said. In contrast, a pit of failure is where users have to climb their way out of the pit to write quality software.
Lippert reiterated that C# was designed to easily write quality software.
"C# was designed so that the obvious things to do and the right thing to do are the same thing. For the most part, that's true. But, no design is perfect," Lippert explained.
I asked Lippert if he could help describe common pain points that developers experience with the language.
One common problem focuses C#'s automatic memory management.
"If you allocate a bunch of memory, then the runtime automatically figures out when you're done using it and returns it back to the system. That's great. But it does not have automatic management of non-memory resources, so things like you open a file, or a database connections or any other scarce resource like that, the runtime doesn't know about them," Lippert said.
Eventually the runtime will clean up those non-memory resources, but it does it on its own schedule. Although it does provide some level of automatic management, you're at the mercy of your garbage collection to free up those resources.
"Just for politeness, programs should be aggressively cleaning up non-memory resources in C#, and that's a very common mistake to not do so," Lippert explained.
Another common problem is value equality and representation in C#. In other words, are these two things equal in C#?
Lippert explained that there's several different to check for equality in C#, and many of those methods are inconsistent with each other.
He illustrated the example, further: Imagine writing the number two on two different pages of paper. Are those two objects equal? Well, the values are equal, but those are two different pieces of paper.
"So there are often situations in C# where you think you're doing comparisons and values, but you're actually comparing references or vice versa," Lippert said.
Although you can painstakingly debug your code for these common C# programming problems, Coverity's development testing platform helps eliminate these hassles in a cinch.

The Future of C#

Today, we're up to C# 5.0, and C# 6.0 is on the horizon. Although C# 6.0 has been announced, there's no schedule that tells us when the new version will be released. And most interesting is Microsoft's work with its Roslyn Project, which aims to break down the traditional model of blackbox compilers by providing developers with a documented and publicly available interface. Currently, the project is in a Community Technology Preview (CTP) state.
"The point of the Roslyn API isn't just to improve the quality of the compiler itself and make it easier for the compiler team to add new features in the future, but also it's to make it easier for companies like Coverity to work on static analysis of those programming languages," Lippert said.
Once the Roslyn library is available for public use, then companies will be able to provide accurate analyzes because their products will be able to run on the same library of underlying tools as the Microsoft compiler.
Talking about the Microsoft development system, Lippert emphasized that the company is very much in the business of investing time and research into producing quality languages, such as the up and coming TypeScript JavaScript-variant language.

References :


C# is pretty much the language for developing business applications targeting a Windows environment, and it's a leading Web language, as well as gaining ground in game programming with the XNA Framework plugin and easy porting of titles between PC and XBox. According to statistics at TIOBE Software based on recruited positions by employers and advertised programming language skills among developers, C# is currently the number 5 language, behind C, Java, Obj-C and C++


Objective-C's popularity is driven by the resurgence of Apple technologies, starting around 2006 with the iPhone and iPod Touch, and bleeding back into desktops with OSX in several key development fields such as graphics design, audio production etc. C and C++ have always been must-have languages across the spectrum, especially for "close-to-the-metal" development work like device drivers and performance-critical graphics and calculation-intensive applications, as well as for Linux distros and applications therefore (though Mono, a .NET workalike, is not unheard of in that space). Java's current popularity is tied to that of Android, which has recently overtaken iOS to become the most popular mobile OS on the planet. It's also a popular web language, and not unheard of for desktop development work either (Apache OpenOffice and several other office productivity competitors to Microsoft Office are written in it).


However, most small to medium businesses need one thing from their in-house developers; applications that run on Windows (the dominant OS for business workstations; 80%+ of corporate market share), which allow the user to retrieve and manipulate information from a data storage server (traditionally an in-house DB server, increasingly cloud data services). For many such applications, inter-op with applications installed on the workstation is a must, and that usually precludes an HTML-based intranet application of any language. C# and the .NET Framework excels in this space; the language was designed to produce powerful, inter-operable desktop applications quickly and efficiently. 


On top of that, it would be nice to use the same language and libraries of common business logic to create that customer-facing web portal, too; C# and ASP .NET are very common choices here for that reason. The .NET Framework powers about 17% of websites with a known server-side architecture, which puts it at #2 behind a dominant PHP (largely due to the widespread adoption of low-cost PHP "website-in-a-box" products like Joomla, WordPress, Drupal, phpBB, SMF, vBulletin etc which power the overwhelming majority of online discussion forums and blog sites). Anything else on the radar (Servlets/JSP, Python, RoR, Perl, Node.JS) is in the low single digits of not at fractions of a percent of known server architectures.



So yeah, people and companies still use C#. Knowing your stuff in .NET is a hot commodity, so much so that long-term unemployment (jobless > 6 months) among people with significant (3+ years) .NET experience is something like 0.4%, beating the industry average of 2.8%.


References :



These tips are based upon common knowledge and experimentation.
An optimized web page not only provides for a more responsive site for your visitors, but also reduces the load on your web servers and Internet connection. This can be crucial for high volume sites or sites which have a spike in traffic due to unusual circumstances such as breaking news stories.
Optimizing page load performance is not just for content which will be viewed by narrow band dial-up or mobile device visitors. It is just as important for broadband content and can lead to dramatic improvements even for your visitors with the fastest connections.

EDIT

Reduce page weight

Page weight is by far the most important factor in page-load performance.
Reducing page weight through the elimination of unnecessary whitespace and comments, commonly known as minimization, and by moving inline script and CSS into external files, can improve download performance with minimal need for other changes in the page structure.
Tools such as HTML Tidy can automatically strip leading whitespace and extra blank lines from valid HTML source. Other tools can "compress" JavaScript by reformatting the source or by obfuscating the source and replacing long identifiers with shorter versions.

Minimize the number of files

Reducing the number of files referenced in a web page lowers the number of HTTP connections required to download a page.
Depending on a browser's cache settings, it may send an If-Modified-Since request to the web server for each CSS, JavaScript or image file, asking whether the file has been modified since the last time it was downloaded.
By reducing the number of files that are referenced within a web page, you reduce the time required for these requests to be sent, and for their responses to be received.
If you use background images a lot in your CSS, you can reduce the amount of HTTP lookups needed by combining the images into one, known as an image sprite. Then you just apply the same image each time you need it for a background, and adjust the x/y coordinates appropriately. This technique works best with elements that will have limited dimensions, and will not work for every use of a background image. However, the fewer HTTP requests and single image caching can help reduce pageload time.
Too much time spent querying the last modified time of referenced files can delay the initial display of a web page, since the browser must check the modification time for each CSS or JavaScript file, before rendering the page.

Reduce domain lookups

Since each separate domain costs time in a DNS lookup, the page load time will grow along with the number of separate domains appearing in CSS link(s) and JavaScript and image src(es).
This may not always be practical; however, you should always take care to use only the minimum necessary number of different domains in your pages.

Cache reused content

Make sure that any content that can be cached, is cached, and with appropriate expiration times.
In particular, pay attention to the Last-Modified header. It allows for efficient page caching; by means of this header, information is conveyed to the user agent about the file it wants to load, such as when it was last modified. Most web servers automatically append the Last-Modified header to static pages (e.g. .html.css), based on the last-modified date stored in the file system. With dynamic pages (e.g. .php.aspx), this, of course, can't be done, and the header is not sent.
So, in particular for pages which are generated dynamically, a little research on this subject is beneficial. It can be somewhat involved, but it will save a lot in page requests on pages which would normally not be cacheable.
More information:
  1. HTTP Conditional Get for RSS Hackers
  2. HTTP 304: Not Modified
  3. HTTP ETag on Wikipedia
  4. Caching in HTTP
  5. Learn HTML

Optimally order the components of the page

Download page content first, along with any CSS or JavaScript that may be required for its initial display, so that the user gets the quickest apparent response during the page loading. This content is typically text, and can therefore benefit from text compression in transit, thus providing an even quicker response to the user.
Any dynamic features that require the page to complete loading before being used, should be initially disabled, and then only enabled after the page has loaded. This will cause the JavaScript to be loaded after the page contents, which will improve the overall appearance of the page load.

Reduce the number of inline scripts

Inline scripts can be expensive for page loading, since the parser must assume that an inline script could modify the page structure while parsing is in progress. Reducing the use of inline scripts in general, and reducing the use of document.write() to output content in particular, can improve overall page loading. Use modern AJAX methods to manipulate page content for modern browsers, rather than the older approaches based ondocument.write().

Use modern CSS and valid markup

Use of modern CSS reduces the amount of markup, can reduce the need for (spacer) images, in terms of layout, and can very often replace images of stylized text -- that "cost" much more than the equivalent text-and-CSS.
Using valid markup has other advantages. First, browsers will have no need to perform error-correction when parsing the HTML (this is aside from the philosophical issue of whether to allow format variation in user input, and then programmatically "correct" or normalize it; or whether, instead, to enforce a strict, no-tolerance input format).
Moreover, valid markup allows for the free use of other tools which can pre-process your web pages. For example, HTML Tidy can remove whitespace and optional ending tags; however, it will refuse to run on a page with serious markup errors.

Chunk your content

Tables for layouts are a legacy method that should not be used any more. Layouts utilizing <div> blocks, and in the near future, CSS3 Multi-column Layout or CSS3 Flexible Box Layout, should be used instead.
Tables are still considered valid markup, but should be used for displaying tabular data. To help the browser render your page quicker, you should avoid nesting your tables.
Rather than deeply nesting tables as in:
<TABLE>
  <TABLE>
    <TABLE>
          ...
    </TABLE>
  </TABLE>
</TABLE>
use non-nested tables or divs as in
<TABLE>...</TABLE>
<TABLE>...</TABLE>
<TABLE>...</TABLE>

Minify and compress SVG assets

SVG produced by most drawing applications often contains unnecessary metadata which can be removed. Configure your servers apply gzip compression for SVG assets.

Specify sizes for images and tables

If the browser can immediately determine the height and/or width of your images and tables, it will be able to display a web page without having to reflow the content. This not only speeds the display of the page but prevents annoying changes in a page's layout when the page completes loading. For this reason, height and width should be specified for images, whenever possible.
Tables should use the CSS selector:property combination:
table-layout: fixed;
and should specify widths of columns using the COL and COLGROUP HTML tags.

Choose your user-agent requirements wisely

To achieve the greatest improvements in page design, make sure that reasonable user-agent requirements are specified for projects. Do not require your content to appear pixel-perfect in all browsers, especially not in down-version browsers.
Ideally, your basic minimum requirements should be based on the consideration of modern browsers that support the relevant standards. This can include recent versions of Firefox, Internet Explorer, Google Chrome, Opera, and Safari.
Note, however, that many of the tips listed in this article are common-sense techniques which apply to any user agent, and can be applied to any web page, regardless of browser-support requirements.

References :

Thursday, September 8, 2016

What are some examples of how C# and Java differ in syntax and capabilities?


C# on the left, Java on the right:


1. Properties: You will immediately notice, that in java you have to write get/set methods instead of properties.

2. Virtual/Final:  Very important difference is, that all methods and properties in java are implicitly virtual. In C# you have to explicitly tell that the property or method is virtual. On the other side, in java, you have to implicitly tell that a method is final (resp, sealed).

3. In C# you can also write properties and method using Lambda syntax (see Test property);

4. In C# you can write optional method parameters. In Java you can achieve the same by method overloading:

Related : To Learn C# fromSratch

5. implicit typing:

  1. //C#:
  2. var person = new Person();
  3. //variable person is of type Person, obviosly
  4.  
  5. //Java
  6. Person person = new Person(); //variable type must be expressed explicitelly


6. Linq:
given that I have following collection of people:

  1. var people = new[]
  2. {
  3. new Person { FirstName = "Daniel", LastName = "Turan" },
  4. new Person { FirstName = "John", LastName = "Smith" },
  5. new Person { FirstName = "John", LastName = "Brown" }
  6. }


in C# i can query against the collection like:

  1. var me = people .Where(p => p.FirstName == "Daniel").First();
  2.  
  3. var numberOfJohns = people.Count(p => p.FirstName == "John");
  4.  
  5. var mostFrequestNames = people
  6. .GroupBy(p => p.FirstName)
  7. .OrderByDescenting(group => group.Count())
  8. .Select(group => new
  9. {
  10. Name = group.Key,
  11. Occurences = group.Count()
  12. });


Linq has fundamentally changes the way we write C# code. In java there is still no alternative that is good enough.

There is much more syntactic sweetness in C#, like async/await, which greatly improves readability and maintainability of asynchronous code, string interpolation, extension method and a lot more.

References :

What does it exactly mean when people say that C# is better than Java?



C# learnt from many mistakes that Java had.

  • C# has decimal fixed point.
  • C# has var (local variable type inference) since 3.0.
  • C# has real generics ("reified generics") since 2.0. Java has fake generics ("erasure generics") since Java 5.
  • C# has real properties.
  • C# has value types.
  • C# has attributes since the very beginning. Java only has annotations (the Java equivalent to attributes) since Java 5.
  • Ditto for for-each loops.
  • Ditto for auto-boxing and auto-unboxing.
  • Ditto for varargs.
  • C# has using (and the dispose pattern, via IDisposable) since the very beginning. Java only has try-with-resources (the Java equivalent to using) since Java 7.
  • Ditto for string switches. Also note that C# switches are more versatile than Java's ones; you can use goto case and goto default to jump to other cases.
  • C# has lambdas since 3.0, long before Java did (Java 8).
  • Ditto for extension methods. (The closest thing Java has to extension methods are interface default methods, and those are introduced in Java 8.)
  • C# has static classes (non-instantiable classes where all methods have to be static) since 2.0. In Java, you can hack around it by making a class with only private constructors, but you can still define non-static methods in such a class.
  • C# methods are non-virtual by default. In Java you can only make a method non-virtual by making it private or final.
  • C# requires using override when overriding, and forbids using override when not overriding. This makes it easier to detect when a refactor is breaking other code.
  • C# has operator overloading.
  • C# has compile-time constants using const. In Java, you can only have compile-time constants for numbers, booleans, characters, and strings.
  • C# does not have checked exceptions. Many programmers consider checked exceptions a broken concept.
  • C# has named and optional arguments since 4.0.
  • C# has ref and out parameters. In Java, everything is pass-by-value; it's not possible to have pass-by-reference.
  • C# has enumerator generators via yield since 2.0.

Having said that, there are things that actually appeared in Java first, that C# either doesn't have or has caught up to later:

  • Covariant and contravariant generic type parameters have been around since Java 5, but were introduced in C# 4.0.
  • Java enumerations (which are full-fledged classes) are much more advanced than C# enumerations (which are basically just integers). For example, you can use it to implement a simple state machine.
  • Java has BigDecimal which provides decimal floating point, as opposed to C#'s builtin decimal fixed point.
Yes. C# lacks some stuff java has but events with deleagetes, async/await or LINQ have advantage over type variance (covariance and contravariance) in java.


Currently, which one is best: C#, Java or C++?



  • If you are developing applications for Windows desktops, or for Windows servers (e.g. ASPdotNET), or for Windows phone, then C#.
  • If you are developing a PC game or writing an OS, then C or C++.
  • If you are writing server applications (e.g. web or mobile), or targeting Android phones, then Java.
  • If you are targeting iPhones/iPads, then ObjectiveC or Swift.
  • If you are building the browser side of an application, or if using node.js, then Javascript.
  • Since the comments I keep getting are pointing out how non-universal my original answer to this silly question was, I should point out that there are many other computer languages that are great for various uses. Python, PHP, Perl, Ruby, assembly, whatever.

Simply using the "best" language related to the domain still doesn't mean it's going to give you the "best" results in the "quickest" / "easiest" manner. Just that it's more possible than with others. It's still very much up to what the programmer knows and implements. None of them (any language ever invented - not just those you've listed) are anything close to a "magic-bullet".

Therefore "best" is not just an irrelevant term (especially if no specialization in domain is stated), it's also subjective and individual- / group dependent. I.e. before stating the "best", first state "what" you want to do as well as what you know and how well you can use it (unless you're willing / able to spend a lot of time trying to become an expert in something you don't know). Only then could you even attempt at rating a language's suitability.


Frankly speaking, every programming language is Best, if you can master it. For example, A person with sound knowledge over only C is a valuable key resource compared with a person having 'basic knowledge' on many languages.

The interesting thing is that, once you master a single language, conquering others will not be that tough!

So, suggestion for the beginners: Be the master of a modern language(whatever suits you) & after that try to gather basic knowledge of others, eventually if you have time, master those as well.

The Past, Present, and Future of C#




The Evolution of the C# Language

An interesting part of our conversation revolved around the concept that developers are often divided into two different camps when it comes to the evolution of programming languages. In one camp, you've got those who believe that the evolution of software languages will provide improvements that ultimately make software better. In the other camp, you've got others who believe that these programming languages should stay the way they are because they're too complex as is. Furthermore, this second camp also believes that the lack of new functionalities lets developers concentrate on learning and understanding the intricacies of the language.
When Anders Hejlsberg led the initiative to develop the C# language nearly 12 years ago, the language was developed with the intention to be a simple object-orientated language that would be familiar to C, C++, and Java users. There's been a lot of innovation that's transpired over the past 12 years, such as adding a general type system, query comprehension, interoperability with dynamic languages, and a myriad of features that have been added to the language over time.
With that said, the evolution of C# has brought new complexities to the table.
"Simple is no longer accurate. It's now a very complicated language," Lippert said.
Lippert went on to describe a tension that exists for most developers.
"Sometimes it's not even two camps, per se. I often get this from the same person in a conversation, where they say, 'I really want this new feature, and I would make really good use of that feature, but I worry I will have to train my coworkers on how to use it correctly,'" Lippert said.
This train of thought is something that's on the minds of many C# developers. Lippert elaborated by saying that future developments made to the language really need to balance how new and useful features can be included in the language without being overly complex.
Lippert also outlined several questions that should be asked when considering to implement new features into a language:
Is this new feature easy to use?
Does this new feature add enough benefit to include in the language?
Does this new feature do a good job of not introducing strange interactions with existing features?
Does this new feature make it susceptible for developers to introduce errors into their code?


Writing Quality Code with C#: Common Gotchas

Related: "Future of C# Apps"
"One of the architects on the .NET Framework, Rico Mariani, used to say that he wanted C# to be a pit of quality language. You throw users into the pit of quality, and everything they do is quality," Lippert said. In contrast, a pit of failure is where users have to climb their way out of the pit to write quality software.
Lippert reiterated that C# was designed to easily write quality software.
"C# was designed so that the obvious things to do and the right thing to do are the same thing. For the most part, that's true. But, no design is perfect," Lippert explained.
I asked Lippert if he could help describe common pain points that developers experience with the language.
One common problem focuses C#'s automatic memory management.
"If you allocate a bunch of memory, then the runtime automatically figures out when you're done using it and returns it back to the system. That's great. But it does not have automatic management of non-memory resources, so things like you open a file, or a database connections or any other scarce resource like that, the runtime doesn't know about them," Lippert said.
Eventually the runtime will clean up those non-memory resources, but it does it on its own schedule. Although it does provide some level of automatic management, you're at the mercy of your garbage collection to free up those resources.
"Just for politeness, programs should be aggressively cleaning up non-memory resources in C#, and that's a very common mistake to not do so," Lippert explained.
Another common problem is value equality and representation in C#. In other words, are these two things equal in C#?
Lippert explained that there's several different to check for equality in C#, and many of those methods are inconsistent with each other.
He illustrated the example, further: Imagine writing the number two on two different pages of paper. Are those two objects equal? Well, the values are equal, but those are two different pieces of paper.
"So there are often situations in C# where you think you're doing comparisons and values, but you're actually comparing references or vice versa," Lippert said.
Although you can painstakingly debug your code for these common C# programming problems, Coverity's development testing platform helps eliminate these hassles in a cinch.

The Future of C#

Today, we're up to C# 5.0, and C# 6.0 is on the horizon. Although C# 6.0 has been announced, there's no schedule that tells us when the new version will be released. And most interesting is Microsoft's work with its Roslyn Project, which aims to break down the traditional model of blackbox compilers by providing developers with a documented and publicly available interface. Currently, the project is in a Community Technology Preview (CTP) state.
"The point of the Roslyn API isn't just to improve the quality of the compiler itself and make it easier for the compiler team to add new features in the future, but also it's to make it easier for companies like Coverity to work on static analysis of those programming languages," Lippert said.
Once the Roslyn library is available for public use, then companies will be able to provide accurate analyzes because their products will be able to run on the same library of underlying tools as the Microsoft compiler.
Talking about the Microsoft development system, Lippert emphasized that the company is very much in the business of investing time and research into producing quality languages, such as the up and coming TypeScript JavaScript-variant language.

References :

Do people/companies still use C# programming


C# is pretty much the language for developing business applications targeting a Windows environment, and it's a leading Web language, as well as gaining ground in game programming with the XNA Framework plugin and easy porting of titles between PC and XBox. According to statistics at TIOBE Software based on recruited positions by employers and advertised programming language skills among developers, C# is currently the number 5 language, behind C, Java, Obj-C and C++


Objective-C's popularity is driven by the resurgence of Apple technologies, starting around 2006 with the iPhone and iPod Touch, and bleeding back into desktops with OSX in several key development fields such as graphics design, audio production etc. C and C++ have always been must-have languages across the spectrum, especially for "close-to-the-metal" development work like device drivers and performance-critical graphics and calculation-intensive applications, as well as for Linux distros and applications therefore (though Mono, a .NET workalike, is not unheard of in that space). Java's current popularity is tied to that of Android, which has recently overtaken iOS to become the most popular mobile OS on the planet. It's also a popular web language, and not unheard of for desktop development work either (Apache OpenOffice and several other office productivity competitors to Microsoft Office are written in it).


However, most small to medium businesses need one thing from their in-house developers; applications that run on Windows (the dominant OS for business workstations; 80%+ of corporate market share), which allow the user to retrieve and manipulate information from a data storage server (traditionally an in-house DB server, increasingly cloud data services). For many such applications, inter-op with applications installed on the workstation is a must, and that usually precludes an HTML-based intranet application of any language. C# and the .NET Framework excels in this space; the language was designed to produce powerful, inter-operable desktop applications quickly and efficiently. 


On top of that, it would be nice to use the same language and libraries of common business logic to create that customer-facing web portal, too; C# and ASP .NET are very common choices here for that reason. The .NET Framework powers about 17% of websites with a known server-side architecture, which puts it at #2 behind a dominant PHP (largely due to the widespread adoption of low-cost PHP "website-in-a-box" products like Joomla, WordPress, Drupal, phpBB, SMF, vBulletin etc which power the overwhelming majority of online discussion forums and blog sites). Anything else on the radar (Servlets/JSP, Python, RoR, Perl, Node.JS) is in the low single digits of not at fractions of a percent of known server architectures.



So yeah, people and companies still use C#. Knowing your stuff in .NET is a hot commodity, so much so that long-term unemployment (jobless > 6 months) among people with significant (3+ years) .NET experience is something like 0.4%, beating the industry average of 2.8%.


References :

Sunday, July 3, 2016

Tips for fast loading of HTML pages



These tips are based upon common knowledge and experimentation.
An optimized web page not only provides for a more responsive site for your visitors, but also reduces the load on your web servers and Internet connection. This can be crucial for high volume sites or sites which have a spike in traffic due to unusual circumstances such as breaking news stories.
Optimizing page load performance is not just for content which will be viewed by narrow band dial-up or mobile device visitors. It is just as important for broadband content and can lead to dramatic improvements even for your visitors with the fastest connections.

EDIT

Reduce page weight

Page weight is by far the most important factor in page-load performance.
Reducing page weight through the elimination of unnecessary whitespace and comments, commonly known as minimization, and by moving inline script and CSS into external files, can improve download performance with minimal need for other changes in the page structure.
Tools such as HTML Tidy can automatically strip leading whitespace and extra blank lines from valid HTML source. Other tools can "compress" JavaScript by reformatting the source or by obfuscating the source and replacing long identifiers with shorter versions.

Minimize the number of files

Reducing the number of files referenced in a web page lowers the number of HTTP connections required to download a page.
Depending on a browser's cache settings, it may send an If-Modified-Since request to the web server for each CSS, JavaScript or image file, asking whether the file has been modified since the last time it was downloaded.
By reducing the number of files that are referenced within a web page, you reduce the time required for these requests to be sent, and for their responses to be received.
If you use background images a lot in your CSS, you can reduce the amount of HTTP lookups needed by combining the images into one, known as an image sprite. Then you just apply the same image each time you need it for a background, and adjust the x/y coordinates appropriately. This technique works best with elements that will have limited dimensions, and will not work for every use of a background image. However, the fewer HTTP requests and single image caching can help reduce pageload time.
Too much time spent querying the last modified time of referenced files can delay the initial display of a web page, since the browser must check the modification time for each CSS or JavaScript file, before rendering the page.

Reduce domain lookups

Since each separate domain costs time in a DNS lookup, the page load time will grow along with the number of separate domains appearing in CSS link(s) and JavaScript and image src(es).
This may not always be practical; however, you should always take care to use only the minimum necessary number of different domains in your pages.

Cache reused content

Make sure that any content that can be cached, is cached, and with appropriate expiration times.
In particular, pay attention to the Last-Modified header. It allows for efficient page caching; by means of this header, information is conveyed to the user agent about the file it wants to load, such as when it was last modified. Most web servers automatically append the Last-Modified header to static pages (e.g. .html.css), based on the last-modified date stored in the file system. With dynamic pages (e.g. .php.aspx), this, of course, can't be done, and the header is not sent.
So, in particular for pages which are generated dynamically, a little research on this subject is beneficial. It can be somewhat involved, but it will save a lot in page requests on pages which would normally not be cacheable.
More information:
  1. HTTP Conditional Get for RSS Hackers
  2. HTTP 304: Not Modified
  3. HTTP ETag on Wikipedia
  4. Caching in HTTP
  5. Learn HTML

Optimally order the components of the page

Download page content first, along with any CSS or JavaScript that may be required for its initial display, so that the user gets the quickest apparent response during the page loading. This content is typically text, and can therefore benefit from text compression in transit, thus providing an even quicker response to the user.
Any dynamic features that require the page to complete loading before being used, should be initially disabled, and then only enabled after the page has loaded. This will cause the JavaScript to be loaded after the page contents, which will improve the overall appearance of the page load.

Reduce the number of inline scripts

Inline scripts can be expensive for page loading, since the parser must assume that an inline script could modify the page structure while parsing is in progress. Reducing the use of inline scripts in general, and reducing the use of document.write() to output content in particular, can improve overall page loading. Use modern AJAX methods to manipulate page content for modern browsers, rather than the older approaches based ondocument.write().

Use modern CSS and valid markup

Use of modern CSS reduces the amount of markup, can reduce the need for (spacer) images, in terms of layout, and can very often replace images of stylized text -- that "cost" much more than the equivalent text-and-CSS.
Using valid markup has other advantages. First, browsers will have no need to perform error-correction when parsing the HTML (this is aside from the philosophical issue of whether to allow format variation in user input, and then programmatically "correct" or normalize it; or whether, instead, to enforce a strict, no-tolerance input format).
Moreover, valid markup allows for the free use of other tools which can pre-process your web pages. For example, HTML Tidy can remove whitespace and optional ending tags; however, it will refuse to run on a page with serious markup errors.

Chunk your content

Tables for layouts are a legacy method that should not be used any more. Layouts utilizing <div> blocks, and in the near future, CSS3 Multi-column Layout or CSS3 Flexible Box Layout, should be used instead.
Tables are still considered valid markup, but should be used for displaying tabular data. To help the browser render your page quicker, you should avoid nesting your tables.
Rather than deeply nesting tables as in:
<TABLE>
  <TABLE>
    <TABLE>
          ...
    </TABLE>
  </TABLE>
</TABLE>
use non-nested tables or divs as in
<TABLE>...</TABLE>
<TABLE>...</TABLE>
<TABLE>...</TABLE>

Minify and compress SVG assets

SVG produced by most drawing applications often contains unnecessary metadata which can be removed. Configure your servers apply gzip compression for SVG assets.

Specify sizes for images and tables

If the browser can immediately determine the height and/or width of your images and tables, it will be able to display a web page without having to reflow the content. This not only speeds the display of the page but prevents annoying changes in a page's layout when the page completes loading. For this reason, height and width should be specified for images, whenever possible.
Tables should use the CSS selector:property combination:
table-layout: fixed;
and should specify widths of columns using the COL and COLGROUP HTML tags.

Choose your user-agent requirements wisely

To achieve the greatest improvements in page design, make sure that reasonable user-agent requirements are specified for projects. Do not require your content to appear pixel-perfect in all browsers, especially not in down-version browsers.
Ideally, your basic minimum requirements should be based on the consideration of modern browsers that support the relevant standards. This can include recent versions of Firefox, Internet Explorer, Google Chrome, Opera, and Safari.
Note, however, that many of the tips listed in this article are common-sense techniques which apply to any user agent, and can be applied to any web page, regardless of browser-support requirements.

References :

Social Impact