Lisp Scheme

Discussion in 'Mac Programming' started by Mac7, Sep 5, 2012.

  1. Mac7 macrumors 6502a

    Mac7

    Joined:
    Jun 14, 2009
    #1
    Any helpful tips for a beginning programmer with no experience in any language? Taking a programming class and we will be using Lisp Scheme
     
  2. 960design macrumors 68000

    Joined:
    Apr 17, 2012
    Location:
    Destin, FL
    #2
    When are you taking this class 1980?

    Kidding! It will not teach you anything to do with current languages. Not one bit of it is relavent. Does that help?

    This sucks, I'm trying to be positive and cannot think of one redeeming feature of Lisp ( common or scheme ). It's easy to learn? But so is C and that leads to C++, Java, C#, php, ect.

    Good luck, I truly mean it!

    PS Why do some computer science classes teach such crap? If the teacher knew anything relevant they would have a job writing code? The ones that know weird stuff get university jobs? Of course I'm being silly and truly appreciate my instructors long ago. The first language I learned was GW-Basic, but I was 9 and self taught. My first university language was Java and that was a huge and painful step up from C ( again self-taught or was it the self teaching that caused the pain ). Maybe they will teach the right way to do things from the beginning with a language that doesn't really get in the way of theory.

    Yeah! I PS'd on something positive!
     
  3. Ap0ks macrumors 6502

    Joined:
    Aug 12, 2008
    Location:
    Cambridge, UK
    #3
    Maybe it's you that is stuck in the 1980s, functional programming is used in a number of industry sectors and has recently seen a resurgence thanks to languages like Erlang and Scala being used by companies like Facebook et al...

    When learning programming it's about the concepts and theory not the language. Once you have the knowledge you can transfer it to any language relatively easily.

    Who would teach the next generation of coders if everyone got a job writing coding?

    @OP - the main tip is to not focus too much on the language syntax, instead on how and why the code does what it does.
     
  4. JoshDC macrumors regular

    Joined:
    Apr 8, 2009
    #4
    I was taught Scheme at University, and the book "Structure and Interpretation of Computer Programs" came highly recommended.

    Further to what Ap0ks said, this is about teaching you some of the fundamentals of programming and not a specific language. I think it's very important you don't question the relevancy of a course purely on the language being taught. You will learn concepts that will be relevant to a career in computer science.
     
  5. 960design, Sep 6, 2012
    Last edited: Sep 6, 2012

    960design macrumors 68000

    Joined:
    Apr 17, 2012
    Location:
    Destin, FL
    #5
    Quite possible, the 80's had pretty amazing clothes, music and hair.

    Could not agree more; which is why I am at a loss for the educational benefits of lisp. None of its theory applies to current languages, the loops are... well, different; I'm not going into a language bashing monologue.

    I understand more than most, pick the right language for the job. Lisp scheme was created to teach people to learn to program, back in the 80's. All I'm saying is that it is not relevant for today's languages. The tools and techniques cannot be applied today.

    Learning to ride a horse will not assist you in flying a jet, in anyway. 100 years ago horse riding was a great skill, if not mandatory. Today, not so much. That's all I'm saying.

    It's not the students fault at all, I blame the university and the lazy professor for not keeping current with technology ( although that is a fairly useless past time as well, at least C is still relevant ).

    Name one that would come from lisp. I tried really hard to come up with a few positives and failed. Help me out here. I know there has to be a good reason, somewhere and I'm just missing it. Couldn't get the answer to Wheel of Fortune yesterday either, even though all but one letter was showing. Must be something I ate.

    I do wish you luck and good fortune in the future. We need tons more of computer science guys around. I work with buildings full of them! [sarcasm][smile]Man you cannot imagine the parties we have.[/smile][/sarcasm]
     
  6. bilboa macrumors regular

    Joined:
    Jan 16, 2008
    #6
    Basic control flow, recursion, abstract datatypes, functions, modules, OO programming... In fact I'm having a hard time thinking of any basic concepts that you can't learn in lisp. Can you come up with one?

    I agree with you that Lisp is not in widespread commercial use these days, but then learning new programming languages should be very easy once someone has a good understanding of programming concepts. I almost consider the programming language to be a detail, compared to a good conceptual understanding of software engineering. A computer science degree should focus on teaching concepts, especially at the beginning, rather than just teaching whatever the current most popular programming language is.
     
  7. Ap0ks macrumors 6502

    Joined:
    Aug 12, 2008
    Location:
    Cambridge, UK
    #7
    Ranching cattle would be a lot easier on horse back than in a jet. As you've said yourself pick the right tool for the job, but just because there aren't many cattle ranching jobs doesn't mean they don't exist ;)
     
  8. 960design macrumors 68000

    Joined:
    Apr 17, 2012
    Location:
    Destin, FL
    #8
    Thank you Ap0ks and biboa:
    Too right you are. How could I have forgotten the really basic stuff like structure, function concepts ( scheme does OOP? that's new to me also )?

    I guess I was missing the base by looking at the.... ooohhh pretty, shiny....

    I'm an idiot, please disregard everything I've written. Now stop reading and start coding!
     
  9. bilboa macrumors regular

    Joined:
    Jan 16, 2008
    #9
    Scheme doesn't have OO as a language feature, but it's easy to implement OO features in scheme, and there are several implementations of classes and generic methods for scheme, modeled on CLOS from Lisp. I actually think implementing OO features yourself is an excellent way to demystify OO programming. It makes it clear that OO programming is a design methodology, and language features that support it just make it more convenient.

    I don't totally disagree with you by the way. I think reasonable arguments could be made for the position that programming courses should be taught in languages that are in current widespread commercial use. I think the validity of those arguments depends in part on what kind of course we're talking about. If it's part of some relatively short vocational training then it probably would be better for the course to focus on giving you some skills that you can immediately get a job with, so I think it probably should use a widely used language. If the course is part of a university computer science program then I think the argument has much less validity, because a computer science program should focus on teaching concepts and techniques which are independent of any particular language, which give you a solid foundation to be a good software engineer.

    I first learned programming in Pascal, which was not used much commercially, but that seems irrelevant in hindsight. I learned control flow, dividing code into functions and modules, how to use arrays, pointers, implement linked lists and trees, and other various programming basics. During my university years I learned C, C++, Scheme, Lisp, ML, OCaml, Awk, Perl, Python, Basic, and Matlab. In the last 15 years of professional programming I have become proficient in Java, Objective C, Ruby, C#, Haskell, F#, PHP, Javascript, and probably some other languages that I'm forgetting. So from my point of view, the idea that the language you learn in your first programming course has to be some particular language just seems silly, since at least if your career goes anything like mine you'll end up needing to learn lots of languages anyway. If anything the first language should be a language which is easy to learn so it doesn't get in the way of learning the concepts you're supposed to be learning, and I think Scheme is a great first language because it's so simple.
     
  10. blesscheese macrumors 6502a

    blesscheese

    Joined:
    Apr 3, 2010
    Location:
    Central CA
    #10
  11. Bill McEnaney macrumors 6502

    Joined:
    Apr 29, 2010
    #11
    Wow! Someone is using a language I love.

    Here's a link to an online edition of an excellent book about Scheme.

    http://htdp.org

    ----------

    I'm inclined to agree about SICP, but I've just suggested a book written for high school students that teaches them how to design programs. It's much different from most programming books I learned from in college because those books start with programming language statements, not with principles.

    ----------

    You may want to download this program and install it.

    http://racket-lang.org/
     
  12. MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #12
    What I don't get is, if they're getting you to learn a Functional Language as a first language, why not Haskell or Scala?
     
  13. jazzbo macrumors member

    Joined:
    Oct 11, 2008
    Location:
    Bangor, ME
    #13
    I think some of the answer to that is above -- the texts available for Lisp, such as SICP are really well established and really well suited for teaching. I don't know if the same exists exists for Haskell or Scala. Most likely the idea here it to get the students thinking about how to program and the underlying language isn't really that important -- as learning the basics will allow people who are programming oriented to pick up another language.
     
  14. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #14
    Just like object orientated languages there are numerous options for functional languages. The argument could be made for any of the following languages as well:

    • Erlang
    • F#
    • ML
    • OCaml

    sometimes you just need to make a decision and stick with it. There are always going to be alternatives and if you spend too long looking for the "perfect" choice you end up not making a decision at all. Sometimes you just need to be pragmatic about things and Scheme is a popular language at Universities around the world.
     
  15. MorphingDragon, Sep 13, 2012
    Last edited: Sep 13, 2012

    MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #15
    I realize that, but Languages like Haskell or Clojure is used in industry and Universities around the world and are much more modern. Scheme is also very unforgiving of tinkering, which denies some students who learn that way the chance to learn in a way that is most useful to them. A good teaching language should be flexible to various learning styles. (EG: Python) F# would fit that nicely, as much as I despise the .Net platform.
     
  16. kthielen macrumors newbie

    Joined:
    Mar 10, 2011
    #16
    Scheme, SICP, etc

    As the others have, I'd also like to put in a good word for Scheme and SICP. I think that Scheme is a great language for tinkering, as long as you develop some muscle memory for balancing parentheses (of course, every language is going to have some syntactic rigidity).

    One aspect of Scheme that hasn't been emphasized yet is the short distance between code (Scheme programs) and data (Scheme values). For this reason, it's very easy to write an interpreter in Scheme, and it may be that you find a smooth ramp up in your exploration of interpreters and compilers through Scheme.

    Also, I've worked on some sensitive software for some major large companies, and I've put Scheme interpreters (which I've built myself) into production. Scheme is definitely not an irrelevant language. If anything, it (as minor syntactic sugar on top of lambda calculus) is a fixed-point of language design. After the nuclear holocaust, there will be nothing but rubble, cockroaches, and Scheme.
     
  17. edenwaith macrumors 6502a

    edenwaith

    Joined:
    Aug 7, 2001
    #17
    Recursion. Lots and lots of recursion.

    I learned CLISP in my AI class and even touched a bit of other functional languages, but it was mostly in CLISP. Haven't touched it in quite a few years. Did have CLISP on an old iBook running Mac OS X 10.1. Not sure if CLISP has been updated to run on modern Macs, though.
     
  18. bilboa, Sep 14, 2012
    Last edited: Sep 14, 2012

    bilboa macrumors regular

    Joined:
    Jan 16, 2008
    #18
    I'm a big fan of Haskell and use it for a lot of hobby projects, but I don't think it's a great first programming language. The problem I see with it is that its simplicity is deceptive. There is some fairly advanced magic to the way lazy evaluation and type inference work in the language, which a programming newbie would have a hard time understanding. To some extent any high level language will have implementation details that a newbie wouldn't understand, but the difference is in Haskell you can't just ignore the magic, because it's integral to understanding why certain things work at all, or don't work.

    Here's a simple example. Say I have a function readIntsFromFile which reads a file containing ints and returns a lazy list of the ints:

    readIntsFromFile :: String -> IO [Int]

    If I wanted to find the max int in this file I might naively write:

    Code:
    main = do 
        ints <- readIntsFromFile "FileOfInts"
        let maxInt = foldl max 0 ints
        putStrLn ("Max int is " ++ maxInt)
    However this will run your program out of memory if the file is big enough, because foldl keeps building up a larger and larger unevaluated thunk as it goes along. You can fix this by using a strict version of foldl, implemented like this:

    Code:
    foldl' f a []     = a
    foldl' f a (x:xs) = strict (foldl' f) (f a x) xs
    But try explaining to a beginner why they need to do this, or how they can tell when to use the strict version of foldl or the lazy version. I have found that it's fairly easy to run into problems like this. Experienced Haskell programmers develop an instinctive understanding of lazy evaluation and use it to write very succinct, elegant and modular code, but it takes some sophisticated understanding of programming and data structures to understand it.

    I've found that type inference is similarly deceptive in its simplicity. It makes it possible to write very succinct and elegant code, but when something doesn't work it often takes a fair amount of sophistication to understand why and what to do about it.

    I do think it's a great idea for students to learn Haskell at some point, just not as a first programming language.

    I also can't figure out what you mean by saying Scheme isn't amenable to tinkering.
     
  19. AlanShutko macrumors 6502a

    Joined:
    Jun 2, 2008
    #19
    Mainstream software is rediscovering a lot of the concepts from lisp.

    Google's infrastructure relies heavily on MAPREDUCE, which is based on the map and reduce from Lisp. Functional programming in general is making a huge
    comeback, because it is so easy to adapt to multiprocessor systems.

    Many java patterns are complex workarounds for the lack of functions as first-class objects in the language. Closures, now available in Java, Objective C, Ruby, Python and other languages, came from Lisp.

    The extremely dynamic object models in Ruby and Javascript are quite close to the object model in Common Lisp Object System (CLOS). Javascript is a prototype model instead of class-based, but that's remarkably easy to build in Lisp.

    If you want to understand the cutting edge concepts in software development right now, learning Lisp and Haskell will get you there.

    ----------

    The CLISP interpreter is available on modern Macs and just about everything else, but it's interpreted. SBCL is available almost as many places and is fully compiled and very fast.
     
  20. MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #20
    Oh of course. It was only an example. If I had to design a syllabus for a beginners course in Haskell, it would only be a small subset of the language. Avoiding map, fold, reduce and Lazy Evaluation until a secondary intro course, much like some universities avoid introducing OO proper until another secondary course.

    It's un-amenable in the opposite way that Haskell isn't. Haskell requires you to think about what your code is doing, and small changes can cause the Type Inference to fail and chuck up unhelpful error messages to a beginner. Scheme has a dynamic system, and in my experiments with it similar code can do exactly the same thing and when it does break it's not clear what you broke.
     
  21. bilboa macrumors regular

    Joined:
    Jan 16, 2008
    #21
    I see, dynamic typing vs. static typing. I used to believe that static typing was clearly easier and dynamic typing inevitably led to difficult to find type errors. However, after doing a couple of large-ish projects in Python and Ruby for work, I've come to the conclusion that the disadvantages of dynamic typing are greatly exaggerated, especially for small projects with only one or two people working on them, such as would be done in a beginning programming class. In practice any runtime type errors would usually show up as soon as I tested the code, and were always very easy to diagnose due to the excellent error-reporting capabilities of languages which run in a virtual machine.

    Certainly if you need to formally prove that your code is correct, then strict static typing along with referential transparency makes that much more possible. Similarly I might be uncomfortable about working on a large project with lots of developers of varying skill levels contributing to it, with a dynamically typed language, since static typing lets you enforce more of interface requirements between components at compile time. I don't believe either of these concerns apply to a beginning programming class. I also think that if you look at real life experience you'll see that it's very common to teach beginning programming classes in Scheme or some other dynamically typed language, and I have never seen any evidence that students fare worse than in a class which uses say Java or C++.
     
  22. MorphingDragon, Sep 15, 2012
    Last edited: Sep 15, 2012

    MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #22
    I have no issue with Dynamic Typing, My First "real" programming language was Objective-C. :D But in teaching languages its helpful if you can break things down easily. Generics is also very bad at doing just that. :/

    I also think C++ and Java are not ideal teaching languages. :eek: Although coding at the terminal is beneficial, when trying to convince someone that programming is fun, quickly making a GUI or Sprite Engine in a language helps a lot.

    When I (privately) tutor people, I often teach them in Python and the concept catches on much better than C#. (The teaching Language Waikato uses) Python has very verbose error messages in IDLE and it is very receptive to fiddling.
     
  23. bilboa macrumors regular

    Joined:
    Jan 16, 2008
    #23
    I agree with most of what you said, but I must say I'm now even more confused about your attitude toward Scheme since you praise Python for being "receptive to fiddling." I don't see what is fundamentally different about the Scheme and Python languages in this regard. One difference between Scheme and Python is that almost all Python programmers use some version of the same implementation of Python, whereas there are many different implementations of Scheme. This means Python programmers get pretty uniform experience with error reporting, whereas Scheme programmers will see very different behavior depending in which Scheme implementation they're using. I'm going to guess that you're basing your opinion of Scheme's unhelpful error messages on some particular Scheme implementation that you've used which didn't produce good error messages. If I were going to teach Scheme in a class, I'd probably use DrScheme, since that gives a pretty nice and beginner-friendly experience.
     
  24. blesscheese macrumors 6502a

    blesscheese

    Joined:
    Apr 3, 2010
    Location:
    Central CA
    #24
    CLISP exists for modern Macs, but is a little clunky.

    Clozure is a nice up-to-date Mac Lisp, and is available on the App store fo' free!
     
  25. Amigaman macrumors regular

    Amigaman

    Joined:
    Sep 29, 2007
    Location:
    Greenville, MI
    #25
    Has anyone else looked at newLisp? It's a general-purpose scripting language based on Lisp. I haven't played with it all that much, but it looks like a neat little language.
     

Share This Page