Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 28, 2013, 12:01 PM   #1
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Writing a Programming Language...

With each language I learn, I find new parts that I wish were in others, and I find that typical parts that I like are missing. I assume everyone who knows more than 2 or 3 languages probably feels this same way.

What I'm wondering is... at some point, should I write my own programming language that has all those features I miss when I change from language to language?

IE, my favorite part of Obj-C, which is kind of present in Python but not really (and isn't in any other language that I've learned so far), is the inmethod arguments. But at the same time, I like how Python has ditched a lot of confusion snags, IE, what is the difference between nil, null, and NULL? When do I use switch/cases? (Python's answer to most questions like that is simply removing incorrect answers.)

Has anyone else here ever written their own programming language? Was it worth the effort? I've heard that supposedly only 2% of programming languages ever get to the point where they're used by anyone besides the original creator of it.
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   1 Reply With Quote
Old Jul 28, 2013, 12:05 PM   #2
Scrub175
macrumors Demi-God
 
Join Date: Apr 2012
Location: Jensen Beach FL
Even though I'm a very new beginner at programming, isn't the purpose of programming to get the computer to do what you need it to do? With that said, creating a new language is precisely what you should do if current languages can't or don't do what you need. Programming solves problems so a new language would be the answer.
Scrub175 is offline   0 Reply With Quote
Old Jul 28, 2013, 01:02 PM   #3
mrichmon
macrumors 6502a
 
Join Date: Jun 2003
Quote:
Originally Posted by ArtOfWarfare View Post
(Python's answer to most questions like that is simply removing incorrect answers.)
What makes the answers incorrect? The Python community generally presents the argument as the other languages are "incorrect" but in reality, it is a matter of taste and what the language designer(s) are trying to achieve.

No one language is good for everything. No one language has sufficient expressibility or the right level of abstractions for all uses. This becomes particularly apparent when you move into supporting domain-specific languages to allow non-programmers the power that shallow programming in a particular domain provides.

But given your questions about nil, null, and NULL, and "confusing" aspects of other languages I suggest that maybe Python is the first language where your understanding of programming has started to come together. You might want to get experience with other languages before venturing into writing your own. There are many common approaches to language design and it is worth understanding the paths that are already well trodden.

Some key languages that take different approaches than Python, Objective-C, and Java are: Lisp, Haskell, Smalltalk, Self, Scala, Verlog, C++, Prolog.
mrichmon is offline   0 Reply With Quote
Old Jul 28, 2013, 01:28 PM   #4
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by mrichmon View Post
What makes the answers incorrect? The Python community generally presents the argument as the other languages are "incorrect" but in reality, it is a matter of taste and what the language designer(s) are trying to achieve.
Sorry, miswording on my part. Python decided to remove sticking points like that by coming up with a single solution and not having the others. They carefully debate the options, and pick one. In the case of switch/case, they decided to forgo it because the main reason it was introduced in languages like C is to take advantage of jumping between addresses in memory. Such a feature wouldn't actually help in Python, since it's an interpreted language. Java has it for little reason besides that C had it, as far as I can tell.

Quote:
But given your questions about nil, null, and NULL, and "confusing" aspects of other languages I suggest that maybe Python is the first language where your understanding of programming has started to come together. You might want to get experience with other languages before venturing into writing your own. There are many common approaches to language design and it is worth understanding the paths that are already well trodden.
I believe I am adequately familiar with this... nil / null / NULL, from what I recall, stems from C aiming to incorporate some features of C++ and Obj-C being determined to be a perfect superset of C. As a result, there's redundancy.

Quote:
Some key languages that take different approaches than Python, Objective-C, and Java are: Lisp, Haskell, Smalltalk, Self, Scala, Verlog, C++, Prolog.
I'm quite familiar with C++ and I've used Verilog in school... I've read some about Lisp. I suppose I'll look into some of those other languages.

Edit:

I'm reading all about smalltalk and finding it quite fascinating. I like a lot of the ideas and I'm surprised at how many of the ideas I had independently come up with that I thought would be unique to my language are actually in Smalltalk, but there's a good deal that I think my language will have that Smalltalk doesn't.

http://web.cecs.pdx.edu/~harry/musin...kOverview.html
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)

Last edited by ArtOfWarfare; Jul 28, 2013 at 02:21 PM.
ArtOfWarfare is offline   0 Reply With Quote
Old Jul 28, 2013, 02:24 PM   #5
InTheMist
macrumors member
 
Join Date: Jun 2013
The closest I've ever come to this is writing an assembly compiler in Visual Basic. True.

But I can fully understand where you're coming from. Objective-C has so many different types of syntax, it would be nice if that was all wrapped into one.
InTheMist is offline   0 Reply With Quote
Old Jul 28, 2013, 02:42 PM   #6
Red Menace
macrumors 6502
 
Join Date: May 2011
Location: Littleton, Colorado, USA
Another thing you should realize is that anything you do will not come anywhere near the level of the mainstream languages, simply because you aren't going to be able to put anywhere near that amount of time into it.

I know a few guys that use a language that was home grown long, long, long ago. They still use it today probably because they are intimately familiar with it, but it is light weight and pretty good for what it is. I suppose it comes in handy to be able to just whip out the source code and tweak it for some new feature, but this kind of thing looks to be fading fast.
__________________
MacBook Pro / OS X Mavericks (10.9.4) / Xcode 5.1.1 / RubyMotion FTW
Red Menace is offline   1 Reply With Quote
Old Jul 28, 2013, 04:13 PM   #7
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
For a compiler I plan on writing it so that it can compile down to C, and then letting a C compiler compile it into machine language. I also plan on having some sort of command line interpreter like Python has.
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old Jul 28, 2013, 04:56 PM   #8
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
Are you going to be building real features into this language or is it just things you can abstract in another language?
robvas is offline   0 Reply With Quote
Old Jul 29, 2013, 12:38 AM   #9
ytk
macrumors regular
 
Join Date: Jul 2010
Quote:
Originally Posted by ArtOfWarfare View Post
What I'm wondering is... at some point, should I write my own programming language that has all those features I miss when I change from language to language?
If you want to do it for your own education or as a hobby, go nuts. Otherwise, no.

Quote:
Originally Posted by ArtOfWarfare View Post
IE, my favorite part of Obj-C, which is kind of present in Python but not really (and isn't in any other language that I've learned so far), is the inmethod arguments.
MacRuby supports calling methods with inline arguments (not that I really think it's a great way to do things). And as of Ruby 1.9, you can pass pseudo-arguments to a method via a notation that makes it look like they're named arguments, but are really coming in as a Hash.

Honestly, if you generally like Obj-C, but are unhappy with certain things about it, you really should learn Ruby (especially so if you're interested in Smalltalk, since many concepts in Ruby are lifted directly from Smalltalk). In fact, every Mac programmer should learn Ruby. I'd go so far as to say that, for the vast majority of purposes, MacRuby is a better Obj-C than Obj-C. Python is fine for what it is, but if you're using a Mac you owe it to yourself to learn Ruby.

Quote:
Originally Posted by ArtOfWarfare View Post
Has anyone else here ever written their own programming language?
I haven't, but I've read a number of articles on TheDailyWTF about people who thought it was a good idea.

Quote:
Originally Posted by ArtOfWarfare View Post
Was it worth the effort? I've heard that supposedly only 2% of programming languages ever get to the point where they're used by anyone besides the original creator of it.
Be thankful it's not higher. There are enough languages available today that we don't really need another one that simply improves a couple of annoyances some other language has. It would have to pretty revolutionary to warrant its existence.
ytk is offline   0 Reply With Quote
Old Jul 29, 2013, 03:35 AM   #10
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Go look at LLVM. It is essentially a toolkit for building compilers. And has a good-quality Mac back-end...
robbieduncan is offline   0 Reply With Quote
Old Jul 29, 2013, 02:38 PM   #11
subsonix
macrumors 68030
 
Join Date: Feb 2008
It makes the most sense if you have created a fairly complex program and want an alternative interface, a domain specific language will provide an arbritariness that is not possible by normal means. I guess a middle ground is to make a library or commandline interface.

I don't think a general purpose makes much sense, there are already so many to choose from.
subsonix is offline   0 Reply With Quote
Old Jul 29, 2013, 05:39 PM   #12
ghellquist
macrumors regular
 
Join Date: Aug 2011
Location: Stockholm Sweden
Designing and creating a computer language is great fun and a great learning experience. It takes a lot of work though to get the language up and running. Even a simplistic compiler without too much intellegence will include a large software effort and quite a few things to learn and code and debug. You have to decide if it is worth it.

I have been down that road a few times, but none of my efforts has survived for long.

Gunnar
ghellquist is offline   1 Reply With Quote
Old Jul 29, 2013, 08:22 PM   #13
firewood
macrumors 603
 
Join Date: Jul 2003
Location: Silicon Valley
Creating a toy programming language and a functional compiler or interpreter for it is about a medium hard quarter or semester long project in an upper division CS class. I've done that... once for school, and once for "fun".

If you search the web, you'll find a few implementations, tiny/toy Forth, Lisp/Scheme, Basic, Pascal, etc. interpreters of several hundred to a few thousand lines-of-code.

One easier way to get started is to play with the C pre-processor, or adding a more sophisticated pre-processor on top of that, to create your language. That's how the earliest developments of C++ and Objective C actually got started.
firewood is offline   0 Reply With Quote
Old Jul 29, 2013, 08:48 PM   #14
ChrisA
macrumors G4
 
Join Date: Jan 2006
Location: Redondo Beach, California
Quote:
Originally Posted by ArtOfWarfare View Post
With each language I learn, I find new parts that I wish were in others, and I find that typical parts that I like are missing. I assume everyone who knows more than 2 or 3 languages probably feels this same way....
If you just start adding features you get a mess. Better idea is to remove every feature you do not need.

Some examples are PL/1 which had every feature then known. On the other end of the spectrum we have Lisp, which is syntactically minimum.

If you want one that makes sense and was well thought out look at Ada

But if you want to do something useful that work on specialized languages for a specific purpose. It turns out if you can make the structure of the language fit the structure of the task then you reduce the effort to create programs. So the trick is to select a task area like say Computer Vision. Or natural Languag Processing. When you narrow the application area down like that then you can invent something.

Trying to re-invent a general purpose language like C++ or Perl is ony goig to create more un-used compilers.

Yes LOTS of people do this. Compiler writing was a required class for Computer Science students. And of course one of the projects in the class is a compiler, usually a very simple one.

But pick a subject area that you know well, games, robots, signal processing, whatever and write a very narrow language. It many cases you can make it (like SQL) not executable, but really it specifies the problem, or what the rest should look like.
ChrisA is offline   0 Reply With Quote
Old Jul 29, 2013, 09:27 PM   #15
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
I've been brainstorming for the past few days about this and at this point, I have something that borders on looking like an esoteric language. But only because I threw out just about every syntax I was familiar with and started from scratch. I'm wondering if I should put assignments back into my language... and return values...
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old Jul 29, 2013, 10:23 PM   #16
960design
macrumors 6502a
 
Join Date: Apr 2012
Location: Destin, FL
Quote:
Originally Posted by ArtOfWarfare View Post
Has anyone else here ever written their own programming language?
Yes. I've written several compliers and several languages for custom
applications.

Quote:
Was it worth the effort?
Not sure how to answer this one. Yes? Just about everything I do 'was' worth the effort. You should have tasted the egg-drop Ramen I just made! Most definitely worth it.
__________________
TI-99/4A, tape cassette, 12" B&W Zenith
960design is offline   0 Reply With Quote
Old Jul 30, 2013, 10:08 AM   #17
mslide
macrumors 6502a
 
Join Date: Sep 2007
Why bother? If this is purely for academic reasons, then go for it. Otherwise, don't bother. The world doesn't need more programming languages. There's already too many of them that are virtually identical aside from syntax and semantics. After all, just about any problem can be solved with just about any language.

If it were me and I had a lot of spare time to learn something new, then I'd spend it becoming more of an expert in areas that would further my career.
mslide is offline   2 Reply With Quote
Old Aug 3, 2013, 10:29 AM   #18
dyrer
macrumors member
 
Join Date: Feb 2010
Location: Greece
There is no perfect program or perfect programmer, always there BUGS :roll eyes:
Try to improve your skills, give a try more languages (as already mentioned here) there are plenty of them.
__________________
Always have your stuff when you need it with @Dropbox. Sign up for free! https://db.tt/jurO802
dyrer is offline   0 Reply With Quote
Old Aug 7, 2013, 02:47 AM   #19
haley01
macrumors newbie
 
Join Date: Jun 2013
Re:

Hey....I am fresher in development. Writing a programming language is very tough job. Could you please share something more knowledge with us.
haley01 is offline   0 Reply With Quote
Old Aug 7, 2013, 06:55 AM   #20
ghellquist
macrumors regular
 
Join Date: Aug 2011
Location: Stockholm Sweden
Quote:
Originally Posted by haley01 View Post
Hey....I am fresher in development. Writing a programming language is very tough job. Could you please share something more knowledge with us.
Sorry, this is not really fit to be answered in this forum. I actually suggest instead using google and search for "write compiler". One of the first answers there has a long list of references. Many of them are written a lot better than I can (not beeing modest, only realistic).
http://stackoverflow.com/questions/1...ite-a-compiler
ghellquist is offline   0 Reply With Quote
Old Aug 7, 2013, 07:02 AM   #21
xArtx
macrumors 6502a
 
Join Date: Mar 2012
So long as it's not interpreted live on the platform.
Worked with one of those to try to write a program with it,
couldn't even receive on the serial port because the interpreter couldn't poll it fast enough.
xArtx is offline   0 Reply With Quote
Old Aug 7, 2013, 11:32 AM   #22
firewood
macrumors 603
 
Join Date: Jul 2003
Location: Silicon Valley
Quote:
Originally Posted by haley01 View Post
Hey....I am fresher in development. Writing a programming language is very tough job. Could you please share something more knowledge with us.
I started out by reading a few textbooks on the subject (computer languages and compiler construction). Then I took apart and rewrote portions of some small toy languages for which I found short enough source code on the net (a tiny Scheme interpreter, IIRC) to read the entire thing.

----------

Quote:
Originally Posted by xArtx View Post
So long as it's not interpreted live on the platform.
Worked with one of those to try to write a program with it,
couldn't even receive on the serial port because the interpreter couldn't poll it fast enough.
Ha. One of my slow toy language interpreters now runs about 100X faster (polling, etc.) on an iPad, than did my best hand-coded and optimized assembly language on a Mac Plus.
__________________
Apple II+, Mac 128k->512ke, Duo 210, MacBook Air 11, iPhone 5, iPad Mini Retina
firewood is offline   0 Reply With Quote
Old Aug 7, 2013, 01:13 PM   #23
ChrisA
macrumors G4
 
Join Date: Jan 2006
Location: Redondo Beach, California
Quote:
Originally Posted by mslide View Post
Why bother? If this is purely for academic reasons, then go for it. Otherwise, don't bother. The world doesn't need more programming languages. There's already too many of them that are virtually identical aside from syntax and semantics. After all, just about any problem can be solved with just about any language.
As I wrote above, it you pick a narrow task domain, say "computer vision" or "signal processing", or "robot control" and then design a language just for that task. Now you've made working in that task area MUCH easier then using some general purpose language like C++ to control robots.

This is likely the only productive use of new languages and even then you'd be better off extending something that already exists.

SQL is a fine example of this. It is nearly perfect for the very narrow task of searching a database. For example "select a, b, c where a > b" is very easy to write and to understand and is SO MUCH simpler than writing code in C++ to search a file of data.

So your robot control language might just allow the user to specify and end condition and to put constraints of the movement. This would make programming easy.

A language for signal processing you not have data type like integers and strings. You would have "streams" as you data type and operators for filters and resampling and conversion from time and frequency domains. The language would operate on much higher level objects and so the user would not need to write a lot of code for common DSP tasks.

That is the "secret" of designing a good language, defining data types that are a good fit to the task and then good operators on those types.
ChrisA is offline   0 Reply With Quote
Old Aug 7, 2013, 02:29 PM   #24
jtara
macrumors 65816
 
Join Date: Mar 2009
"writing a programming language" is a rather ambiguous term. One might define a new programming language, implement one (once defined), or both.

I've implemented one twice, and defined and implemented once, and 30-so years ago. One presumes the tools needed to do this are easier to use today...

First time was a Computer Science course. We had to implement a compiler for a language that was defined by the instructor. We implemented in PL/1. (What's *that*, LOL!)

Later, I defined and implemented a new language, called VSL, or "Variation Simulation Language". I think this is a good illustration of a legitimate need for a new language. This type of usage is known today as a Domain-Specific Language, or DSL. (Though the term was not yet in use at the time.)

I was working for a company that had a product called VSA - "Variation Simulation Analysis". The had gotten rights to the product from a university professor who had implemented it on a mainframe. This had originally come out of work done at Willow Run Labratories during WWII. They had used the classic "room full of women on mechanical calculators" to do this analysis, and was certainly a contributing factor in our being able to churn-out thousands of airplanes for the war with minimal assembly difficulty.

The product has changed hands several times since then, and it still exists today, 30 years later. It's part of Siemen's Team Center Lifecycle Visualization:

http://www.plm.automation.siemens.co...ation_analyst/

In fact, it's the most popular software used today to perform this type of analysis, and it's been used to help design just about every high-tech complex mechanical product we use, from cars to aircraft to disk drives. I have no idea of VSL is still in use "under the hood" as it's all been long-since made into visual point-and-click operation.

The problem at the time (30 years ago) was that mechanical engineers had to write models in Fortran. Fortran is cumbersome, especially when dealing with multi-dimensional arrays, and mechanical engineers don't generally write very good Fortran code. (Sorry, they are mechanical engineers, not programmers...)

So, they would write a model, then they would have to link it with a static library. (VSA was written in Fortran.) This took about 1/2 hour. (linking compiled object code took a lot longer back then - typically much longer than compiling!) Then, they would discover a mistake and try again.

What I did was a two-step process. First, I defined a simple stack-based interpreter, and implement it in Fortran. It would read a file into an array, and execute simple instructions.

Then, I defined a language specific to the task. It made it very easy to deal with the kinds of things needed for these models - points, lines, planes, assemblies, etc. - and for manipulating them, join, move, etc.

Then I wrote a compiler for VSL using C and the classic Yacc/Prep/Lex stack.

Now a program could be compiled in a short time (maybe less than a minute) and there was no need for the lengthy link step, since now a pre-compiled program could be used that just read the output from the compiler (the interpreter code) and execute it.

Programs ran quickly, because most of the time was spent in complex math-related library functions, which were all written in Fortran. The time spent in program logic (branching, loops, expressions, etc.) was minimal vs. the time spent in the math library.

Use of VSA skyrocketed after that, due to the increase in productivity - the time needed to create a model was now a small fraction of what it had been. Early uses were, for example, to move from mouting hoods using slots (and having to carefully adjust the alignment of the hood during assembly) to using simple drilled holes. Gaps around windshield glass were eliminated and trim replaced with caulking material, as the windshield opening could now be designed to be more precise. Engine pollution levels could be predicted before actually building any engines, speeding the process of complying with new emission regulations.
jtara is offline   0 Reply With Quote
Old Aug 7, 2013, 10:01 PM   #25
xArtx
macrumors 6502a
 
Join Date: Mar 2012
Quote:
Originally Posted by firewood View Post
Ha. One of my slow toy language interpreters now runs about 100X faster (polling, etc.) on an iPad, than did my best hand-coded and optimized assembly language on a Mac Plus.
Hehe.. nice to hear.
My first effort resulted in a micro controller between a GPS and the receiving
device to buffer the serial data, and retransmit it at snail pace so the
interpreter could catch every character:

http://www.engadget.com/2005/11/21/gpsp-gps-on-the-psp/

There was never a version 2... I discovered the native language was C,
and did the vector based GPS.
xArtx is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Which programming language is best for android development? HenrryBerg iPhone/iPad Programming 1 May 17, 2014 06:52 AM
LG or Samsung for programming and writing curiousprgrmr MacBook Air 3 Jul 12, 2013 06:11 PM
Recommend me a programming language shawnb123 Mac Programming 7 Dec 24, 2012 12:31 AM
What programming language do I need to learn to make iPhone apps? sakau2007 iPhone/iPad Programming 6 Jun 26, 2012 07:29 AM

Forum Jump

All times are GMT -5. The time now is 01:56 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC