I hope someone can assist, I am a beginner in computer programming and had purchased a book (Visual Basic - Step by Step), I was making good progress until I read an article on the internet about Windows Presentation Foundation (WPF) - apparently this the future.
I read up on Xaml and I find the syntax extremely difficult to understand, for instance I have been coding using the following format:
texbox1.text = "Hello World!"
However the guides I read on Xaml show that the coding in the .cs file are as follows:
<Grid>
<TextBlock Text="Hello World!" />
</Grid>
I am confused on which 'language' I should be learning!
I hope someone can shed some light into this.
Many thanks
There are many aspects to programming, and it can certainly become overwhelming for a beginner quickly. For starters, let's clear up a few terms:
VB (Visual Basic), C#, and C++ (mentioned in your title) are all high-level programming languages. Assuming that when you say Visual Basic you are referring to VB.NET (which is likely, unless the book you're reading is a decade old...), VB and C# are both languages that can be used with Microsoft's .NET Framework, a set of libraries and tools for building (primarily Windows) applications.
(C++, meanwhile, is a slightly lower-level language not directly connected to .NET. It requires an understanding of certain concepts that the .NET languages hide from you, such as pointers and memory management.)
Now, the programming languages mentioned above are not tied to a specific presentation technology - there are many ways to create interactive programs that display output to users and accept input regardless of the the language you use. The .NET languages, however, are typically used alongside a couple of powerful tools that the .NET Framework provides for creating graphical applications:
Among the simplest user interface methods, you can create a console program which takes typed input and produces text output on the system console. Nothing fancy here.
Windows Forms - originally provided with the pre-.NET versions of Visual Basic, this is a venerable API to the native Windows user interface. It is driven primarily by Form objects that contain Controls and are driven by user Events. Here is a primer.
WPF (Windows Presentation Foundation) is a newer technology than Windows Forms. It is used alongside an XML-like file format, which you've shown above, called XAML (eXtensible Application Markup Language) that lets you build user interfaces by quickly declaring a hierarchy of visual objects. The learning curve for building WPF applications is slightly higher (in my opinion) than that for Windows Forms, but it is a more versatile technology that better supports several good design patterns (that's hand-wavy, I know, but take my word for it for now).
So, to clear up a few points of confusion:
The programming language you use and the framework for building graphical user interfaces are two separate choices.
Both VB.NET and C# can be used to write the underlying logic for Windows Forms or WPF applications
WPF, the graphical subsystem, and XAML, the declarative markup language, are not the same thing, but they are used hand-in-hand with each other.
When creating WPF controls, you will have a file containing XAML (suffixed with .xaml) that is attached to a "code-behind" file containing C# (with a .cs extension) or VB (with a .vb extension), depending on which language you choose.
In general, a .NET programmer (which is an easy example for me to give, as I happen to be one) will use either VB or C# depending on what s/he is most comfortable with (or what's mandated by their team!) From a beginner's perspective especially, the two have different syntaxes but are functionally equivalent. I personally prefer C# for its similarity to the languages (Java and C) in which I learned to program.
Now, whatever the language, a programmer then selects the appropriate user interface technology for the project at hand. For graphical applications running on Windows, I believe that WPF is the tech to beat (especially because it's very similar to Silverlight, which can be used to target the web and Windows Phone).
I hope that at least begins the process of clearing up what is a very complex but navigable topic! I've already linked to it once above, but check out Microsoft's Beginner Developer Center as another resource to get you on your feet. Good luck!
The way you were coding and the xaml markup code does the same thing. The primary reason of XAML existence is to let the UI designers work on the UI using XAML and later programmers would tie up the business functionality using C# or XAML. XAML is primarily used in WPF but languages like C#, VB can be used to do a lot more things. Regarding what languages to learn, it all depends on your interest areas and your job.
djacobson's answer hits 90% of what I was about to write... so this is just a little supplement to that answer giving my personal advice.
If you're just starting out learning programming... it doesn't really matter too much where you start with which 'language' you choose. It looks like you've started out with learning Visual Basic. I write mostly in C#... but for the most part... they can do the same things, and are both good options to start learning about programming.
For your first couple of projects, simply create console applications that don't really have a user interface besides the command prompt (console).
As you move forward and want to start creating applications with a GUI (Graphical User Interface), then you can look into XAML (WPF if you're creating a desktop app, Silverlight if it's a web based app).
You'll still write your business logic code using Visual Basic or C#, the XAML is simply a way to define how your GUI will look and behave using the familiarity of XML rather than an older technology such as Windows Forms.
I'll be the first to say that I absolutely love WPF and XAML, but I truly feel that you're best off learning the basics of the language of your choice first, then work your way into the UI technologies later.
Since from last 2 years I am working on WPF and even I was like blank when it came to WPF. I would prefer C# over C++ and still you can find solutions for every language. But it depends on you what you are comfortable.
Related
Is it possible for kids with only HTML/CSS programming experience to do game programming in SilverLight 4.0?
They are using Visual Web Developer 2010 Express edition.
Do they have to learn c# or any other language since they are just starting out?
Thanks
What age range are you talking about? I imagine if you had really smart kids, they could pick-up SilverLight 4.0, but yes, learning C# for the logic and XAML for the GUI would be required.
Ergo, my recommendation is to skip SilverLight given your requirements.
Instead, you should try Scratch which is a programming language designed for kids. It's very visually based and introduces the basic concepts of programming yet allows them to create their own games with ease.
I would say that Silverlight (and infact HTML/Javascript) would be difficult for children to grasp and easily produce a game without getting bored and frustrated.
You could try Kodu as a possible alternative:
Kodu is a visual programming language
made specifically for creating games.
It is designed to be accessible for
children and enjoyable for anyone.
Kodu provides an end-to-end creative
environment for designing, building,
and playing your own new games. The
core of the Kodu project is the
programming user interface. The
language is simple and entirely
icon-based. Programs are composed of
pages, which are broken down into
rules, which are further divided into
conditions and actions. Conditions are
evaluated simultaneously.
Well, lets start that - HTML / CSS is not programming. There is no logic in there that requires programming, so ANY programming is a totalyl different area an they will have to get started at point 0. If you would have javascript in the HTML/CSS side that would be different.
C# would be required - Silverlight backend is done in C#. Quite a lot is required. C# for logic, XAML for the UI, including the powerfull mechanisms for databinding etc. Not a totally easy starter, but as a nice side course it could work.
They will have to learn C#, yes. You can do a lot of the visuals using the XAML declarative markup, but the logic will be driven by C# code.
Let's suppose you're an IT student with a basic knowledge of C++ and C#. Let's suppose that you want to design apps that:
need to deliver some performance like archivers, cryptographic algorithms, codecs
make use of some system calls
have a gui
and you want to learn an Api that will enable you to write apps like those described earlier and:
is mainstream
is future proof
entitles you to find a decent job
is easy enough - I mean easy like VCL, not easy like winapi
So, making these assumptions, what Api will you choose? MFC, WPF, other? I really like VCL and QT, but they're not mainstream and I think few employers will want you to write apps in QT or Visual C++ Builder...
Thanks for answers.
Note: The following answer was written several years ago with Desktop application development in mind. Today (in 2018), you'd probably just build a web application to end up with something reasonably cross-platform and device-independent. (For example, using ASP.NET Core on the server side, coupled with a UI framework/library such as React, Vue.js, or Angular on the client side).
Win32 API -- I'd forget about it, if I were you. Programming a Windows application directly via the Win32 API only makes sense if you're programming in pure C, or if you really need to do a lot of system calls, or if you're concerned about the additional overhead introduced by more "comfortable" platforms or frameworks (such as the ones named below). Programming UIs directly through the Win32 API is tiresome, messy, and you need to deal with lots of details. It's also not platform-independent at all, but you may or may not be concerned about that.
MFC -- Perhaps an option if you're programming in C++ and fixed on the Windows platform. I never understood what's so great about it, other than it makes the Win32 API much more comfortable (AFAIK it's basically a collection of object-oriented wrappers around the Win32 API that take away some of it's complexity / messyness). Also, it's also not very platform-independent.
Qt, wxWidgets -- Fairly widespread UI frameworks. Might be good options where platform independence plays a role. AFAIK both frameworks are targeted at the C++ language.
WinForms (.NET) -- Similar to MFC, this is also based on the Win32 API (USER32 and GDI+). AFAIK the WinForms framework is now being ported to Mono, and therefore somewhat cross-platform. However, it's not exactly the most up-to-date technology. For complex UIs it can also be somewhat sluggish sometimes. If I had to decide today which framework to use, I'd rather choose...:
WPF (.NET) -- More modern than WinForms, with more graphical capabilities and, apparently, faster rendering, as it is no longer based on the Win32 API (GDI). (And it runs on .NET, which I find a great platform to develop for. Programming in C# is so much easier than programming in C++ IMHO, which is also an argument against Win32 API, MFC, Qt, and wxWidgets.) Note that WPF is not cross-platform, it exists only on the Windows platform so far.
Then of course there's Java, including the UI frameworks that come with it. I can't say much about that since I'm not a Java person, but I could imagine that Java would be the best choice for platform independence; and it's the dominant platform (over .NET) in certain industries (e.g. mobile phones, banking, due to the very solid JVM and security considerations).
So my recommendation would be the .NET framework, and WPF for the UI, if you're planning to stay mostly in the Microsoft world. Remember that you can still use the Win32 API (you won't come closer to "system calls" than that) via P/Invoke.
If you enjoy coding in C# and working with the .Net framework I'd recommend that you have a look at WPF. WPF is a great GUI framework where you can do just about anything - and also make it shine! WinForms might be easier to get a grasp on, but I'd say WPF is more "future proof". Another positive thing is that WPF is really similar to Silverlight, so if you handle WPF well you should be able to write Silverlight applications too - if that's of interest. Please don't bother to learn MFC.. I can't believe there are many that is using MFC today for other reasons than that they were using it before, and didn't get an opportunity to change..
There are a lot of good jobs out there for .Net programmers, so being able to handle some GUI framework in addition to C# and general knowledge about the .Net framework will be worthwhile.
When it comes to your points about being able to "deliver some performance like archivers, cryptographic algorithms, codecs" this really shouldn't depend on your choice of GUI framework. This kind of code will be writen in layers outside of the GUI layer, and will typically be bound to the GUI. With WPF you'd write your e.g. cryptographic algorithms in C# in some class independent of the GUI layer, and then the View written in WPF would bind to C# code and get its answer from here. However, if you used WinForms you'd still do the same thing, and the performance relies on the algorithms - not the GUI.
When it comes to getting started with WPF there are a lot of questions on SO helping with this. So you should find good help with a quick search.
Good luck!
Is there a pdf or video or some media that can inform me on how to program Winforms with C++. Obviously C++ is the most common programming language and I already have some prior knowledge. But when I try to find media about programming in C++, the examples are usually Console applications. I want some media that can teach me how to program Winforms in C++.
Here's a tutorial showing how to write Windows Forms applications in C++/CLI.
Just be aware that most samples tend to be in C#. Many people purposely use C# for the forms, C++ for their logic, and use C++/CLI to expose their logic as .NET assemblies (For easy use by C#/VB.NET). This helps, since the design-time experience is much nicer in C# or VB.NET for Windows Forms.
Bad idea, IMHO. Managed C++ is ugly; it was never meant to be a garbage-collected language. Its strength lies elsewhere. I recommend C# instead - similar syntax, highly marketable skill.
Preemtive snarky comment: all C++ is ugly.
Have you looked at the MSDN articles? I'm not saying I recommend this, but they do at least give a start.
As far as Seva Alekseyev's comment that all C++ is ugly: it's like the old comment about democracy being the worst form of government except for all the others. He's right that all C++ is ugly, but fails to mention that all the alternatives are even worse.
Just create a new C++ .NET project and start programming your C++. And additional syntax applies to .NET is managed pointers and .NET classes. Information about them you can find in MSDN, including lots of useful examples.
Well, there are opinions all over the place on this topic. My motto is always to use the right size hammer for the job-- and, in general, C++ is the wrong size hammer for making winforms. I love C++, but I only use it when there is an absolute necessity for speed of operations.
C# (or VB.Net, if you must) has MUCH better support for UI creation than C++, though I have noticed that Visual Studio 2010 offers some much needed enhancements to make developing Winforms easier in .NET 4.0. If you MUST stick with C++, look into obtaining a beta version of Visual Studio 2010. Otherwise, use C# as your UI, data access, file manipulation, general purpose language and C++ if you have to write a custom physics engine to go with it.
i recently saw some videos on F#. it seems it used mainly for Service or Classes only? i see no "F# WPF" app in VS2010 Beta?
F# actually has some very nice constructs for creating event-driven UI applications, such as First Class Events, Object Expressions, calling property setters from a constructor e.g.:
new Form(Text="My Window Title", Width=600, Height=400),
and much else.
However, creating a forms designer in VS reqiures a CodeDom for your language. The current CodeDom architecture works great, as long as your language looks exactly like C# or VB; it does not lend itself well to generation of F# code (this from a webcast or interview that I can't locate right now). It also requires partial classes, which if I recall correctly, are not supported in the language as of Beta 1. Rather than focus on designer support in the first release, the F# team decided to spend their resources on enhancing other parts of the language, such as asynchronous and parallel programming, etc.
What this means is that you have at least 4 choices for creating UI in F#:
Write all UI code by hand, which is fine for simple apps;
Create your F# code as a library to handle the "hard parts," like asynchronous and parallel code, or computation centric code, and call it from C#/VB;
Create your UI code as a C#/VB library, and both drive it from F# and delegate event handling to F#; or
Use a DSL or Computation Expression (monad) to simplify building the UI by hand (just discovered this while looking for other links in this answer).
Of these, calling a C# UI library from F# may be the most flexible while still retaining a familiar paradigm. But, using computation expressions for quickly building UI by hand is certainly worth looking at.
You can certainly create GUIs in F# - it's just another .NET language, after all.
Tomas Petricek's book, Functional Programming for the Real World (which I've helped out with a little bit) has various GUI examples. The source code is available to download if you want to see examples.
Admittedly some aspects of GUI programming don't map terribly well to a functional style, as there's a lot of mutation involved, but there are ways and means around that :)
With F# 3.0 and the XAML type provider it's possible to create a WPF designer for F# in Visual Studio 11. See http://www.navision-blog.de/2012/03/22/wpf-designer-for-f/
We sell a commercial library called F# for Visualization that is written in 100% F# code and uses WPF to provide interactive graphics with typeset mathematics from your F# code:
(source: ffconsultancy.com)
So it is certainly possible to write GUI apps in F# using WPF.
It is a .NET language, so it can use the .NET class library. Which means Winforms, WPF or anything else you might use in C#.
Updated according to the link by James Hugard
For now F# will not be used much for GUIs because it is not the most important use case for it. From Don Syme's blog:
In this first supported release, our aim has to be to focus on the core strengths of F# for exploratory programming with F# Interactive, programming with data and implementing parallel and asynchronous components.
Although you can theoretically use F# and the standard GUI libraries if you need a GUI you should use VB or C#:
F# users should use the Visual Studio designer tools to generate C# or Visual Basic code and incorporate those components into their F# applications.
In the longer term "presentation-oriented designer tools that generate F# code" are, according to Syme, "definitely feasible".
Of course you can use all the WPF classes from F#, too. You can create Windows, controls and everything else from F# and I also sometimes use it from the F# console.
It's not as tightly integrated into Visual Studio as C# or VB yet, but as you can see in the comments, designer support in the future is feasible. I guess we'll have to wait until then (or use other tools).
I have seen lots of questions recently about WPF...
What is it?
What does it stand for?
How can I begin programming WPF?
WPF is a new technology that will supersede Windows Forms.
WPF stands for Windows Presentation Foundation
Here are some useful topics on SO:
What WPF books would you recommend
What real world WPF applications are out there
From my practice I can say that WPF is a truly amazing technology however it takes some time to get used to because it's totally different from the WinForms.
I would recommend you to take a look at this demo.
WPF is the next frontier with Windows UIs.
Built on top of DirectX, it opens up hardware acceleration support for
your .Net 3.0+ user-interfaces.
Emphasis on Vector Graphics - UIs scale and render better
Composable UIs. You could nest animated buttons in combo boxes.. the world's your oyster.
Is a rewrite with only minimal core components written in unmanaged code VS GDI-User Dll based Winforms approach which is a thin managed layer over largely unmanaged code.
Declarative approach to UI programming, User Interfaces are largely specified in a XML variant called XAML (eXtensible Application markup language) pronounced Zammel. This opens up WPF to designer folks who can specialized tools to craft UIs that the developers can then code up. No translation losses between wireframes to final product.
MS 'allegedly' will not provide any future updates to Winforms. Heavily invested in WPF as the way forward
Oh yeah, before I forget. Works best on Vista :)
You can get either Adam Nathan's WPF Unleashed Book or Chris Sells Programming WPF .. those seem to be the way to go. I just read the first chapter of Adam's (Lead for WPF at MS) book. Hence the WPF praise fountains :)
Take a look here http://windowsclient.net/ and here Windows Presentation Foundation (WPF)
Basically WPF is created to make windows form easier to design because of the use of XAML, designers can work on the design and programmers on the underlying code
WPF is the Windows Presentation Foundation. It is Microsoft's newest API for building applications with User Interfaces (UIs), working for both standalone and web-based applications.
Unsurprisingly, there is a very detailed but not all that helpful Windows Presentation Foundation page at Wikipedia.
The WPF Getting Started Page at the Microsoft MSDN site is probably a better place to start.
Is the new Windows Gui system. I don't believe its aim is to make development easier per se but more to address fundamental issues with WinForm, such as transparency and scaling, neither of which WinForm can effectively address. Furthermore it seeks to address the "one resolution only" paradigm of WinForm by mapping sizes to real-pixel sizes and making flow layout easier and more fundamental.
It's also based on an XML derivative making it easier to change the UI and forcing a separation of the UI and the core code (although technically you can still badly hack it together in this manner).
This separation also drives a desire to be able to divide the work into two camps, the designers taking charge of the XAML and layout and the programmers taking care of developing the objects used in the XAML.
Check out Eric Sink's Twelve days of WPF 3D.
Windows Presentation Foundation. It's basically Microsoft's latest attempt to make development easier, and provide a whole heap of nice functionality out of the box. I'm not sure where to start, but googling "WPF 101" should throw up a few useful links.
WPF is part of the .net 3.0 stack. Its microsoft's next generation Graphical User Interface system. All the information you need can be found on wikipedia and msdn's wpf site
To Get Started programming I guess check out the essential downloads on windows client