Message Boards Message Boards

0
|
12158 Views
|
12 Replies
|
37 Total Likes
View groups...
Share
Share this post:

Real advantage of Wolfram Language

Posted 11 years ago
Hello dear community ,

I write an elaboration on the Wolfram Language. This raises the question to me , so far which is a real advantage of this language? I have some written in Python, as well as in WL and could still see no real advantage. Can anyone point where a real advantage , with an example.
POSTED BY: Max Rasumak
12 Replies
@Max, this is a question many people will ask. I myself is heavy python user for lots of bug/JIRA management with urllib and pycurl. I like both language because they have very flexible list/vector manipulation and syntax, typically the support of lambda function. 

Just like Udo said, the strong front end, visualization  and expression-oriented style endows WL great strength. Very often I need to use Python and WL interactively, which make Mathematica doing alot beyond math. Also as WA is growing, WL is backed by a very strong database and smart input interface. These features turn this language into very good at fast-prototyping with a handful of lines. Users now can focus on their ideas more than coding. 

On the other hand, I can use python's url modules to call WA's API. This makes python even stronger in the STEM domain besides its well-known scipy module and data analysis capability. With the strong text processing nature of Python and its native support for dict data structure/JSON, its is very easy to get customized ouput. I can later embed them into django or jsp swiftly. 

As an engineer, I see less rivalry than between the two languages than collabration. Just use the best tool to do the suitable job
POSTED BY: Shenghui Yang
Szabolcs - very nice explanation. There are also some illustrated pages:

Why Mathematica?
Mathematica Features
POSTED BY: Sam Carrettie
As I said, there's no such thing as "real advantage" without a context: what do you want to do with it?

As Udo said, the example you show would be pretty much the same in every language because it is just putting together a number of library functions in a simple way.  It shows off almost nothing of the language, only what functions are available in its library.

I don't want to discuss marketing terms such as "a new way of computing" ... it's not really what matters to me as a long-time user.  Instead here are a few things that make Mathematica an objectively unique language, and a few things that make Mathematica subjectively useful for me:
  1. A main reason why I am productive in Mathematica is that my workflow is often based on something people have called "improvisational programming".  I do not write single lines of code as you'd do with a command line interface and throw them away later.  Neither do I write a complete program in a source file, and test it when it's ready.  Instead I put together the code that I need incrementally, from many little pieces, continually testing each piece of code as I add layers over it.

    Most of what I do is interactive scientific programming or data processing, and Mathematica is very suitable for this.  The main theme here (for my own use!) is improvisational programming, and the fact that in many cases (not always) I can convert my thought into Mathematica code near "real-time".  Sometimes if I'm working with a colleague and we have an idea, I can test it right away, during the discussion.  I don't have to tell him that I need time to write the program.  It's quick enough to do it right away.  The video Nasser linked to illustrates this to some extent, though it doesn't really drive the point home that the snappy solutions you see there happen really quickly during actual use as well.

    So one of the the main theme in the following is going to be how Mathematica enables this "improvisational programming".
  2. The notebook interface.  This is not part of the language, but it's an important reason why I can work quickly with Mathematica. If you use it for a while, you'll discover that for interactive work it's superior to both command lines (which are too linear) and writing a program in a file than running it.  You get notebooks in other sustems too now: most computer algebra systems have had it for a long time (Maple, MuPad), and now Sage has it, IPython has it, and MATLAB's "cell mode" essentially enables the same workflows.  All of these are inspired by Mathematica, as far as I can tell, and Mathematica's notebook, with its tight integration of graphics and expression formatting is still the best.  I really miss the notebook when I have to work with a command-line-only tool such as R ...
  3. Mathematica is symbolic and everything is an expression. All data structures are expressions.  Program code is an expression (the language is homoiconic).  The same functions that canbe used to manipulate lists and arrays can manipulate expressions.  It is extremely easy to re-shape data into the most suitable format or to work with complex data structures.  In other languages if you need to represent an XML-like data structure, you need to look for a library.  Mathematica's expressions are directly usable to represent an XML file, no extra work needed.  This propery of the language also enables metaprogramming and the creation of DSLs for specific problems.  Here's an example where I use such techniques (code transformation) to create an easier syntax for vectorization.  The key point is that this is not only possible, but easy enough that people actually commonly do it.
  4. Mathematica is based on term rewriting and pattern matching.  This makes Mathematica unique as a programming language.  There are other - pure - languages based on this principle, but Mathematica is the only relatively widely known and used language like this.
  5. Mathematica is mainly functional and very high level. The tradeoff here is that once you're fluent, it enables very quick imprivisational programming in terms of a large number of high level constructs such as Map, ReplaceAll, Outer, Thread, Cases, etc.  However, due to the large number of these fairly fundamental constructs it takes longer to get familiar with them (especially with how they can be used together effectively, which is different from simply knowing them).  When using a lower level language with comparable scope, such as MATLAB, to accomplish a new task, usually there's either a library function to do the task, or I have to do it myself.  If I have to do it myself, it's often very clear how to approach the problem.  It's straighforward, but it also takes time: it's necessary to sit down, and spend time typing in all that code.  Figuring out how to do the same thing with Mathematica is often a more difficult mental exercise (there's isn't one clear strightforward way), but the end result is more compact and much quicker to type. I have to think more, but in the end I end up being faster.  It's also more fun ;-)
  6. Mathematica tends towards declarative APIs.  This is part of being strongly symbolic and functional.  The prime example here are graphics.  In most languages you tell the computer what to draw.  In Mathematica graphics, like everything else, are represented as expressions (and graphics expressions are automatically formatted as the drawing they represent).  Existing graphics can be changed and manipulated the same way as any other expression: there's no need for a separate graphics manipulation API, the basic language directly supports it through having flexible expression manipulation and pattern matching features.
  7. Last but not least, here's a different reason why I love Mathematica: it's a lot of fun!  Early versions already had fancy graphics, sound output, MIDI, etc.   Fun creative projects pop up regularly in the user community.  It's part of the Mathematica user culture, and it's supported by WRI (you'll find lots of cool things on this site).  Here are a few graphics examples.


I probably forgot a few things, but I don't have time to write more today ...
POSTED BY: Szabolcs Horvát
Posted 11 years ago
That's a really nice breakdown Szabolcs, thank you. Has given me a few ideas for explaining the advantages of our tech stack more clearly.
POSTED BY: Scott Kubie
Posted 11 years ago
Thanks it helps me much. Nice WORK !!! 
POSTED BY: Max Rasumak
I think a very important point to remember - among many others - that WL is a "knowledge based" programming language. It means it has an ocean of built in curated data. Take a look HERE at data tabs - what other language has that? Also - read through this:

Stephen Wolfram Demos Knowledge-Based Programming Language As It Approaches Official Release
POSTED BY: Sam Carrettie
Even within this example you could avoid useless intermediate variables
data = Import["Data.csv"];
fft = Abs[Take[Fourier[PadRight[Last[Transpose[data]], 32768, 0.]], 16385]];
min = Round[(# - Floor[#])&[(First[Transpose[data]][[(Position[fft, RankedMax[fft, 2]][[1, 1]] -
                                                      Position[fft, RankedMax[fft, 3]][[1, 1]])]]) 24] 60]

and avoid syntax errors in your Mma example
<snip>
freq = (time[[(pos1 - pos2)]]) * 24;
hours = Floor[freq];
min = Round[(frequenz - stunden)*60]

hours is not the same as stunden as well as freq is not the same as frequenz.
POSTED BY: Udo Krause
My question is, where is the new way of computing? I really do not want to criticize this language. I just want to have something that I really get an extreme advantage to gain through this language. 

You open a file, do a fourier transformation and really ask, where the new way of computing is? Really? The file could be opened with fortran 66 or even with Zuse's machine and a fourier transformation is a fourier transformation is a fourier transformation.

For me Mathematica is an algorithmic laboratory - you can use things together which are elsewhere far away from each other - look at some of the Vitaliy Kaurov posts in this forum or for example see the post Dancing with friends and enemies by Simon Woods in this forum. Try to redo that. 

In the end - because of Wolfram's own Principle of Computational Equivalence - there is no extreme advantage of Mathematica over other systems on philosophical grounds: but it matters a lot if you like or dislike a language you are using, whether you have an integrated system or not, whether you can use a problem oriented programming style or not, whether you can work on the problem inside the notebook structure or not, whether you have data at your disposal or not  ...  

An advantage which is not so small: Reading the help by chance you stumble about stuff you probably didn't know before.
POSTED BY: Udo Krause
The main difference is that Mathematica is symbolic based. Best way to get an idea what this means is to watch Wolfram's video here

Starting to Demo the Wolfram Language
POSTED BY: Nasser M. Abbasi
Posted 11 years ago
Thank you for your response. I know thats symbolic based, but what are the benefits of the new Symbolic character ? What would be the reason to upgrade to this language? What can not I do the same with the other languages ???

I am working a few months with WL and have created many projects, but so far not found a significant advantage.
POSTED BY: Max Rasumak
This question is overly broad, has no context, and is unlikely to lead to a constructive debate (regardless of your intention of posting it).

Different tools are meant for different purposes, have different strength and weaknesses.  You'll find plenty of examples of what people do with Mathematica on this forums as well as on Mathematica.SE.

If you have a specific application in mind, it would make this question much more answerable.
POSTED BY: Szabolcs Horvát
Posted 11 years ago
Thank you for your response. I really do not want to criticize this language. I'm going to ask this one on the aspects / visions of Stephen Wolfram. He says : 

"We call it the Wolfram Language because it is a language. But it’s a new and different kind of language. It’s a general-purpose knowledge-based language. That covers all forms of computing, in a new way:

Something Very Big Is Coming: Our Most Important Technology Project Yet

An example: 

fft of 28800 Data from a SCV File (the tides)

Wolfram Language 
 data = Import["Data.csv"];
 time = data[[All,1]];
 water = data[[All,2]];
 f = Fourier[PadRight[water,32768,0.]];
 fft = Abs[Take[f,16385]];
 pos1 = Position[fft,RankedMax[fft,2]][[1,1]];
 pos2 = Position[fft,RankedMax[fft,3]][[1,1]];
 freq = (time[[(pos1 - pos2)]]) * 24;
 hours = Floor[freq];
min = Round[(frequenz - stunden)*60];

Python
 file = open('Data.csv',"rb")
 reader = csv.reader(file)
 time = []
 water = []
 for data in reader
   time.append(float(data[0]))
   water.append(float(data[1]))
 file.close()
 N = len(water)
FFT = sy.fft(water,32768)/N
FFT_abs = abs(FFT[:16385])
data = heapq.nlargest(3, enumerate(FFT_abs), key = lambda x:x[1])
indices, vals = zip(*data)
pos1 = indices[1]
pos2 = indices[2]
freq = time[((pos1) - (pos2))-1]*24
hours = int(math.floor(freq))
min = int((freq - hours)*60)

In the core area , I have a the identical expense. It was carried out a time measurement:

Wolfram Language
(with csv read) = 12, 6 sec
(without csv read) = 0,26 sec

Python
(with csv read) = 2,4 sec
(without csv read) = 0,49 sec


My question is, where is the new way of computing? I really do not want to criticize this language. I just want to have something that I really get an extreme advantage to gain through this language. 
Thx
POSTED BY: Max Rasumak
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract