Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pascal vs C

Name: Anonymous 2010-04-05 17:12

If you were to give a language like Python static typing and make it a compiled language instead of interpreted, you basically end up with something like Pascal. So how would you rate Pascal's abilities compared to C? I know dynamic typing requires runtime checking, but would it be possible to have dynamic typing in a compiled language like Pascal?

Name: Anonymous 2010-04-06 6:04

Common Lisp compiles quite nicely to native code (such as x86). Go look at SBCL, CCL, ACL, SCL, LW, XCL, ... I actually have trouble thinking of what doesn't have some native code support, even CLISP which is one of the slowest/interpreted has a JIT, so it's not entirely interpreted.

CL is fully dynamically typed, and can compile code at runtime. You can however, give hints to the compiler about something's type and if the compiler is good, it may be able to store something unboxed/without tag bigs/no runtime checks or in a more efficient manner.

Full-on dynamic typing is inherently slower than static typing because you have to check if types/functions compatible, and the compiler will generate typechecking code for you(you can do it manually too). Of course, if the compiler can infer types, some safe optimizations are possible. SBCL can to some degree, but Lisp is a very dynamic language, which makes things like ML's or Haskell's typechecking system incompatible with the language design. A subset can be compatible, but you can't gurantee the ``correctness'' of a program at compile-time. Think about functions which can take arguments functions and other arguments of unknown types then call the functions with those arguments (like APPLY/MULTIPLE-VALUE-CALL/FUNCALL/...) or CLOS which allows you to add methods or redefine classes at runtime. I think CL strikes a good balance between dynamic typing and leaving things open to optimization, but it's still not perfect.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List