Phil Trelford's Array
POKE 36879, 255

Oops

October 7, 2014 14:27 by phil

Are you working in the enterprise?

Do you find yourself, day-in-day-out, up to the eyeballs in unmaintainable code?

Does the once beautiful architecture now more closely resemble a big ball of mud, that no amount of tooling will dig you out of?

What can you do?

1) Bury your head in the sand

head-in-the-sand

A very popular option, you just need to keep practising denial.

2) Turn to drink

gazza

Another popular option, although unfortunately this strategy is only likely to last as long as your liver.

3) Become a scrum master

scrum master

This is an easy way out, scrum certification is just a 2 day course away, but there’s probably no looking back.

4) Admit there’s a problem

AA

This is one of the hardest and least popular options, but possibly the most rewarding.

Start by saying out loud: “Object Oriented Programming is an expensive disaster which must end” and then take each new day as it comes.


Tags:
Categories: C# | C++ | Java
Actions: E-mail | Permalink | Comments (7) | Comment RSSRSS comment feed

Strangeloop 2012

September 26, 2012 07:38 by Phil

This year I had the privilege of attending and speaking at the Strangeloop conference in St Louis. The venues, the Union Street Marriot (a National Historic Landmark), and the Peabody Opera House were spectacular.

StLouisUnionStationHotelExterior

The range of sessions and speakers was literally mind boggling. Some of my favourites:

The breakfast hallway conversations were friendly and insightful, thanks to everyone for all the great feedback on my talk.

F# for Trading

Many people in the community use F# for Trading, and not just developers, traders too. Community matters in a language. The talk looked at some of the reasons people choose to use F# in Trading and some of the projects they have built to support their efforts, like Type Providers for Excel and the R statistical programming language.


The talk was recorded so expect a video to appear on InfoQ at some point in the future.

References

Strangeloop.zip (4.15 mb)


Tags:
Categories: .Net | BDD | C# | C++ | F# | JavaScript | Twitter
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

F# eye for the C++ guy

September 19, 2012 00:23 by phil

As a C++11 programmer you’ve probably played with type inference and lambda functions and may now feel curious about trying a functional first programming language like F#. F# is a first class .Net programming language that ships with Visual Studio. Although C# shares the familiar moustache based syntax of C++, you may like me actually find F# more familiar in terms of power features like immutability, function inlining and even sprintf .

Comparing some of the good parts of C++11 with C# and F#:

C++11 C# F#
Architect
Committee 
formerly B. Stroustrup
Anders Hejlsberg* Don Syme
Statically typed Yes Yes
Yes
Generic programming Template classes, methods & functions
e.g. list<T>
Generic types & methods
e.g. List<T>
Generic types, methods & functions
e.g. list<T>
Type aliasing typedef keyword
e.g. typedef list<int> xs;
using directive
e.g. using xs=List<T>;
type keyword
e.g. type xs = list<int>
Type inference auto keyword
on local & global variables
var keyword
on local variables
let keyword
on values, variables, parameters & return values
Math functions Built-in
e.g. abs, min, sin, pow
System.Math class
e.g. Math.Abs
Built-in
e.g. abs, min, sin, pown
String format sprintf function 
e.g. sprintf(“%d”, 1)
String.Format method
String.Format(“{0}”,1)
sprintf function
e.g. sprintf “%d” 1
Inline functions inline keyword
N/A inline keyword
Immutability const correctness
mutable keyword
readonly fields Immutable by default
mutable keyword
Immutable collections N/A N/A Built-in
e.g. list, set, map
Agents Concurrency runtime
Agents library
DevLabs project
TPL Dataflow
Built-in
MailboxProcessor<T>
Resource management Resource acquisition is initialization (RAII) Explicit scope with using statement on IDisposable objects Automatic scope with use keyword or explicit scope with using function
Interop COM & P/Invoke P/Invoke & COM P/Invoke & COM

* Note: Anders Hejlsberg is reported to be currently working on JavaScript tooling

Resource management

In .Net, garbage collection replaces C++’s delete method for reclaiming memory. For resources like files or database connections that implement IDisposable, .Net can feel a bit more clumsy requiring explicit disposal, over using C++ with  RAII.

In C# to determine if a class implements IDisposable you must look at the implementation, and then explicitly dispose the object with either a using block or calling the Dispose method.

using (Font font1 = new Font("Arial", 10.0f))
{
    byte charset = font1.GdiCharSet;
}

In F# you can tell if a class implements IDisposable by hovering over it in Visual Studio. Also types implementing IDisposable must be created using the new keyword, which gives an explicit code indication. Finally F# has a use keyword which can be used in place of the let keyword for IDisposable types and automatically calls Dispose when the object is out of scope.

use font1 = new Font("Arial", 10.0f)
let charset = font1.GdiCharSet

Print

Like C++, F# provides a printf and sprintf function. What may be a little more surprising is that in F# they are type safe:

thetypefloatisnotcompatible

F# will generate a compile time error if the number or type of parameters don’t match.

Headers

Although not required F# supports signatures which are akin to C++ header files and useful for libraries (for example F#’s built-in libraries uses them), particularly for separating code documentation examples from the actual implementation code.

Summary

If you’re interested in augmenting your high performance C++ code with some high level functional code, look beyond the syntax and you may find F# more familiar and feature rich.


Tags:
Categories: C++ | C# | F# | .Net
Actions: E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed