/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous thread:

Other urls found in this thread:

github.com/golang/go/issues/19182
github.com/bitemyapp/websocket-shootout/pull/3
github.com/hashrocket/websocket-shootout/pull/14#issuecomment-244551430
codegolf.stackexchange.com/questions/110485/leak-memory-in-as-few-bytes-as-possible
git-scm.com/docs/git-submodule
twitter.com/AnonBabble

D

Lisp and you can't stop me.

Ruby !sempai got his name from the ruby colored socks he wears in the trap pics he posts to 8ch~

gib /dpt/ discord pl0x, i need to talk about haskell and rust with other intelligent beings

I left my WPF work in the middle to continue on Revit architectural design while I have dreams for an app. I hate being a civil engineer that must do everything on his own. I'm like Da Vinci but ghetto version.

Ruby is a girl, not a trap

OK guiz I have a moral choice to make. I made some git commits mentioning the wrong ticket number in a private work repository, and they've already been merged in a pull request. Rewriting the history is easy enough, but then the pull request won't link to the correct commit hashes. On the other hand, we need to rewrite the repo to remove some old config files before we OSS it, so the pull request history will end up broken anyways.

Should I rewrite the commits or just leave it? Our issue tracker uses the mentions in commit messages to link to log progress on the tickets.

The main reason why I think C is the best first language to learn is that it requires you to understand computers at a depper level than something like python. And by that it teaches you this "thinking like a computer" thing which imo is a must for every good programmer.
btw I use python daily, and it's usually my favorite language of choice.

Plebeian. Learn assembler code. What are you, a baby, wanting C to hand-hold you?

Working on a 2d data structure that i can use for other programs.

>enjoying dynamic typing

github.com/golang/go/issues/19182

nice language gotards

>rust
Hey you great and smart individual you should totally leave Sup Forums and join us other intelligent living things at >>>github or >>>reddit

git question:

I'm writing a library and a program to test it (C++), and I want to publish both on github someday as separate repos.
So I thought the most logical way would be to make the library a submodule of the test program. But I don't want to store the library twice on my hdd and have to checkout the submodule each time I make a change in the library.
Is it possible to make a submodule the primary repo somehow? If so how do I go about doing this?

Also what if I want to make a second or third library that depends on the first, and have the test program test both at the same time. How do I organize this? Is submodule even a good option here or should I just drop the library repo in the system-wide include and lib directories?

Working on writing a package manager. In C. Difficult but making slow progress.

public class Java
{

public static void main(String[] args)
{


}

}

>Just ignore all of this code
>You will learn about it later

This is how they literally teach programming

That's what you get for using your own NIH toolchain from the 80s instead of LLVM.

What's wrong with dynamic typing as long as it's also strong typing?

Rust prevents you from making rookie C mistakes at the expense of creative freedom unless you put everything in unsafe { } blocks. Nobody is using it but stupid webdevs who read about heartbleed once and genuinely believe that goto is some kind of crime against humanity.

Go prevents you by making rookie C mistakes by outright banning most useful C features from the language. Nobody wants to use it, not even google.

Are we stuck with C for the next 50 years?

Well that's certainly one school of thought, but you know what they say "you can lead a horse to water, but you can't make them drink." And you can teach a coder C, but you can't convince them to ask themselves "what is this API I'm using probably doing behind the scenes and what is the complexity of its growth?" Pearls before swine and all that.

>haskell
>billions of language extensions to get anything done
>broken records
>strings as [Char]
>lazy I/O
>most libraries in alpha state
>deficient macro system
>no totality checking
>no dependent types
>easily subverted type system with unsafe functions
>line noise everywhere
>laziness makes it harder to reason about algorithmic complexity
>not proven in the industry

Here's one for Haskell: github.com/bitemyapp/websocket-shootout/pull/3
github.com/hashrocket/websocket-shootout/pull/14#issuecomment-244551430

Haskell quality.

yea?

This is literally true

in my first programming class (in java), we were already on "extends" and polymorphism and the teacher was still handwaving it off saying it's not important, just copy it like written here.

I'm so glad I dropped out.

>using Java for 101 courses
Why if Pascal exists?

>copypasta followed by issues on 3rd party library
did haskell kill your baby or something?

Eh, even though you can debate whether or not Java's forcing of Object Oriented design is a good thing, pretty much every language is going to start out that way.

#include

using namespace std;

int main( int argc, char* arcgv[]) {

return 0;
}
Just ignore all of this, you will learn about it later.

This is why Java shouldn't be the first thing taught at unis.
At mine, I don't think students were ever even taught what args is or the exact definition of static

It doesn't make any sense to teach about objects first before the basic stuff like variables, if else statements, and loops.

It allows your variables to behave differently depending on what section you are in?
>inb4 don't assign them different kinds of types
If you need to assign variables different kinds of types you made your program poorly and didn't think about the path to your goal.

main = putStrLn "Hello World!"

>main is the action performed by the program
>putStrLn displays a message on the console
>"Hello World!" is a string literal

Well I would be happy with C with little smarter compiler + better standard library
They already are doing optional stuff in C standard so why not just declare some kind of optional api for general allocators, containers, directory handling and stuff.

programming languages shouldn't be taught at the university level, period.

if you can't muster up the motivation to learn a language yourself, you don't deserve to be in CS.

Oh, forgive me. I meant "every real language."

thisbaitstheg

Nah, I don't even know what that language is.

thisbaitsthegharder

Just about every non-toy language will do that though.

> B-but muh python
SHUT THE FUCK UP YOU LYING FAGGOT.

def main():
print("Suck my snake dick")

if __name__ == "__main__":
main()


This shit is absolutely retarded, and we all know it.You're either teaching people the WRONG thing, which is inexcusable, or you're teaching them the if __name__ == "__main__" bullshit. Either way you're an asshole.

However, there are good reasons for all of those things to be there. They're scaffolding for building larger programs. You'll learn more about them later.

Despite everyone's bitching and moaning, and falling all over themselves to build bizarre convoluted replacements for it, C continues to enjoy widespread use.

The combination of "good enough" and decades of momentum makes it nearly invincible.

Remove the namespace and the args and then it becomes lecture 1. Are you literally retarded?

This goes to a deeper social issue of devalued university education in 21st century.
Firstly imo dynamic typing may have some downsides but the upsides outweigh them (if done correctly, like in python, unlike in javascript).
>inb4 don't assign them different kinds of types
>If you need to assign variables different kinds of types you made your program poorly and didn't think about the path to your goal.
I don't get it. You just debunked your own point?

You cant make generic containers that arent a shitshow in C. And you probably don't need them anyways if what you're doing is warranted to be written in C

That's the language where strings were different types depending on their length, right?

Why do you think that mongoloid excuse for a language was taken behind the shed and shot?

Pascal is not a good language, and it's not good for getting things done in the modern era. I could understand, but not completely agree if you said Python (but see ), but Pascal? Fuck no.

>the upsides outweigh them
wrong
>...
i think he means inference

>teaching explicit namespaces and linkers in lesson 1
You haven't been a beginner programmer in a LOOOOOOOOONG time have you?

I think Java (as it is traditionally taught) is a horrible first language, however I think that C++ as a first language is much, much worse.

But things in C are either an int, a float, or an array of one of those two. How much genericness do you really need?

Dynamic typing with optional compile-time static checking is optimal.

Or maybe dependent typing. I'm still undecided.

>wrong
not an argument

When people say generic in C, they want a real typeof() operator that works during runtime, which is next to impossible, because assembler has no concept of types other than what was enforced during compilation.

What?
Structs are a thing that exists and are useful.
But I'm saying you don't really need generic containers in C because you want direct control over memory layout and allocation anyways.

That's why colleges shouldn't teach Java as a first language.

You can do work inside the submodules and commit it. Checkout in the toplevel will never lose your changes. If necessary stash them to get a clean subrepo temporarily, or go in detached HEAD mode if you need to go back in time. Also it's perfectly permissible to compile your program with uncommitted changes in the submodules, or the toplevel repo, or both.

>That's the language where strings were different types depending on their length, right?
Ummm... no?

>Why do you think that mongoloid excuse for a language was taken behind the shed and shot?
I think you're confused, Pascal is still one of the most used languages in the world and growing. It's more popular than Perl, Ruby, Go, Objective-C, D, Lua, Scala, LISP, Haskell, Rust and most languages Sup Forums keeps memeing about.

>Pascal is not a good language
It's great. Its memory management and string handling is light-years ahead of C, its object-orientation model is way ahead of C++ with support for interfaces and class helpers, it compiles to fast object code unlike Java, it's one of the most mature and type-safe languages out there and is supported on virtually every platform out there.

You're just mad your little pet toy language is not as popular as Pascal. Stay rectally shattered.

I meant similar and not different in the rebuttal

People are going to implement them anyway like glib, apache portable runtime and some core library that every bigger projects defines themselves.
At least could be some attempt that if the standard just defined api but did not require implementation maybe those who continue implement new core libraries in C would at least try to have same kind of api.

>he fell for the TIOBE meme

[citation needed]

All I see is emotionally charged fluff, no arguments.

> When people say generic in C, they want a real typeof() operator that works during runtime,
This is called "reflection" and no one wants it in C. When people say generic in C they want something like templates in C++, something strictly at compile-time, and they recently got _Generic in C11.

Even on PyPL Pascal is fairly relevant.

You meant to quote .

codegolf.stackexchange.com/questions/110485/leak-memory-in-as-few-bytes-as-possible

What the fuck, Perl?

>a shitshow
>warranted to be in C
Were my main points. We need something better than C for writing huge monolithic graphical interface applications but C++ is also full of problems.
I don't really know. Programming sucks

what are the upsides to dynamic typing?

I meant to quote both.

Compile-time errors become runtime errors and thus are not your problem anymore but the user's!

Are you from Russia by any chance? They still teach programming in schools using Turbo Pascal here, and I guess this is where 50% of Delphi users are from.

easier for dumb people to write

>le meme
>le me loving le reddit

...

When static typing is too restrictive
Easier to represent data structures that are dynamic in nature (e.g. syntax trees, JSON objects).

But the submodules still need to have a separate origin right? There's no way to set the submodule directory as origin?

Originally from Argentina, working in Germany atm.

That's in no way the RIGHT(R) way to proceed m8, it's needed only on things like http.server, that can be either a imported or run directly. But for anything else it's silly to use it, and keeping the black magic for the special cases is part is making simple things easy and hard things possible, which is why pythonistas dig python so much. You can perfectly teach that after your students have written both main programs and modules separarely because by then it's not complicated, but being able to go straight to the point when writing Hello World or Fizzbuzz isn't a defect.

>he doesn't use a dynamic language with compile-time type declarations and inference

>Ummm... no?
In the original version of the language, there was no real concept of C-style array decay, and "array of 10 integers" and "array of 20 integers" were distinct (and incompatible) types. So for an integer-sorting algorithm, you'd have to write a different function for every array length.

C and Python for life

There's always room for Lua too.

>he needs complex high-overhead workarounds for something that could be easily fixed with simple Liskov substitution

C and Lisp for life

and Java

>what is CLOS

>subtyping
You disgust me

>he doesn't have at a glace type information at all times

The original version of the language is also almost 50 years old and was never meant for real-world use. The original version of C didn't even have structs or void functions.

>[current year]
>defending manifest typing

>been wanting to learn a new language
>decided to go with Rust
how'd i do?

What about it? That's a legit strategy for some programs.

>But the submodules still need to have a separate origin right? There's no way to set the submodule directory as origin?
Right. I assumed you already had a github repo as an origin for it. Well everything isn't lost:
> is the relative location for the cloned submodule to exist in the superproject. If does not exist, then the submodule is created by cloning from the named URL. If does exist and is already a valid Git repository, then this is added to the changeset without cloning. This second form is provided to ease creating a new submodule from scratch, and presumes the user will later push the submodule to the given URL.
So pretend you already have the github origin, and use its url-to-be.
RTFM: git-scm.com/docs/git-submodule or $ git help submodule

If you are sjw you found your place otherwise you kind of fucked up.

An overly complex kludge on top of an esoteric programming language.

if you haven't read this book, consider flipping burgers instead.

[citation needed]

Liskov substitution is more than subtyping, you brainlet.

>discord
We use IRC here.

>C
great
>Python
okay
>Java
fuck off, pajeet

Also /home/user/somewhere/libfuck.git is a perfectly valid origin url

We're not buying your book, Walt.

This is one of a few languages you can actually learn something new from, besides new syntax for the same old semantics.

Alright. Don't listen to /dpt/, it's a good language.

Why do you need the validation of others? Poor self-esteem?

>programming 1 course
>toil with a couple of the homework exercises for literally 6 hours and can't get them right
>next day see the answers and they are actually pretty simple yet I couldn't do them

Why must I be this FUCKING STUPID?! I JUST WANTED TO BECOME A PROGRAMMER.

Is there any hope for me?

if /dpt/ wrote a book what would it be about?