Author Topic: DIY programming language  (Read 81812 times)

Elystan

  • Newcomer
  • Posts: 14
  • Karma: +0/-0
    • 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

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • 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

  • Newcomer
  • Posts: 14
  • Karma: +0/-0
    • 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

  • Rogueliker
  • ***
  • Posts: 52
  • Karma: +0/-0
    • 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

  • Newcomer
  • Posts: 27
  • Karma: +0/-0
    • 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

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • 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

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • 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

  • Newcomer
  • Posts: 27
  • Karma: +0/-0
    • 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

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • 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

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • 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

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • 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

  • Newcomer
  • Posts: 27
  • Karma: +0/-0
    • 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

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • 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

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • 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

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • 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.