• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
DvDmanDT

Functional languages in gamedev

30 posts in this topic

Does anyone here use (or know of someone using) a functional langauge in gamedev? Any game that there's a remote chance I may have heard of?

A friend and I was having this discussion about languages when he mentioned Scheme. He posted some examples of scenarios where scheme was much simpler/cleaner [than <insert_imperative_language_of_choice>] and so on, in particular an algorithm to generate primes. While I may or may not agree, he can be right for arguments sake at least. My response was "the question is how nice and clean you can do something more practial.." to which he said that Lisp was invented for AI, so it should at least be able to handle that, and probably also physics..

I then asked him if he could name an example, which he couldn't. I'm guessing that's because there are none, (feel free to prove me wrong) but why is that? Education among developers (or lack thereof)? Lack of performant implementations? No significant advantage? Solution looking for a problem?
0

Share this post


Link to post
Share on other sites
Well I'm using racket scheme to make small demos, though not a game. The advantages for are that it's functional, and has all the advantages that come with that (Of which I'm never going back to an imperative language for personal use). You can mix imperative code with functional, which is necessary for doing inputs and outputs, e.g. drawing graphics, loading files, keyboard input etc.

Also it has macros which allow you do add extensions to the language, e.g. I used this to make a system for loading and setting shaders.


[code]

(define (some-effect)
(effect
(attribute "a_pos" 0)
(attribute "a_nor" 1)

(uniform "a" 0.0 0.3 0.0)
(uniform "b" 0.9)

(vertex "
#version 150
attribute vec3 a_pos, a_nor;
uniform mat4 u_modelViewProjMat;
varying vec3 c;

void main() {
gl_Position = u_modelViewProjMat * vec4(a_pos,1.0);
c = abs(normalize(a_nor));
}")

(fragment "
#version 150
varying vec3 c;
uniform float b[2];
uniform vec3 a;


void main() {
gl_FragColor = vec4(c+a+vec3(0.0,b[1],b[0]),1.0);
}")))


[/code]




The disadvantages are that you have to write interfaces to c shared libraries to do anything useful, e.g. latest version of opengl, physics, sound, window etc. Though some of the other lisps might have bindings for those things already (I know common lisp does, but I prefer scheme).

I'm currently in the process of writing a library that auto generates bindings from c header files (nearly complete), it uses macros so that you just make a module and call a macro from my library which when compiled will auto generate the bindings for you.

I have a feeling writing a physics engine in it wouldn't be as fast as one written in c/c++, but for a game, if all the intensive code is imported from c bindings leaving the the rest in scheme, it should be fine. 
1

Share this post


Link to post
Share on other sites
About 5 years ago, Tim Sweeney (creator of the Unreal Engine) was making a lot of noise about Haskell/Erlang ([i]can't remember which[/i]) being the next big language for game development, but AFAIK, they're still sticking with procedural C++/UnrealScript.

A search for his name + Haskell or Erlang might turn up some of these presentations.
1

Share this post


Link to post
Share on other sites
Naughty Dog supposedly did a lot of their work using a language called GOAL, which was a customized version of Lisp. I've heard conflicting reports about the extent to which this was actually successful, including an old insider who told me that the public description of GOAL was pretty much BS. I'm not sure, but I know they did build a lot of the old games in it.
1

Share this post


Link to post
Share on other sites
If I were to pick a functional language and try to write a game in it right now, it's probably be Scala. Scala actually has a mixture of functional and procedural/OO paradigms, but it is [i]heavily[/i] influenced by Scheme/Lisp in its idioms. The good thing is that the language compiles down to Java bytecode to run on the JVM (and can utilize any Java class library), and there are a bunch of Java libraries for game development, so it [i]might[/i] actually work.
1

Share this post


Link to post
Share on other sites
I think the main barriers to adoptation as a game language are functional purity; its hard to think of a game where you wouldnt want to mutate state at some point (and do it efficiently). I know you are supposedly able to do all this in functional languages, but give me set_pixel(x,y,color) any day of the week.

On a related issue, most successful game languages have relatively smooth interoperability with C.

The only way I could see myself using a functional language in a game, would be if I was making the game in C#. The seemless interoperability of F# with the .NET platform is a pretty awesome thing.
0

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1324274731' post='4895196']
About 5 years ago, Tim Sweeney (creator of the Unreal Engine) was making a lot of noise about Haskell/Erlang ([i]can't remember which[/i]) being the next big language for game development, but AFAIK, they're still sticking with procedural C++/UnrealScript.

A search for his name + Haskell or Erlang might turn up some of these presentations.
[/quote]

You mean [url="http://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf"]this[/url]? He talked about Haskell's advantages but said that the syntax is not accessible enough for new programmers. It was essentially a call for a new, practical and easily accessible functional PL.
1

Share this post


Link to post
Share on other sites
Andrew111, check out [url="http://www.swig.org/"]SWIG[/url]. I haven't had an opportunity to use it yet, but it looks like a solid project for auto-generating wrappers. A quick check shows that they support Racket.

[quote name='andrew111' timestamp='1324266690' post='4895176']
The disadvantages are that you have to write interfaces to c shared libraries to do anything useful, e.g. latest version of opengl, physics, sound, window etc. Though some of the other lisps might have bindings for those things already (I know common lisp does, but I prefer scheme).

I'm currently in the process of writing a library that auto generates bindings from c header files (nearly complete), it uses macros so that you just make a module and call a macro from my library which when compiled will auto generate the bindings for you.
[/quote]
0

Share this post


Link to post
Share on other sites
There are thousands of 18-year olds who have 5 years of experience in C++ (because it's fast) applying for every single job to work 90 hours a week at minimum wage.

The odd math PhD that benefits from functional programming is a poor fit in such environments. And they'll probably apply at Wall Street anyway.


On technical side, graphics APIs, due to being defined in C and based on legacy of decades of C usage aren't perfect fit. Functional programming also produces non-deterministic running-time results, which isn't a problem when expressiveness is concerned, but is a big deal for real-time systems. There is also dire lack of tooling. So even if functional approaches are used, they need to be watered down. Finally there's deadlines. With project development cycles ranging from 1 year and down to 2 weeks, there simply isn't time for experimentation of any kind. There is essentially no new tech being developed outside of middleware and research companies and for something to be used it needs to have a track record of several years to demonstrate real world maturity.
0

Share this post


Link to post
Share on other sites
[quote name='DvDmanDT' timestamp='1324263650' post='4895166']
I then asked him if he could name an example, which he couldn't. I'm guessing that's because there are none, (feel free to prove me wrong) but why is that? Education among developers (or lack thereof)? Lack of performant implementations? No significant advantage? Solution looking for a problem?
[/quote]
It is an interesting question.

Given that both imperative (FORTRAN) and functional (LISP) came on the scene at about the same time (very early 1950) the question can be reduced to "why is the use of imperative programming so much more widespread than functional programming?"

I think there are two possible answers.

Firstly, imperative languages were effectively "higher level" versions of the machine code used to program computers at the time when they were invented, whereas functional languages were effectively an implementation of a fairly obscure branch of mathematics (Church's lambda calculus, which McCarthy was teaching at the time). Thus, imperative programming came naturally to the "old hands" then working the altar of big iron and functional programming limited to a few interest courses in better universities. When CODASYL was struck to determine the way forward for the next several decades, it consisted mostly of "old hands." Thus the foundation for the supremacy of imperative programming languages was laid.

A second possibly answer is that imperative languages are easier for Joe Bitpack to pick up: you don't need to understand about partially-enumerable functions to understand "make this box blue". Since most pointy-haired bosses see all code monkeys as interchangeable, grabbing the first guy to apply who has the right TLAs on his CV and can wipe the drool off his chin most of the time is seen as cost-effective. Natural selection in such an environment gives the reproductive advantage to a paradigm that does not tire out the lips as quickly.

Be thankful. When I was in university I was told that all the old languages were dead and everything would be programmed using 5th-generation languages like Prolog. I am sure my flying car is programmed using Prolog today.
1

Share this post


Link to post
Share on other sites
[quote name='Bregma' timestamp='1324319264' post='4895401']

A second possibly answer is that imperative languages are easier for Joe Bitpack to pick up: you don't need to understand about partially-enumerable functions to understand "make this box blue".[/quote]

Almost any real-world problem that needs to be encoded is nothing remotely close to pure. While it can be converted into mathematical form, it won't reduce to a nice equation.

Consider a very trivial thing - clicking on a button. Windows feels different from Linux or Mac UIs. Even though point-in-rect math is exactly the same, Windows has a few extra checks looking something like this: "if user hovered over second--to-last item for more than 1600ms then accept +3 pixels to left, unless there are less than 3 items in menu or there is a separator and only if US or UK English is selected, under Germanic locales adjust border to +5 and for LTR IME have border on left, but also adjust left window offset by 4."

And these details are the difference between software worth billions and college projects flooding open source repositories. The code above does not come from deep mathematical derivation but from user testing over period of years in real world situations.

[quote]Be thankful. When I was in university I was told that all the old languages were dead and everything would be programmed using 5th-generation languages like Prolog. I am sure my flying car is programmed using Prolog today.[/quote]

A lot of business actually is, just not in the way it was imagined.

UX and A/B testing, applied on everything from trivial UIs to business processes is the 5th gen language. It's not automated, but it's how, for example, Google, Facebook, most of newer games work. Programmers no longer make decisions no more than they do in original button click question. They merely shape the data they gather. The syntax this is done in is mostly inconsequential.

Prolog was about: "Is X human?". Development today is: "Will changing button to blue improve revenue?". Applied AI is not only in use today, but is just about only profitable programming venue left, outside of monopolies. And this approach is absurd. People start with some dumb app, then follow the flow into profitability, never being any the wiser as to what or why they are doing it.

We are living in the future.
0

Share this post


Link to post
Share on other sites
[quote name='npatrick04' timestamp='1324305116' post='4895295']
Andrew111, check out [url="http://www.swig.org/"]SWIG[/url]. I haven't had an opportunity to use it yet, but it looks like a solid project for auto-generating wrappers. A quick check shows that they support Racket.

[quote name='andrew111' timestamp='1324266690' post='4895176']
The disadvantages are that you have to write interfaces to c shared libraries to do anything useful, e.g. latest version of opengl, physics, sound, window etc. Though some of the other lisps might have bindings for those things already (I know common lisp does, but I prefer scheme).

I'm currently in the process of writing a library that auto generates bindings from c header files (nearly complete), it uses macros so that you just make a module and call a macro from my library which when compiled will auto generate the bindings for you.
[/quote]
[/quote]
Thanks! I'd heard of it but had totally forgotten about it.


0

Share this post


Link to post
Share on other sites
I did a mapgen in F# once as a 'real' project since the problem fit the language fairly nicely and it could integrate with the rest of the C# game. I don't remember really how it went. Probably not so well given my inexperience with F# at the time.

In general, it's a solution looking for a problem. People, even programmers, just don't think in that sort of 'cascading series of functions' manner; certainly not for anything sizable.
0

Share this post


Link to post
Share on other sites
[quote name='Telastyn' timestamp='1324328997' post='4895467']
I did a mapgen in F# once as a 'real' project since the problem fit the language fairly nicely and it could integrate with the rest of the C# game. I don't remember really how it went. Probably not so well given my inexperience with F# at the time.

In general, it's a solution looking for a problem. People, even programmers, just don't think in that sort of 'cascading series of functions' manner; certainly not for anything sizable.
[/quote]

Well, referential transparency and deep immutability are quite generally useful tools in my opinion that deserve to be used a lot more. Tools, that is, that I would wish to be able to opt into whenever I want, instead of getting them shoved down my throat, after which I have to take a doctorate in CS to relearn how to print to the command line using monad-magic.

I am quite eagerly waiting for D 2.0 to mature. It is still buggy at present, but it has the right idea: being able to mark functions as pure, and being able to declare data as deeply immutable. That, plus functions as first class citizens, is basically all I want from the functional world.

On an unrelated note, I heartily despise the terseness of most functional languages. I dont care if you can reduce the syntax of your language to lambda-calculus, I want to be able to see the structure of my code at a glance. I think python has the right idea there. Make whitespace a rule rather than a convention, ditch the damn braces, and use descriptive names for operators rather than cryptic symbols. Code gets read a lot more often than it is written, and writing do_useful_operation isnt really that much more work than writing '%^, but its a lot easier to parse to the human eye. Functional language designers seem to have all the wrong ideas here, that kind of hacker mentality which boils down to not realizing brainf*ck was never anything but an example of what not to do.
1

Share this post


Link to post
Share on other sites
Keep in mind that Scheme is not a functional language -- It may prefer functional constructs and share some other features, but the macro system in Scheme and Lisp make it a very different beast, allowing you, essentially, to build up your own language moreso than with any other -- in fact, Scheme was created with the goal of taking that ability to its logical conclusion, wherein most of what you think is Scheme itself, is really just Scheme code running on the very core of Scheme itself. You can effectively build scheme into all sorts of paradigms.

Scheme and functional languages map pretty clearly to problems that are fundamentally a transformation -- though efficiency can be difficult. They tend also to map well to problems that can be defined with a declarative style (good functional APIs often read as declarative statements).

The graphics pipeline is essentially a functional one, so its something of a shame that the first high-level shader languages were modeled on C. In the earliest shader models, the C-like model actually broke down, though today the hardware is evolving upwards to meet the language model that was foisted upon it. Many shaders become exceedingly short if you remove all the cruft that's modeled after C.
1

Share this post


Link to post
Share on other sites
I used F# for one of my tech test. It uses C# / SlimDX for the graphics side while I used F# for the entire car dynamics module.
It was incredibly smooth, bug free and a very rewarding programming experience overall. The ability of F# to keep that "imperative door" open sort of makes you feel safe you'll never find yourself trapped in some pure functional nonsense lockdown, at the same time it gives you the challenge to implement it functionally.

It is incredible how true is the claim that once you get the thing to compile, you'll hardly need to debug it.. it sounds like a marketing slogan, it really isn't. You just switch around the development time, investing more time designing a functional solution to the problem (this might get better with experience) rather than chasing bugs later in the development stage.

Learning functional languages was one of the best thing that happened to me in the last 2 years of programming, the influence even in my production C++ is huge, and more and more of my classes are now immutable right from the start. I wish C++ added a "readonly" keyword just as C# did.

So I would say, regardless of its present or future use in production code, I would recommend learning functional languages to every programmer interested in an whole new approach to problem solving.
0

Share this post


Link to post
Share on other sites
[quote name='kunos' timestamp='1324369445' post='4895625']
I used F# for one of my tech test. It uses C# / SlimDX for the graphics side while I used F# for the entire car dynamics module.
It was incredibly smooth, bug free and a very rewarding programming experience overall. The ability of F# to keep that "imperative door" open sort of makes you feel safe you'll never find yourself trapped in some pure functional nonsense lockdown, at the same time it gives you the challenge to implement it functionally.

It is incredible how true is the claim that once you get the thing to compile, you'll hardly need to debug it.. it sounds like a marketing slogan, it really isn't. You just switch around the development time, investing more time designing a functional solution to the problem (this might get better with experience) rather than chasing bugs later in the development stage.

Learning functional languages was one of the best thing that happened to me in the last 2 years of programming, the influence even in my production C++ is huge, and more and more of my classes are now immutable right from the start. I wish C++ added a "readonly" keyword just as C# did.

So I would say, regardless of its present or future use in production code, I would recommend learning functional languages to every programmer interested in an whole new approach to problem solving.
[/quote]

I'm curious, what does F# bring to the table over C# now with linq & lambdas? I haven't toyed with F# at all but i'm wondering what the craze is about as the few i've seen was things that were done before they were implemented in C# but now the same is available on both sides.

What does C# miss that F# has, in today's .NET 4 world?
0

Share this post


Link to post
Share on other sites
[quote name='ranakor' timestamp='1324378739' post='4895664']

I'm curious, what does F# bring to the table over C# now with linq & lambdas? I haven't toyed with F# at all but i'm wondering what the craze is about as the few i've seen was things that were done before they were implemented in C# but now the same is available on both sides.

What does C# miss that F# has, in today's .NET 4 world?
[/quote]

I don't consider myself an expert in F#. Being C# a very modern language I don't think there is a single thing that you can do with F# and you can't in C#. But the default assumptions are different, in C# you can make an immutable value by declaring it readonly, in F# it's just the opposite, you need to mark it "mutable" if you dont want immutability.. most, if not all, bugs in F# come from mutable values. so, in a way, you're marking yourself the places where anything can go wrong. So it is no what you can or cant do, but it is more about how the language "wants" you to use it and how the language drives you towards a certain style of solution.


Plus F#'s syntax is much more clean and simple.. if that's an added value. I hope MS will invest in better tools to navigate F#'s source code and improves intellisense with it.
0

Share this post


Link to post
Share on other sites
[quote name='ranakor' timestamp='1324378739' post='4895664']
What does C# miss that F# has, in today's .NET 4 world?
[/quote]

F# has [url="http://msdn.microsoft.com/en-us/library/dd233243.aspx"]units of measure[/url], [url="http://msdn.microsoft.com/en-us/library/dd233198.aspx"]some syntactic sugar for type fiddling[/url], [url="http://msdn.microsoft.com/en-us/library/hh156509%28v=vs.110%29.aspx"]type providers[/url] (which are cool for programming language theorists, but I haven't seen them do much in practice yet). But mostly [url="http://msdn.microsoft.com/en-us/library/dd233248.aspx"]F#'s fancy pattern matching capabilities[/url].

Personally I don't think that those are anywhere near enough, given C#'s advantages with tooling and more natural integration with existing .NET code.

[quote]
Well, referential transparency and deep immutability are quite generally useful tools in my opinion that deserve to be used a lot more. Tools, that is, that I would wish to be able to opt into whenever I want, instead of getting them shoved down my throat, after which I have to take a doctorate in CS to relearn how to print to the command line using monad-magic.
[/quote]

Indeed. And that's what we're seeing. Scala and C# pulling in the good stuff of functional programming to use where applicable.

[quote]
On an unrelated note, I heartily despise the terseness of most functional languages.
[/quote]

I very much agree, though among programming language theorists it's not even discussed. Take a look through [url="http://lambda-the-ultimate.org"]LtU[/url] sometime and see how much of the site is dedicated to programmer usability. But then again, I tend to be on [url="http://tangent-lang.blogspot.com/2010/12/shiny-things.html"]the far end of the spectrum[/url] in wanting/making verbose programming languages.
0

Share this post


Link to post
Share on other sites
I think the rub, for me anyway, is that these 5th-gen PLs are becoming more and more functional. It's almost like, us as programmers, are in some weird denial process. We use imperative languages that are becoming more and more functional. But at the same time we say, "OMG, it's functional! The syntax. My eyes, my eyes!" (ok, there's some exaggeration there) We should just brace F#/OCaml/Lisp and be done with it.

(end rant)
1

Share this post


Link to post
Share on other sites
[quote name='Telastyn' timestamp='1324391382' post='4895710']
[quote name='ranakor' timestamp='1324378739' post='4895664']
What does C# miss that F# has, in today's .NET 4 world?
[/quote]

F# has [url="http://msdn.microsoft.com/en-us/library/dd233243.aspx"]units of measure[/url], [url="http://msdn.microsoft.com/en-us/library/dd233198.aspx"]some syntactic sugar for type fiddling[/url], [url="http://msdn.microsoft.com/en-us/library/hh156509%28v=vs.110%29.aspx"]type providers[/url] (which are cool for programming language theorists, but I haven't seen them do much in practice yet). But mostly [url="http://msdn.microsoft.com/en-us/library/dd233248.aspx"]F#'s fancy pattern matching capabilities[/url].

Personally I don't think that those are anywhere near enough, given C#'s advantages with tooling and more natural integration with existing .NET code.
[/quote]
Dunno, considering how painless it is to add an F# project to your C# solution and just call its functions, id say the barrier to entry is very low. I dont see F# replacing C# anytime soon, but its certainly a nice option.

Dont forget the type polymorphism.

[quote][quote]
Well, referential transparency and deep immutability are quite generally useful tools in my opinion that deserve to be used a lot more. Tools, that is, that I would wish to be able to opt into whenever I want, instead of getting them shoved down my throat, after which I have to take a doctorate in CS to relearn how to print to the command line using monad-magic.
[/quote]

Indeed. And that's what we're seeing. Scala and C# pulling in the good stuff of functional programming to use where applicable.
[/quote]
C# does not have deep immutability (dereferencing an immutable object always returning an immutable object), nor can one declare functions as being pure. I dont see either of these changes coming in C# I suppose.

[quote][quote]
On an unrelated note, I heartily despise the terseness of most functional languages.
[/quote]

I very much agree, though among programming language theorists it's not even discussed. Take a look through [url="http://lambda-the-ultimate.org"]LtU[/url] sometime and see how much of the site is dedicated to programmer usability. But then again, I tend to be on [url="http://tangent-lang.blogspot.com/2010/12/shiny-things.html"]the far end of the spectrum[/url] in wanting/making verbose programming languages.
[/quote]

Interesting post. Cant find a link to more info about the language though.
0

Share this post


Link to post
Share on other sites
Trying not to get too off track...

[quote name='Eelco' timestamp='1324397057' post='4895744']
C# does not have deep immutability (dereferencing an immutable object always returning an immutable object), nor can one declare functions as being pure. I dont see either of these changes coming in C# I suppose.
[/quote]

I don't see deep-immutability as being a language feature (unless I misunderstand you). If you want an immutable object, make one; declare it sealed.
Likewise with pure functions. If you want a pure function, write one.

The optimizer loses some opportunities, but the core concurrency benefits will exist regardless.

[quote]
Interesting post. Cant find a link to more info about the language though.
[/quote]

Clicking the blog title brings you to the [url="http://tangent-lang.blogspot.com/"]landing page[/url]. Most info is there, otherwise a PM might yield better answers to questions.
0

Share this post


Link to post
Share on other sites
[quote name='Telastyn' timestamp='1324398835' post='4895763']
Trying not to get too off track...

[quote name='Eelco' timestamp='1324397057' post='4895744']
C# does not have deep immutability (dereferencing an immutable object always returning an immutable object), nor can one declare functions as being pure. I dont see either of these changes coming in C# I suppose.
[/quote]

I don't see deep-immutability as being a language feature (unless I misunderstand you). If you want an immutable object, make one; declare it sealed.
Likewise with pure functions. If you want a pure function, write one.

The optimizer loses some opportunities, but the core concurrency benefits will exist regardless.
[/quote]
Well, of course one can always program in an immutable style by convention, in any language. But aside from compiler optimizations, its also a matter of coding efficiency. If I use a library function marked as 'pure', I know what im getting into. If I pass into a function an object declared as immutable, I know its going to be the same before and after the call. Without having to dig into the function and check for myself if the person making that function stuck to the convention.

Sealed only applies to declarations, not to instances of the class, or am i missing something?


0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0