[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
4Archive logo
/dpt/ - Daily Programming Thread
If images are not shown try to refresh the page. If you like this website, please disable any AdBlock software!

You are currently reading a thread in /g/ - Technology

Thread replies: 321
Thread images: 24
File: DPT.png (389 KB, 934x1000) Image search: [iqdb] [SauceNao] [Google]
DPT.png
389 KB, 934x1000
What are you working on, /g/?
>>
First for static typing and not using type inference
>>
OCaml is the only language worth knowing.
>>
>>52527581
Type inference >>>>>>>>>>>> no type inference.
Static typing >>>>>> dynamic typing.
>>
>>52527581
what's wrong with type inference?
>>
>>52527598
explicit >>>>>>>>>>>>>>>>>>>>>>>>> implicit
>>
>>52527616
You ======== retarded
>>
>>52527610
what's not wrong with type inference?
>>
>>52527626
>inane redundancy
>good
Choose one.
>>
>>52527626
it simplifies what is otherwise verbose and unnessesary code
>>
>>52527639
>clear unambiguous code
>bad

spotted the neet
>>
>>52527639
>>52527643
kill yourselves

good code values safety above being able to read it quickly. it's not even easier to read when it's harder to find out what type a variable is and when you have to keep it in your head or mouse over everything in your IDE.
>>
>>52527647
Even the C++ developers are pushing towards type inference (on the right).
>>
>>52527668
on the right, how does that even work?

so not on the left hand side?
>>
File: 6Qc1svk9zc.jpg (94 KB, 400x400) Image search: [iqdb] [SauceNao] [Google]
6Qc1svk9zc.jpg
94 KB, 400x400
I'm working on a JavaScript library that's basically wrapped around effects/transitions c:
>>
>>52527668
Yeah, because C++ programmers are the experts on clear code...
>>
File: l.png (291 KB, 533x698) Image search: [iqdb] [SauceNao] [Google]
l.png
291 KB, 533x698
>>52527689
>using animations outside of HTML5 Canvas

Absolutely disgusting. It's just a gimmick.
>>
>>52527724
this

even this javascript-using weeb knows what's up

most sites shouldn't even be using javascript at all
>>
>>52527625
Is this the new PHP comparison operator?
>>
>>52527682
I meant this:
https://youtu.be/xnqTKD8uD64?t=1930
>>
>>52527661
>good code values safety above being able to read it quickly
That's what makes type inference so great

> it's not even easier to read when it's harder to find out what type a variable
It's rare you need to know the exact type a given variable is to not be able to infer what it is just from reading the code without type annotations.
>>
>>52527740
:^)
>>
>>52527756
>not knowing the exact type of a variable
>safe
>>
>>52527724
>>52527738

What's wrong with JavaScript? xD
>>
>>52527563
>casting from *void in c++

unsigned char *buffer = (unsigned char*)malloc(filesize);


It works but how do I make it not retarded. Everything I look up says to just cast.

>inb4 stop using c++
>>
>>52527780
exactly. The compiler guarantees safety. No need to scum up your codebase with noise.
>>
>>52527782
a lot of fucking things are wrong with javascript
>>
>>52527793
literally fucking kill yourself retard
>>
>>52527799
nothing's wrong with javascript except the language, and the people using it
>>
>>52527799
An example to back up your opinion would be nice. <3
>>
>>52527782
Nothing, it's just stupid to use animations for things that don't need animating.

I don't want a drop down menu to fade in, I want it to appear instantly.
>>
>>52527792
just cast but some C++ pedant might tell you to use some other type of cast
>>
>>52527811
>I can't explain why he's wrong
>I'll just get really impotently angry at him, that'll convince him I'm right.
You make me happy anon.
>>
>>52527792
malloc returns void*, and you want unsigned char*

You have no choice but to cast.
>>
>>52527814
>>52527816
running some bloated garbage script in the browser just for animations or checkboxes or whatever is fucking cancer when all you need is HTML+CSS
>>
>>52527823

I see you're point, and I agree with you. No need to add shit to shit to make it shit.

I'm more focused on making current transitions better. (example: image sliders).
>>
>>52527828
literally fucking retarded

i'm not going to waste my time on you

type inference can lead to silent errors when the return type of a method changes

it can lead to errors when the programmer's intuition gets it wrong
>>
Why is codeeval not scoring my submissions?

Is anyone else having this problem
>>
Dude weed
>>
>>52527855
use HTML+CSS you fucking cancer

it's GPU-accelerated and everything

what do you think you need javascript for?!
>>
>>52527859
>type inference can lead to silent errors when the return type of a method changes
No it doesn't.

>it can lead to errors when the programmer's intuition gets it wrong
Please provide an example.
>>
>>52527563
Scheme interpreter

>>52527792
Use new or vectors.
>>
>>52527861
It's confused why your C program took that long to run, so it's debating with fellow associates whether or not to allow you points.
>>
>>52527870
No, don't use animations at all in a web page.
They're always shit.
>>
>>52527875
That's a good idea, the only downside is the heap but that doesn't matter for this.
>>
I'm finally starting to grasp BPF assembly. I now understand this magnificent construct:

ldxb 4*([14]&0xf)
ldh [x + 14]


It loads the version/IHL field from the IP header, removes the version number and multiplies the remaining part by four and stores it in the X register, giving the size of the IP header in bytes. The next line indirectly loads the first two bytes (half-word) from the TCP/UDP header, ie. the source port number. Simple!

Accessing IPv6 payload is a bitch, though. If there's extra headers, you're fucked, because you can't loop and trying to iterate through the header chain is therefore next to impossible in BPF. You can hardcode it, but it's going to be ugly. If you dump BPF programs with tcpdump's -d switch, you'll notice it tries to handle fragmentation header this way, but without loops it handles only one extra header.
>>
>>52527902
>the only downside is the heap
What?
You are aware that new, malloc and vectors all commonly use what known as heap, right?
>>
>>52527881
it shouldn't take that long, all my previous submissions run in only 4ms
>>
>>52527598
>he needs typing
you'll coward don't even do asm
>>
>>52527870
I've got more knowledge within JavaScript than Html & CSS. Is it wrong to go with something that your more comfortable coding?
>>
>>52527939
If it's JS, then yes.
>>
>>52527916
Oh I was thinking about arrays for some reason never mind
>>
>>52527740
kek
>>
>>52527859
>type inference can lead to silent errors when the return type of a method changes
You have no clue what you're saying do you?
>>
>>52527598
>Static typing >>>>>> dynamic typing.
why
>>
>>52527948
The only times I've ever seen my websites being slow is when I code really bad JS, all it takes is to optimize the code and it works fine (imo). If it doesn't, I don't use it.
>>
>>52527871
yes it does

if the new return type has the same methods it will not cause a compiler error but the result will likely be wrong since you wrote the code under the assumption that the inferred type was the old return type
>>
>>52527859
>type inference can lead to silent errors when the return type of a method changes
>>
>>52527939
Using JS for graphics is like using a rusty hammer to open a can of beans, whereas html+css would be a purpose-built can opener.
Sure, the hammer will get the can open, but jesus fuck why would you do that?
>>
Recently finished work on a quick HTML5 chatroom:
http://www.raskie.com/#on-notice

Opinions welcome.
Also being doing some functional language work recently.
>>
>>52527939
yes it fucking is

HTML+CSS isn't hard to learn at all you lazy shitkid

>>52527980
most people have more than one website and more than one program open at a time. the bloat adds up.
>>
>>52527982
Please teach your anus to be silent while you think.
>>
>>52527986
>>52527971
see >>52527982

RETARDS
>>
>>52527996
lots of people also don't use an i7 for browsing
>>
>>52527937
When you have abstraction, you need typing. When you don't have abstraction (like in ASM), you don't need typing because you're aware of all the details at all time.
>>
>>52527982
>if the new return type has the same methods
eh.. yeah, if the return type happens to have the same methods, then it's probably very similar to the old type, and will probably behave exactly the same when you call the same methods with the same parameters.

Like.. what is an example here? Like a real world example where you have a method, and you change the return type and to your dismay the new return type is almost the same as the old one and now code is running erroneously with the new type...
>>
>>52528000
kill yourself RETARD

i will NOT waste more time on you thank you

enjoy your low quality software
>>
>>52528012
How is that a "silent" error?

>>52528017
Forth and macro assemblers have abstraction
>>
>>52527977
It prevents metric fucktons of errors, and complex type systems can even enforce, at compile-time, pre- and post-conditions. Which would you rather have, a program that runs for 3 days just to crash due to a type error, losing 3 days' worth of time, or a program that doesn't run because of a type error until it is fixed? Nobody sane would rather have the former.
>>
>>52528032
>it will not cause a compiler error
>it will not cause a compiler error
>it will not cause a compiler error
i shiggy diddly
>>
>>52528025
autists with aspergers are really violent watch out guys
>>
>>52528032
Forth is shit because no types.
>>
>>52528033
>pre- and post conditions at compile time
fucking how?

function foo(int i < 10) ....

foo(user_input)
>>
>>52528000
trips for truth

>>52528025
>I can't explain to anyone why I am right
>I'll just call the retarded
you must be fantastic to work with
>>
>>52528033
>a program that runs for 3 days
the "programs" that these python shitters make don't run for 3 days
>>
>>52528046
Ooops misread that.
But what has type inference to do with?

Of course if you change the behaviour of a elsewhere used class, it can cause errors.

Not even pro-inference.
>>
>>52528060
define fn (x : limited(int, larger(0))) : limited(int, smaller(0)) {
return -x;
}
>>
>>52527994
It depends on what kind of graphics you are talking about though. I like to use JS for more complex animations. (For example: An animation that would keep information in an object to then change whether the animation would then do A or B. If that makes sense.)

>>52527996
I said "I've got more knowledge within x than z and y". It's what I prefer, not whether I'm too "lazy" to learn more of a certain language.
>>
>>52527871
The guy you're replying to is an absolute mong but anyway, when he says "silent errors" he doesn't mean error at all.

I think what he means is if you had a number variable, then later you add more numbers to it, and print it out.
If at some point you concatenate a string to the var, you lose the ability to add future numbers arithmetically, instead concatenating strings to the end.

So what you get is an unnoticed "error" because the compiler doesn't bitch at you for doing something that probably doesn't actually make any sense.
In other words, it's much easier to make sure you're not misusing variables if they're statically typed.
It's not "unsafe" in that you'll get memory access violations, instead everything will "just werk" but it wont "just werk" they way you expected it to.
>>
>>52528081
That looks like run-time
>>
>>52528072
>Please teach your anus to be silent while you think.
>Please teach your anus to be silent while you think.
>Please teach your anus to be silent while you think.
such an enlightening comment there buddy
>>
>>52528046
>>52528012
>>52528025
I feel like this anon knows he's incredibly wrong, but he's so deep at this point, he doesn't know how to admit it without damaging his throbbing, rock-hard pride.
>>
>>52528077
Scientific simulations typically do. Do you not realize how many scientists use python? Webservers do. Do you not know how many people unironically use python for the web?
With type inference, you also lose absolutely nothing with the correctness you gain. It doesn't matter that your script runs for 1s or 1y, you want it to work right anyway.
>>
>>52528078
if you change the return type it will give a compiler error where the variable is declared and assigned, but only if you use an explicit type specifier
>>
>>52527994

Only people who have no experience of animation programming would say that. JavaScript and Lua are probably the two best languages out there for UI and graphics scripting. The key to the work is flexibility.

The JavaScript and Lua data/object models are perfectly suited to describing things that will change often at runtime. Like web forms, or character sprites.

To do similar stuff in the likes of C++/Java, you'd need to jump through a lot of hoops, and spend more time on working object structure than you would ever want to.
>>
>>52528094
It's compile-time. If the pre-condition invariant can't be proven, the call is rejected. The post-condition invariant is proven trivially due to the pre-condition.
>>
>>52528103
literally projecting this hard lmfao

>>52528109
they would run literally in minutes instead of days with a normal programming language.
>>
ITT: Assblasted static typing users.
>>
>>52528133
Please use a trip so everyone can disregard the rest of your inane ramblings.
>>
>>52528133
No because they use thin bindings over C or cuda code. They would be faster but not noticeably so.
>>
>>52528118
Which is fucking with established behaviour of an object, which is stupid and causes problems with any language.
>>
>>52528126
Only people who have no experience of HTML+CSS would say that. HTML and CSS are probably the two best languages out there for website UI and graphics scripting. The key to the work is flexibility.

KILL YOURSELF
>>
>>52527859
>type inference can lead to silent errors when the return type of a method changes

Nobody is forcing you to use type inference 100% of the time. For a functions it is generally better to use an explicit signature, as type inference will resolve to the most general type. Regardless, you can use type inference in many more places than just function signatures.
>>
>>52528092
>If at some point you concatenate a string to the var
... What? The var is of type 'number'. You can't set it be be a string later. Are you following the thread?
>>
>>52528127
So I can use the function only with static variables?
That's fucking useless.
>>
>>52528148
>no one refactors code ever
>if they do, it should silently fail if possible
k tard
>>
>>52528118
If the inferred type does not match a spec signature anywhere in the program then no. The advantage of inference is that you don't have to look up every declaration and manipulation site just because you changed from int to uint at one point.
>>
I should make a program that counts how many times someone says "kill themselves" in a /dpt/ thread
>>
>>52528176
You're talking about returning a different object with the same interface that behaves differently.

Yes, that is stupid.
>>
>>52528172
Have you never written a program before?
>>
>>52528180
the compiler will point it out for you and the IDE will fix it for you
>>
>>52528150
Sit the fuck down. lmao xDDD

GetBackOnTehShertBus.png
>>
>>52528126
Before you reply, >>52528150 isn't even me.

I didn't say you should never use JS, but if you can get away with just using html+css to achieve something, then why wouldn't you?

Also, doing any frontend web stuff with C++/Java is flat out retarded.
>>
File: pZsAIrU.png (6 KB, 461x177) Image search: [iqdb] [SauceNao] [Google]
pZsAIrU.png
6 KB, 461x177
>>52528092
Do you mean like pic related?
>>
>>52528176
>it's silent because I say so!
>examples? Who needs them? Proof? That's for people who are right!
>I WIIIIIIIIIN
Could you be any more butthurt?
>>
>>52528195
Have you?
What program worth running twice uses nothing but static variables?
>>
>>52528198
>spending half an hour correcting redundant descriptions is good!
>who cares about productivity???
Well apparently, everyone else in the world. There's a reason why var/auto is so popular.
>>
>>52528224
Hello world does not count as (real) programming. Sorry, Pajesh.
>>
>>52528150

It's why Lua's used in plenty of games.
Google it. And then Google the similarities between Lua and Javascript.

Also try writing a compiled extension for a dynamic language, and write an equivalent in C/C++. Java though, would provide a better comparison. Conduct a performance test, and then realise how bad a Java programmer you are.
>>
>>52528231
he's right, a program with only static variables doesn't even need to be compiled+executed since there no dynamic environment to work on.
>>
>>52528231
What the fuck are you talking about?
A hello world program would be exactly the kind of static useless program I was bitching about.
>>
>>52528170
>what is dynamic typing
>>
>>52528271
Something we're not talking about you fat retard. The topic is type inference.
>>
>>52528268
>>52528269
Rajeet and Pajesh, are you taking a shitting break again?
>>
>>52528271
We're talking about type inference, dumbass.
>>
>>52528271
Tell us when you're tired of being retarded. We'll tell you how to end your pathetic existence.
>>
>>52528268
>>52528269
Nobody said anything about static variables besides you. The reason you are being assblasted is because you came to the wrong conclusion.
>>
>>52528247
idiot

lua is only used for simple scripted events like cutscenes and such because it lacks performance and expressive power
>>
>>52528247
Do you have any experience in Lua? I'm genuinely wondering whether I should learn it.
>>
>ITT: heated conversations about static typing and implicit casting become confused and now everyone is fucking MAD
>>
>>52528312
>my sides when
>pic related
>>
>>52528306

>>52528127
>It's compile-time. If the pre-condition invariant can't be proven, the call is rejected.
>It's compile-time. If the pre-condition invariant can't be proven, the call is rejected.
>It's compile-time. If the pre-condition invariant can't be proven, the call is rejected.
>>
>>52528306
Static in the sense that they are made solely out of constants.
Not the static keyword in C-likes.
If that's where your confusion lies.
>>
>>52528330
>forgot pic
>>
>>52528205
Well yeah, but instead if you tried:

ayy = ayy.ToString + "lmao";

Or whatever the C# syntax would be. If that doesn't work then var can only use inference when declared?
In which case you really fucking should be declaring explicitly.
>>
>>52528322
>and implicit casting
Congrats, you're clinically retarded!
>>
>>52528284
>>52528306
>>52528312
>>52528330
>>52528336
>>52528341

Never fucking reply to me again unless you're contributing to the thread.
>>
>>52528306
>what is the static and dynamic environment.
>>
>>52528344
implicit typing, whatever
>>
>>52528358
Congrats, you're even more retarded than initially thought!
>>
>>52528320
Lua is like C but easymode. Very simple syntax, but without a clusterfuck of options to do the most basic tasks.
>>
>>52528341
Dude, i'm gonna type as sober as possible, that honestly looks fucking pathetic and digusting compared to my meal. and I'm being one hundred percent serious. Sorry we dont cook shit that was perviously in cans. you're a fucking joke dude, and im dead fucking serious. gert areal family that cooks good food, drinks beer and wine and winecoolers and has a good fucking time, and has a milliondollar house on the beach, im seriously.. dont eever potst your fucking poverty dinner on these forums ever the fuck again bro, and by bro i mean never my bro, fucking faggot.
>>
Why did nobody tell me makefiles were the best thing since sliced bread?
>>
>>52528375
You've got me curious now, anon. Explain your thought process.
>>
>>52528342
>In which case you really fucking should be declaring explicitly.

Sure, let me just write Dictionary<String, Dictionary<Tuple<Int, Int>, List<Tuple<String, Float, List<String>>>>> every time.
>>
>>52528379
Looks good to me.
Food generally looks a lot worse in pictures if you don't what you're doing.
>>
>>52528376
Ah ok, that sounds cool.
>>
>>52528386
no one tells you some of the most crucial info you have to dig everything up yourself to be sure
>>
>>52528401
Why not just learn how to properly design OOP programs instead?
>>
>>52528401
You're doing something wrong if you use something like that
>>
>>52528416
>>52528418
Professional Hello World programmers from india detected!
>>
>>52528312

Don't worry son, I'll do the Googling for you.

http://gamedev.stackexchange.com/questions/73728/how-does-lua-work-as-a-scripting-language-in-games
https://en.wikipedia.org/wiki/Category:Lua-scripted_video_games

>>52528320

Very little, but if you have some JavaScript experience, then you can read Lua and get up to speed quickly, as they work on the same underlying principles:

http://phrogz.net/lua/LearningLua_FromJS.html

Polycode looks like a good environment to learn Lua with. It's works in a similar way to how Javascript works in Unity.
>>
>>52528416
this

at the very least you can wrap it into another object which any Ctard and Cshart can do
>>
File: rinbDtn.png (8 KB, 768x218) Image search: [iqdb] [SauceNao] [Google]
rinbDtn.png
8 KB, 768x218
>>52528342
C# is static typed.

You cannot assign a string value to 'ayy' ever once it's first implicitly typed.

Can you explain your last statement a bit more? What does that have to do with the necessity to declare explicitly?
>>
>>52528416
>>52528418
It was a hyperbole. You cannot deny that even well designed programs can still suffer from excessively long type names.
>>
I wonder if the screaming pajeet is all from a single guy just randomly replying to people without any involvement in the previous discussion.

Not even giving him a "(You)"
>>
>>52528433
>wrap it into another object
Hooray, more needless bloat. I shudder to think what your code look like without type inference.
>>
>>52528432
Oh sick, looks like I'll be learning this for the next 12 hours c:
>>
>>52528432
i seriously hope you don't believe most of those games use lua as the primary language

>CryEngine
>Written in C++, Lua
>>
>>52528450
Then stop with the excessively long type names.
>>
How can I get "The field cannot be left blank to alert?
HTML
<!doctype>

<html>

<head>
<link type = "jsstuff/style01.css" rel = "stylesheet"></link>
<script src = "jsstuff/jstest.js"></script>
</head>

<body>

<h2>Fill out the form below and click "order now" to order</h2>

<form id = "theForm" action= "message.html" method = "post" onSubmit = "validateTextbox();">

<div class = "row">
<label for = "name">Name:</label>
<input type = "text" id = "name" name = ""> </br> </br>
</div>

<div class = "row">
<label for = "address">Address:</label>
<input type = "text" id = "address" name = ""> </br> </br>
</div>

<div class = "row">
<label for = "phone">Phone:</label>
<input type = "tel" id = "phone:" name = ""> </br> </br>
</div>

<div class = "row">
<label for = "Email">Email:</label>
<input type = "text" id = "email" name = "">
</div>

</br> </br>

<input type = "Submit" value = "Submit"></input>

</form>

</body>


</html>


Javascript
function validateTextbox() {

var box = document.getElementById("name");
if (box.value == "") {
alert("The field marked in red cannot be blank");
return false;

}


}
>>
>>52528464
kill yourself idiot
>>
>>52528416
Nice performance.
>>
>>52528464
Why even bother with an OOP language if that's your philsophy?
>>
>>52528276
>>52528288
>>52528296
At what point did I say I was talking about type inference?
As I said before, that poster is a complete mong who seems to be confusing the two ideas.
The "silent errors" he is talking about are from dynamic types, not type inference.

I provided an example to show you what the fuck is going on inside this retard's mind, and instead you are all continuing to argue on completely separate topics because nobody seems to be able to explain themselves very clearly.
>>
an issue with type inference is that it may delay a compiler error from the position where it's actually caused to a later point
this isn't a large issue, though, especially not if you are making heavy use of abstractions (these type of errors are usually detected when calling a function, as the erroneous type would violate the contract).
types should be used explicitly in the name of documentation and readability when it's appropriate, for instance when writing functions or when using the return value of a function where the type might improve readability.
>>
>>52528437
That has nothing to do with type inference, retard.
>>
>>52528463
I'd bet my dick that nearly all of the posts saying 'kill yourself' are from a 17-year-old that just took his first Java class.
>>
>>52528488
For most cases:
Proper encapsulation > performance
>>
In vimrc, I want to move the following command into a function block so I can add more logic to it:

map <F1> "zyiw:exe ":Hoogle ".@z.""<CR>


What's the proper execute syntax to run it? Getting syntax errors on the following:
map <F3> :call HoogleSearchToggle()<CR>
let g:HoogleSearchOpen = 0
function! HoogleSearchToggle()
if g:HoogleSearchOpen
execute "HoogleClose"
let g:HoogleSearchOpen = 0
else
execute "zyiw:exe ":Hoogle ".@z.""<CR>
let g:HoogleSearchOpen = 1
endif
endfunction

Error detected while processing function HoogleSearchToggle:                             
line 5:
E121: Undefined variable: :Hoogle
E15: Invalid expression: :Hoogle ".@z.""<CR>
>>
>>52528501
Csharts cannot into logic and think they get significantly better performance than with java
>>
>>52528518
Why tell *me* that?
>>
>>52528518
LITERALLY projecting this hard lmfao kill yourself
>>
Why is there so many C# shills in here?
>>
>>52528545
Because C# is a normie language.
>>
>>52528545
Because it's so popular for baby's first GUI
>>
File: iio.png (614 KB, 640x890) Image search: [iqdb] [SauceNao] [Google]
iio.png
614 KB, 640x890
How do I start being productive?
>>
>>52528505
>The "silent errors" he is talking about are from dynamic types
The whole fucking thread is in the context of type inference. Languages with type inference are not dynamic typed. Jesus
>>
>>52528517
My post literally shows an example of type inference, followed by the fact that the type is then static and not able to be changed after the type is initially inferred.

>>52527859 claimed type inference leads to silent errors, and >>52528092 assumed he was referring to dynamic typing. His mistake was trying to defend a retard, which in turn caused the rest of us to become confused.
>>
>>52528558
read reddit instead of 4chan
>>
>>52528545
because you faggots started sharing the legendary slides to image on reddit and now C++, C# and Java normies have flocked this place
>>
>>52528401
>every time
>once per declaration
Stop being so fucking lazy, saving yourself one goddamn type and hoping nobody ever reads through your code trying to work out what the fuck is going on.
If you had a type that convoluted, you need the explicit type more than ever. If not, you'll need comments to explain what the fuck is going on.

I get your point about not wanting to retype redundant information, but it's not redundant once it gets that complicated.
>>
>>52528336
>>52528338
>>52528357
Extending from the pseudo-code example in >>52528060, the following is logically sound and would compile.

function foo(int i < 10) ....

if user_input < 10 then
foo(user_input)


Again, nobody said anything about static variables and your fundamental knowledge of the problem is flawed.
>>
>>52528545
Easy to write, lots of support, plenty of jobs, and it's very useful for other jobs besides being a straight programmer, such as sysadmin and business intelligence.
>>
>>52528558
delete internet explorer
>>
>>52528578
Which includes a run--time check...
>>
>>52528482
What you need to use are eventlisteners. Something like this.

HTML
<!doctype>


<body>
<h2>Fill out the form below and click "order now" to order</h2>

<form id = "theForm" action= "#" method = "post">

<div class = "row">
<label for = "name">Name:</label>
<input type = "text" id = "name" name = ""> </br> </br>
</div>

<div class = "row">
<label for = "address">Address:</label>
<input type = "text" id = "address" name = ""> </br> </br>
</div>

<div class = "row">
<label for = "phone">Phone:</label>
<input type = "tel" id = "phone:" name = ""> </br> </br>
</div>

<div class = "row">
<label for = "Email">Email:</label>
<input type = "text" id = "email" name = "">
</div>

</br> </br>

<input type = "Submit" value = "Submit"></input>

</form>

</body>


JS
var form = document.getElementById("theForm");
form.addEventListener("submit", function(event){
var box = document.getElementById("name");
if(box.value == ""){
alert("Something");
}
event.preventDefault();
})


Sorry, did that in a rush.
>>
>>52528580
Found the shill.
>>
>>52528482
if(!box.value) { }
>>
>>52528558
Stop shitposting anime.
Faggot.
>>
>>52528593
Not a single claim I made was untrue.
>>
>>52528482
To add to that, the event.preventDefault() should be in the same if(){} that the alert is in. Otherwise the form should submit as usual.
>>
>>52528472

For game logic?

Of course!

Adjusting parabolic curves, AI search graphs, vehicle properties... The type of stuff that makes the game? DEFINITELY do that in script. It's the most common development pattern you'll see in industry, predicted in the Mythical Man Month long ago...

Why the fuck would you want to do subjective UI layer work in C, if you can maintain performance and avoid compilation in script?
You'll save time in design and implementation.
That's going to either make you more productive, or more creative.
>>
>>52528586
The fact that the check happens at run-time is irrelevant, the compiler can guarantee that foo will never be called with a value >= 10.
>>
Very interesting, I thought I was done but I might have a minor (or major) issue at hand with this Lua thing i've got going on.

The array system i've got set up in C is fine, i've ensured there's no issues with it (it really is just an array'd struct that contains an ID number).

The issue with with the table system in Lua, or at least it should be. It looks like when I remove an object between two objects (example, removing an object with the ID of 2) and add a new object (which will use a free'd ID, in this example, 2) the game crashes. The error it tells me is that a function or table within this newly made table doesn't exist. So it must be a recycling issue, I don't know.
>>
>>52528404
some of the worst looking food taste the best.
>>
>>52528505
Inbred confirmed.
>>
File: 1451683583776.gif (2 MB, 400x600) Image search: [iqdb] [SauceNao] [Google]
1451683583776.gif
2 MB, 400x600
no CHIP-8 update tonight lads, boss wants me to info scrape thousands of apartments from a site, and instead of doing it manually, I'll modify my python image scraper
>>
Is it wise to use haskell for non-event driven GUI applications?
>>
>>52528615
Which is completely useless.
>>
>>52528563
>Retard keeps hamming the same incorrect point
>Clearly he is insane, and not just confusing 2 similar ideas

If that's what you really want to believe I'm not going to change your mind.

Yes, everyone is talking about type inference. However, not everyone here seems to fucking understand what that is exactly.
Maybe try explaining it properly, that might actually help instead of
>Hurrr kill yourself retard
>>
>>52528631
Too old.
>>
>>52528639
>non-event driven GUI applications
What exactly does this mean?

What's an example?

Not being an ass, just trying to learn.
>>
>>52528643
>Which is completely useless.
The program not failing randomly at runtime is useless? I'm sorry but you're retarded.
>>
File: 1453262463037.jpg (138 KB, 720x720) Image search: [iqdb] [SauceNao] [Google]
1453262463037.jpg
138 KB, 720x720
This should be the next /dpt/ picture
>>
>>52528631
You could have that done in about 15 minutes.
Also, I said stop posting the same shit over and over anon FUCK.
>>
>>52528673
It still needs a run-time check.
Why not do just that, instead of forcing me to do it manually (like in your example)?
>>
>>52528639
>Is it wise to use haskell
no.
>>
File: 1451683513443.gif (2 MB, 400x225) Image search: [iqdb] [SauceNao] [Google]
1451683513443.gif
2 MB, 400x225
>>52528689
>You could have that done in about 15 minutes.
I got a lass coming over too though
>>
>>52528687
>Stallman in the background
We've outgrown him, anon.
>>
>>52528524
Think I need to use the normal command, but still trying to figure it out.

this deletes a line:
normal dd


this apparently does nothing:
normal zyiw:exe :Hoogle ".@z"<CR>
>>
>>52528697
what's wrong with it?
>>
>>52528701
Yup, I should have asked the OP of this picture to shop one without him yesterday.
>>
>>52528715
MEMES
>>
>>52528691
>Why not just write perfect code 100% of the time
Because even if you claim to never make mistakes (you do), I doubt your employer would want to wade through code trying to decide if it works when a compiler can tell them almost instantly.
>>
>>52528739
What in the hell are you babbling about?

I LIKE design by contract, and languages that support pre- and post-conditions.

But they check that shit in run-time - if they couldn't that they'd be completely useless.
>>
>>52528739
>Having an employer
Not everyone is a codemonkey.
>>
>>52528578
Wait, what's wrong with this code?

What are the potential issues? What should pre-compile be seeing about this that's wrong?
>>
File: mKPaxAm.png (217 KB, 540x1888) Image search: [iqdb] [SauceNao] [Google]
mKPaxAm.png
217 KB, 540x1888
I never want to see the word 'type' again.
>>
>>52528771
Not everyone is a NEET
>>
>>52528811
>most people can't shit
>>
>>52528726
what language isn't a meme language?

please...
>>
>>52528776
Because why not have
function foo(int i < 10) ....

foo(user_input)

and have the language translate that to something like:
function foo(int i) { if (i < 10) { ... } else { throw error } }
...
>>
>>52528472

Given up then?

It's ok son. We all get it wrong sometimes.
>>
>>52528826
C and Perl.
>>
>>52528837
>c
>not a meme

good one
>>
>>52528826
JavaScript. The internet is built with it
>>
>>52528770
What are you babbling about?

>>52528771
My point still stands. Having a program that is verifiably correct for free is better than having a program that may or may not fail at runtime.

>>52528776
Nothing. It was to prove that type system constraints do not need static variables to work, like someone incorrectly assumed and then sperged out over it.

>>52528829
If you enjoy having runtime errors, go ahead and do it that way.
>>
>>52528829
so if I enter a number bigger than 10 the program crashes? cool
>>
>>52528858
>If you enjoy having runtime errors, go ahead and do it that way.
Because you can't catch exceptions....

>>52528870
Depends on the language, I think Ada would print you the problem at run-time and halt.
Which is better than completely ignoring the fail condition in the other example. To handle it he would have to add an else - how is that worse than adding a catch (and writing the same pre-condition twice)?
>>
>>52528826
OCaml.
>>
>>52528921
You never indicated any intention to catch the error. Regardless, why not have the compiler tell you when you forget to catch it? There is literally no disadvantage unless you purposefully want to write code with runtime errors.
>>
>>52528829
Because it's slow as fuck, unlike compile-time checking, and the failure happens at compile time instead of runtime. Moreover, you can't have explicit handling in that case. How do you recover from an incorrect user input by telling them to try again, for instance?
>>
>>52528983
Because there are shit-tons of errors you want to cause a failure since there is no useful recovery. Anything related to memory and disk usage for example.
>>
>>52528699
post her instead
>>
>>52529015
You don't need exceptions to exit early.
>>
>>52528639
Haskell is the best language in the world
>>
>>52528983
>why not have the compiler tell you when you forget to catch it?
I have said nothing against languages that don't allow unhandled exceptions.

>>52528995
>Because it's slow as fuck, unlike compile-time checking, and the failure happens at compile time instead of runtime.
How is that slower? Properly optimized they'd result in the exact same program.
>>
>>52529035
The example expansion uses exceptions to exit early and you don't want to catch those so making the compiler force you to handle them would be retarded.
>>
>>52529053
Compile-time checking means 0 costs. Runtime checking means some cost. When you call a function 10k times, it adds up real quickly. Same reason reference counting is slower than GC and both are slower than manual memory management.
>>
>>52528921
>To handle it he would have to add an else

The example was intended to show that you do not need static variables for compile time conditions to work, I excluded an else branch for brevity.
>>
>>52529038
>doesn't even know how to read
Typical Hahasklel coder.
>>
File: 1451683650441.gif (1 MB, 500x281) Image search: [iqdb] [SauceNao] [Google]
1451683650441.gif
1 MB, 500x281
>people still pretending they get run-time errors in dynamic languages
Why do people post shit they've had no experience with, and argue only on a conceptual level?
>>
File: pou.png (548 KB, 609x884) Image search: [iqdb] [SauceNao] [Google]
pou.png
548 KB, 609x884
Post your github, /dpt/.

I want to see your autistic projects.
>>
>>52528614
those things aren't the bulk of the program. i was responding to >>52528247 who's implying lua doesn't have shit performance.
>>
>>52529109
Can someone ban this dumb nigger? Every post is garbage.
>>
>>52529109
github.com/vinheim3
>>
>>52529109
Fresh start. https://github.com/0xBA5/animan
>>
>>52528404
>>52528625
it's pasta: >>52528379
>>
>>52529100
You're missing the point. Would you rather fly in a plane who's code is proven not to fail at runtime, or one with the possibility of it failing and the plane crashing to the ground?
>>
>>52528832
i do actually program, i don't sit every minute of the day ready to respond to fagtards' inane bullshit
>>
>>52529070
You still check at run-time in both cases you retard.

And I don't see how you can't optimize run-time checks in something like:
for i := 1 to 100 do
checkedFoo(user_input)
end

to
if user_input < 10 then
for ...
uncheckedFoo(user_input)
end
end
>>
>>52529150
>GNU General Public License
Use MIT/X11, you autist.
>>
>>52529109
>post github
>/dpt/ finds out I'm female
>flips their shit

I'll spare you the drama
>>
>>52529175
Done :^)
>>
File: hehe.jpg (105 KB, 470x300) Image search: [iqdb] [SauceNao] [Google]
hehe.jpg
105 KB, 470x300
>>52529154
Depends if it has George on board.
>>
>>52529154
Nice conceptual analogy
>>
File: 1445274080593.jpg (31 KB, 480x454) Image search: [iqdb] [SauceNao] [Google]
1445274080593.jpg
31 KB, 480x454
>Dissertation project deadline closing in
>Completley snowed under
>Haven't tackled the big problems of my project yet
>Getting snowed under with exams, and this fucking dissertation, personal issues

Not gunna make it bros.
>>
>>52529211
get off 4chan
>>
>>52529187
Please post, I'll follow you <3
xoxoxo
>>
>>52529187
We honestly don't care about your sex, anon.

We're all mature adults here.
>>
>>52529225
but I literally just finished writing a chapter of my report. If I keep writing/coding non stop without a break I'll go crazy.
>>
>>52529187
Wearing your mother's knee high socks and tucking your dick between your legs doesn't make you female.
>>
>>52529280
It still makes you hot though, so don't stop <3
>>
File: crying frog.jpg (39 KB, 312x247) Image search: [iqdb] [SauceNao] [Google]
crying frog.jpg
39 KB, 312x247
>>52524707
>>52524707

p-pls respond
>>
>>52529171
>look ma, no brain!
>>
>>52529249
do something different other than being on 4chan
go for a walk or something
4chan is a bad place for a break from something very mentally exhausting
>>
>>52529310
You should have asked in here, not that shitty thread, anon.
>>
>>52529310
Try it out.
>>
>>52529320
idk, 4chan is like small amounts of entertainment that i don't feel so guilty for using. i'll look at it for 5-10 mins every few hours. if i start a new book, or start playing a video game, i'll feel guilty as i feel like i'm just putting another project on my plate. hard to explain i guess.

i really cannot wait until this year is over. i can enjoy myself again... so much free time.
>>
>>52529296
Go and stay go. Better yet, off yourself.
>>
Network monitoring system
>>
>>52529379
Don't you have anything better to do than complain about "trannys" 24/7?
>>
>>52529318
Great Arguments.
Why not just post that fabled language that only checks pre-conditions at compile-time.
>>
File: scared jew.png (20 KB, 183x232) Image search: [iqdb] [SauceNao] [Google]
scared jew.png
20 KB, 183x232
>>52529346

Well, it works, but I want to monetize this. There's a lot of people browsing ad sites every day who would pay for an automatic solution. 5 euros per week per site, 5 searches maximum per site.

If too many people make too many requests from the same IP, even with the random delays and different user agents, I don't know if that IP is gonna get the boot. That's my main concern.
>>
>>52529417
>I don't know if that IP is gonna get the boot

Doubtful. Large networks like offices or schools usually have only a handful of external IPs at most, so blacklisting on just a lot of requests from an IP would be dumb.
>>
File: tegegtht.gif (25 KB, 221x198) Image search: [iqdb] [SauceNao] [Google]
tegegtht.gif
25 KB, 221x198
>>52528592
Can you explain this a little more in depth please? the events and eventlistener? Thanks for the help
>>
>>52528482
>>52529481
You don't even need javascript, just do
<input type="text" id="name" required>
>>
>>52529467

But what if the requests occur about every 5 minutes 24/7? Wouldn't that be too suspicious? Are there any free solutions for IP rotation in Java?
>>
>>52529560
Proxies
>>
>>52529568

Alright, thanks, I'll look into that.
>>
>>52529109
my projects are too autistic.
>>
>>52529187
nicely memed bro
>>
>>52529187
you mean like you're doing now?
>>
>>52529231

>We're all mature adults here.
Some of us are.
Most of us aren't.

Personally, I don't care if someone is male, female, or trans, as long as they're not of the "hurr I'm going to fork a bunch of repos, change a few comments/documentation, and call myself a programmer" variety.

>>52529109

I haven't worked on anything public since memesnake. A lot of my work is schoolwork, and tends to get put into a private bitbucket account, which I won't share. Knock yourself out though:

https://github.com/expeditiousRubyist/

A note: Not everything here is interesting... or finished.

>>52529603

Make use of Tor and i2p as well.
>>
>>52529654
>Rubyist

pls go die
>>
>>52529654
>Personally, I don't care if someone is male, female, or trans, as long as they're not of the "hurr I'm going to fork a bunch of repos, change a few comments/documentation, and call myself a programmer" variety.
This is all female github users in a nutshell.
I have yet to find one that didn't have a github full of nothing but diversity slides, "bucket lists" and untouched forks of other people's projects
>>
To all you retards who don't understand how you can statically verify preconditions even for runtime values (from user input, for example):

The precondition is a (typically inductive) type family, or predicate.
data _<_ : Nat -> Nat -> Type where
ZLT : Zero < Succ _
SLT : m < n -> Succ m < Succ n

The predicate (x < y) is defined such that it's only inhabited when x is less than y.

You can prove this predicate for constants for free:
2 = Succ (Succ Zero)
3 = Succ (Succ (Succ Zero))

proof : 2 < 3
proof = SLT (SLT ZLT)


But you can also do a check that works on any two values, even those obtained at runtime.
lt? : (m : Nat) -> (n : Nat) -> Maybe (m < n)
lt? _ Zero = Nothing
lt? Zero (Succ _) = Just ZLT
lt? (Succ m) (Succ n) = fmap SLT (lt? m n)


This concept can be generalized to include more complex types than natural numbers, as well as languages that aren't based on constructive mathematics. However, in a non-constructive language, you need to be careful, since you need to appropriately encapsulate the mechanism for creating proofs of the predicate.
>>
>>52529768
Can't understand shit your saying, not really into autistic languages.
>>
>>52529828
Perhaps you shouldn't make bold statements about what a type system can or cannot do if you don't understand even basic intuitionistic type theory.
>>
>>52529768
Why are you doing coqlight?
>>
>>52529768
what language is this ?
>>
>>52529843
>>52529851
It's pseudo-Agda.
>>
>>52529768
That looks like it's just a language with a dependent type system. Not a language with only compile-time pre-condition checking.
>>
File: 1365901036298.png (38 KB, 300x300) Image search: [iqdb] [SauceNao] [Google]
1365901036298.png
38 KB, 300x300
What are some schema for verifying the legitimacy of a client who's connected?

Also, does anyone have any good reading for (specifically java) implementations of public/private key encryption?
>>
File: 1453293404872.png (399 KB, 626x528) Image search: [iqdb] [SauceNao] [Google]
1453293404872.png
399 KB, 626x528
Reminder that anime posters are racist /pol/ cancer.
>>
>>52529768
>using meme languages
>>
>>52529768
I guess I'll follow up by explaining how the predicate can be used for bounds checking:

Here's a fixed-length vector:
data Vec : Type -> Nat -> Type where
Nil : Vec a Zero
Cons : a -> Vec a m -> Vec a (Succ m)


And here's a safe index operation:
index : (m : Nat) -> Vec a n -> (m < n) -> a
index _ Nil contradiction = absurd contradiction -- some languages let you omit this case, since it's unreachable, but the use of absurd makes it explicit
index Zero (Cons x _) LTZ = x
index (Succ m) (Cons _ xs) (LTS p) = index m xs p


>>52529881
Refinement types are just a special case of dependent types that only allow predicates indexed by a given set of types, typically numeric.

>>52529918
This "meme language" is extremely good at writing succinct proofs that are easily digested by programmers familiar with pattern matching and recursion.
>>
Friendly reminder that most CS graduates can't even write a function that prints odd numbers from 0-100.

Why don't you have a job yet, /g/?
>>
>>52529955
too socially retarded to get a job.
>>
>>52529955
Good question.
>>
File: Untitled.png (13 KB, 1000x388) Image search: [iqdb] [SauceNao] [Google]
Untitled.png
13 KB, 1000x388
>>52529950
Sorry fambly this is all I could see.
>>
>>52529955
for i in range(1, 101):
if i % 2 == 1:
print i

did i do it anon??
>>
>>52529881
>>52529950
And, of course, refinement type inference is decidable. But the principle is the same as what I have outlined here.

>>52529993
>Perhaps you shouldn't make bold statements about what a type system can or cannot do if you don't understand even basic intuitionistic type theory.
>>
>>52529888
Nah. More like racist /pol/ cancer are anime posters.
>>
>>52529955
Are these just ironic memes or buttmad nongrads? Seriously, I've taken 3 semesters of computer science and most of the "CS grads can't even x" are literally things that you learn in the first semester and build upon every subsequent class.
>>
>>52530019
Perhaps you should go back to learn how to green text and go back to reddit.
>>
>>52529955
import std.stdio;

void main(string[] args)
{
foreach(i, 1..101)
{
i % 2 && writeln(i);
}
}
>>
>>52530032
I'm quoting a reply I made earlier. >>52529841
>>
NEW THREAD!

>>52530057
>>52530057
>>
>>52530079
Dumbass
>>
>>52529955

Because working on master's right now.

(1..100).step(2).each { |x| p x }
>>
>>52530035
language?
>>
>>52530091
I think it's D.
>>
>>52530023
You'd be surprised how many people take CS because they have nothing else going for them and just want to make video games.

They either drop out or persist and flounder.
>>
>>52530091
D
>>
>>52529863
>It's pseudo-Agda.
looks violently like Haskell
>>
>>52530135
So does Agda.
>>
>>52529950
How does this do user_input < 10 statically?
>>
>>52529955
[1 .. 2 .. 100] |> Seq.iter (printfn "%i")
>>
>>52529955
(map println (filter odd? (range 100)))
>>
>>52530164
If it's less than 10, you will get Just a proof of the fact, which is passed wherever it's required.

If it's greater than or equal to 10, you will get Nothing, and will not be able to use that value where a proof that it's less than 10 is required.
>>
>>52529997
No you failed.
>>
>>52530183
Which can only be decided when you actually run it and get the user input.
How is that static?
>>
>>52530203
zero is not an even number
>>
>>52530226
Lol'd
>>
>>52530218
Take the vector indexing function. If the vector is of length 10, and you do not have a proof that (x < 10), which is a value of that type, you will not be able to use x as the index. This is enforced by the type system.
>>
>>52530226
Shame on me.
>>
>>52530241
Which is useless.
This forces me to use such broad constraints for any useful program and make my own run-time checks for my exact pre-condition.
>>
>>52529481
So DOM elements can be interacted with using certain events, like clicking, submitting, hovering your mouse over, etc. Each DOM element has the ability to use what are called event listeners that will trigger a callback function when the event occurs.

So in this case, we grab the DOM element that we want to add an event listener to.

var domObject = document.getElementById("domElement");


From there, it's pretty easy to add any type of event listener to a dom element. Each type of dom element may have different events that you can create event listeners for. For instance, you can't submit a <p> tag. But for this example, let's image that domObject is a button.

domObject.addEventListener('click', function(evt){
console.log("I've been clicked");
})


So now, when you click the domObject button, you should see "I've been clicked" in your console. And as your "return false" was supposed to do earlier, the "domObject.preventDefault()" would prevent the default behavior from happening (submitting the form).

You could also create an anonymous function and pass it in as the callback. That's a bit clearer to me, at least.

http://www.w3schools.com/js/js_htmldom_eventlistener.asp

And as >>52529549 said, HTML5 has provided the "required" attribute that will prevent submit if something is missing. There are more validations that HTML5 has that you should check out.

http://www.the-art-of-web.com/html/html5-form-validation/

Sorry if I had any errors, I'm tired.
>>
File: compiling.jpg (14 KB, 400x400) Image search: [iqdb] [SauceNao] [Google]
compiling.jpg
14 KB, 400x400
Re-asking for new thread:
What are some schema for verifying the legitimacy of a client who's connected?

Also, does anyone have any good reading for (specifically java) implementations of public/private key encryption?
Thread replies: 321
Thread images: 24
Thread DB ID: 448689



[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.
If a post contains personal/copyrighted/illegal content, then use the post's [Report] link! If a post is not removed within 24h contact me at [email protected] with the post's information.