Author Topic: DIY programming language  (Read 6110 times)

Elystan

  • Acolyte
  • *
  • Posts: 13
    • View Profile
    • Email
Re: DIY programming language
« Reply #30 on: July 31, 2016, 11:25:30 AM »
Odd. The distinct impression I get from programming languages was that they were created by hacks who only half-understood mathematics - but I love PHP.

Krice

  • Protector of the @
  • *****
  • Posts: 1995
    • View Profile
    • Email
Re: DIY programming language
« Reply #31 on: August 01, 2016, 10:55:47 AM »
You could give some kind of example what they got wrong.

Elystan

  • Acolyte
  • *
  • Posts: 13
    • View Profile
    • Email
Re: DIY programming language
« Reply #32 on: August 01, 2016, 02:43:25 PM »
Floating point numbers. You don't even get a full set of rationals unless you write your own classes. If I were to write a language I'd have all the subsets of complex numbers and matrices as their own datatypes.

Antsan

  • Priest
  • **
  • Posts: 52
    • View Profile
Re: DIY programming language
« Reply #33 on: August 02, 2016, 09:22:06 AM »
Rationals are in Common Lisp. Most languages don't bother with them because for a long time they were too inefficient. Also the precision the offer is mostly not needed.
Common Lisp also has complex numbers. Matrices and complex nmbers, as opposed to integers and floats, are not generally useful but only in certain domains. Putting them in the base language looks like overkill. Matrices have the additional problem of not being one but infintely many datatypes, that is, they'd need to be a parametrized data types.

Some programmming languages (not C/C++ though) were also built with the idea of keeping the base language as small as possible. Notably these languages are mostly built by people with an academic background, because building a minimal language requires way more thought and knowledge about mathematics than building one that just already has everything you want built in.
So, when a mathematician builds a language that is made as a programming language instead as a tool for a certain mathematical field, it is more likely to include less constructs instead of more.

doulos05

  • Acolyte
  • *
  • Posts: 27
    • View Profile
Re: DIY programming language
« Reply #34 on: August 03, 2016, 06:27:49 AM »
6. Why have 'auto' at all? Why not just determine the type? a=10; //int, a=1.0; //floating point, a="string"; //string
Python does this. I used to think it was awesome, but it just makes it easier to shoot yourself in the foot during variable reassignments. Sure, it lets you do a free cool things, but I'm unconvinced it's worth the couple of keystrokes saved. Also, typed variables make reading your code almost infinitely easier because it reminds you what that variable is (making it stand out more clearly if you have a mismatch of some sort).

Krice

  • Protector of the @
  • *****
  • Posts: 1995
    • View Profile
    • Email
Re: DIY programming language
« Reply #35 on: August 03, 2016, 06:49:46 AM »
Floating point numbers.

I guess the two reasons for that are speed and secondly you can do pretty much everything math related used in real world programs with simple computer math.

Krice

  • Protector of the @
  • *****
  • Posts: 1995
    • View Profile
    • Email
Re: DIY programming language
« Reply #36 on: August 03, 2016, 06:53:36 AM »
Also, typed variables make reading your code almost infinitely easier because it reminds you what that variable is

I think these are equally easy to read:

a=1;
int a=1;

In both cases you know it's a integer variable. Type conversions should be strict (using conversion, not just typing a=b), I agree with that.

doulos05

  • Acolyte
  • *
  • Posts: 27
    • View Profile
Re: DIY programming language
« Reply #37 on: August 03, 2016, 08:32:20 AM »
Also, typed variables make reading your code almost infinitely easier because it reminds you what that variable is

I think these are equally easy to read:

a=1;
int a=1;

In both cases you know it's a integer variable. Type conversions should be strict (using conversion, not just typing a=b), I agree with that.
Sure, that's easy to read. But what about with precalculated value?
a = 5*15
// Several lines of code to set up other variables
return_value = a*2

Versus

int a = 5*15
// Several lines of code to set up other variables
int return_value = a*2

These are obviously intentionally brain dead examples because I'm not going to take the time to type fully functional code into my phone. But surely you can see a case this could happen.

Krice

  • Protector of the @
  • *****
  • Posts: 1995
    • View Profile
    • Email
Re: DIY programming language
« Reply #38 on: August 03, 2016, 12:24:55 PM »
But surely you can see a case this could happen.

I guess it's a good point.

Krice

  • Protector of the @
  • *****
  • Posts: 1995
    • View Profile
    • Email
Re: DIY programming language
« Reply #39 on: August 03, 2016, 12:29:02 PM »
Weird, most people figure this kind of stuff out in college.

Prime number formula:
https://en.wikipedia.org/wiki/Formula_for_primes

I think we have tried to solve this for 2300 years without success. I have an idea, but I haven't had the time to check it out... anyway, I don't even think it's that important.

tuturto

  • High Priest
  • ****
  • Posts: 259
    • View Profile
    • pyherc
Re: DIY programming language
« Reply #40 on: August 14, 2016, 03:10:25 PM »
When talking about DIY languages, lisp tends to pop up a lot, and for a good reason. In general, it's good language. In particular, it's great language for writing the language that you want to use to solve a particular problem. Since code and data are interchangeable in lisp, it's a language that is easy to extend to handle features you would like it to have. It's also very simple language. Writing a working lisp interpreter is a weekend excercise (and fun to boot).

There are some features I would like it to have though, one of them being some sort of static typing with inferred types. But I guess I can't have everything, can I?

There's nice set of MIT lectures for Structure and Interpretation of Computer Programs. It's starts very slowly, from very basic things, but eventually gets to really mind blowing stuff. I often rewatch it just for the sheer fun of it.

Coming up with own language is fun exercise, you should definitely try your hand on it and see what you can come up with.
Everyone you will ever meet knows something you don't.
 - Bill Nye

doulos05

  • Acolyte
  • *
  • Posts: 27
    • View Profile
Re: DIY programming language
« Reply #41 on: August 15, 2016, 01:01:54 AM »
Mind blowing is an understatement for that series. Every time I watch that video series, i feel like everything I knew about computers goes pear shaped.

Krice

  • Protector of the @
  • *****
  • Posts: 1995
    • View Profile
    • Email
Re: DIY programming language
« Reply #42 on: August 19, 2016, 09:32:37 AM »
I watched the first part. Besides almost falling to sleep I learned that the students tried hard to look smart, lisp teachers are smug and there was young Bill Gates in the class.

tuturto

  • High Priest
  • ****
  • Posts: 259
    • View Profile
    • pyherc
Re: DIY programming language
« Reply #43 on: August 19, 2016, 10:07:15 AM »
I watched the first part. Besides almost falling to sleep I learned that the students tried hard to look smart, lisp teachers are smug and there was young Bill Gates in the class.

 ;D :-*

On a related note, Humble Bundle has a bunch of programming books for sale currently. Lots of interesting looking titles for languages like Python, F#, Lisp, Erlang and Haskell. And bunch of books that aren't language specific as far as I can tell.
« Last Edit: August 19, 2016, 10:21:42 AM by tuturto »
Everyone you will ever meet knows something you don't.
 - Bill Nye

Krice

  • Protector of the @
  • *****
  • Posts: 1995
    • View Profile
    • Email
Re: DIY programming language
« Reply #44 on: August 19, 2016, 08:18:40 PM »
Don't remember if I mentioned this but I would probably create a language with just one main paradigm and actually restrict the language having possibility for meta-programming. I can't think any better paradigm than OOP, but it has some problems that could(?) be improved. Maybe you could somehow force OOP to have true modular structure so you could like never access member data directly. I don't know. I think that limitations could make the language actually good, rather than multi-paradigm structure that's breaking everything which leads to confusing mass of source code that in some point will get hard or even impossible to maintain.