Static type checking in a small scripting language?

Part of the reason pic related is that popular is because you can learn it in one day.
Say you wanted to created a small scripting language that keeps that property. Are you able to add static type-checking without compromising this goal? Will it be worth it?

Attached: Lua-Logo.png (1200x1200, 73K)

Other urls found in this thread:

github.com/dbohdan/embedded-scripting-languages
github.com/peterhellberg/brandy
twitter.com/SFWRedditImages

bump

People would get confused since they'd be trying to add '1' to 2 and wondering what an "integer" and a "string" is.

OP here. That is one of my worries. The other one is that I can only see this by really crippling some aspects so it would almost be as bad as VBA - minus the non-nestable arrays.
Take arrays or dictionaries, for example, I would need to introduce operators for most actions.

Maybe just leave operators to the core types and make people use functions if they want to do some fancy "add funky objects together" shit.

The problem is that once I add in generics or similar the language is bigger than the primary goal would allow.

As much of a meme flash was, as3 was a really nice language. You had optional static typing. Like
>> var nr = 1;
For dynamic
>> var nr:int = 1;
For static

I wish lua and js had that

lmao just add global type inference

Julia for example has optional types. You can use static types to avoid implicit type conversions for higher performance or dynamic types for easy scripting. There are probably many languages out there with similar concepts

OP here, I want neither, I want basically a proper version of VBA with roughly the size of Lua.
There would be other goodies, for example product types that aren't hash tables.
But alas it seems proper static type checking would pull in too much other stuff.
>t. Hasklel
That doesn't solve the problem, you would still have to deal with other forms of error messages, the user knowing the model of the language, implicit interfaces, interfacing to native code, significant type-checking times for global inference and the (extending on your idea) suckness of structural typing. I could live with partial, local inference for literals and such.
Problem is, safety shouldn't be opt-in. Also, the only way you'd profit in terms of performance in the case of optional types is a convoluted compilation process along the line of JIT compilation. And ultimately, this doesn't make the user interface which the type system is not less complicated. Julia gets away with all that because they do it for performance and deploy a JIT compiler anyway, but for an embedded scripting language it's not an option.
>inb4 LuaJIT
LuaJIT is a crutch that people who designed their scripting API the wrong way have to rely on.

Retards should never be considered in designing a programming language, ever.
Assume the programmer knows what those basic fucking things are.
Your language will turn out much better designed, and still piss easy to learn for actual programmers (your target audience, not crayon eating retards).

>your target audience, not crayon eating retards
Unfortunately my audience isn't the 0.001 % that knows all about proper sum and product types and proper sum enforcement, multiple dynamic dispatch, all kinds of symbolic, generic metaprogramming and constraint checking, proper API design, facilities for asynchronic programming, economic constraints and tool integration...
Chances are, if I dumb a good design down it is still not simple enough but the other half says lolnogenerics.

>LUA
LUA is already infected by LISPtards (they add continuations), now HASCELtards want to shit in it

>Problem is, safety shouldn't be opt-in. Also, the only way you'd profit in terms of performance in the case of optional types is a convoluted compilation process along the line of JIT compilation. And ultimately, this doesn't make the user interface which the type system is not less complicated. Julia gets away with all that because they do it for performance and deploy a JIT compiler anyway, but for an embedded scripting language it's not an option.
Fair enough.
github.com/dbohdan/embedded-scripting-languages
From that list several are statically typed. Maybe one of them is suitable for you.

evereting is infected by LISPtards
use it github.com/peterhellberg/brandy

no Peter stop shilling it
of the few that aren't unsuitable all (that is mostly AngelScript) are too tall (language-wise) already.

OP here; never mind I give up and create a dynamically type-checked one.
Thank you for participating, except for you, Peter.

>you can learn it in one day
>static type-checking
Go is basically that.

There are some things you can typically do in dynamic languages you can't do in statically typed languages, but that doesn't mean static type systems are necessarily harder to use.
Go is an example of a statically typed language that feels just as light as dynamic languages.

I wouldn't call Go a scripting language though. For scripting languages it's kind of necessary that they are dynamically typed and interpreted because their purpose is to run together with a larger compiled core program. Being dynamic enables you to quickly change the parts that are written in the scripting language without having to recompile. You might even dynamically generate some of that code at runtime.

why is lua so fucking fast?

While golang is shit in other regards, it's perfectly possible to embed and interpret statically type-checked languages. You can even generate code at runtime. It's just more annoying on the end of the embedder. See AngelScript, .NET and Lily for reference.

BASIC is faster

It isn't. LuaJIT on the other hand is fast in cherry-picked examples because unlike eg. Python it doesn't have pants-to-head retarded features like creating class hierachies at runtime, so the semantics are simple enough that a JIT compiler can correct them to basically static semancts. Same applies to JavaScript. There is some more smaller details like the choice of API and convention, but basically, Ruby and Python f-ed up.

well, at least Lua is far more consistent than Javashit

Honestly, that's likely just the product of being a smaller language to begin with instead of actual planning.

Use angelscript

I'm not here to use one, user. Though given the choices, I'd probably would, since it has the least bad native interface.

first actual helpful response in this thread

technically, not, since OP wasn't looking for programming languages but guidance about type systems

Just write a forth inside of lua then you can do whatever you want ja ja ja

>all this memeshit
Meanwhile TempleOS can JIT compile 50,000 lines of code a second

dog bless Mike Pall

wew lad, you really went from strong typing to this?