Quantcast

Maximum PC

It is currently Tue Sep 30, 2014 9:28 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Favorite programming idioms and language features...
PostPosted: Mon Mar 08, 2010 1:41 am 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
We constantly discuss why someone should or shouldn't use a particular language without every really getting into any details about the things we like about a language.

So here is your chance to be a fanboy!!! The format / protocol is simple: name the language; discuss the item, feature or technique and why you like it; and, give a small example. I'll get the ball rolling.

1) The first programming language that I learned was BASIC on a Apple IIe clone (a Franklin Ace 1200 that also ran C/PM). Dijkstra was right. BASIC really doesn't have any true redeeming features that a professional developer or academic would find useful or interesting. However, it did have one pretty neat feature. You could go into graphics mode or high-res graphics mode by simply type a g or hg (iirc) and do some "basic" graphics fairly easily. Even a sixth grader could do it... ;-)

OK, that wasn't a very good example... the next one is better. I promise.

2) Java has an incredibly useful method that "splits" a string on a regular expression into an array containing the split pieces.

Code:
String s = "Larry was here!";
String[] arr = s.split(" ");   //arr contains ["Larry", "was", "here!"] now


If anyone knows of any similar functions or methods in other languages, I'd be interested to hear about them.


Top
  Profile  
 
 Post subject: Re: Favorite programming idioms and language features...
PostPosted: Mon Mar 08, 2010 5:12 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Code:
String s = "Larry was here!";
String[] arr = s.split(" ");   //arr contains ["Larry", "was", "here!"] now


That looks strangely familiar :)

Only difference is it accepts a char array by default. If you want to use RegEx you actually use a RegEx class object. A little different but the end result is the same:

http://dotnetperls.com/string-split

Code:
string value = "cat\r\ndog\r\nanimal\r\nperson";
// Split the string on line breaks.
// The return value from Split is a string[] array.
string[] lines = Regex.Split(value, "\r\n");


Top
  Profile  
 
 Post subject: Re: Favorite programming idioms and language features...
PostPosted: Mon Mar 08, 2010 9:39 am 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Mon Jun 14, 2004 4:04 pm
Posts: 985
Location: Earth
Gadget wrote:
So here is your chance to be a fanboy!!! The format / protocol is simple: name the language; discuss the item, feature or technique and why you like it; and, give a small example. I'll get the ball rolling.


I'm not a fan of a single language but I am a fan of several languages:

C#: Because it feels like C++ and I like .NET Framework. The new version, 4.0, will introduce Parallel programming paradigms. LINQ's amazing too as well as lambda expressions.

C/C++: It's fast, it's been around forever and it was the first language(s) I learend.

Ruby: I like Ruby. It's a terse language, very expressive though it can be confusing. Pair it with Rails, you can build websites pretty fast.

LINQ: Because there's nothing like searching a collection like this:

Code:
var q = from i in items
            where i.Property == <Some data>
            select i;


LINQ seems more expressive to me; the same thing can be done on SQL via LINQ to SQL. You can perform operations such as joins.

Objective-C: It's C with OOP sprinkled on top. I'm liking this language.


Top
  Profile  
 
 Post subject: Re: Favorite programming idioms and language features...
PostPosted: Wed Mar 10, 2010 1:37 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
CrashTECH wrote:
That looks strangely familiar :)

Only difference is it accepts a char array by default. If you want to use RegEx you actually use a RegEx class object. A little different but the end result is the same:

It probably looks familiar because they COPIED it from Java! LOL... ;)

Actually, Java has Pattern and Matcher classes that are used to "compile" the regular expression when you need greater performance. I just happened to use the convenience method in the String class because it is... convenient! =)

At first blush, I wanted to say that the ability to use either a character array or regex seemed like a good idea. However, I like that idea after all. A regex is obviously capable of representing any character array (eg {'a','b','c'} is just "abc" as a regex), so the only obvious reason for including both is that you might get a bit more performance compared to using the regex. IMHO, the compiler should be doing this type of optimization wo cluttering up the language. Of course, there could be a good example that I just didn't think of off hand.

While we're on the string topic, Python has a pretty nifty syntax for substrings.

Code:
s = "no datatype declaration here, but it is a string"
t = s[:2]  //t = "no"... there is a silent 0 there equivalent to [0:2]
u = s[3:10] //u is also "datatype" assuming I counted correctly
v = s[-5:] //v is equal to "string", the negative value starts from the end


Of course, strings are always immutable in Python which I'm sure makes some people crazy.


Top
  Profile  
 
 Post subject: Re: Favorite programming idioms and language features...
PostPosted: Wed Mar 10, 2010 2:33 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
DJSPIN80 wrote:
Gadget wrote:
So here is your chance to be a fanboy!!! The format / protocol is simple: name the language; discuss the item, feature or technique and why you like it; and, give a small example. I'll get the ball rolling.

Let me get this straight... you quoted the format/protocol, then decided to not follow it (except for the LINQ example). When did you start working at MS? =)

DJSPIN80 wrote:
I'm not a fan of a single language but I am a fan of several languages:

Which is part of the reason why I created the thread. Most languages have at least one or two idioms that are worth knowing, even if you never use the language for some reason.

DJSPIN80 wrote:
The new version, 4.0, will introduce Parallel programming paradigms.

Interesting... I'm sure that C# must have the equivalent of threads, locks, semaphores and all of the standard low-level concurrency primitives. Are they adding something that resembles a functional programming language -- Lisp or Erlang inspired?

DJSPIN80 wrote:
LINQ's amazing too as well as lambda expressions.

Really? Are lambda expressions the same thing as lambda functions in Lisp?

DJSPIN80 wrote:
LINQ: Because there's nothing like searching a collection like this:

Um, yes there is... 40 year old Lisp. ;P

DJSPIN80 wrote:
LINQ seems more expressive to me; the same thing can be done on SQL via LINQ to SQL. You can perform operations such as joins.

Now that is pretty cool... SQL is horrible for doing anything complicated. I find myself spending far too much time googling for the incantation when I could have written the query in a programming language in a fraction of the time. I actually wrote a small interactive sql environment in Java mainly so that I could pull out the raw data and then solve what ever problem I was working on without developing a brain tumor in the process.

DJSPIN80 wrote:
Objective-C: It's C with OOP sprinkled on top. I'm liking this language.

Now I see that I should have mentioned something about having good taste in programming languages when I started the thread. ;)

NOTE: Any beginners or barely intermediate programmers reading the next paragraph SHOULD learn OOP. This is one of those things that you can debate with the grey beards in industry or academia AFTER you have a job... and with the current emphasis on OOP, you'll need to know OOP in order to get a job, so learn it. Just don't pray to it.

I used to be a huge proponent of OOP. It seemed like most of my larger projects would just go to hell without using OOP (which was probably my fault and not something magical about OOP). Lately, I'm starting to wonder if the programming world hasn't gone OOP crazy though. Paul Graham makes a comment in On Lisp about how many of the G4 design patterns go away when using a language like Lisp, and I've seen several academic papers on how language x with feature y is equivalent to pattern z. The very quotable Alan Kay has made some interesting comments on the state of OOP in languages like C++ and Java...

"OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them."

"Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind."

I wonder if it will take industry longer to get past the current OOP frenzy than it has taken some companies to adopt OOP.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2010 3:19 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
.Net has all that multi-threading stuff. 4.0 is just adding things like parallel loops and parallel linq. It does it automagically for you.

I would NOT write any of the applications I support in LISP, it makes no sense. I will be honest, LINQ is amazing. I don't care that LISP had it forever ago, because it doesn't matter. I wouldn't program anything like what I work on daily in LISP. It would be painfully awful. There are lots of things that LISP just shouldn't be used for, even if it can do it. (Webservices anybody?) Why shouldn't it be a big deal that a new language has features giving more capabilities?

What do you REALLY have against OOP? Your last bit there seems to be really hating on it, which I don't see a reason to. My truck gets me from A to B just as well as Jip's Jeep, or my Wife's car. They all do the same thing, but differently.

Elaborate on this lang x with feature y stuff.... I am curious to where that goes. Why is fewer patterns better?

You seem to favor "old" languages because of how they do things, and seem to "pimp" that they are better because they came first. Seems kind of silly actually. Just because it came first doesn't mean it is better.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2010 3:22 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
Regarding Ruby, I just happened to come across an interview with John McCarthy (one of the fathers of AI and the creator of Lisp):

Quote:
Interviewer: ... many modern programming languages like Ruby are claiming big influences from Lisp. Have you seen those langugaes or do you have any ideas about the current state of programming languages?

JM: I don't know enough, for example, about Ruby to know in what way it's related to Lisp. Does it use, for example, list structures as data?

Interviewer: No.

JM: So if you want to compute with sums and products, you have to parse every time?

Interviewer: Yes.

JM: So, in that respect, Ruby still isn't up to where Lisp was in 1960.


Obviously, the possibility of "programming" the Lisp programming language (ie modifying the language to suit your problem/needs without having to making changes to the underlying lisp system) is an incredibly powerful feature -- once you're able to comprehend the significance, which is no easy task!

Here is an example from a discussion that I was having earlier this week with CrashTECH in a different thread...

Code:
;;until loop macro
;;I copied this from the CL wikipedia article, but I think it originally appeared in On Lisp by Paul Graham...
;;Heck, for all I know, Perl actually copied this loop idea from Lisp
(defmacro until (test &body body)
  `(do ()
    (,test)
    ,@body))

;example usage...
(until (learns 'CrashTech 'Lisp)
       (print "hello?!"))


Four lines of code... very brief lines of code at that... and you have added to the language without having to modify anything in the underlying system.

POWER!!!


Top
  Profile  
 
 Post subject: Re: Favorite programming idioms and language features...
PostPosted: Thu Mar 11, 2010 9:47 am 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Mon Jun 14, 2004 4:04 pm
Posts: 985
Location: Earth
Well, to be honest, I was at work and wanted to keep it succinct. Well, I kept it too succinct. :P

As Crash noted, multi-threading has been around since the .NET 1.0 days. 4.0 introduces parallelism plus some dynamic programming. Oh, and .NET 4.0 will also introduce the DLR for Ruby and Python.

To be frank, like Crash, I don't care about LISP. I'm not against peeps who like it, it's just not for me. LINQ has changed the way I write code. LINQ to SQL allowed me to write complicated logic that massages my data at the business layer (where it's supposed to be) so I don't have to deal with complicated T-SQL at the stored proc level.

I guess I should be more specific about Objective-C (Obj-C). It's like C++ in that it's a superset of C. You can call C functions in Obj-C like you would in C++. They now have garbage collection (introduced in Obj-C 2.0 which is part of the Snow Leopard release) and a few paradigms I've yet to read up on. I'm new to Obj-C but from what I've read and from dev's that I know, they love it...and I'm wanting to find out why.

One day, when I have both time and the desire to look at LISP, maybe I will. :P


Top
  Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2010 10:09 am 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
Not exactly what I had in mind...

CrashTECH wrote:
I would NOT write any of the applications I support in LISP, it makes no sense.

That is your prerogative; however, LISP is not just a historical footnote or a dead language. Lisp has an extremely successful track record in just about every domain of computing: everything from web companies (Yahoo store) to games (Dexter and Jak) to robotics (iRobot) to operating systems and even hardware has been done in Lisp.

CrashTECH wrote:
There are lots of things that LISP just shouldn't be used for, even if it can do it. (Webservices anybody?)

Actually, many of the travel sites use a web service provided in... yep, Lisp. There are quite a few Lisp libraries for developing web apps, connecting to databases, etc. Paul Graham, Robert Morris and a 3rd person (the name escapes me at the moment) created what became Yahoo Store by themselves in an attic.

Most of the gods of computing (Dijkstra, Knuth, Kay, Minsky, Norvig and on and on) have all spoken out in favor a single language... ;)

CrashTECH wrote:
Why shouldn't it be a big deal that a new language has features giving more capabilities?

If a new language did offer "more" capabilities that would be a big deal. However, we both know that in the strict mathematical sense this isn't possible (ie LISP is Turing complete). In the pragmatic programming sense, if someone were to create an interesting new language feature like OOP, it could simply be added using the macro system -- this is how OOP was added to Lisp.

CrashTECH wrote:
What do you REALLY have against OOP? Your last bit there seems to be really hating on it, which I don't see a reason to.

I have absolutely nothing against OOP. My last comment was critical of "industry". It is "industry" that has made OOP into the latest silver bullet in a long line of silver bullets. In another decade, industry will move on to using AOP to fix all of the problems that OOP supposedly caused (which, of course, isn't true).

CrashTECH wrote:
Elaborate on this lang x with feature y stuff.... I am curious to where that goes. Why is fewer patterns better?

Part of it is the distinction between design patterns and design strategies (see Norvig's paper here: http://norvig.com/design-patterns/). Design strategies are generally a good thing. The main criticism of "design patterns" is they provide functionality that is missing from more expressive/powerful languages (see Greenspun's tenth rule). Norvig's example of a subroutine once being a "design pattern" is pretty insightful. Adding functions to a programming language means that you no longer have to push parameters onto the stack, create a return label and jump to and from the subroutine. The "design strategy" is still there; The language has simply eliminated the manual work. Language features like first-class functions, closures, and language abstraction (ie Lisp's macro system), make many of the other design patterns invisible in the same way that a language supporting functions makes the "subroutine pattern" invisible (note: this isn't just something that is limited to Lisp, Smalltalk, Erlang, or Python, my book on Java Reflection gives several examples of how meta-programming simplifies and/or eliminates several of the original gang of four patterns).

Interpreter pattern:

http://en.wikipedia.org/wiki/Interpreter_pattern#Uses_for_the_Interpreter_pattern wrote:
The interpreter pattern specifies how to evaluate sentences in a language. The basic idea is to have a class for each symbol (terminal or nonterminal) in a specialized computer language. The syntax tree of a sentence in the language is an instance of the composite pattern and is used to evaluate (interpret) the sentence.


The reverse polish notation example given in Java and C# results in the creation of 5 classes, one interface, and approximately two screens of code (plus, keep in mind this is an extremely simple example). In Lisp, this design pattern "disappears" because you don't have to implement all of this machinery to support an embedded language.

Strategy pattern:

http://en.wikipedia.org/wiki/Strategy_pattern wrote:
In computer programming, the strategy pattern (also known as the policy pattern) is a particular software design pattern, whereby algorithms can be selected at runtime.
In some programming languages, such as those without polymorphism, the issues addressed by this pattern are handled through forms of reflection, such as the native function pointer or function delegate syntax. This pattern is invisible in languages with first-class functions. See the Python, Scala, Javascript, or Perl implementations for examples.


Comparing the Java and Python implementation is quite an eye opener. Not only is the Python implementation a fraction of the length -- It is FAR clearer what the hell is going on.

CrashTECH wrote:
You seem to favor "old" languages because of how they do t hings, and seem to "pimp" that they are better because they came first. Seems kind of silly actually. Just because it came first doesn't mean it is better.

No. I prefer Java to C++ and C++ to C with classes; however, I prefer C to C++ for lower-level tasks. The only "old" language that I really use is Common Lisp. It just happens to be the case that I can do things in CL that I simply can't do in Java or C++. Of course, just because something comes along decades later doesn't make it better either. ;)


Top
  Profile  
 
 Post subject: Re: Favorite programming idioms and language features...
PostPosted: Thu Mar 11, 2010 11:29 am 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
DJSPIN80 wrote:
As Crash noted, multi-threading has been around since the .NET 1.0 days. 4.0 introduces parallelism plus some dynamic programming. Oh, and .NET 4.0 will also introduce the DLR for Ruby and Python.

Just how dynamic the DLR ends up being is going to be an interesting question. The IronLisp team stopped development of Lisp for the DLR, and decided to use the lessons learned to implement IronScheme; however, they claim the DLR just didn't support the kind of dynamic features necessary for either CL or Scheme. OTOH, it appears that IronPython is coming along pretty nicely.

DJSPIN80 wrote:
I guess I should be more specific about Objective-C (Obj-C).

You don't need to be... for some reason, I read Objective-C, but in my head, I thought that you had written C with classes. My mistake. I've seen examples of Obj-C and spoken to people who use it regularly. From what I gather, I'd probably prefer it to C++.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2010 5:57 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
I understand everything (valid points mind you) you are saying, but it really boils down to sounding like you are saying... "Why use anything else, when LISP is 40 years old and already does it?"

We point out that .NET 4.0 adds newer features to make parallelism automatic and what I get from your replies is that you think it is irrelevant.

http://www.danielmoth.com/Blog/2009/01/ ... net-4.html

Code:
Parallel.ForEach (arr, (string item) =>{
  // Do something
});


I want to see that in LISP.... I honestly don't know it well enough to be able to compare them, but you have to agree that making parallel processing require adding a single key word pretty GD awesome.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2010 7:42 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
CrashTECH wrote:
I understand everything (valid points mind you) you are saying, but it really boils down to sounding like you are saying... "Why use anything else, when LISP is 40 years old and already does it?"

A) Part of the reason that I started this thread to discuss features and languages that we normally don't see covered very much around here... something besides Java, C# and C++.

B) All that I said was, "Um, yes there is... 40 year old Lisp. ;P". I believe the only other Lisp comment that I had made was an inquiry about whether lambda functions in C# were basically the same thing as in Lisp (which I would hope IS the case given their mathematical definition / heritage).

CrashTECH wrote:
We point out that .NET 4.0 adds newer features to make parallelism automatic and what I get from your replies is that you think it is irrelevant.

Huh? I wrote...
Quote:
Interesting... I'm sure that C# must have the equivalent of threads, locks, semaphores and all of the standard low-level concurrency primitives. Are they adding something that resembles a functional programming language -- Lisp or Erlang inspired?


I actually hadn't heard of this .NET feature and was simply inquiring about it.

CrashTECH wrote:
I want to see that in LISP.... I honestly don't know it well enough to be able to compare them, but you have to agree that making parallel processing require adding a single key word pretty GD awesome.

Oh, it is cool, but not novel. Apple's Grand Central Dispatch appears to do the same thing, and I brought up "Are they adding something that resembles a functional programming language" because I figured that it was similar to a type of parallelization that functional programming languages like Lisp, Haskel, ML, Erlang have supported for a number of years. However, instead of using a looping pattern, they typically use mapping functions due to their support of higher-order functions:

Code:
(mapcar #'(lambda (x) (* x x)) '(1 2 3 4 5))
(1 4 9 16 25)
CL-USER>


If there are no dependencies between the elements of my list or array, you can then operate on each item in parallel. The same thing is true in the C# parallel for loop. Often, a second step is performed is to "reduce" the previous computation into a single value. This Lisp idiom is what inspired Google's MapReduce algorithm.

Code:
CL-USER> (reduce #'+ (mapcar #'(lambda (x) (* x x)) '(1 2 3 4 5)))
55


This style of programming, known as "applicative programming", is popular with functional programming languages (note: I'm referring to the use of higher-order mapping functions, not the automatic parallelization). Now whether or not this occurs "out of the box" in Lisp depends on your implementation. Certainly, it has been done by a number of companies and universities (http://en.wikipedia.org/wiki/Connection_Machine is a good read).

Of course, if it wasn't supported by your implementation, you could write a macro to do it (Of course, you could write your own function to do it in C# as well). IIRC, there is a macro in On Lisp that does this very thing, but I don't have the book with me at the moment so I can't check right now.

I believe that Haskell will also automatically memoize your function result that way any repeated computation is a quick hash table lookup. Pretty cool. =)


Top
  Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2010 7:47 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
CrashTECH wrote:
I want to see that in LISP.... I honestly don't know it well enough to be able to compare them, but you have to agree that making parallel processing require adding a single key word pretty GD awesome.

I forgot something... they didn't add a keyword to the language:

Quote:
A related question arises of why not embedding this functionality in the language (the obvious suggestion being introducing a pfor loop construct). The answer is that having it as a library offering instead of built-in to the language allows it to be used by *all* .NET languages instead of restricting it to a few. Also, once something is embedded into the language it typically stays there forever so we take great care about such decisions e.g. it is too early to tie C# or VB to the System.Threading.Tasks namespace.

MS just went ahead and wrote the function for you. ;)


Top
  Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2010 4:50 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Gadget wrote:
CrashTECH wrote:
I want to see that in LISP.... I honestly don't know it well enough to be able to compare them, but you have to agree that making parallel processing require adding a single key word pretty GD awesome.

I forgot something... they didn't add a keyword to the language:

Quote:
A related question arises of why not embedding this functionality in the language (the obvious suggestion being introducing a pfor loop construct). The answer is that having it as a library offering instead of built-in to the language allows it to be used by *all* .NET languages instead of restricting it to a few. Also, once something is embedded into the language it typically stays there forever so we take great care about such decisions e.g. it is too early to tie C# or VB to the System.Threading.Tasks namespace.

MS just went ahead and wrote the function for you. ;)


You are arguing semantics and not the point I brought up.

The point is, that it exists now for EVERY .NET language to use. It isn't like it is a common function you'd have to implement and tweak from application to application. The concept of common libraries is great, except that not every project you do needs every cool function you wrote. Code gets duplicated, that is life.

So why is it that MS makes this function easier and you say that it is irrelevant (you still haven't defended your stance on that btw).


Top
  Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2010 10:38 am 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Mon Jun 14, 2004 4:04 pm
Posts: 985
Location: Earth
I wrote this long discourse and I'm editing to recant.

LISP looks interesting, actually. The idioms alone are pretty interesting. Solving problems in the business domain is pretty similar if you think about it; most of the time, you're taking data (usually in the form of a table, which is nothing but a two-dimensional list) and you're aggregating/massaging data to view the outcome based on some business assumption.

It seems that LISP's design provides an implicit expressiveness and terseness in the language. Though I would want to explore the language further down the road, when I have time (and I mean, time, I travel too much for leisure).

Though, to compare C# against LISP. I consider C# to be very expressive and terse. When they introduced Lambda expressions in 3.5, it has changed the way I write code, because now I can do things in less lines as well as express my logic in a way that's more mathematical.

Parallelism will be achieved using: Parallel.ForEach(...); a function call. Not sure if this is similar to Lisp/Haskel/Erlang. Fill us in.


Top
  Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2010 7:42 am 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Every halo uses an extremely LISP-like scripting engine. Just thought I'd point that out.


Top
  Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2010 4:36 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
CrashTECH wrote:
You are arguing semantics and not the point I brought up.

I'm not arguing for/against anything. Just pointing out that the parallel for loop isn't a keyword. That is all.

CrashTECH wrote:
So why is it that MS makes this function easier and you say that it is irrelevant (you still haven't defended your stance on that btw).

Well, I haven't "defended my stance" on the relevancy of this .NET feature because, once again, I never said that the parallel for loop is irrelevant! In my first post on the subject, I said that it was "interesting" and inquired about more details -- Interesting + inquiry != irrelevant. I have never made a single disparaging remark about this CrashTECH.

I'm sure that it will be something that many .NET developers find very useful. I'm also sure that many Apple developers find GSD to be very useful as well. Neither of them solve any really thorny concurrency issues, so I'm not prepared to say that either one of them is revolutionary or ground-breaking (especially in light of the things that Erlang, Haskell, ML and Lisp HAVE done). I imagine that the author of the article you provided would mostly agree with that sentiment as well.


Top
  Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2010 6:13 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
Dwood15 wrote:
Every halo uses an extremely LISP-like scripting engine. Just thought I'd point that out.

OK... =)

Now share some of your favorite language features / idioms!


Top
  Profile  
 
 Post subject:
PostPosted: Sun Mar 14, 2010 1:35 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Gadget wrote:
Dwood15 wrote:
Every halo uses an extremely LISP-like scripting engine. Just thought I'd point that out.

OK... =)

Now share some of your favorite language features / idioms!


#ifdef

#endif

in C++. If you ever make an addon for a program that has multiple versions, or a game that has multiple versions... Or simply just differences between debug//release builds, that's your best friend. :)


Top
  Profile  
 
 Post subject: Re: Favorite programming idioms and language features...
PostPosted: Fri Apr 02, 2010 4:58 pm 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Thu Jul 22, 2004 11:11 am
Posts: 5108
Location: RFC 1149 - Pidgeon Network
Gadget wrote:
Code:
String s = "Larry was here!";
String[] arr = s.split(" ");   //arr contains ["Larry", "was", "here!"] now


If anyone knows of any similar functions or methods in other languages, I'd be interested to hear about them.


AutoIT

StringRegExp ( "test", "pattern" [, flag ] [, offset ] ] )
With the flag set to 1, will return the array of matches.
can be used to split the "test" string, or simply parse out sections.

e.g.
$Ar=StringRegExp ( "hello mello melly nelly mao", "mell[oy]",3)
$Ar is [mello, melly]


$Ar=StringRegExp ( "hello mello melly nelly mao", "m\S*",3)
$Ar is [mello, melly, mao]

nice for parsing - matching + splitting in one.
It does require knowledge of the regular expression syntax, but this is the same matching expression used in php and perl.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.