C ++杀死了我的祖父-C ++很难,C ++编码器隐藏在哪里?

After learning BASIC and ASM, for a job I started coding in C, when Hello World on Windows was 92 lines of code. (Apparently Hello World is easier now, says Pete Brown)

学习了BASIC和ASM之后,为了工作,我开始用C语言进行编码,当时Windows上的Hello World是92行代码。 (显然, Hello World现在更容易了,皮特·布朗说)

One of my first big projects was an app called Foolproof that kept kids in high school from breaking into their school's lab computers. It had a C core engine, a TurboVision DOS component and a 16-bit Windows C++ App. I did the DOS, Win16 and later the Win32 API all in C++. Later I did some VB3, then Delphi, then worked at Nike doing Java (right when RMI was starting, and HotJava when we wrote once and debugged everywhere) until I finally ended up in managed code, mostly doing C#.

我的第一个大型项目之一是一个名为Foolproof的应用程序,该应用程序可以防止高中孩子闯入学校的实验室计算机。 它具有一个C核心引擎,一个TurboVision DOS组件和一个16位Windows C ++ App。 我使用C ++完成了DOS,Win16和更高版本的Win32 API。 后来我做了一些VB3,然后是Delphi,然后在Nike从事Java工作(恰好是RMI启动时,而HotJava是我们编写一次并在各处调试时),直到我最终使用托管代码,主要是使用C#。

Some folks don't know Microsoft has a free C++ Express Edition of Visual Studio 2010 and that it's one of the most used free versions out there. Someone is coding C++, and they are doing a lot of it.

有些人不知道Microsoft有免费的Visual Studio 2010 C ++ Express Edition ,它是其中最常用的免费版本之一。 有人正在编写C ++,而他们正在做很多事情。

Are you coding in C++, Dear Reader? What are you doing?

亲爱的读者,您使用C ++进行编码吗? 你在做什么?

Most "managed people" cringe at the idea of using C++, thinking it's perhaps a language of the past and that it's not even possible to write Windows Apps in C++ without a Master's Degree. ;)

大多数“受管理的人”都讨厌使用C ++的想法,认为这可能是过去的一种语言,而且如果没有硕士学位,甚至不可能用C ++编写Windows应用程序。 ;)

However, I just noticed there's a new project called Hilo with source to show people how to use the shiny new things in Windows 7 from C++ and how to make modern Windows applications that have animations and magical stuff that managed people assume belongs only to them.

但是,我只是注意到有一个名为Hilo的新项目,它带有源代码,向人们展示如何使用C ++从Windows 7中使用闪亮的新事物,以及如何制作具有动画和神奇内容的现代Windows应用程序,这些东西被管理人员认为仅属于他们。

The first drop of "Hilo" is apparently the first of many, all moving towards building a larger application. This first sample is a content browser (touch enabled!) for looking at videos and photos (yeah, yeah, I know) but you could totally use it to browse other stuff or use it as underlayment for your own app. This from the Windows Team Blog:

“ Hilo”的第一滴显然是许多滴滴中的第一滴,所有滴滴都朝着构建更大的应用程序发展。 第一个示例是用于浏览视频和照片的内容浏览器(启用触摸!)(是的,是的,我知道),但是您可以完全使用它来浏览其他内容,也可以将其用作您自己的应用程序的基础。 这来自Windows团队博客:

The main technologies used in Hilo: Direct2D, Windows Animation Manager, Windows Touch, Libraries and the Shell API.

Hilo中使用的主要技术:Direct2D,Windows动画管理器,Windows Touch,库和Shell API。

  • Direct2D: For high performance and high-quality rendering of graphics.

    Direct2D :用于图形的高性能和高质量渲染。

  • Windows Animation Manager: To give the application a unique personality and to improve the user experience.

    Windows Animation Manager :赋予应用程序独特的个性并改善用户体验。

  • Windows Touch: To provide a more natural user interface through which the user can just “point” and “do”.

    Windows Touch :提供更自然的用户界面,用户可以通过它“指向”和“执行”。

  • Libraries: To enable the application to provide users with a single, coherent view of their files.

    :使应用程序能够为用户提供其文件的单个一致视图。

  • Shell API: To navigate the images, to optimize by using the pre-built thumbnail cache and also to provide icons from actual content.

    Shell API :浏览图像,使用预建的缩略图缓存进行优化以及提供实际内容中的图标。

Even if you're not going to start coding C++, it's always a good idea to "see how the other half lives." For me, it's a return to what I thought I knew, and a way to look at C++ with fresh eyes.

即使您不打算开始使用C ++进行编码,“查看另一半的生命如何”也是一个好主意。 对我来说,这是对我所知道的东西的回归,并且是一种以崭新的眼光看C ++的方式。

What surprised me was that this app was written against Windows itself, with no frameworks. I always assumed you kind of needed MFC or some other library to be productive.

令我惊讶的是,该应用程序是针对Windows本身编写的,没有任何框架。 我一直以为您需要MFC或其他一些库才能发挥作用。

I'm not sure why I remember it this way, but C++ always made me think of regular expressions, and I assumed my code would **be &all like->this.you~know? You do need to know more about Windows, to be sure, as there is likely a decade of managed programmers who have forgotten what a message pump is, but it wasn't as scary as I had remembered.

我不确定为什么要记住这种方式,但是C ++总是让我想到正则表达式,并且我假设我的代码会“像所有的一样”-> this.you〜知道吗? 当然,您确实需要了解有关Windows的更多信息,因为可能有十年的托管程序员忘记了消息泵是什么,但是它并不像我所记得的那样可怕。

Just download C++ Express, then the Hilo source, and build it. It has some cool effects with the carousel, like inertia when it spins, scaling, Z-ordering, hardware graphics acceleration. Now all they need is a designer! ;)

只需下载C ++ Express ,然后下载Hilo源码并进行构建即可。 它对转盘有一些很酷的效果,例如旋转时的惯性,缩放,Z顺序,硬件图形加速。 现在,他们需要的只是一个设计师! ;)

As an interesting example, it uses Direct 2D and has an animation for the orbit of the carousel. I removed all the if (SUCCEEDED(hr)) code from this snippet below because that's still the one thing about C++ on Windows that irks me. Don't judge then, judge me for yanking it for brevity.

作为一个有趣的示例,它使用Direct 2D并为旋转木马的轨道制作了动画。 我从下面的这段代码中删除了所有的if(SUCCEEDED(hr))代码,因为那仍然使Windows上的C ++感到困扰。 那就不要判断,为简洁起见,请判断我。

This source is extremely defensive, dutifully checking HResults at every step. I mean, seriously, if it doesn't Succeed, what are you going to do about it? If (NOTSCREWED(hr)), you know.

此来源极具防御性,应认真检查每一步的HResults。 我的意思是说,认真的,如果没有成功,您将如何处理? 如果(NOTSCREWED(hr)),您知道。

For this source, the salient point is that there's some nice high-level Animation constructs like timers, transitions and storyboards.  For some wrongheaded reason I thought it'd be a pile of math so I was pleasantly surprised.

对于此来源,重点是要有一些不错的高级Animation构造,例如计时器,过渡和情节提要。 由于一些错误的原因,我认为这会是一堆数学,所以我感到惊喜。

HRESULT OrbitAnimation::Setup(D2D1_ELLIPSE targetEllipse, double targetOpacity, double duration)
{
HRESULT hr = S_OK;

// Animation objects
ComPtr<IUIAnimationManager> animationManager;
ComPtr<IUIAnimationTimer> animationTimer;
ComPtr<IUIAnimationTransitionLibrary> transitionLibrary;
ComPtr<IUIAnimationStoryboard> storyboard;

// Transition objects
ComPtr<IUIAnimationTransition> centerXTransition;
ComPtr<IUIAnimationTransition> centerYTransition;
ComPtr<IUIAnimationTransition> radiusXTransition;
ComPtr<IUIAnimationTransition> radiusYTransition;
ComPtr<IUIAnimationTransition> opacityTransition;

// Initialize animation variables if necessary
if (nullptr == m_centerX)
{
hr = Initialize(targetEllipse, targetOpacity);
}

// Retrieve animation objects
hr = AnimationUtility::GetAnimationManager(&animationManager);
hr = AnimationUtility::GetTransitionLibrary(&transitionLibrary);

hr = AnimationUtility::GetAnimationTimer(&animationTimer);

// Initialize storyboard
hr = animationManager->CreateStoryboard(&storyboard);

// Create one transition for each orbit variable
hr = transitionLibrary->CreateLinearTransition(duration, targetEllipse.point.x, &centerXTransition);
hr = storyboard->AddTransition(m_centerX, centerXTransition);

hr = transitionLibrary->CreateLinearTransition(duration, targetEllipse.point.y, &centerYTransition);
hr = storyboard->AddTransition(m_centerY, centerYTransition);

hr = transitionLibrary->CreateLinearTransition(duration, targetEllipse.radiusX, &radiusXTransition);
hr = storyboard->AddTransition(m_radiusX, radiusXTransition);

hr = transitionLibrary->CreateLinearTransition(duration, targetEllipse.radiusY, &radiusYTransition);
hr = storyboard->AddTransition(m_radiusY, radiusYTransition);

hr = transitionLibrary->CreateLinearTransition(duration, targetOpacity, &opacityTransition);
hr = storyboard->AddTransition(m_opacity, opacityTransition);

hr = AnimationUtility::ScheduleStoryboard(storyboard);

return hr;
}

I was also pleased to see that intellisense worked nicely for everything typed as well as -> deferenced pointers, as seen in the screenshot below. Call me an intellicrack addict or weak-minded but it does speed things up once you know what you're looking for. The C++ Express SKU was a small download as well.

我也很高兴看到intellisense可以很好地处理所有键入的内容以及->引用的指针,如下面的屏幕快照所示。 称我为智能机架上瘾者或头脑较弱的人,但是一旦您知道要寻找的东西,它的确会加快速度。 C ++ Express SKU也是一个很小的下载。

I'm not saying it's all puppies and cotton candy, but it's not the post-apocalyptic-Where-is-John-Connor-wasteland I thought it would be. I'll be giving C++ another look as I aim to learn (or relearn) another programming language this year (along with Scala). I'll report back as this application gets bigger and more interesting.

我并不是说所有的都是小狗和棉花糖,但这不是世界末日后的约翰·康纳(John-Connor)荒原。 我打算在今年学习(或重新学习)另一种编程语言(与Scala一起)时,给C ++另一种外观。 随着这个应用程序变得越来越大和越来越有趣,我将进行报告。

Related Links

相关链接

翻译自: https://www.hanselman.com/blog/c-killed-my-grandpappy-is-c-hard-and-where-are-the-c-coders-hiding

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值