Good languages that are elegant and fast executing

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Good languages that are elegant and fast executing

Post by josh »

I love PHP, but I've also been reading about using PHP as the "glue" to piece together components compiled in lower level code, etc.. I'm thinking about playing with a lot algorithms that might be CPU intensive and thus a candidate for a compiled language. Most likely I'd create a library of separate utilities that can work together on the shell, and just use PHP to glue these together with objects and shuttle data in & out of mysql. My question is what languages should I be looking at? I've heard of smalltalk, erlang, haskell, java, Eiffel, ANSI C.. all that stuff but what seems like a good candidate for what I'm doing? Portability isn't really a factor. Doesn't java integrate with PHP somehow? Do a lot of languages have solid mysql integration?

I like the idea of having a refactoring browser, the wierd syntax of smalltalk intimidates me, so does python.. I think I'd have to get used to not using the curly braces.. in practices is this just me being anal, or does this really make it easier to screw up your indentation? I'm guessing ANSI C will probably perform best? I guess I realize compiled languages are going to be best, but how do I even start to contrast the trade-offs between performance, ease of learning, productivity, etc?

To clarify these are going to be mostly data crunching to infer meaning from interesting data sets. For instance if you have user rating for items on a website you can use various algorithms like pearson correlation effect ( http://www.texasoft.com/images/winkpe1.jpg ), Bayesian and neural networks, etc etc..

I'll probably port my centroid function too ;-) ( viewtopic.php?f=1&t=44074&p=247765 )

I also have some interesting map rendering code and even access to some nice vector GIS data sets.. all the legacy code I wrote is in PHP and we eventually axed the thing and replaced it with google maps anyways.. but I'm thinking I might be able to rewrite some of this stuff in faster languages and be able to render out the detail that we were lacking before, due to logistics with performance, and do some interesting things...

Anyone else play with anything like this? Even if some of you can just point out interesting languages I can research, it would be very helpful. There's just something cool about the thought of setting up a cluster of data crunching boxes in my garage :-D

On a side note any cool machine learning or general mathematics libraries that should steer me towards one language over another?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Good languages that are elegant and fast executing

Post by Chris Corbyn »

Java certainly won't be fastest at raw speed. It's not "really" a compiled language like C... it runs in a virtual machine.

I'd probably say go with C since it's a familiar language to a lot of people and it's fairly easy to pick up.

Better suggestion though... have a play with a handful and see how they compare :)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Good languages that are elegant and fast executing

Post by Eran »

If you go with C, you can compile your programs into PHP extensions for better integration with your PHP scripts. The PECL site has plenty of resources on starting with extension writing - http://pecl.php.net/support.php#tutorials
wei
Forum Contributor
Posts: 140
Joined: Wed Jul 12, 2006 12:18 am

Re: Good languages that are elegant and fast executing

Post by wei »

Try hadoop and http://wiki.apache.org/pig/PigTutorial

can scale from 1 machine up to thousands. It is used extensively within yahoo for crunching many things with huge data sets (e.g >10 PB).
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Good languages that are elegant and fast executing

Post by alex.barylski »

My question is what languages should I be looking at?
I would suggest C/C++

That way you don't have to much around with language bindings to use the libraries that PHP itself uses. It's faster than anything else (if performance is a concern).
Do a lot of languages have solid mysql integration?
Most probably offer a language bindings, yes.
like the idea of having a refactoring browser
I'm not familiar with Haskell but Java and C++ probably have the largest library of tools, refactoring, profiling, etc.
I'm guessing ANSI C will probably perform best
Without a dought.
guess I realize compiled languages are going to be best, but how do I even start to contrast the trade-offs between performance, ease of learning, productivity, etc?
C is a systems language...it's bar far the most flexible and fastest. It's syntax is clear but pointers make it cryptic. It's easy to learn the basics though and has all the power you can imagine when you want it/need it.

The biggest issue for anyone new to C are pointers. Most libraries are developed by expert C developers and they are geared for optimization. So when you try and use, say MySQL, you are essentially forced into using pointers.
Anyone else play with anything like this? Even if some of you can just point out interesting languages I can research, it would be very helpful. There's just something cool about the thought of setting up a cluster of data crunching boxes in my garage
Many years ago, yes. I developed a flight planner that rendered the navigational aids extracted from MSFS BGL files on a vectored map, along with runways, ILS, frequencies, etc.

The first version was done in VB3 then I decided to switch to C. The performance increase was insane, but that was some 15 years ago running Windows 3.1, I'm not sure the difference in performance would be so obvious these days.

Cheers,
Alex
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Good languages that are elegant and fast executing

Post by josh »

pytrin wrote:If you go with C, you can compile your programs into PHP extensions for better integration with your PHP scripts. The PECL site has plenty of resources on starting with extension writing - http://pecl.php.net/support.php#tutorials
Thanks. I actually just ordered a book on embedding PHP and writing extensions, which was discussed in a similar thread. So you can create PHP extensions with C++ or just C?

Pig and Hadoop look interesting. They will definitely be among the languages I try out.

PCspectra can you link me up or explain what language bindings are exactly? I'd like to get a book that just explains the high level stuff I can't learn on my own, I'm sure most of us like to learn new languages by writing them not reading about them.. any book suggestions then? I already have a head first java book that will be a good reference if I get into Pig / Hadoop

PS. spectra, I started out w/ VB4, you were 1 version ahead of me :lol:
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Good languages that are elegant and fast executing

Post by alex.barylski »

So you can create PHP extensions with C++ or just C?
You could use a mixture of both, except when defining the interfaces PHP expects, if you wrapped those up in a class you would have problems because the 'this' pointer. You could however, build a parsing extension you and use Spirit parser framework and/or Boost libraries, etc.
PCspectra can you link me up or explain what language bindings are exactly?
Essentially they are wrappers or adapters.

Function parameters at a low level, are passed in using several methods, each with it's pro/con of course. Knowing when to use one over the other is mostly a matter of convention but also performance.

http://www.programmersheaven.com/2/Calling-conventions
http://www.openwatcom.org/index.php/Calling_Conventions

Because of these conventions, if you wanted to use a library written in C, in your favorite language B, B would need a wrapper to essentially accept parameters in it's native language/calling convention and then the adapter would then call the library function using the required calling convention.

For instance, Google mysql_query:

[cpp]int mysql_query(MYSQL *mysql, const char *stmt_str) [/cpp]

Then compare that to:

Code: Select all

resource mysql_query ( string $query [, resource $link_identifier ] )
PHP needs a wrapper/adapter in order to communicate with the C API. I don't like the term wrapper/adapter as there are some technical differences, but conceptually that is what a language binding usually is.
I'd like to get a book that just explains the high level stuff I can't learn on my own, I'm sure most of us like to learn new languages by writing them not reading about them.. any book suggestions then? I already have a head first java book that will be a good reference if I get into Pig / Hadoop
High level stuff? Do you have any experience in C/C++? A good starting book would be a learn C in 21 days type book. Yes they go over in great detail the basics on programming, like explaining what control structures are (IF, WHILE, etc) but they often include little annotated tips.

I cannot think of any books that start you off as an intermediate developer (assume some programming experience) for C as most books are either:

1. Assume you know nothing and just started programming 20 years ago when C was the only serious language so there was no "experience from something else"
2. Advanced C programming, covering algorithms like qsort, pointer arithmetic, matricies, etc.

Your best bet would be to start programming and get a feel for what compiling, building, etc is all about.

Bloodshed is a decent C/C++ IDE which will get you started fast. Alternatively you could use the Borland C/C++ compiler (which produces the smallest/fastest machine code -- Intel I have heard is really good as well -- better than M$).

The best IDE for writting C/C++ is Visual C++/studio but it's not free and will only compile on Windows. GNU C compiler would be better choice if you plan on converting the code into an extension.

The problem with using the CLI is you will grow very tired of trying C/C++ without having the entire build process automated, at least to some degree.

If you want a book that really covers ground for C++ I would check out Thinking in C++: http://www.mindview.net/Books/TICPP/Thi ... CPP2e.html

One of the best books I have ever read, period, not just programming. His writing style, detailed approach, no non-sense, etc. He has a book for Java as well, but I'd stick to C/C++ if your ready to get your feet wet with a lower level language.

C/C++ are cross platform, more so than any other language, so you get natively compiled applications that run as fast as possible. You can use C++ libraries like STL to essentially emulate all the pointer-less/GC facilities like in Java so it's really the better language to learn IMHO.

What Java might have over C++ is a better runtime model. But there are "apparently" compiler hacks which introduce RTT facilities like reflection, etc into C++ so...if you look hard enough...who knows.
PS. spectra, I started out w/ VB4, you were 1 version ahead of me
Lucky you. I started with a Commodore Vic-20 and a built-in BASIC interpreter on a blistering 1Mhz processor and 5KB of memory.

I still have the book with the source code that I entered into the computer for the very first time:

Code: Select all

 
1: FOR H = 1 TO 505
2: PRINT "*";
3: NEXT
4: FORC = 8 to 255 STEP 17
5: POKE 36879, C
6: FOR T = 1 TO 500: NEXT
7: NEXT
8: GOTO 4
RUN
 
I remember it like it was 819936000 seconds ago. :P
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Good languages that are elegant and fast executing

Post by josh »

PCSpectra wrote:2. Advanced C programming, covering algorithms like qsort, pointer arithmetic, matricies, etc.
That's what I'm looking for ideally..
PCSpectra wrote:Your best bet would be to start programming and get a feel for what compiling, building, etc is all about.
Did this a couple years ago, made temperature converters, and other command line stuff
PCSpectra wrote: GNU C compiler would be better choice if you plan on converting the code into an extension.
I'd be compiling under linux, so yeah..
PCSpectra wrote: The problem with using the CLI is you will grow very tired of trying C/C++ without having the entire build process automated, at least to some degree.
That's what shell scripts are for, no?
PCSpectra wrote: If you want a book that really covers ground for C++ I would check out Thinking in C++: http://www.mindview.net/Books/TICPP/Thi ... CPP2e.html

One of the best books I have ever read, period, not just programming. His writing style, detailed approach, no non-sense, etc. He has a book for Java as well, but I'd stick to C/C++ if your ready to get your feet wet with a lower level language.
Hmm well yeah I already have plenty of material on java, I'll probably purchase this though...

Thanks for the guidance. Any recommendations for statistical algorithm libraries, etc..? I saw openCV has a few
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Good languages that are elegant and fast executing

Post by josh »

PS what refactoring tools would you recommend looking at for C++?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Good languages that are elegant and fast executing

Post by alex.barylski »

I can't really recommend any single tool in this regard as I never really used refactoring tools in C++ development, plus my interest was primarily Windows development so I used Visual Studio which will sheild you from a lot and keep you from finding alternative solutions as M$ products are always "good enough" know what I mean?

I played with Refactor! for a while but never religiously: http://msdn.microsoft.com/en-us/visualc/bb737896.aspx

Google refactoring tools and source code browsers and your sure to find dozens of tools which you may experiment with.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Good languages that are elegant and fast executing

Post by Chris Corbyn »

jshpro2 wrote:
PCSpectra wrote: The problem with using the CLI is you will grow very tired of trying C/C++ without having the entire build process automated, at least to some degree.
That's what shell scripts are for, no?
GNU Make indeed. I've don't manually build things but I do build on the command line. It helps to gain an understanding of what the compiler and linker tools are actually doing. Then when you use an IDE like XCode you won't have such a hard time knowing what all the compile settings actually do. Makefiles (or Ant scripts if you're writing Java) are nice since you can refactor them into small compile tasks that work together and build them up as your application grows (just like the Build process in your IDE).

An IDE makes everything so much simpler in the end, but an IDE would have confused the hell out of me if I hadn't worked with gcc on the command line before.

I'm a Mac user, who came from a Linux background so everything is very GNU-centric in terms of the build tools. Even XCode uses gcc in the background.

I never quite got around to building an iPhone app :roll:
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Good languages that are elegant and fast executing

Post by josh »

I've been custom compiling on my servers for a while, I use packages where possible for things like PHP or FFmpeg or things w/ lots of dependencies you just need a good old command line.

I think I am going to learn LISP
Lisp (or LISP) is a family of computer programming languages with a long history and a distinctive, fully parenthesized syntax. Originally specified in 1958, Lisp is the second-oldest high-level programming language in widespread use today; only Fortran is older. Like Fortran, Lisp has changed a great deal since its early days, and a number of dialects have existed over its history. Today, the most widely known general-purpose Lisp dialects are Common Lisp and Scheme.

Lisp was originally created as a practical mathematical notation for computer programs, based on Alonzo Church's lambda calculus. It quickly became the favored programming language for artificial intelligence (AI) research. As one of the earliest programming languages, Lisp pioneered many ideas in computer science, including tree data structures, automatic storage management, dynamic typing, object-oriented programming, and the self-hosting compiler.

The name Lisp derives from "List Processing Language". Linked lists are one of Lisp languages' major data structures, and Lisp source code is itself made up of lists. As a result, Lisp programs can manipulate source code as a data structure, giving rise to the macro systems that allow programmers to create new syntax or even new domain-specific programming languages embedded in Lisp.
Check out what else I found:
http://www.aclweb.org/anthology-new/P/P90/P90-1018.pdf

Its written in Prolog
Prolog is a logic programming language. It is a general purpose language often associated with artificial intelligence and computational linguistics. It has a purely logical subset, called "pure Prolog", as well as a number of extralogical features.

Having its roots in formal logic, and unlike many other programming languages, Prolog is declarative: The program logic is expressed in terms of relations, and execution is triggered by running queries over these relations. Relations and queries are constructed using Prolog's single data type, the term. Relations are defined by clauses. Given a query, the Prolog engine attempts to find a resolution refutation of the negated query. If the negated query can be refuted, i.e., an instantiation for all free variables is found that makes the union of clauses and the singleton set consisting of the negated query false, it follows that the original query, with the found instantiation applied, is a logical consequence of the program. This makes Prolog (and other logic programming languages) particularly useful for database, symbolic mathematics, and language parsing applications. Because Prolog allows impure predicates, checking the truth value of certain special predicates may have some deliberate side effect, such as printing a value to the screen. This permits the programmer to use some amount of conventional imperative programming when the logical paradigm is inconvenient.

The language was first conceived by a group around Alain Colmerauer in Marseille, France, in the early 1970s, while the first compiler was written by David H. D. Warren in Edinburgh, Scotland. Prolog was one of the first logic programming languages, and remains among the most popular such languages today, with many free and commercial implementations available. While initially aimed at natural language processing, the language has since then stretched far into other areas like theorem proving, expert systems, games, automated answering systems, ontologies and sophisticated control systems, and modern Prolog environments support the creation of graphical user interfaces, as well as administrative and networked applications.
So I can probably embed these kinds of obscure but frickin cool things into my C / C++ apps, and then open them up to PHP as an extension? That would be frickin cool
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Good languages that are elegant and fast executing

Post by alex.barylski »

So I can probably embed these kinds of obscure but frickin cool things into my C / C++ apps, and then open them up to PHP as an extension? That would be frickin cool
If you can think it, you can do it, is a good rule of thumb with C/C++

By embed, there are several ways to achieve this:

1. You build the executable in Lisp, Prolog, etc and actually include the resulting EXE as a resource of the C executable.
2. You compile the executable in Lisp as a LIB file or DLL and dynamically/statically use that library (static is akin to embedding)

Honestly though, niche languages like Fortran, Prolog, Lisp, etc...are glorified internal DSL's. C is king because it's a systems language but at the same time, a general application programming language. A lot of those languages are intended for academia and not really practical for real world development. That being said, there is little harm in learning anything new and it's not like your so old your on your death bed, so giver!

Personally, I would try and find supporting libraries or DSL's which are used in conjunction with C/C++

For instance, I know you are interested in language theory, parsing, etc.

C++ has a nice framework called Spirit (http://spirit.sourceforge.net/) which lets you express a EBNF grammar in C++ using templates. It's a brilliant idea and makes learning about parsers much easier than reading up on Flex/Bison/Yacc, etc.

The benefit of C/C++ is the tremedous amount of existing code you have to work with.

In fact, you could probably find Lisp interpreters which you could include in your C/C++ applications and embed Lisp code that way -- thats very common in Windows applications and is how most apps provide scripting facilities within, using using JavaScript or Perl.

Here is a Python example: http://www.codeproject.com/KB/cpp/embedpython_1.aspx

I have seen Perl and JavaScript somewhere in the bowls of the CodeProject.com in times past, so I know they exist.

Here is link which may be of interest to you, it's a list of many languages and various implementations. I can't believe this link still exists. :)

http://gd.tuwien.ac.at:8050/F/1/

Cheers,
Alex
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Good languages that are elegant and fast executing

Post by josh »

Hah they're running a secret internet behind our backs on port 8050, thanks for the links
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Good languages that are elegant and fast executing

Post by josh »

Hmm Erlang looks enticing.
Erlang solves one of the most pressing problems facing developers today: how to write reliable, concurrent, high-performance systems. It's used worldwide by companies who need to produce reliable, efficient, and scalable applications. Invest in learning Erlang now.

Moore's Law is the observation that the amount you can do on a single chip doubles every two years. But Moore's Law is taking a detour. Rather than producing faster and faster processors, companies such as Intel and AMD are producing multi-core devices: single chips containing two, four, or more processors. If your programs aren't concurrent, they'll only run on a single processor at a time. Your users will think that your code is slow.

Erlang is a programming language designed for building highly parallel, distributed, fault-tolerant systems. It has been used commercially for many years to build massive fault-tolerated systems that run for years with minimal failures.

Erlang programs run seamlessly on multi-core computers: this means your Erlang program should run a lot faster on a 4 core processor than on a single core processor, all without you having to change a line of code.

Erlang combines ideas from the world of functional programming with techniques for building fault-tolerant systems to make a powerful language for building the massively parallel, networked applications of the future.
Or is Haskell better? ( for clustered, process intensive number crunching applications that need to "run in the cloud" )
Post Reply