Author Topic: F# the new lisp?  (Read 8748 times)

0 Members and 1 Guest are viewing this topic.

DraxJDM

  • Newt
  • Posts: 47
F# the new lisp?
« on: September 22, 2012, 08:11:10 AM »
hey all

I am just starting to learn some programming for autocad and the question like many have, where do i start.

After looking around a bit i find lisp to be the best way to go.
Why, because of a few things. It is easy to learn, you don't have to recode for different versions of autocad like in .NET (is something i find back very often as draw back for .NET)
And then i found some things to F#, a special this slide show  http://secretgeek.net/content/fsharp_leonb.pdf]  at slide 82 it is presentend as the replacement for lisp.

The question, is there anyone of you that is looking in to F#?

Greetz john

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: F# the new lisp?
« Reply #1 on: September 22, 2012, 08:22:46 AM »
The question, is there anyone of you that is looking in to F#?

Speak to gile, he is our resident F# fanatic  :lol:

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: F# the new lisp?
« Reply #2 on: September 22, 2012, 12:03:55 PM »
Hi,

I'm not really "fanatic" nor the single one here to have shown some interest for F#.
I like F# because I like the "functional way of thinking" and also the concision and elegance provided by the F# syntax.
IMO, F# has also its defaults:
  • it's quite confidential, AFAIK, we're only very few trying to use F# programming for AutoCAD (the only ones I know: kaefer, Bobby C. Jones, Jeff H and I here at TheSwamp and Kean Walmsley).
  • the F# runtime isn't istalled with the .NET Framework (at least until Framework 4.0) and needs a separated installation to run F# assemblies.
  • F# does not provide a visual editor to build GUIs as other .NET languages do.

Anyway, learning F# won't be, IMO, really easier than learning any other .NET language, AFAIK, all the F# guys named upper had a .NET knowledge (C# or VB) before they started with F#.
AutoLISP stays the easiest way to begin programming AutoCAD.

About the slide #82 in the slide show you linked, I don't think it means that F# is a replacement for LISP, but that LISP (not strictly AutoLISP) is still the reference when talking about functional programming.
Speaking English as a French Frog

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: F# the new lisp?
« Reply #3 on: September 22, 2012, 01:13:13 PM »
About the slide #82 in the slide show you linked, I don't think it means that F# is a replacement for LISP, but that LISP (not strictly AutoLISP) is still the reference when talking about functional programming.
Yep, even Python (which was supposed to be "Lisp without the parentheses") has some features missing which are available to full-blooded lisps (note AutoLisp is definitely not one of those). BTW, Kean has a blog on how to get Python (or rather IronPython = with DotNet) working as an interpreted language inside AutoCAD. I think there are quite a few IDE's available for Python including GUI designers (e.g. QT / wxWigets) - especially in the Linux world.

Gile: Would a F# "assembly" still need recompilation if a newer version of DotNet is required? Like has happened recently with 2013 and C#/VB.Net? Or is it interpreted from source instead of IL? Sorry, I've only glanced over it a bit - and my impression was that you still had to compile to a DLL file in order to use it. Maybe I missed something.

And of course as per the new DotNet class design from ADesk: it won't matter what language you use if they decide to do so again. You would still need to modify your source (at least) in order to use the new class structure and/or add extra references. Even lisp would not be immune to such a change - though ADesk hasn't changed the lisp library much (only added to instead of altering), maybe the biggest reason that lisp lasted so long: The old stuff still works - no need for recoding.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: F# the new lisp?
« Reply #4 on: September 22, 2012, 02:56:46 PM »
Irne,

F# is a ".NET first class language" as C# or VB, and is compiled in IL in the generated assembly.
The inconvenient about F# I talked upper is due to the using of specific libraries which requires the F# runtime to be installed for the Just in Time compilation from IL.
As for the other .NET languages, there's no need to recompile an assembly built against the Frameowrk 2.0 to use it with newer framworks. The successive .NET framworks are supposed to be like layers added to the previous ones to insure compatibility.

About the AutoCAD .NET API, a little "break" occurs with A2010 which concerned very few class implementation and requiered to rewrite some codes, but most of the apps I wrote for A2007 (Framework 2.0) still work with all versions to A2012 without any change in the code or recompilation wathever the source language.
With A2013, this is a major break due to a "big split" in the AutoCAD referenced libraries which requires to recompile the assemblies even if there's non change in the code (which is the case most of the time).

I don't know much about Python and don't know why it is compared to LISP, but AFAIK it's certainly not for the same reasons as for F#.
As LISP, python is dynamically typed but I don't think it's a functional language. On the other hand, as LISP, F# provides an encourage functional programmaing but is very staticly typed (more than C#).
« Last Edit: September 22, 2012, 03:02:58 PM by gile »
Speaking English as a French Frog

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: F# the new lisp?
« Reply #6 on: September 23, 2012, 04:36:33 AM »
If you have some time to watch some video, I'd recommand:
- An Introduction to Microsoft F# by Luca Bolognese, the funiest F# presentation I saw
- Developping for AutoCAD using F# by Kean Walmsley.

You can try F# without installing anything with Try F#.
Speaking English as a French Frog

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #7 on: September 23, 2012, 12:55:49 PM »
While talking about F# and functional languages, is there anybody here who's worked with Allegro CL?
There's an express version available. If it's any good, I might give it a try...
Greetings to all of you.

DraxJDM

  • Newt
  • Posts: 47
Re: F# the new lisp?
« Reply #8 on: September 23, 2012, 01:08:08 PM »
to Kerry

no that is not my post ..
going to read it now ..


Gille

i have seen the video from Luca..
really like that one ...
for the moment I'm searching the web for examples with Blocks and attributes ( my personal greatest intrest for writing a program)

John
« Last Edit: September 23, 2012, 01:13:01 PM by john »

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: F# the new lisp?
« Reply #9 on: September 23, 2012, 01:27:22 PM »
john,

As I said, you won't find so much AutoCAD F# samples (very very much less than LISP ones...).

One more time, if you're newby with programmation, start with LISP. It's much more easier and, most of the time, really enough powerfull.
Speaking English as a French Frog

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #10 on: September 23, 2012, 02:29:39 PM »
One more time, if you're newby with programmation, start with LISP. It's much more easier and, most of the time, really enough powerfull.

Also very useful is extending lisp with LispFunctions. I'm using them all the time to extend and improve old lisp code. Also, using LispFunctions, there's no need to use DCL or OpenDCL. You can write your dialogs in any .net language and pass data back and forth between .net and lisp code.
From lisp, you can also use the com api.

DraxJDM

  • Newt
  • Posts: 47
Re: F# the new lisp?
« Reply #11 on: September 23, 2012, 02:39:46 PM »
thx for the reply you all

I'm gonna follow Gile's advise and just use lisp... i know it is powerfull enough
to my by the few examples of F# is have seen it looks like easy to learn .. and maybe moor future proof

G.R.  what do you mean with extending lisp with lispfunctions? do you mean visual lisp?

sorry I'm just to new to all this...

 
just a axample of what i have found on the net for autoccad an F#
http://bobbycjones.wordpress.com/2009/05/12/more-f-adventures-you-win-some-you-lose-some/
http://bobbycjones.wordpress.com/2009/05/06/manipulating-polylines-in-autocad-with-f-%E2%80%93-part-i/
« Last Edit: September 23, 2012, 03:36:36 PM by john »

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #12 on: September 23, 2012, 03:33:58 PM »
John,
So called "LispFunctions" are written using the .net api.
They are functions you write using VB.net or C# and  which may then be called from lisp same as any other function written in lisp itself.
If you want more information on that topic, see the AutoCAD .net Developers Guide or do a Google search for "AutoCAD .net api lispfunctions" or something like that.
To write them, you'll need to learn the .net api as well. If I were you, if as you wrote, you decide to go for lisp, just start with lisp proper. There's no need to to start with the .net api all at once. Take it easy, easy does it.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: F# the new lisp?
« Reply #13 on: September 23, 2012, 06:08:46 PM »
While talking about F# and functional languages, is there anybody here who's worked with Allegro CL?
There's an express version available. If it's any good, I might give it a try...
Greetings to all of you.
I haven't tried Allegro CL, though what I've read seems quite good. Another you could also try is LispWorks. They've got a free-to-try version with some restrictions, but the nice thing is they've got a GUI-IDE which produces windows / dialogs / etc in a system independent way: I think they use wxWidgets, which means no matter to what OS you compile it to (Win/Linux/OSX) the actual GUI uses the OS's native stuff. Not sure if Allegro also has such a GUI designer, but I know both can at least compile to native code - though I'm not too sure how they do it. If it's like GNU-CL then all it basically does is link the entire CL library into the EXE file (i.e. the EXE is several megs in size no matter what it actually does).

At the moment I'm using ECL a bit, there's a version which is incorporated inside Qt: EQL. But I'm using wxWidgets myself - just because it's directly using native code instead of Qt's libraries. Though I do like Qt's posibilities: it's like the difference between Java's AWT and NetBeans. Or if you don't mind not having a GUI designer, then ECL has an interactive LispIDE (written in DotNet).

All those lisps are actually in the family of Common Lisp. CL is not necessarily a "functional" language. Not that you "can't" write functional, it's just that CL doesn't "suggest" functional instead of imperative like F# does. And CL does not necessarily handle recursion well (since its spec does not require tail-recursion-optimization). If you want a "more-functional" lisp, then look towards the Scheme branch - tends to prefer functional code and ensures optimal recursion. Though the libraries are much less extensive than CL's.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #14 on: September 23, 2012, 11:59:45 PM »
to irneb,

Thanks for the reply.
I'll have a look at LispWorks.