old thread: What are you working on, Jow Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
yegor256.com
nim-lang.org
twitter.com
First for Smalltalk.
should i learn pharo?
How many lines of code you have written today?
700 mandatory lines and counting here.
Definitely!
pic or didn't happen
>pajeets seething at the notion that less code is better
wwwwwwwwwwwww
Your code isn't full of holes is it, Jow Forums?
What is the best IDE and why is it Light Table, /dpt/?
>he needs a full web browser instance and 2GB of ram to edit a 2kb text file
Y-you mean like empty lines?
yegor256.com
Python crash course or automate the boring stuff?
What's the point of postfix ++'s high precedence in C if it doesn't increment the value before it's used in say a dereference?
So you can do stuff like while (*p++).
This is main file. Other files have other class.
Total is around 760 now.
>multi-line comment headers
>counting
wew, it gets even worse
what in the actual fuck
I use empty lines between most non-like lines so my code isn't an unreadable mess like his
Not dumb to give you commented lines.
6 * 8 = 48 lines of class comments was deducted.What have you written faggot?
>Why? In short, because a method should not contain "parts." A method should always do one thing and its functional decomposition should be done by language constructs (for example, new methods), and never by empty lines.
what a fucking brainlet
anyone who uses the term "code smell" can safely be ignored.
>that line width
do you even 2-up sempai
talking about lines of code is dumb
this made me physically sick, reminds me of reading at ugly densely packed gnu code
>muh 24 lines terminal!
oh I think there is such a thing as a "code smell," but anything having to do with the format of the code and not what it does sure isn't one
If your lines are longer than 80 chars, your code sucks
>writing boilerplate code and bragging about how many lines of code you've written
It isn't about what fits on the screen, it is about making whats on the screen not look like one entire related block. It's not like you write sentences or paragraphs without full stops and spaces, so why do something similar in code?
>heusesspaceswhenhetypes
i meant spaces between paragraphs in this case but i didn't really phrase that well
>lighttable
>dark as fuck
Who thought this was a good idea?
there's no such thing, it's just SV numalespeak for programming concepts that have no real weight in actual projects
it's for webjeets anyway
the term code smell has been around for ages and it is a real thing
light as in light beer
goto is the most powerful statement
no it's not.
it's literally just
>YOU FORMAT DIFFERENT THAN ME
>YOUR CODE BAD
>MY CODE GOOD
dude calm down
code smells aren't about formatting
they're different for every language too
>you do things differently than me
>i don't like that
just say bad code like a normal person.
I hate all this nu-programmer shit.
And i realize code-smell isn't technically nu-shit, but it may as well be.
"code smell" describes symptoms of bad code. The example posted is a fucking joke, it doesn't have anything to do with formatting
Partial application is exactly the name for it. You could call the function a curried function.
Haskell has special syntax for partially applying operators, called operator sections (x op) and (op x), as i showed you.
i'v seen people use code-smell so liberally it's lost all meaning.
But saying "bad code" in a language like C++/java/etc is redundant anyway.
How to make a remote repo in git?
Say my new project is foobar.git, in the remote I did:
git init --bare /my/path/foobar.git
but when I'm trying to clone the repo to my working machine with git clone foo@bar:/my/path/foobar.git
I got fatal: Couldn't find remote ref HEAD
>no spacing around the colon
>writing code on Sunday
is that megumin?
2 then follow it up with 1
You have to push into bare repo before being able to clone it.
Friendly reminder lines of code is a terrible metric and people boasting about it are usually copy pasting pajeets who can't write generics to save their lives
welp, unemployment was fun
time to go back to the real world ;_;
Who?
How to push something to the bare repo before clone it?
The ideal programming language would have syntax requiring punctuation between all words, so that spaces could be part of an identifier.
The only good LOC metric is a negative one
or you know just indentation + spaces
>what is git and how I create local repos?
Should I learn python as my first language?
No, starting with a dynamic language is bad idea.
Yes, starting with a dynamic language is a good idea
install nim
nim-lang.org
Where is your full stop at the end of the sentence, you dynamic faggot?
it was inferred
No
why not
It's shit and it will poison your mind. Learn something else, shit or otherwise, that won't poison your mind.
DON'T LEARN:
> javascript
> python
> java
> ruby
so what should I learn? I'm guessing C?
yes
python is easy to learn, java is hard, c is pretty standard in school.
it all depends what you want to do.
if your just a light programmer, do python. the advantages from C programming really wont be seen if your just doing small hobby projects. also, python is really easy to actually DO stuff on when your first learning.
after python/C pick up either c# or Java if you actually want to make money
Just don't learn the four I've listed. People who really learn them don't seem to unlearn them
well I kind of want to learn about exploitation and I know I need to know C and asm for that but I wanted to learn something simpler first before diving into that so I guess python then C then some form of assembly
god forbid a language handles pointers and garbage collection for you
>well I kind of want to learn about exploitation
your choice of language wont matter too much then.
knowing asm is an absolute requirement but you wont be programming in it, you will be using it to reverse engineer binaries.
as far as the exploitation goes, you can do this in python very easy and test your exploits much easier with the python shell rather than having to recompile a binary every test run.
t. infosec analyst
automatic period insertion, dumbass
Programming language design is about making things fast. Trading a lot of speed for a little ease of use is not a valid compromise.
thanks for the help man sounds awesome. I have lots of time so python and assembly then
np.
its also worth taking time to learn C as well, this will help with your ASM.
the more C code you write, the easier it is to understand what is going on in a binary when you attempt to reverse engineer it
>Programming language design is about making things fast
no, this is not true.
as user pointed out, he is interested in software exploitation. execution time has literally nothing to do with this unless if you are trying to exploit a race condition, which a beginner exploiter would never be able to recognize anyways.
>Programming language design is about making things fast
no it isn't
it's about how the end user writes programs
if all you cared about was speed you'd just use machine language
But think of code evolution along the same lines as a box full of Schrö-
dinger’s cats: every decision results in a different version of the future.
How many possible futures can your code support? Which ones are more
likely? How hard will it be to support them when the time comes?
Can anyone help me "translate" this line of code? I'm fairly new to C++, I can do some basic shit but to learn more I've jumped onto a project to help out in small ways. Thus far all I've been doing is making small changes that are sort of dictated to me and seeing what the outcome is.
The problem is I'm new to really long strings of code like this. There is a lot going on here and I'm getting confused as to what it's doing.
shared_ptr newFocus = loadedFocuses.find("The_third_way")->second.makeCustomizedCopy(Home->getTag());
>C++
dumb frogposter
Just think about it step by step
I'm a lonely NEET with no friends so the only social interaction I'm able to get is from Jow Forums and contributing code to Github repos.
There is no inference in dynamic shit. Did you mean "crashed with runtime exception" or "silently garbled all the data"?
dumb frogposter
Okay I'm trying to start with shared_ptr, but that's leaving me even more confused
>Manages the storage of a pointer, providing a limited garbage-collection facility, possibly sharing that management with other objects.
Neat, what the fuck does that mean?
It's a wrapper around a type so you can pass it to different functions and not worry about which one is responsible for deallocating it.
It creates customized copy of "The_third_way" focus.
What are you doing with the game, user?
a shared pointer is a pointer for an object that is shared, so rather than calling delete when one shared_ptr is released, delete is called when all shared_ptrs to a particular object are released
You have two approaches, top down and bottom up.
Weigh off what you like more: abstract theory / math (Haskell) or low level hardware (C / ASM). Do you want to do something on the web (JS), do you want to do computer graphics (C / C++). Do you want to make tools for pentesting and want to be a pentester (ASM / C / Python).
So yes it really depends on what you want to do. Some languages are objectively bad but you don't have an alternative (like JavaScript). Most of these languages can be made bareable by using linters, formatters and strong typing. Unfortunately a lot of jobs can be found in languages that are pretty bad (like JavaScript, Java, C++).
Most of the concepts of one language can be transferred to another language. So don't worry too much, just make sure you have fun along the way.
You're not ready to write modern C++ if you're not familiar with smart pointers.
But the short answer is that it's a reference counted pointer to an object. When all the shared_ptrs go out of scope, the object is deleted.
It's a savegame converter, so you can take a save file from the end of Victoria 2 and keep playing it in Hearts of Iron 4. I already knew broadly what the line does, what I'm trying to figure out is how it does it. What I've been doing is just changing the focus that the line looks for so I can add more focuses. This is what the project lead asked me to do and it's been working so far, except now for some reason it's not creating and printing certain focuses that I need it to. Because I don't understand HOW it does what it does, I can't really troubleshoot it.
Just as a measure of how new I am to this, I only vaguely know what a type is, and I have no clue what a wrapper is.
This is not true in the slightest. It depends on your use case but most of the time safety and stability are much more important than raw speed.
This is a Hearts of Iron mod?
First, if you don't know what they are, learn what pointers are. shared_ptr is a Standard Template Library feature (i.e. "inbuilt") that essentially works like a pointer that keeps track of how many shared pointers refer to an object and, if the counter drops to 0, erases it from the memory. It is used to avoid "memory leaks"
The code snippet creates such a shared pointer to a "HoI4Focus" type of object. It seems that there is a vector (array of variable length) named loaded focuses (the "find" method is a std::vector method) containing std::pair (this is another container which lumps up two pieces of data named "first" and "second") It seems the first entry in these pairs are strings, so first the code searches for a pair whose first element is a string that contains "the third way". Then, it uses a method called make customized copy (which is an attribute of the second piece of data stored in the pair) which returns a shared pointer to the "new focus"
I see.
>Because I don't understand HOW it does what it does, I can't really troubleshoot it
There is no information in your code snipped about the how. All I can see is that
>loadedFocuses.find("The_third_way")
you find an object, that is registered under "The_third_way" key in loadedFocuses container
>->second
Take that object's member, called 'second', and
>.makeCustomizedCopy(Home->getTag())
call its makeCustomizedCopy method, passing Home->getTag() which I presume tag of a player country.
How exactly that happens is inside that makeCustomizedCopy method.
BAMCIS, thank you guys. Just had the lightbulb moment I needed.
Please tell us what godly object oriented language you use senpai, I feel wisdom coming out of your post.
without having to install a whole IDE, how would I debug java webapps on linux (and java applications in general)?
>inb4 hurr java webapps
>godly object oriented language
stop saying dumb things
Don't worry by the age of 29 you will start working for yourself.