PDA

View Full Version : Writing a Programming Language...




ArtOfWarfare
Jul 28, 2013, 12:01 PM
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.



Scrub175
Jul 28, 2013, 12:05 PM
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.

mrichmon
Jul 28, 2013, 01:02 PM
(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.

ArtOfWarfare
Jul 28, 2013, 01:28 PM
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.

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.

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/musings/SmalltalkOverview.html

InTheMist
Jul 28, 2013, 02:24 PM
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.

Red Menace
Jul 28, 2013, 02:42 PM
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.

ArtOfWarfare
Jul 28, 2013, 04:13 PM
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.

robvas
Jul 28, 2013, 04:56 PM
Are you going to be building real features into this language or is it just things you can abstract in another language?

ytk
Jul 29, 2013, 12:38 AM
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.

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.

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.

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.

robbieduncan
Jul 29, 2013, 03:35 AM
Go look at LLVM. It is essentially a toolkit for building compilers. And has a good-quality Mac back-end...

subsonix
Jul 29, 2013, 02:38 PM
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.

ghellquist
Jul 29, 2013, 05:39 PM
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

firewood
Jul 29, 2013, 08:22 PM
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.

ChrisA
Jul 29, 2013, 08:48 PM
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.

ArtOfWarfare
Jul 29, 2013, 09:27 PM
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...

960design
Jul 29, 2013, 10:23 PM
Has anyone else here ever written their own programming language?
Yes. I've written several compliers and several languages for custom
applications.

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.

mslide
Jul 30, 2013, 10:08 AM
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.

dyrer
Aug 3, 2013, 10:29 AM
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.

haley01
Aug 7, 2013, 02:47 AM
Hey....I am fresher in development. Writing a programming language is very tough job. Could you please share something more knowledge with us.

ghellquist
Aug 7, 2013, 06:55 AM
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/1669/learning-to-write-a-compiler

xArtx
Aug 7, 2013, 07:02 AM
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.

firewood
Aug 7, 2013, 11:32 AM
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.

----------

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.

ChrisA
Aug 7, 2013, 01:13 PM
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.

jtara
Aug 7, 2013, 02:29 PM
"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.com/en_us/products/tecnomatix/quality_mgmt/variation_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.

xArtx
Aug 7, 2013, 10:01 PM
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.

psingh01
Aug 8, 2013, 09:14 AM
Sure why not? That's how all languages get created, someone finds a need for it. In all likelihood it will be more effort than its worth but it doesn't mean you shouldn't try.

smallduck
Aug 12, 2013, 01:15 PM
You might be interested in Eero, modifications to the Clang Objective-C compiler that one guy has done to bend the Objective-C syntax into one more to his liking: http://eerolanguage.org

You and the community might be well served if you use & contribute to this (or fork it) and then work from scratch only on the interpretive shell part of your idea. I'd be interested in an immediate interactive environment for the Objective-C runtime (one that wasn't F-Script).

Also, let me plug this language whose development I was following for a while http://xlr.sourceforge.net Although I'm less of a fan now with how the author has evolved the syntax to be so pascal-y, some of the ideas there are brilliant. If nothing else, I believe this language compiles (translates?) down to C so the source code might be a good reference.

ArtOfWarfare
Aug 12, 2013, 01:44 PM
You might be interested in Eero, modifications to the Clang Objective-C compiler that one guy has done to bend the Objective-C syntax into one more to his liking: http://eerolanguage.org

You and the community might be well served if you use & contribute to this (or fork it) and then work from scratch only on the interpretive shell part of your idea. I'd be interested in an immediate interactive environment for the Objective-C runtime (one that wasn't F-Script).

Also, let me plug this language whose development I was following for a while http://xlr.sourceforge.net Although I'm less of a fan now with how the author has evolved the syntax to be so pascal-y, some of the ideas there are brilliant. If nothing else, I believe this language compiles (translates?) down to C so the source code might be a good reference.

Eero looks interesting - I like how much they've taken away from the existing syntax of obj-C. I'll have to look into how the parser works.

subsonix
Aug 12, 2013, 02:00 PM
You might be interested in Eero, modifications to the Clang Objective-C compiler that one guy has done to bend the Objective-C syntax into one more to his liking: http://eerolanguage.org

You and the community might be well served if you use & contribute to this (or fork it) and then work from scratch only on the interpretive shell part of your idea. I'd be interested in an immediate interactive environment for the Objective-C runtime (one that wasn't F-Script).


The claim is that readability matters, well sure but so does maintainability, compatibility and portability among other things. I have not looked into it that much but some problems I see are reliance on white space, single quotes instead of double quotes even though they do not mean the same thing in C, removal of @ means introduction of new reserved words which can also break existing code.

If all you want is a scripting language for Cocoa there are already both Ruby and Python bindings.

ArtOfWarfare
Aug 16, 2013, 10:50 AM
Question:

What is the point of the import command in Python? I understand why most languages have it (for compilation), but it seems to me that as Python is interpreted, it has no need for import statements. When it comes to a variable that doesn't exist in the local, function, class, or global namespace, it should then attempt whatever it does when you type import.

Second (related) Question:

Does Smalltalk have an import command or anything equivalent?

What I'm getting at is that I'd like to not have any import command. It strikes me as needless boilerplate code. It'd be the equivalent of, before greeting someone, saying "import Greetings". (I understand that it can somehow avoid namespace collisions, but I have a different method of avoiding namespace collisions.)

subsonix
Aug 16, 2013, 11:12 AM
Question:

What is the point of the import command in Python? I understand why most languages have it (for compilation), but it seems to me that as Python is interpreted, it has no need for import statements. When it comes to a variable that doesn't exist in the local, function, class, or global namespace, it should then attempt whatever it does when you type import.


It enables expansion beyond what is offered in the language itself with modules, and it allows code to be written in more than one file. That's the main uses I can think of right now.

ArtOfWarfare
Aug 16, 2013, 12:21 PM
It enables expansion beyond what is offered in the language itself with modules, and it allows code to be written in more than one file. That's the main uses I can think of right now.

But why not use the method I provided? IE, right now if I try using a module before the import statement for it, it'll fall on its face and throw errors about how it doesn't recognize the module, instead of attempting to implicitly import it.

subsonix
Aug 16, 2013, 01:35 PM
But why not use the method I provided? IE, right now if I try using a module before the import statement for it, it'll fall on its face and throw errors about how it doesn't recognize the module, instead of attempting to implicitly import it.

What I can think of is avoiding having to text search all modules on the system every time the code is run. And beyond that, naming collisions. There may be more reasons that I have missed.

jf1450
Aug 16, 2013, 01:43 PM
I swore back in my dBase II days (showing my age) I was going to write a language with 2 statements:

set bugs off
DoWhatIThink

danwilliams
Aug 16, 2013, 02:49 PM
I swore back in my dBase II days (showing my age) I was going to write a language with 2 statements:

set bugs off
DoWhatIThink

Oh! You mean this (http://upload.wikimedia.org/wikipedia/en/4/44/ST-TNG_Nth_Degree.jpg)?

ArtOfWarfare
Sep 2, 2013, 02:31 PM
My biggest issue with Obj-C/Cocoa, I think, are lines of code like this:

NSCharacterSet * characterSet = [NSCharacterSet characterSetWithCharactersInString:@".\r\n"];

This one line of code is totally useless by itself but is 93 characters long.

The three main issues I have with it are:
- It repeats what it is 3 times. The full class name is repeated twice, and then for some reason it was felt that it was necessary to have the name of the class method contain the class's name. This practice is repeated with many foundation classes, but NSCharacterSet is particularly annoying because of how long the name is.
- Why is the phrase "CharactersIn" in the method name? Why not just "WithString"? It's impossible for those words to have helped improved the user's understanding of how the method worked.
- What is "NS" supposed to mean to me, as the user of this class. Yes, I know what it means, but how is it useful to me in any way? The answer is it's not. It doesn't give me any greater insight into how it works - if anything it makes me confused about what it means and possibly makes me worry that it'll do something other than what I expect.

Ultimately, that line should look more like (this is written how the syntax of my language looks so far.):

CharacterSet named:characterSet usingString:".\n\r";

Just 52 characters.

Edit: Even worse, you could have an NSMutableCharacterSet, I just realized.

NSMutableCharacterSet *characterSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] mutableCopy];

102 characters.

lee1210
Sep 2, 2013, 07:31 PM
I realize this might fall on deaf ears, but:
Verbosity isn't evil. I tend to prefer over-verbosity to extreme terseness.
In IDEs generally you get completion of classes and methods, so you aren't typing 102 characters, you type 20 or 30.
If you want a +withString:(NSString *) factory, by all means add one with a category. This is a great feature of Objective-C.
Name spacing in class names to avoid conflicts is a bit clumsy, but alternatives like packages in Java have downsides, too. If you need access to two classes with the same name in one file, one will appear fully-qualified throughout. Yuck. Again, NS feels a little clumsy, but certainly doesn't seem that confusing.

In general Apple seems to be working to simplify things, such as NSArray, NSDictionary, and NSNumber literals. This helps make things that should be easy feel that way.

I'd also like to point out that some gripes are with the APIs provided rather than the language itself. Many of these can likely be tweaked using your own helpers, wrappers, categories, etc. As an aside, C++ (so likely Objective-C++) has added auto for typing, to reduce some of the verbosity. So your example in an Obj-C++ file with a category might be:
auto characterSet = [NSCharacterSet withString:@".\r\n"];

Maybe the compiler would choke on inferring the type of a method pass, but I think it could handle it.

My general point is that most languages have rough edges, but generally using tools and your own code (that you can always bring in as a library) can smooth them out a bit.

-Lee

ArtOfWarfare
Sep 3, 2013, 07:54 AM
This isn't a difference between verbose and terse. This is a difference between concise and redundant.

The issue with the character count isn't writing them, it's reading them. There's twice as much code to read.

ElectricSheep
Sep 3, 2013, 10:03 AM
Yes, Cocoa APIs can be quite verbose. But, there is something to be said for the line:

NSCharacterSet * characterSet = [NSCharacterSet characterSetWithCharactersInString:@".\r\n"];

I don't need any additional comments to tell me what this line of code does. It get a new NSCharacterSet containing the characters ".", "\r", and "\n" copied from an NSString literal @".\r\n". This, however:

CharacterSet named:characterSet usingString:".\n\r";

Might leave me wondering: What does "usingString" mean in terms of resource ownership? Is the string being copied? Is the string being retained with a weak or strong reference? If I pass in a huge string and subsequently release it, does "usingString" imply that it will not necessarily be freed as a resource?

ghellquist
Sep 3, 2013, 12:10 PM
Hmm.
But this is not about the language -- it is about the libraries. If you make new librarys the same thing could be
T1 * c= [T1 I:@".\r\n"];

Better?


My biggest issue with Obj-C/Cocoa, I think, are lines of code like this:

NSCharacterSet * characterSet = [NSCharacterSet characterSetWithCharactersInString:@".\r\n"];

This one line of code is totally useless by itself but is 93

chown33
Sep 3, 2013, 01:39 PM
This, however:

CharacterSet named:characterSet usingString:".\n\r";

Might leave me wondering: What does "usingString" mean in terms of resource ownership? Is the string being copied? Is the string being retained with a weak or strong reference? If I pass in a huge string and subsequently release it, does "usingString" imply that it will not necessarily be freed as a resource?

I don't wonder at all. Those are all the responsibility of the class. If it's properly written, they aren't my responsibility. If it's improperly written, then that's a bug, and my only responsibility then is whether to use a buggy class or not.

The ownership issue, as well as copying, are already defined by Cocoa conventions. I see nothing that would lead me to expect anything different. This is especially so if the docs for the method say nothing special about ownership or copying.

ArtOfWarfare
Sep 3, 2013, 09:47 PM
Hmm.
But this is not about the language -- it is about the libraries. If you make new librarys the same thing could be
T1 * c= [T1 I:@".\r\n"];

Better?

No, you have a lot of Obj-C baggage (*, [, @, and ]), you still repeated the name of the class, and now your code is illegible.

Regarding the libraries, I have an issue with the fact that after I write my library, you're going to have to write many of the same functions for your own library, as will every other programmer have to write the same functions. That's a huge amount of wasted time. On top of DRY, there should also be DROP (Don't Repeat Other Programmers). The issue is that there's no good way of getting other peoples libraries. The quality is iffy, the legality is iffy, there's special conditions about how you can compile it, there's a lot of options, the documentation is poor, when an update is released are you going to get it, on and on. Bleh bleh bleh.

I have a lot more than just a language planned. Originally my idea was to just make a plugin for Xcode, but as my ideas multiplied I realized I needed to create an entire ecosystem for all my ideas to work together in. I need a new IDE, a new language, and a new version/package control system to make everything come together.

lee1210
Sep 3, 2013, 10:25 PM
I know it's irrelevant at this point, but adapting a mature language vs. building your own seems way better.

I know none of this is impressive, but a
-(NSCharacterSet *) asCharacterSet
category on NSString. Then:
NSCharacter *set = [@". \r\n" asCharacterSet];
Yes, characterSet appears twice. If methods didn't describe this, nesting message passes would be indecipherable.
Again, I think auto would work, so even:
auto set = [@". \r\n" asCharacterSet];

Pretty concise, and leverages existing language features. You get to keep using all the existing libraries and support.

Again, more power to you, but having 0 people know a language and support it is rough.

-Lee

ghellquist
Sep 3, 2013, 11:51 PM
Not anything new. Check out what the perl programmers did in the library cpan.
http://www.cpan.org/




Regarding the libraries, I have an issue with the fact that after I write my library, you're going to have to write many of the same functions for your own library, as will every other programmer have to write the same functions. That's a huge amount of wasted time. On top of DRY, there should also be DROP (Don't Repeat Other Programmers). The issue is that there's no good way of getting other peoples libraries. The quality is iffy, the legality is iffy, there's special conditions about how you can compile it, there's a lot of options, the documentation is poor, when an update is released are you going to get it, on and on. Bleh bleh bleh.
.

ArtOfWarfare
Sep 4, 2013, 06:27 AM
Not anything new. Check out what the perl programmers did in the library cpan.
http://www.cpan.org/

I am aware that others have tried this before. As far as I can tell, all of them suck. 112k modules isn't necessarily something to brag about - I suspect there's a huge amount of useless code in there, although I confess I haven't been exposed to it so I may be wrong.

ghellquist
Sep 5, 2013, 05:18 AM
Add that you need a lot of friends helping you to write and insure the quality of the libraries. My guess is that getting those together is going to be really difficult part.

As you have already just about killed every other effort of cooperative programming, you really need to define something totally new. I wish you best of luck. The few that has succeeded, ie Linus Thorvald, will be remembered in computer history a long time.

// Gunnar


I have a lot more than just a language planned. Originally my idea was to just make a plugin for Xcode, but as my ideas multiplied I realized I needed to create an entire ecosystem for all my ideas to work together in. I need a new IDE, a new language, and a new version/package control system to make everything come together.

ArtOfWarfare
Sep 5, 2013, 06:23 AM
As you have already just about killed every other effort of cooperative programming,

I don't understand what you're saying here...

I'm not getting rid of cooperative programming - I'm going to coordinate it to make it as productive and non-redundant as possible.

More than having the entire ecosystem take off, I just want to make a Smalltalk 2.0 or something, where other people replicate the ideas that I introduce and popularize them - it's okay if my system falls into obscurity.

ghellquist
Sep 5, 2013, 09:10 AM
Well, sorry if I read you wrong. I read this and you sort of imply that all other librares ever created are included:

The issue is that there's no good way of getting other peoples libraries. The quality is iffy...

In contrast, I find that there is lot of high quality open source code freely available in the languages I have been working in. Only a few examples:

c: there is literally tons of very high quality code available in every thinkable application area. It might take a bit of time to find it, but that investment pays back several times. (in my experience, but YMMV ) .

perl: the library cpan has some really good code.

wordpress: the plugin library is full of very good functions and most of them are completely free.

Of course, in the open source, free world the quality varies. But generally, and again in my experience, the general quality is very high. Some areas of code has "gateways" of people guarding what code is published, some not. But if you look at as example the Linux / GNU area which has gateway keepers you will find professional level quality code well above what I myself will be able to produce.

Regardless, keep up your good work. You have high ambitions, which is a lot better than the alternatives.

// gunnar

ArtOfWarfare
Sep 6, 2013, 05:48 PM
Here's another fun one liner:

NSRegularExpression * tagWithClassRegex = [NSRegularExpression regularExpressionWithPattern:@"<[^>]*?class\\s*=\\s*(\"[^\">]+?\"|\\w+).*?>" options:NSRegularExpressionDotMatchesLineSeparators error:NULL];

203 characters. Again, totally useless on its own.

RegularExpression named:tagWithClassRegex usingPattern:"<[^>]*?class\s*=\s*(""[^"">]+?""|\w+).*?>";

(It seems to me the dot preference should be assumed... I don't understand why it's not in most implementations of regex. It seems to me you should need to explicitly set the opposite.)

Down to 99 characters. Although I may not stick with this way of escaping double quotes in strings... I can imagine problems it could cause.

lee1210
Sep 6, 2013, 07:11 PM
auto tagWithClassRegex = [@"<[^>]*?class\s*=\s*(""[^"">]+?""|\w+).*?>" asRegularExpression];

Regexs always suck.

-Lee

d0vr
Sep 8, 2013, 09:01 AM
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?

I haven't read other replies so you'll have to forgive me if I'm just repeating what others have said, but $^#@ no.

The only reason you should do this is if you have a lot of funding behind you, a very strong core team dedicated to the job, and a reason beyond "this code writes funny."

You can't write a language that is good for everything. If you have a problem to solve and don't think any language is available that adequately solves the problem (not perfectly mind you), AND you can fulfill the other above criteria, go nuts. Otherwise, my personal opinion is that you'd be wasting your time.

Catfish_Man
Sep 8, 2013, 03:19 PM
I haven't read other replies so you'll have to forgive me if I'm just repeating what others have said, but $^#@ no.

The only reason you should do this is if you have a lot of funding behind you, a very strong core team dedicated to the job, and a reason beyond "this code writes funny."

You can't write a language that is good for everything. If you have a problem to solve and don't think any language is available that adequately solves the problem (not perfectly mind you), AND you can fulfill the other above criteria, go nuts. Otherwise, my personal opinion is that you'd be wasting your time.

Well... not wasting their time perhaps. Doing it properly (i.e. not just a syntax-level reskinning of an existing language) is a pretty great educational experience.

I wouldn't expect to produce something generally useful though, true.

Giuly
Sep 8, 2013, 04:46 PM
what is the difference between nil, null, and NULL?

It's Nil, nil and NULL.

ArtOfWarfare
Sep 8, 2013, 06:26 PM
It's Nil, nil and NULL.

:rolleyes:

The way you can blend C and Obj-C (and C++) is both a blessing and a curse. It makes writing valid Obj-C code easier for people leaping from C or C++, but then it also makes it less likely that you'll use some of Obj-C's features (IE, using enumeration blocks instead of for loops.)

d0vr
Sep 9, 2013, 08:10 AM
Well... not wasting their time perhaps. Doing it properly (i.e. not just a syntax-level reskinning of an existing language) is a pretty great educational experience.

I wouldn't expect to produce something generally useful though, true.

Very true, an exceptionally wonderful learning experience if that is what you are doing it for, but in terms of the OP wanting to blend parts of different languages they liked together, I still believe a waste of time.